From a93bd3c187d1f49af5670ebe627ad691798f5017 Mon Sep 17 00:00:00 2001 From: Sebastien L Date: Wed, 29 Dec 2021 15:08:24 -0500 Subject: [PATCH] temp fix network manager log verbosity --- CMakeLists.txt | 99 ------------------- components/platform_console/cmd_config.c | 4 + components/wifi-manager/network_manager.c | 2 +- components/wifi-manager/network_manager.h | 13 ++- .../wifi-manager/network_manager_handlers.c | 33 ++++--- 5 files changed, 33 insertions(+), 118 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 95e26107..f973b8d4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,102 +27,3 @@ set_property(TARGET recovery.elf PROPERTY RECOVERY_PREFIX app_recovery ) include(squeezelite.cmake) set(PROJECT_VER $ENV{PROJECT_VER}) - - -#target_compile_definitions(__idf_services PRIVATE -DLOG_LOCAL_LEVEL=ESP_LOG_DEBUG) -target_compile_definitions(__idf_esp_eth PRIVATE -DLOG_LOCAL_LEVEL=ESP_LOG_WARN) -target_compile_definitions(__idf_driver PRIVATE -DLOG_LOCAL_LEVEL=ESP_LOG_WARN) -target_compile_definitions(__idf_wifi-manager PRIVATE -DLOG_LOCAL_LEVEL=ESP_LOG_WARN) -target_compile_definitions(__idf_esp_wifi PRIVATE -DLOG_LOCAL_LEVEL=ESP_LOG_WARN) -#target_compile_definitions(__idf_platform_console PRIVATE -DLOG_LOCAL_LEVEL=ESP_LOG_DEBUG) - -#target_compile_definitions(__idf_app_recovery PRIVATE -DLOG_LOCAL_LEVEL=ESP_LOG_INFO) -# target_compile_definitions(__idf_esp_eth PRIVATE -DLOG_LOCAL_LEVEL=ESP_LOG_INFO) -# target_compile_definitions(__idf_esp_event PRIVATE -DLOG_LOCAL_LEVEL=ESP_LOG_INFO) -# target_compile_definitions(__idf_esp_netif PRIVATE -DLOG_LOCAL_LEVEL=ESP_LOG_DEBUG) - -# target_compile_definitions(__idf_freertos PRIVATE -DLOG_LOCAL_LEVEL=ESP_LOG_DEBUG) -target_compile_definitions(__idf_bt PRIVATE -DLOG_LOCAL_LEVEL=ESP_LOG_ERROR) -# target_compile_definitions(__idf_mdns PRIVATE -DLOG_LOCAL_LEVEL=ESP_LOG_DEBUG) -# target_compile_definitions(__idf_tcpip_adapter PRIVATE -DLOG_LOCAL_LEVEL=ESP_LOG_DEBUG) -# target_compile_definitions(__idf_tcp_transport PRIVATE -DLOG_LOCAL_LEVEL=ESP_LOG_DEBUG) - -#target_compile_definitions(__idf_app_squeezelite PRIVATE -DLOG_LOCAL_LEVEL=ESP_LOG_DEBUG) -# target_compile_definitions(__idf_app_trace PRIVATE -DLOG_LOCAL_LEVEL=ESP_LOG_DEBUG) -# target_compile_definitions(__idf_app_update PRIVATE -DLOG_LOCAL_LEVEL=ESP_LOG_DEBUG) -# target_compile_definitions(__idf_asio PRIVATE -DLOG_LOCAL_LEVEL=ESP_LOG_DEBUG) -# target_compile_definitions(__idf_audio PRIVATE -DLOG_LOCAL_LEVEL=ESP_LOG_DEBUG) -# target_compile_definitions(__idf_bootloader_support PRIVATE -DLOG_LOCAL_LEVEL=ESP_LOG_DEBUG) - -# target_compile_definitions(__idf_cbor PRIVATE -DLOG_LOCAL_LEVEL=ESP_LOG_DEBUG) -# target_compile_definitions(__idf_cmock PRIVATE -DLOG_LOCAL_LEVEL=ESP_LOG_DEBUG) -# target_compile_definitions(__idf_coap PRIVATE -DLOG_LOCAL_LEVEL=ESP_LOG_DEBUG) -# target_compile_definitions(__idf_console PRIVATE -DLOG_LOCAL_LEVEL=ESP_LOG_DEBUG) -# target_compile_definitions(__idf_cxx PRIVATE -DLOG_LOCAL_LEVEL=ESP_LOG_DEBUG) -# target_compile_definitions(__idf_display PRIVATE -DLOG_LOCAL_LEVEL=ESP_LOG_DEBUG) -# target_compile_definitions(__idf_driver PRIVATE -DLOG_LOCAL_LEVEL=ESP_LOG_DEBUG) -# target_compile_definitions(__idf_driver_bt PRIVATE -DLOG_LOCAL_LEVEL=ESP_LOG_DEBUG) -# target_compile_definitions(__idf_efuse PRIVATE -DLOG_LOCAL_LEVEL=ESP_LOG_DEBUG) -# target_compile_definitions(__idf_esp-dsp PRIVATE -DLOG_LOCAL_LEVEL=ESP_LOG_DEBUG) -# target_compile_definitions(__idf_esp-tls PRIVATE -DLOG_LOCAL_LEVEL=ESP_LOG_DEBUG) -# target_compile_definitions(__idf_esp32 PRIVATE -DLOG_LOCAL_LEVEL=ESP_LOG_DEBUG) -# target_compile_definitions(__idf_espcoredump PRIVATE -DLOG_LOCAL_LEVEL=ESP_LOG_DEBUG) -# target_compile_definitions(__idf_esp_adc_cal PRIVATE -DLOG_LOCAL_LEVEL=ESP_LOG_DEBUG) -# target_compile_definitions(__idf_esp_common PRIVATE -DLOG_LOCAL_LEVEL=ESP_LOG_DEBUG) -# target_compile_definitions(__idf_esp_gdbstub PRIVATE -DLOG_LOCAL_LEVEL=ESP_LOG_DEBUG) -# target_compile_definitions(__idf_esp_hid PRIVATE -DLOG_LOCAL_LEVEL=ESP_LOG_DEBUG) -# target_compile_definitions(__idf_esp_https_ota PRIVATE -DLOG_LOCAL_LEVEL=ESP_LOG_DEBUG) -# target_compile_definitions(__idf_esp_http_client PRIVATE -DLOG_LOCAL_LEVEL=ESP_LOG_DEBUG) -# target_compile_definitions(__idf_esp_http_server PRIVATE -DLOG_LOCAL_LEVEL=ESP_LOG_DEBUG) -# target_compile_definitions(__idf_esp_hw_support PRIVATE -DLOG_LOCAL_LEVEL=ESP_LOG_DEBUG) -# target_compile_definitions(__idf_esp_ipc PRIVATE -DLOG_LOCAL_LEVEL=ESP_LOG_DEBUG) -# target_compile_definitions(__idf_esp_local_ctrl PRIVATE -DLOG_LOCAL_LEVEL=ESP_LOG_DEBUG) -# target_compile_definitions(__idf_esp_pm PRIVATE -DLOG_LOCAL_LEVEL=ESP_LOG_DEBUG) -# target_compile_definitions(__idf_esp_ringbuf PRIVATE -DLOG_LOCAL_LEVEL=ESP_LOG_DEBUG) -# target_compile_definitions(__idf_esp_rom PRIVATE -DLOG_LOCAL_LEVEL=ESP_LOG_DEBUG) -# target_compile_definitions(__idf_esp_serial_slave_link PRIVATE -DLOG_LOCAL_LEVEL=ESP_LOG_DEBUG) -# target_compile_definitions(__idf_esp_system PRIVATE -DLOG_LOCAL_LEVEL=ESP_LOG_DEBUG) -# target_compile_definitions(__idf_esp_timer PRIVATE -DLOG_LOCAL_LEVEL=ESP_LOG_DEBUG) -# target_compile_definitions(__idf_esp_websocket_client PRIVATE -DLOG_LOCAL_LEVEL=ESP_LOG_DEBUG) -# target_compile_definitions(__idf_expat PRIVATE -DLOG_LOCAL_LEVEL=ESP_LOG_DEBUG) -# target_compile_definitions(__idf_fatfs PRIVATE -DLOG_LOCAL_LEVEL=ESP_LOG_DEBUG) -# target_compile_definitions(__idf_freemodbus PRIVATE -DLOG_LOCAL_LEVEL=ESP_LOG_DEBUG) -# target_compile_definitions(__idf_hal PRIVATE -DLOG_LOCAL_LEVEL=ESP_LOG_DEBUG) -# target_compile_definitions(__idf_heap PRIVATE -DLOG_LOCAL_LEVEL=ESP_LOG_DEBUG) -# target_compile_definitions(__idf_jsmn PRIVATE -DLOG_LOCAL_LEVEL=ESP_LOG_DEBUG) -# target_compile_definitions(__idf_json PRIVATE -DLOG_LOCAL_LEVEL=ESP_LOG_DEBUG) -# target_compile_definitions(__idf_libsodium PRIVATE -DLOG_LOCAL_LEVEL=ESP_LOG_DEBUG) -# target_compile_definitions(__idf_log PRIVATE -DLOG_LOCAL_LEVEL=ESP_LOG_DEBUG) -# target_compile_definitions(__idf_lwip PRIVATE -DLOG_LOCAL_LEVEL=ESP_LOG_DEBUG) -# target_compile_definitions(__idf_main PRIVATE -DLOG_LOCAL_LEVEL=ESP_LOG_DEBUG) -# target_compile_definitions(__idf_mbedtls PRIVATE -DLOG_LOCAL_LEVEL=ESP_LOG_DEBUG) -# target_compile_definitions(mbedcrypto PRIVATE -DLOG_LOCAL_LEVEL=ESP_LOG_DEBUG) -# target_compile_definitions(mbedtls PRIVATE -DLOG_LOCAL_LEVEL=ESP_LOG_DEBUG) -# target_compile_definitions(mbedx509 PRIVATE -DLOG_LOCAL_LEVEL=ESP_LOG_DEBUG) -# target_compile_definitions(__idf_mqtt PRIVATE -DLOG_LOCAL_LEVEL=ESP_LOG_DEBUG) -# target_compile_definitions(__idf_newlib PRIVATE -DLOG_LOCAL_LEVEL=ESP_LOG_DEBUG) -# target_compile_definitions(__idf_nghttp PRIVATE -DLOG_LOCAL_LEVEL=ESP_LOG_DEBUG) -# target_compile_definitions(__idf_nvs_flash PRIVATE -DLOG_LOCAL_LEVEL=ESP_LOG_DEBUG) -# target_compile_definitions(__idf_openssl PRIVATE -DLOG_LOCAL_LEVEL=ESP_LOG_DEBUG) -# target_compile_definitions(__idf_perfmon PRIVATE -DLOG_LOCAL_LEVEL=ESP_LOG_DEBUG) -# target_compile_definitions(__idf_platform_config PRIVATE -DLOG_LOCAL_LEVEL=ESP_LOG_DEBUG) -# target_compile_definitions(__idf_protobuf-c PRIVATE -DLOG_LOCAL_LEVEL=ESP_LOG_DEBUG) -# target_compile_definitions(__idf_protocomm PRIVATE -DLOG_LOCAL_LEVEL=ESP_LOG_DEBUG) -# target_compile_definitions(__idf_pthread PRIVATE -DLOG_LOCAL_LEVEL=ESP_LOG_DEBUG) -# target_compile_definitions(__idf_raop PRIVATE -DLOG_LOCAL_LEVEL=ESP_LOG_DEBUG) -# target_compile_definitions(__idf_sdmmc PRIVATE -DLOG_LOCAL_LEVEL=ESP_LOG_DEBUG) - -# target_compile_definitions(__idf_soc PRIVATE -DLOG_LOCAL_LEVEL=ESP_LOG_DEBUG) -# target_compile_definitions(__idf_spiffs PRIVATE -DLOG_LOCAL_LEVEL=ESP_LOG_DEBUG) -# target_compile_definitions(__idf_spi_flash PRIVATE -DLOG_LOCAL_LEVEL=ESP_LOG_DEBUG) -# target_compile_definitions(__idf_squeezelite PRIVATE -DLOG_LOCAL_LEVEL=ESP_LOG_DEBUG) -# target_compile_definitions(__idf_squeezelite-ota PRIVATE -DLOG_LOCAL_LEVEL=ESP_LOG_DEBUG) -# target_compile_definitions(__idf_telnet PRIVATE -DLOG_LOCAL_LEVEL=ESP_LOG_DEBUG) -# target_compile_definitions(__idf_tools PRIVATE -DLOG_LOCAL_LEVEL=ESP_LOG_DEBUG) -# target_compile_definitions(__idf_ulp PRIVATE -DLOG_LOCAL_LEVEL=ESP_LOG_DEBUG) -# target_compile_definitions(__idf_unity PRIVATE -DLOG_LOCAL_LEVEL=ESP_LOG_DEBUG) -# target_compile_definitions(__idf_vfs PRIVATE -DLOG_LOCAL_LEVEL=ESP_LOG_DEBUG) -# target_compile_definitions(__idf_wear_levelling PRIVATE -DLOG_LOCAL_LEVEL=ESP_LOG_DEBUG) -# target_compile_definitions(__idf_wifi_provisioning PRIVATE -DLOG_LOCAL_LEVEL=ESP_LOG_DEBUG) -# target_compile_definitions(__idf_wpa_supplicant PRIVATE -DLOG_LOCAL_LEVEL=ESP_LOG_DEBUG) -# target_compile_definitions(__idf_xtensa PRIVATE -DLOG_LOCAL_LEVEL=ESP_LOG_DEBUG) \ No newline at end of file diff --git a/components/platform_console/cmd_config.c b/components/platform_console/cmd_config.c index d263fbbb..93a70a0a 100644 --- a/components/platform_console/cmd_config.c +++ b/components/platform_console/cmd_config.c @@ -200,6 +200,10 @@ int check_missing_parm(struct arg_int * int_parm, FILE * f){ } char * strip_bt_name(char * opt_str) { + if(!opt_str || strlen(opt_str)==0){ + ESP_LOGW(TAG,"strip_bt_name: opt_str is NULL"); + return NULL; + } char *result = malloc_init_external(strlen(opt_str)+1); char *str = strdup_psram(opt_str); const char * output_marker=" -o"; diff --git a/components/wifi-manager/network_manager.c b/components/wifi-manager/network_manager.c index 57670074..19941a9c 100644 --- a/components/wifi-manager/network_manager.c +++ b/components/wifi-manager/network_manager.c @@ -658,7 +658,7 @@ esp_err_t network_get_hostname(const char** hostname) { return esp_netif_get_hostname(get_connected_interface(), hostname); } -void network_set_timer(uint16_t duration) { +void network_set_timer(uint16_t duration, const char * tag) { if (duration > 0) { if (!NM.state_timer) { ESP_LOGD(TAG, "Starting new pulse check timer with period of %u ms.", duration); diff --git a/components/wifi-manager/network_manager.h b/components/wifi-manager/network_manager.h index 9734960b..63e02929 100644 --- a/components/wifi-manager/network_manager.h +++ b/components/wifi-manager/network_manager.h @@ -82,6 +82,7 @@ typedef struct uint16_t dhcp_timeout; uint16_t wifi_dhcp_fail_ms; queue_message * event_parameters; + const char * timer_tag; } network_t; @@ -308,7 +309,7 @@ void network_manager_initialise_mdns(); * @brief Register a callback to a custom function when specific network manager states are reached. */ bool network_is_wifi_prioritized(); -void network_set_timer(uint16_t duration); +void network_set_timer(uint16_t duration, const char * tag); void network_set_hostname(esp_netif_t * netif); esp_err_t network_get_ip_info_for_netif(esp_netif_t* netif, tcpip_adapter_ip_info_t* ipInfo); void network_start_stop_dhcp(esp_netif_t* netif, bool start); @@ -327,7 +328,8 @@ void network_manager_format_from_to_states(esp_log_level_t level, const char* pr void network_manager_format_state_machine(esp_log_level_t level, const char* prefix, state_machine_t * state_machine, bool show_source, const char * caller) ; char* network_manager_alloc_get_mac_string(uint8_t mac[6]); -#if defined(LOG_LOCAL_LEVEL) && LOG_LOCAL_LEVEL >=ESP_LOG_VERBOSE +#if defined(LOG_LOCAL_LEVEL) +#if LOG_LOCAL_LEVEL >=5 #define NETWORK_PRINT_TRANSITION(begin, prefix, source,target, event, print_source,caller ) network_manager_format_from_to_states(ESP_LOG_VERBOSE, prefix, source,target, event, print_source,caller ) #define NETWORK_DEBUG_STATE_MACHINE(begin, cb_prefix,state_machine,print_from,caller) network_manager_format_state_machine(ESP_LOG_DEBUG,cb_prefix,state_machine,print_from,caller) #define NETWORK_EXECUTE_CB(mch) network_execute_cb(mch,__FUNCTION__); @@ -335,14 +337,17 @@ char* network_manager_alloc_get_mac_string(uint8_t mac[6]); #define network_exit_handler_print(State_Machine, begin) network_manager_format_state_machine(ESP_LOG_DEBUG,begin?"EXIT START":"END END",State_Machine,false,__FUNCTION__) #define network_handler_print(State_Machine, begin) network_manager_format_state_machine(ESP_LOG_DEBUG,begin?"HANDLER START":"HANDLER END",State_Machine,false,__FUNCTION__) -#elif defined(LOG_LOCAL_LEVEL) && LOG_LOCAL_LEVEL >= ESP_LOG_DEBUG +#elif LOG_LOCAL_LEVEL >= 4 #define network_handler_entry_print(State_Machine, begin) if(begin) network_manager_format_state_machine(ESP_LOG_DEBUG,begin?"BEGIN ENTRY":"END ENTRY",State_Machine,false,"") #define network_exit_handler_print(State_Machine, begin) if(begin) network_manager_format_state_machine(ESP_LOG_DEBUG,begin?"BEGIN EXIT":"END EXIT",State_Machine,false,"") #define network_handler_print(State_Machine, begin) if(begin) network_manager_format_state_machine(ESP_LOG_DEBUG,begin?"HANDLER START":"HANDLER END",State_Machine,false,"") #define NETWORK_PRINT_TRANSITION(begin, prefix, source,target, event, print_source,caller ) if(begin) network_manager_format_from_to_states(ESP_LOG_DEBUG, prefix, source,target, event, print_source,caller )#define NETWORK_EXECUTE_CB(mch) network_execute_cb(mch,__FUNCTION__); #define NETWORK_DEBUG_STATE_MACHINE(begin, cb_prefix,state_machine,print_from,caller) if(begin) network_manager_format_state_machine(ESP_LOG_DEBUG,cb_prefix,state_machine,print_from,caller) -#else +#endif +#endif + +#ifndef NETWORK_PRINT_TRANSITION #define network_exit_handler_print(nm, begin) #define network_handler_entry_print(State_Machine, begin) #define network_handler_print(State_Machine, begin) diff --git a/components/wifi-manager/network_manager_handlers.c b/components/wifi-manager/network_manager_handlers.c index 22e3103b..4c73b11a 100644 --- a/components/wifi-manager/network_manager_handlers.c +++ b/components/wifi-manager/network_manager_handlers.c @@ -362,7 +362,7 @@ static state_machine_result_t ETH_STARTING_STATE_exit_handler(state_machine_t* c static state_machine_result_t NETWORK_ETH_ACTIVE_STATE_entry_handler(state_machine_t* const State_Machine) { network_handler_entry_print(State_Machine,true); network_t* const nm = (network_t *)State_Machine; - network_set_timer(nm->eth_link_down_reboot_ms); + network_set_timer(nm->eth_link_down_reboot_ms,"Ethernet link not detected" ); NETWORK_EXECUTE_CB(State_Machine); network_handler_entry_print(State_Machine,false); return EVENT_HANDLED; @@ -370,6 +370,7 @@ static state_machine_result_t NETWORK_ETH_ACTIVE_STATE_entry_handler(state_machi static state_machine_result_t NETWORK_ETH_ACTIVE_STATE_handler(state_machine_t* const State_Machine) { network_handler_print(State_Machine,true); state_machine_result_t result = EVENT_UN_HANDLED; + network_t* const nm = (network_t *)State_Machine; switch (State_Machine->Event) { case EN_CONNECT_NEW: result= local_traverse_state(State_Machine, &Eth_Active_State[ETH_CONNECTING_NEW_STATE],__FUNCTION__); @@ -387,7 +388,7 @@ static state_machine_result_t NETWORK_ETH_ACTIVE_STATE_handler(state_machine_t* result= local_traverse_state(State_Machine, &Eth_Active_State[ETH_ACTIVE_CONNECTED_STATE],__FUNCTION__); break; case EN_TIMER: - ESP_LOGW(TAG, "Ethernet link timeout. Rebooting to wifi"); + ESP_LOGW(TAG, "Timeout %s. Rebooting to wifi",STR_OR_ALT(nm->timer_tag,"Ethernet link not detected")); network_prioritize_wifi(true); simple_restart(); //result= local_traverse_state(State_Machine, &Wifi_Active_State[WIFI_INITIALIZING_STATE],__FUNCTION__); @@ -411,7 +412,7 @@ static state_machine_result_t NETWORK_ETH_ACTIVE_STATE_handler(state_machine_t* } static state_machine_result_t NETWORK_ETH_ACTIVE_STATE_exit_handler(state_machine_t* const State_Machine) { network_exit_handler_print(State_Machine,true); - network_set_timer(0); + network_set_timer(0,NULL); network_exit_handler_print(State_Machine,false); return EVENT_HANDLED; } @@ -457,7 +458,7 @@ static state_machine_result_t ETH_CONNECTING_NEW_STATE_handler(state_machine_t* } static state_machine_result_t ETH_CONNECTING_NEW_STATE_exit_handler(state_machine_t* const State_Machine) { network_exit_handler_print(State_Machine,true); - network_set_timer(0); + network_set_timer(0,NULL); network_exit_handler_print(State_Machine,false); return EVENT_HANDLED; } @@ -468,7 +469,7 @@ static state_machine_result_t ETH_CONNECTING_NEW_STATE_exit_handler(state_machin static state_machine_result_t ETH_ACTIVE_LINKDOWN_STATE_entry_handler(state_machine_t* const State_Machine) { network_handler_entry_print(State_Machine,true); network_t* const nm = (network_t *)State_Machine; - network_set_timer(nm->eth_link_down_reboot_ms); + network_set_timer(nm->eth_link_down_reboot_ms, "Ethernet link down" ); NETWORK_EXECUTE_CB(State_Machine); messaging_post_message(MESSAGING_WARNING, MESSAGING_CLASS_SYSTEM, "Ethernet link down."); network_handler_entry_print(State_Machine,false); @@ -482,7 +483,7 @@ static state_machine_result_t ETH_ACTIVE_LINKDOWN_STATE_handler(state_machine_t* } static state_machine_result_t ETH_ACTIVE_LINKDOWN_STATE_exit_handler(state_machine_t* const State_Machine) { network_exit_handler_print(State_Machine,true); - network_set_timer(0); + network_set_timer(0,NULL); network_exit_handler_print(State_Machine,false); return EVENT_HANDLED; @@ -494,7 +495,7 @@ static state_machine_result_t ETH_ACTIVE_LINKDOWN_STATE_exit_handler(state_machi static state_machine_result_t ETH_ACTIVE_LINKUP_STATE_entry_handler(state_machine_t* const State_Machine) { network_handler_entry_print(State_Machine,true); network_t* const nm = (network_t *)State_Machine; - network_set_timer(nm->dhcp_timeout); + network_set_timer(nm->dhcp_timeout, "DHCP timeout" ); NETWORK_EXECUTE_CB(State_Machine); messaging_post_message(MESSAGING_INFO, MESSAGING_CLASS_SYSTEM, "Ethernet link up."); network_handler_entry_print(State_Machine,false); @@ -719,7 +720,7 @@ static state_machine_result_t WIFI_CONFIGURING_CONNECT_STATE_handler(state_machi case EN_CONNECTED: result=EVENT_HANDLED; ESP_LOGD(TAG,"Wifi was connected. Waiting for IP address"); - network_set_timer(nm->dhcp_timeout); + network_set_timer(nm->dhcp_timeout,"DHCP Timeout"); break; case EN_GOT_IP: network_status_update_ip_info(UPDATE_CONNECTION_OK); @@ -739,7 +740,7 @@ static state_machine_result_t WIFI_CONFIGURING_CONNECT_STATE_exit_handler(state_ network_exit_handler_print(State_Machine,true); FREE_AND_NULL(((network_t *)State_Machine)->event_parameters->disconnected_event); - network_set_timer(0); + network_set_timer(0,NULL); network_exit_handler_print(State_Machine,false); return EVENT_HANDLED; } @@ -825,7 +826,7 @@ static state_machine_result_t WIFI_CONNECTING_STATE_entry_handler(state_machine_ network_connect_active_ssid(State_Machine); nm->STA_duration = nm->sta_polling_min_ms; /* create timer for background STA connection */ - network_set_timer(nm->STA_duration); + network_set_timer(nm->STA_duration,"Wifi Polling timeout"); NETWORK_EXECUTE_CB(State_Machine); network_handler_entry_print(State_Machine,false); return EVENT_HANDLED; @@ -833,6 +834,7 @@ static state_machine_result_t WIFI_CONNECTING_STATE_entry_handler(state_machine_ static state_machine_result_t WIFI_CONNECTING_STATE_handler(state_machine_t* const State_Machine) { HANDLE_GLOBAL_EVENT(State_Machine); state_machine_result_t result = EVENT_HANDLED; + network_t* const nm = (network_t *)State_Machine; network_handler_print(State_Machine,true); switch (State_Machine->Event) { case EN_CONNECTED: @@ -841,6 +843,7 @@ static state_machine_result_t WIFI_CONNECTING_STATE_handler(state_machine_t* con case EN_TIMER: // try connecting again. // todo: implement multi-ap logic + ESP_LOGI(TAG, "Timer: %s ",STR_OR_ALT(nm->timer_tag,"Ethernet link not detected")); network_connect_active_ssid(State_Machine); break; default: @@ -899,7 +902,7 @@ static state_machine_result_t WIFI_CONNECTING_NEW_STATE_handler(state_machine_t* } static state_machine_result_t WIFI_CONNECTING_NEW_STATE_exit_handler(state_machine_t* const State_Machine) { network_exit_handler_print(State_Machine,true); - network_set_timer(0); + network_set_timer(0,NULL); FREE_AND_NULL(((network_t *)State_Machine)->event_parameters->disconnected_event); network_exit_handler_print(State_Machine,false); @@ -950,7 +953,7 @@ static state_machine_result_t WIFI_CONNECTING_NEW_FAILED_STATE_handler(state_mac } static state_machine_result_t WIFI_CONNECTING_NEW_FAILED_STATE_exit_handler(state_machine_t* const State_Machine) { network_exit_handler_print(State_Machine,true); - network_set_timer(0); + network_set_timer(0,NULL); FREE_AND_NULL(((network_t *)State_Machine)->event_parameters->disconnected_event); network_exit_handler_print(State_Machine,false); @@ -967,7 +970,7 @@ static state_machine_result_t WIFI_CONNECTED_STATE_entry_handler(state_machine_t network_handler_entry_print(State_Machine,true); nm->last_connected = esp_timer_get_time(); // cancel timeout pulse - network_set_timer(0); + network_set_timer(0,NULL); ESP_LOGD(TAG, "Checking if wifi config changed."); if (network_wifi_sta_config_changed()) { ESP_LOGD(TAG, "Wifi Config changed. Saving it."); @@ -1077,7 +1080,7 @@ static state_machine_result_t WIFI_LOST_CONNECTION_STATE_entry_handler(state_mac } /* keep polling for existing connection */ - network_set_timer(nm->STA_duration); + network_set_timer(nm->STA_duration, "Wifi Polling timeout"); ESP_LOGD(TAG, " STA search slow polling of %d", nm->STA_duration); } } @@ -1088,6 +1091,7 @@ static state_machine_result_t WIFI_LOST_CONNECTION_STATE_entry_handler(state_mac } static state_machine_result_t WIFI_LOST_CONNECTION_STATE_handler(state_machine_t* const State_Machine) { HANDLE_GLOBAL_EVENT(State_Machine); + network_t* const nm = (network_t *)State_Machine; state_machine_result_t result = EVENT_HANDLED; network_handler_print(State_Machine,true); switch (State_Machine->Event) { @@ -1095,6 +1099,7 @@ static state_machine_result_t WIFI_LOST_CONNECTION_STATE_handler(state_machine_t result= local_traverse_state(State_Machine, &Wifi_Configuring_State[WIFI_CONFIGURING_STATE],__FUNCTION__); break; case EN_TIMER: + ESP_LOGI(TAG, "Timer: %s ",STR_OR_ALT(nm->timer_tag,"Lost connection")); result= local_traverse_state(State_Machine, &Wifi_Active_State[WIFI_LOST_CONNECTION_STATE],__FUNCTION__); break; case EN_CONNECT: