diff --git a/esp32/get_idf_libs.py b/esp32/get_idf_libs.py index 79f2d852ae..4be0d11f74 100644 --- a/esp32/get_idf_libs.py +++ b/esp32/get_idf_libs.py @@ -59,7 +59,6 @@ def main(): shutil.copy(src + '/vfs/libvfs.a', dsttmpapp) shutil.copy(src + '/wpa_supplicant/libwpa_supplicant.a', dsttmpapp) shutil.copy(src + '/xtensa-debug-module/libxtensa-debug-module.a', dsttmpapp) - shutil.copy(src + '/openthread/libopenthread.a', dsttmpapp) except: print("Couldn't Copy IDF libs defaulting to Local Lib Folders!") traceback.print_exc() diff --git a/esp32/lte/lteppp.c b/esp32/lte/lteppp.c index db3408ba83..2e0523d941 100644 --- a/esp32/lte/lteppp.c +++ b/esp32/lte/lteppp.c @@ -27,6 +27,7 @@ #include "pins.h" #include "mpsleep.h" #include "esp32_mphal.h" +#include "lwip/dns.h" /****************************************************************************** DEFINE CONSTANTS @@ -78,6 +79,8 @@ static bool ltepp_ppp_conn_up = false; static ltepppconnstatus_t lteppp_connstatus = LTE_PPP_IDLE; +static ip_addr_t ltepp_dns_info[2]={0}; + /****************************************************************************** DECLARE PRIVATE FUNCTIONS ******************************************************************************/ @@ -188,6 +191,14 @@ void lteppp_set_state(lte_state_t state) { xSemaphoreGive(xLTESem); } +void lteppp_set_default_inf(void) +{ + pppapi_set_default(lteppp_pcb); + //Restore DNS + dns_setserver(0, &(ltepp_dns_info[0])); + dns_setserver(1, &(ltepp_dns_info[1])); +} + void lteppp_set_legacy(lte_legacy_t legacy) { xSemaphoreTake(xLTESem, portMAX_DELAY); lteppp_lte_legacy = legacy; @@ -656,6 +667,11 @@ static void lteppp_status_cb (ppp_pcb *pcb, int err_code, void *ctx) { lte_gw = pppif->gw.u_addr.ip4.addr; lte_netmask = pppif->netmask.u_addr.ip4.addr; lte_ipv4addr = pppif->ip_addr.u_addr.ip4.addr; + if(lte_ipv4addr > 0) + { + ltepp_dns_info[0] = dns_getserver(0); + ltepp_dns_info[1] = dns_getserver(1); + } // printf("ipaddr = %s\n", ipaddr_ntoa(&pppif->ip_addr)); // printf("gateway = %s\n", ipaddr_ntoa(&pppif->gw)); // printf("netmask = %s\n", ipaddr_ntoa(&pppif->netmask)); diff --git a/esp32/lte/lteppp.h b/esp32/lte/lteppp.h index b0716ee5a3..9977aa9765 100644 --- a/esp32/lte/lteppp.h +++ b/esp32/lte/lteppp.h @@ -124,6 +124,8 @@ extern bool ltepp_is_ppp_conn_up(void); extern void lteppp_suspend(void); extern void lteppp_resume(void); + +extern void lteppp_set_default_inf(void); #ifdef LTE_DEBUG_BUFF extern char* lteppp_get_log_buff(void); #endif diff --git a/esp32/mods/modlte.c b/esp32/mods/modlte.c index 460c52480c..f171b8afb6 100644 --- a/esp32/mods/modlte.c +++ b/esp32/mods/modlte.c @@ -128,7 +128,7 @@ STATIC mp_obj_t lte_connect(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t STATIC mp_obj_t lte_deinit(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args); STATIC mp_obj_t lte_disconnect(mp_obj_t self_in); - +static void lte_set_default_inf(void); /****************************************************************************** DEFINE PUBLIC FUNCTIONS ******************************************************************************/ @@ -322,6 +322,11 @@ static void lte_check_init(void) { } } +static void lte_set_default_inf(void) +{ + lteppp_set_default_inf(); +} + static void lte_check_inppp(void) { if (lteppp_get_state() == E_LTE_PPP) { nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, "LTE modem is in data state, cannot send AT commands")); @@ -1385,4 +1390,5 @@ const mod_network_nic_type_t mod_network_nic_type_lte = { .n_ioctl = lwipsocket_socket_ioctl, .n_setupssl = lwipsocket_socket_setup_ssl, .inf_up = ltepp_is_ppp_conn_up, + .set_default_inf = lte_set_default_inf }; diff --git a/esp32/mods/modnetwork.c b/esp32/mods/modnetwork.c index 8cb0e4592d..b53cfd720c 100644 --- a/esp32/mods/modnetwork.c +++ b/esp32/mods/modnetwork.c @@ -94,13 +94,11 @@ void mod_network_deregister_nic(mp_obj_t nic) { mp_obj_t nic_rem = MP_STATE_PORT(mod_network_nic_list).items[i]; if(mp_obj_get_type(nic_rem) == (mp_obj_type_t *)&mod_network_nic_type_wlan) { - mod_network_nic_type_wlan.set_inf_up(); + mod_network_nic_type_wlan.set_default_inf(); } else if (mp_obj_get_type(nic_rem) == (mp_obj_type_t *)&mod_network_nic_type_lte) { - if (mod_network_nic_type_lte.set_inf_up != NULL) { - mod_network_nic_type_lte.set_inf_up(); - } + mod_network_nic_type_lte.set_default_inf(); } } #endif diff --git a/esp32/mods/modnetwork.h b/esp32/mods/modnetwork.h index 8f0907984c..bc3ca93714 100644 --- a/esp32/mods/modnetwork.h +++ b/esp32/mods/modnetwork.h @@ -84,7 +84,7 @@ typedef struct _mod_network_nic_type_t { // Interface status bool (*inf_up)(void); // Bring Inf_up - void (*set_inf_up)(void); + void (*set_default_inf)(void); } mod_network_nic_type_t; typedef struct _mod_network_socket_base_t { diff --git a/esp32/mods/modwlan.c b/esp32/mods/modwlan.c index 27c89a7560..8179d276ac 100644 --- a/esp32/mods/modwlan.c +++ b/esp32/mods/modwlan.c @@ -124,6 +124,10 @@ static bool is_inf_up = false; //mutex for Timeout Counter protection SemaphoreHandle_t timeout_mutex; +#if defined(FIPY) || defined(GPY) +// Variable saving DNS info +static tcpip_adapter_dns_info_t wlan_sta_inf_dns_info; +#endif /****************************************************************************** DECLARE PUBLIC DATA @@ -157,7 +161,7 @@ static void wlan_timer_callback( TimerHandle_t xTimer ); static void wlan_validate_country(const char * country); static void wlan_validate_country_policy(uint8_t policy); STATIC void wlan_stop_sta_conn_timer(); -STATIC void wlan_inf_up(void); +STATIC void wlan_set_default_inf(void); //***************************************************************************** // //! \brief The Function Handles WLAN Events @@ -347,7 +351,11 @@ STATIC esp_err_t wlan_event_handler(void *ctx, system_event_t *event) { break; case SYSTEM_EVENT_STA_GOT_IP: /**< ESP32 station got IP from connected AP */ xEventGroupSetBits(wifi_event_group, CONNECTED_BIT); - is_inf_up = true; +#if defined(FIPY) || defined(GPY) + // Save DNS info for restoring if wifi inf is usable again after LTE disconnect + tcpip_adapter_get_dns_info(TCPIP_ADAPTER_IF_STA, TCPIP_ADAPTER_DNS_MAIN, &wlan_sta_inf_dns_info); +#endif + is_inf_up = true; break; case SYSTEM_EVENT_STA_DISCONNECTED: /**< ESP32 station disconnected from AP */ xEventGroupClearBits(wifi_event_group, CONNECTED_BIT); @@ -943,13 +951,14 @@ STATIC void promiscuous_callback(void *buf, wifi_promiscuous_pkt_type_t type) } } -STATIC void wlan_inf_up(void) +STATIC void wlan_set_default_inf(void) { +#if defined(FIPY) || defined(GPY) if (wlan_obj.mode == WIFI_MODE_STA || wlan_obj.mode == WIFI_MODE_APSTA) { + tcpip_adapter_set_dns_info(TCPIP_ADAPTER_IF_STA, TCPIP_ADAPTER_DNS_MAIN, &wlan_sta_inf_dns_info); tcpip_adapter_up(TCPIP_ADAPTER_IF_STA); - tcpip_adapter_dhcpc_stop(TCPIP_ADAPTER_IF_STA); - tcpip_adapter_dhcpc_start(TCPIP_ADAPTER_IF_STA); } +#endif } //STATIC void wlan_get_sl_mac (void) { @@ -2619,7 +2628,7 @@ const mod_network_nic_type_t mod_network_nic_type_wlan = { .n_ioctl = lwipsocket_socket_ioctl, .n_setupssl = lwipsocket_socket_setup_ssl, .inf_up = wlan_is_inf_up, - .set_inf_up = wlan_inf_up + .set_default_inf = wlan_set_default_inf }; //STATIC const mp_irq_methods_t wlan_irq_methods = { diff --git a/esp32/pycom_version.h b/esp32/pycom_version.h index 93077042f5..c13efbe5fa 100644 --- a/esp32/pycom_version.h +++ b/esp32/pycom_version.h @@ -10,7 +10,7 @@ #ifndef VERSION_H_ #define VERSION_H_ -#define SW_VERSION_NUMBER "1.20.0.rc12" +#define SW_VERSION_NUMBER "1.20.0.rc12.1" #define LORAWAN_VERSION_NUMBER "1.0.2"