Skip to content

Commit

Permalink
fix: Mlink_notice repeated call error
Browse files Browse the repository at this point in the history
  • Loading branch information
zhanzhaocheng committed Jan 23, 2019
1 parent 98da338 commit 80ee026
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 8 deletions.
4 changes: 2 additions & 2 deletions components/mlink/mlink_handle.c
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ static mdf_err_t mlink_handle_set_ota_fallback(mlink_handle_data_t *handle_data)
ret = mupgrade_version_fallback();
MDF_ERROR_CHECK(ret != MDF_OK, ret, "Upgrade error back to previous version");

return MDF_OK;
return mlink_handle_system_reboot(handle_data);
}

static mdf_err_t mlink_handle_get_config(mlink_handle_data_t *handle_data)
Expand Down Expand Up @@ -717,7 +717,7 @@ mdf_err_t mlink_handle(const uint8_t *src_addr, const mlink_httpd_type_t *type,
ret = mwifi_write(dest_addr, &data_type, handle_data.resp_data, handle_data.resp_size, true);
MDF_LOGD("resp_size: %d, resp: %.*s", handle_data.resp_size, handle_data.resp_size, handle_data.resp_data);
MDF_FREE(handle_data.resp_data);
MDF_ERROR_CHECK(ret != ESP_OK, ret, "mdf_write, ret: %d", ret);
MDF_ERROR_CHECK(ret != ESP_OK, ret, "mdf_write");

return MDF_OK;
}
4 changes: 4 additions & 0 deletions components/mlink/mlink_httpd.c
Original file line number Diff line number Diff line change
Expand Up @@ -863,6 +863,10 @@ mdf_err_t mlink_httpd_start(void)

mdf_err_t mlink_httpd_stop(void)
{
if (!g_httpd_handle) {
return MDF_OK;
}

mdf_err_t ret = MDF_OK;
void *mlink_queue_exit = NULL;

Expand Down
32 changes: 26 additions & 6 deletions components/mlink/mlink_notice.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@

static QueueHandle_t *g_notice_udp_queue = NULL;
static SemaphoreHandle_t g_notice_udp_exit_sem = NULL;
static bool g_notice_udp_exit_flag = false;
static bool g_notice_udp_exit_flag = true;
static bool g_notice_mdns_init_flag = false;
static const char *TAG = "mlink_notice";

Expand Down Expand Up @@ -94,6 +94,10 @@ static mdf_err_t mlink_notice_mdns_init(void)

static void mlink_notice_mdns_deinit(void)
{
if (!g_notice_mdns_init_flag) {
return ;
}

mdns_free();
g_notice_mdns_init_flag = false;
}
Expand Down Expand Up @@ -316,6 +320,12 @@ mdf_err_t mlink_notice_write(const char *message, size_t size, const uint8_t *ad

static mdf_err_t mlink_notice_udp_init()
{
if (!g_notice_udp_exit_flag) {
return MDF_OK;
}

g_notice_udp_exit_flag = false;

if (!g_notice_udp_queue) {
g_notice_udp_queue = xQueueCreate(MLINK_NOTICE_UDP_QUEUE_NUM, sizeof(void *));
}
Expand All @@ -333,12 +343,22 @@ static mdf_err_t mlink_notice_udp_init()

static void mlink_notice_udp_deinit()
{
if (g_notice_udp_exit_flag) {
return ;
}

g_notice_udp_exit_flag = true;
xSemaphoreTake(g_notice_udp_exit_sem, portMAX_DELAY);
vQueueDelete(g_notice_udp_exit_sem);
vQueueDelete(g_notice_udp_queue);
g_notice_udp_exit_sem = NULL;
g_notice_udp_queue = NULL;

if (g_notice_udp_exit_sem) {
xSemaphoreTake(g_notice_udp_exit_sem, portMAX_DELAY);
vQueueDelete(g_notice_udp_exit_sem);
g_notice_udp_exit_sem = NULL;
}

if (g_notice_udp_queue) {
vQueueDelete(g_notice_udp_queue);
g_notice_udp_queue = NULL;
}
}

mdf_err_t mlink_notice_init()
Expand Down

0 comments on commit 80ee026

Please sign in to comment.