@@ -106,37 +106,40 @@ static gui_element_icontext_t wifi_indicator(void) {
106106 wifi_mode_t mode = WIFI_MODE_NULL ;
107107 bsp_radio_state_t state ;
108108 bsp_power_get_radio_state (& state );
109- if (state == BSP_POWER_RADIO_STATE_OFF ) {
110- return (gui_element_icontext_t ){get_icon (ICON_WIFI ), "OFF" };
111- }
112- if (state == BSP_POWER_RADIO_STATE_BOOTLOADER ) {
113- return (gui_element_icontext_t ){get_icon (ICON_WIFI ), "BOOTLOADER" };
114- }
115- if (radio_initialized && esp_wifi_get_mode (& mode ) == ESP_OK ) {
116- if (mode == WIFI_MODE_STA || mode == WIFI_MODE_APSTA ) {
117- if (wifi_connection_is_connected () && esp_wifi_sta_get_ap_info (& connected_ap ) == ESP_OK ) {
118- pax_buf_t * icon = get_icon (ICON_WIFI_0 );
119- if (connected_ap .rssi > -50 ) {
120- icon = get_icon (ICON_WIFI_4 );
121- } else if (connected_ap .rssi > -60 ) {
122- icon = get_icon (ICON_WIFI_3 );
123- } else if (connected_ap .rssi > -70 ) {
124- icon = get_icon (ICON_WIFI_2 );
125- } else if (connected_ap .rssi > -80 ) {
126- icon = get_icon (ICON_WIFI_1 );
109+ switch (state ) {
110+ case BSP_POWER_RADIO_STATE_OFF :
111+ return (gui_element_icontext_t ){NULL , "" };
112+ case BSP_POWER_RADIO_STATE_BOOTLOADER :
113+ return (gui_element_icontext_t ){NULL , "BOOT" };
114+ case BSP_POWER_RADIO_STATE_APPLICATION :
115+ default :
116+ if (radio_initialized && esp_wifi_get_mode (& mode ) == ESP_OK ) {
117+ if (mode == WIFI_MODE_STA || mode == WIFI_MODE_APSTA ) {
118+ if (wifi_connection_is_connected () && esp_wifi_sta_get_ap_info (& connected_ap ) == ESP_OK ) {
119+ pax_buf_t * icon = get_icon (ICON_WIFI_0 );
120+ if (connected_ap .rssi > -50 ) {
121+ icon = get_icon (ICON_WIFI_4 );
122+ } else if (connected_ap .rssi > -60 ) {
123+ icon = get_icon (ICON_WIFI_3 );
124+ } else if (connected_ap .rssi > -70 ) {
125+ icon = get_icon (ICON_WIFI_2 );
126+ } else if (connected_ap .rssi > -80 ) {
127+ icon = get_icon (ICON_WIFI_1 );
128+ }
129+ return (gui_element_icontext_t ){icon , (char * )connected_ap .ssid };
130+ } else {
131+ return (gui_element_icontext_t ){get_icon (ICON_WIFI_OFF ), "Disconnected" };
132+ }
133+ } else if (mode == WIFI_MODE_AP ) {
134+ return (gui_element_icontext_t ){get_icon (ICON_WIFI_OFF ), "" }; // AP mode is currently unused
135+ // The device will be in AP mode by default until connection to a network is
136+ } else {
137+ return (gui_element_icontext_t ){get_icon (ICON_WIFI_UNKNOWN ), "Other" };
127138 }
128- return (gui_element_icontext_t ){icon , (char * )connected_ap .ssid };
129139 } else {
130- return (gui_element_icontext_t ){get_icon (ICON_WIFI_OFF ), "Disconnected " };
140+ return (gui_element_icontext_t ){get_icon (ICON_WIFI_ERROR ), "" };
131141 }
132- } else if (mode == WIFI_MODE_AP ) {
133- return (gui_element_icontext_t ){get_icon (ICON_WIFI_OFF ), "" }; // AP mode is currently unused
134- // The device will be in AP mode by default until connection to a network is
135- } else {
136- return (gui_element_icontext_t ){get_icon (ICON_WIFI_UNKNOWN ), "Other" };
137- }
138- } else {
139- return (gui_element_icontext_t ){get_icon (ICON_WIFI_ERROR ), "" };
142+ break ;
140143 }
141144}
142145
0 commit comments