From 19ec1c975b0f446d6ff48c288cc60c2016ea8a62 Mon Sep 17 00:00:00 2001 From: "yao.yqg" Date: Thu, 24 Jun 2021 11:18:10 +0800 Subject: [PATCH 1/2] fix the bug that NULL parameters cause reconnection failed --- src/netmgr_service.c | 10 ++++++++++ src/netmgr_wifi.c | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/netmgr_service.c b/src/netmgr_service.c index d4f651f..e80dbbf 100644 --- a/src/netmgr_service.c +++ b/src/netmgr_service.c @@ -243,6 +243,16 @@ int netmgr_get_ifconfig(netmgr_hdl_t hdl, netmgr_ifconfig_info_t* info) void netmgr_set_auto_reconnect(netmgr_hdl_t hdl, bool enable) { + if(hdl == NULL) + { + hdl = netmgr_get_dev(DEV_WIFI_NAME); + if(hdl == -1) + { + printf("get dev %s handler failed!\n\r", DEV_WIFI_NAME); + return; + } + } + if(get_hdl_type(hdl) == NETMGR_TYPE_WIFI) { netmgr_wifi_auto_reconnect(enable); } diff --git a/src/netmgr_wifi.c b/src/netmgr_wifi.c index a047bc0..d9b6c93 100644 --- a/src/netmgr_wifi.c +++ b/src/netmgr_wifi.c @@ -605,7 +605,7 @@ static void reconnect_task_handle(void* arg) memset(¶ms, 0, sizeof(params)); NETMGR_WIFI_LOGI("%s:%d\n", __func__, __LINE__); //netmgr_stat_chg_event(m, NOTIFY_CONN_RECONNECT, NULL); - if(0 != netmgr_wifi_connect(0, ¶ms)) { + if(0 != netmgr_wifi_connect(conn->hdl, ¶ms)) { if(ioctl(conn->hdl, WIFI_DEV_CMD_CANCEL_CONNECT, NULL) != 0) { NETMGR_WIFI_LOGE("WIFI_DEV_CMD_CANCEL_CONNECT failed\n"); } -- Gitee From a24b4345e1563c323daab0f9800bde50ce1ef76b Mon Sep 17 00:00:00 2001 From: "yao.yqg" Date: Thu, 24 Jun 2021 15:03:04 +0800 Subject: [PATCH 2/2] modify the handling input invalid parameter for netmgr_set_auto_reconnect() --- src/netmgr_service.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/netmgr_service.c b/src/netmgr_service.c index e80dbbf..29e87d4 100644 --- a/src/netmgr_service.c +++ b/src/netmgr_service.c @@ -243,7 +243,7 @@ int netmgr_get_ifconfig(netmgr_hdl_t hdl, netmgr_ifconfig_info_t* info) void netmgr_set_auto_reconnect(netmgr_hdl_t hdl, bool enable) { - if(hdl == NULL) + if(get_hdl_type(hdl) == NETMGR_TYPE_UNKNOWN) { hdl = netmgr_get_dev(DEV_WIFI_NAME); if(hdl == -1) -- Gitee