Skip to content

Commit

Permalink
Fix #287: wifi_manager_stop causes panic handler when it is called be…
Browse files Browse the repository at this point in the history
…fore wifi_manager_start (#288)

* Fix #287: wifi_manager_stop causes panic handler when it is called before wifi_manager_start

* [#287] Fix code smell found by SonarCloud
  • Loading branch information
TheSomeMan authored Apr 16, 2024
1 parent 3c2e46f commit 9fd73e9
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/wifi_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,10 @@ wifi_manager_disable_wps(void)
void
wifi_manager_stop(void)
{
if (!wifi_manager_is_initialized())
{
return;
}
if (!wifiman_msg_send_cmd_stop_and_destroy())
{
LOG_ERR("%s failed", "wifiman_msg_send_cmd_stop_and_destroy");
Expand Down
10 changes: 10 additions & 0 deletions src/wifi_manager_internal.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,16 @@ static os_sema_static_t g_scan_sync_sema_mem;
static os_mutex_recursive_t g_p_wifi_mutex;
static os_mutex_recursive_static_t g_wifi_manager_mutex_mem;

bool
wifi_manager_is_initialized(void)
{
if (NULL == g_p_wifi_mutex)
{
return false;
}
return true;
}

void
wifi_manager_init_mutex(void)
{
Expand Down
3 changes: 3 additions & 0 deletions src/wifi_manager_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ extern EventGroupHandle_t g_p_wifi_manager_event_group;
extern esp_wps_config_t g_wps_config;
extern bool g_wifi_wps_enabled;

bool
wifi_manager_is_initialized(void);

void
wifi_manager_init_mutex(void);

Expand Down

0 comments on commit 9fd73e9

Please sign in to comment.