8
8
#include " esp/esp_lib_unified.h"
9
9
#include " rpc_wifi_api_hal.h"
10
10
11
+ int wifi_mode = RTW_MODE_NONE;
12
+
13
+ uint32_t wifi_get_netif (tcpip_adapter_if_t tcpip_if)
14
+ {
15
+ if (wifi_mode == RTW_MODE_STA_AP && tcpip_if == TCPIP_ADAPTER_IF_AP){
16
+ return 1 ;
17
+ }
18
+
19
+ return 0 ;
20
+ }
11
21
// ! @name rpc_wifi_drv
12
22
// @{
13
23
@@ -236,16 +246,19 @@ int wifi_rf_off(void)
236
246
237
247
int wifi_on (rtw_mode_t mode)
238
248
{
249
+ wifi_mode = mode;
239
250
RPC_FUN_RETURN_1 (wifi_on, (uint32_t )mode, int );
240
251
}
241
252
242
253
int wifi_off (void )
243
254
{
255
+ wifi_mode = RTW_MODE_NONE;
244
256
RPC_FUN_RETURN_0 (wifi_off, int );
245
257
}
246
258
247
259
int wifi_set_mode (rtw_mode_t mode)
248
260
{
261
+ wifi_mode = mode;
249
262
RPC_FUN_RETURN_1 (wifi_set_mode, (uint32_t )mode, int );
250
263
}
251
264
@@ -489,6 +502,11 @@ int wifi_get_reconnect_data(wlan_fast_reconnect_profile_t *wifi_info)
489
502
return ret;
490
503
}
491
504
505
+ int wifi_clear_reconnect_data ()
506
+ {
507
+ RPC_FUN_RETURN_0 (wifi_clear_reconnect_data, int32_t );
508
+ }
509
+
492
510
int32_t wifi_scan_start ()
493
511
{
494
512
RPC_FUN_RETURN_0 (wifi_scan_start, int32_t );
@@ -622,36 +640,43 @@ esp_err_t tcpip_adapter_ap_start(uint8_t *mac, tcpip_adapter_ip_info_t *ip_info)
622
640
623
641
esp_err_t tcpip_adapter_stop (tcpip_adapter_if_t tcpip_if)
624
642
{
625
- RPC_FUN_RETURN_1 (tcpip_adapter_stop, (uint32_t )tcpip_if, esp_err_t );
643
+ uint32_t netif = wifi_get_netif (tcpip_if);
644
+
645
+ RPC_FUN_RETURN_1 (tcpip_adapter_stop, (uint32_t )netif, esp_err_t );
626
646
}
627
647
628
648
esp_err_t tcpip_adapter_up (tcpip_adapter_if_t tcpip_if)
629
649
{
630
- RPC_FUN_RETURN_1 (tcpip_adapter_up, (uint32_t )tcpip_if, esp_err_t );
650
+ uint32_t netif = wifi_get_netif (tcpip_if);
651
+
652
+ RPC_FUN_RETURN_1 (tcpip_adapter_up, (uint32_t )netif, esp_err_t );
631
653
}
632
654
633
655
esp_err_t tcpip_adapter_down (tcpip_adapter_if_t tcpip_if)
634
656
{
635
- RPC_FUN_RETURN_1 (tcpip_adapter_down, (uint32_t )tcpip_if, esp_err_t );
657
+ uint32_t netif = wifi_get_netif (tcpip_if);
658
+
659
+ RPC_FUN_RETURN_1 (tcpip_adapter_down, (uint32_t )netif, esp_err_t );
636
660
}
637
661
638
662
esp_err_t tcpip_adapter_get_ip_info (tcpip_adapter_if_t tcpip_if, tcpip_adapter_ip_info_t *ip_info)
639
663
{
640
664
FUNC_ENTRY;
665
+ uint32_t netif = wifi_get_netif (tcpip_if);
641
666
esp_err_t ret = ESP_OK;
642
667
if (ip_info == NULL )
643
668
{
644
669
return ESP_ERR_TCPIP_ADAPTER_INVALID_PARAMS;
645
670
}
646
671
binary_t _ip_info;
647
- ret = (esp_err_t )rpc_tcpip_adapter_get_ip_info ((uint32_t )tcpip_if , &_ip_info);
672
+ ret = (esp_err_t )rpc_tcpip_adapter_get_ip_info ((uint32_t )netif , &_ip_info);
648
673
if (ret == ESP_OK)
649
674
{
650
675
memcpy (ip_info, _ip_info.data , sizeof (tcpip_adapter_ip_info_t ));
651
676
}
652
677
// tcpip_adapter_ip_info_t *temp = (tcpip_adapter_ip_info_t *)_ip_info.data;
653
- // RPC_DEBUG("tcpip_if :%d ip_addr:%d netmask:%d, gw:%d", tcpip_if , ip_info->ip, ip_info->netmask, ip_info->gw);
654
- // RPC_DEBUG("tcpip_if :%d ip_addr:%d netmask:%d, gw:%d", tcpip_if , temp->ip, temp->netmask, temp->gw);
678
+ // RPC_DEBUG("netif :%d ip_addr:%d netmask:%d, gw:%d", netif , ip_info->ip, ip_info->netmask, ip_info->gw);
679
+ // RPC_DEBUG("netif :%d ip_addr:%d netmask:%d, gw:%d", netif , temp->ip, temp->netmask, temp->gw);
655
680
if (_ip_info.data != NULL )
656
681
{
657
682
erpc_free (_ip_info.data );
@@ -664,6 +689,7 @@ esp_err_t tcpip_adapter_get_ip_info(tcpip_adapter_if_t tcpip_if, tcpip_adapter_i
664
689
esp_err_t tcpip_adapter_set_ip_info (tcpip_adapter_if_t tcpip_if, tcpip_adapter_ip_info_t *ip_info)
665
690
{
666
691
FUNC_ENTRY;
692
+ uint32_t netif = wifi_get_netif (tcpip_if);
667
693
esp_err_t ret = ESP_OK;
668
694
if (ip_info == NULL )
669
695
{
@@ -672,7 +698,7 @@ esp_err_t tcpip_adapter_set_ip_info(tcpip_adapter_if_t tcpip_if, tcpip_adapter_i
672
698
binary_t _ip_info;
673
699
_ip_info.dataLength = sizeof (tcpip_adapter_ip_info_t );
674
700
_ip_info.data = (uint8_t *)ip_info;
675
- ret = (esp_err_t )rpc_tcpip_adapter_set_ip_info ((uint32_t )tcpip_if , &_ip_info);
701
+ ret = (esp_err_t )rpc_tcpip_adapter_set_ip_info ((uint32_t )netif , &_ip_info);
676
702
FUNC_EXIT;
677
703
return ret;
678
704
}
@@ -681,28 +707,30 @@ esp_err_t tcpip_adapter_set_dns_info(tcpip_adapter_if_t tcpip_if, tcpip_adapter_
681
707
{
682
708
FUNC_ENTRY;
683
709
esp_err_t ret = ESP_OK;
710
+ uint32_t netif = wifi_get_netif (tcpip_if);
684
711
if (dns == NULL )
685
712
{
686
713
return ESP_ERR_TCPIP_ADAPTER_INVALID_PARAMS;
687
714
}
688
715
binary_t _dns;
689
716
_dns.dataLength = sizeof (tcpip_adapter_dns_info_t );
690
717
_dns.data = (uint8_t *)dns;
691
- ret = (esp_err_t )rpc_tcpip_adapter_set_dns_info ((uint32_t )tcpip_if , (uint32_t )type, &_dns);
718
+ ret = (esp_err_t )rpc_tcpip_adapter_set_dns_info ((uint32_t )netif , (uint32_t )type, &_dns);
692
719
FUNC_EXIT;
693
720
return ret;
694
721
}
695
722
696
723
esp_err_t tcpip_adapter_get_dns_info (tcpip_adapter_if_t tcpip_if, tcpip_adapter_dns_type_t type, tcpip_adapter_dns_info_t *dns)
697
724
{
698
725
FUNC_ENTRY;
726
+ uint32_t netif = wifi_get_netif (tcpip_if);
699
727
esp_err_t ret = ESP_OK;
700
728
if (dns == NULL )
701
729
{
702
730
return ESP_ERR_TCPIP_ADAPTER_INVALID_PARAMS;
703
731
}
704
732
binary_t _dns;
705
- ret = (esp_err_t )rpc_tcpip_adapter_get_dns_info ((uint32_t )tcpip_if , (uint32_t )type, &_dns);
733
+ ret = (esp_err_t )rpc_tcpip_adapter_get_dns_info ((uint32_t )netif , (uint32_t )type, &_dns);
706
734
if (ret == ESP_OK)
707
735
{
708
736
memcpy (dns, _dns.data , sizeof (tcpip_adapter_dns_info_t ));
@@ -719,13 +747,14 @@ esp_err_t tcpip_adapter_get_dns_info(tcpip_adapter_if_t tcpip_if, tcpip_adapter_
719
747
esp_err_t tcpip_adapter_get_mac (tcpip_adapter_if_t tcpip_if, uint8_t *mac)
720
748
{
721
749
FUNC_ENTRY;
750
+ uint32_t netif = wifi_get_netif (tcpip_if);
722
751
esp_err_t ret = ESP_OK;
723
752
if (mac == NULL )
724
753
{
725
754
return ESP_ERR_TCPIP_ADAPTER_INVALID_PARAMS;
726
755
}
727
756
binary_t _mac;
728
- ret = (esp_err_t )rpc_tcpip_adapter_get_mac ((uint32_t )tcpip_if , &_mac);
757
+ ret = (esp_err_t )rpc_tcpip_adapter_get_mac ((uint32_t )netif , &_mac);
729
758
if (ret == ESP_OK)
730
759
{
731
760
memcpy (mac, _mac.data , _mac.dataLength );
@@ -742,6 +771,7 @@ esp_err_t tcpip_adapter_get_mac(tcpip_adapter_if_t tcpip_if, uint8_t *mac)
742
771
esp_err_t tcpip_adapter_set_mac (tcpip_adapter_if_t tcpip_if, uint8_t *mac)
743
772
{
744
773
FUNC_ENTRY;
774
+ uint32_t netif = wifi_get_netif (tcpip_if);
745
775
esp_err_t ret = ESP_OK;
746
776
if (mac == NULL )
747
777
{
@@ -750,29 +780,33 @@ esp_err_t tcpip_adapter_set_mac(tcpip_adapter_if_t tcpip_if, uint8_t *mac)
750
780
binary_t _mac;
751
781
_mac.dataLength = strlen ((char *)mac) + 1 ;
752
782
_mac.data = (uint8_t *)mac;
753
- ret = (esp_err_t )rpc_tcpip_adapter_set_mac ((uint32_t )tcpip_if , &_mac);
783
+ ret = (esp_err_t )rpc_tcpip_adapter_set_mac ((uint32_t )netif , &_mac);
754
784
FUNC_EXIT;
755
785
return ret;
756
786
}
757
787
758
788
esp_err_t tcpip_adapter_dhcps_start (tcpip_adapter_if_t tcpip_if)
759
789
{
760
- RPC_FUN_RETURN_1 (tcpip_adapter_dhcps_start, (uint32_t )tcpip_if, esp_err_t );
790
+ uint32_t netif = wifi_get_netif (tcpip_if);
791
+ RPC_FUN_RETURN_1 (tcpip_adapter_dhcps_start, (uint32_t )netif, esp_err_t );
761
792
}
762
793
763
794
esp_err_t tcpip_adapter_dhcps_stop (tcpip_adapter_if_t tcpip_if)
764
795
{
765
- RPC_FUN_RETURN_1 (tcpip_adapter_dhcps_stop, (uint32_t )tcpip_if, esp_err_t );
796
+ uint32_t netif = wifi_get_netif (tcpip_if);
797
+ RPC_FUN_RETURN_1 (tcpip_adapter_dhcps_stop, (uint32_t )netif, esp_err_t );
766
798
}
767
799
768
800
esp_err_t tcpip_adapter_dhcpc_start (tcpip_adapter_if_t tcpip_if)
769
801
{
770
- RPC_FUN_RETURN_1 (tcpip_adapter_dhcpc_start, (uint32_t )tcpip_if, esp_err_t );
802
+ uint32_t netif = wifi_get_netif (tcpip_if);
803
+ RPC_FUN_RETURN_1 (tcpip_adapter_dhcpc_start, (uint32_t )netif, esp_err_t );
771
804
}
772
805
773
806
esp_err_t tcpip_adapter_dhcpc_stop (tcpip_adapter_if_t tcpip_if)
774
807
{
775
- RPC_FUN_RETURN_1 (tcpip_adapter_dhcpc_stop, (uint32_t )tcpip_if, esp_err_t );
808
+ uint32_t netif = wifi_get_netif (tcpip_if);
809
+ RPC_FUN_RETURN_1 (tcpip_adapter_dhcpc_stop, (uint32_t )netif, esp_err_t );
776
810
}
777
811
778
812
esp_err_t tcpip_adapter_set_hostname (tcpip_adapter_if_t tcpip_if, const char *hostname)
0 commit comments