改了重连的配置
This commit is contained in:
parent
0c89787e77
commit
a5a8647d6a
|
@ -69,6 +69,7 @@
|
||||||
"stdio.h": "c",
|
"stdio.h": "c",
|
||||||
"time.h": "c",
|
"time.h": "c",
|
||||||
"ch32v30x.h": "c",
|
"ch32v30x.h": "c",
|
||||||
"lwutil.h": "c"
|
"lwutil.h": "c",
|
||||||
|
"netdev.h": "c"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
* @Author: mbw
|
* @Author: mbw
|
||||||
* @Date: 2024-11-30 15:46:21
|
* @Date: 2024-11-30 15:46:21
|
||||||
* @LastEditors: mbw && 1600520629@qq.com
|
* @LastEditors: mbw && 1600520629@qq.com
|
||||||
* @LastEditTime: 2025-02-21 14:49:11
|
* @LastEditTime: 2025-02-21 18:33:03
|
||||||
* @FilePath: \ble_bjq_ch303rct6_ml307\bsp\src\at_device_ml307.c
|
* @FilePath: \ble_bjq_ch303rct6_ml307\bsp\src\at_device_ml307.c
|
||||||
* @Description:
|
* @Description:
|
||||||
*
|
*
|
||||||
|
@ -884,7 +884,6 @@ static void ml307_init_thread_entry(void *parameter)
|
||||||
#define CGATT_RETRY 10
|
#define CGATT_RETRY 10
|
||||||
#define ML307_AT_DEFAULT_TIMEOUT 5000
|
#define ML307_AT_DEFAULT_TIMEOUT 5000
|
||||||
int i;
|
int i;
|
||||||
rt_uint8_t retry_num = INIT_RETRY;
|
|
||||||
rt_err_t result = RT_EOK;
|
rt_err_t result = RT_EOK;
|
||||||
at_response_t resp = RT_NULL;
|
at_response_t resp = RT_NULL;
|
||||||
struct at_device *device = (struct at_device *)parameter;
|
struct at_device *device = (struct at_device *)parameter;
|
||||||
|
@ -900,7 +899,7 @@ static void ml307_init_thread_entry(void *parameter)
|
||||||
|
|
||||||
LOG_D("start init %s device.", device->name);
|
LOG_D("start init %s device.", device->name);
|
||||||
ml307_power_off(device);
|
ml307_power_off(device);
|
||||||
while (retry_num--)
|
while (1)
|
||||||
{
|
{
|
||||||
/* power on the ml307 device */
|
/* power on the ml307 device */
|
||||||
rt_thread_mdelay(1000);
|
rt_thread_mdelay(1000);
|
||||||
|
@ -966,7 +965,6 @@ static void ml307_init_thread_entry(void *parameter)
|
||||||
result = -RT_ERROR;
|
result = -RT_ERROR;
|
||||||
goto __exit;
|
goto __exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
#define ML307_NETDEV_HWADDR_LEN 8
|
#define ML307_NETDEV_HWADDR_LEN 8
|
||||||
#define ML307_IMEI_LEN 15
|
#define ML307_IMEI_LEN 15
|
||||||
|
@ -1153,7 +1151,7 @@ static void ml307_init_thread_entry(void *parameter)
|
||||||
if (result != RT_EOK)
|
if (result != RT_EOK)
|
||||||
{
|
{
|
||||||
/* power off the ml307 device */
|
/* power off the ml307 device */
|
||||||
// ml307_power_off(device);
|
ml307_power_off(device);
|
||||||
rt_thread_mdelay(1000);
|
rt_thread_mdelay(1000);
|
||||||
|
|
||||||
LOG_I("%s device initialize retry...", device->name);
|
LOG_I("%s device initialize retry...", device->name);
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
* @Author: mbw
|
* @Author: mbw
|
||||||
* @Date: 2024-11-30 15:46:21
|
* @Date: 2024-11-30 15:46:21
|
||||||
* @LastEditors: mbw && 1600520629@qq.com
|
* @LastEditors: mbw && 1600520629@qq.com
|
||||||
* @LastEditTime: 2025-02-21 14:47:59
|
* @LastEditTime: 2025-02-22 15:59:21
|
||||||
* @FilePath: \ble_bjq_ch303rct6_ml307\bsp\src\bsp_ml307.c
|
* @FilePath: \ble_bjq_ch303rct6_ml307\bsp\src\bsp_ml307.c
|
||||||
* @Description:
|
* @Description:
|
||||||
*
|
*
|
||||||
|
@ -26,7 +26,7 @@
|
||||||
#if IOT_MODULE_SWITCH == 1
|
#if IOT_MODULE_SWITCH == 1
|
||||||
#define ML307_THREAD_STACK_SIZE (4096 + 2048)
|
#define ML307_THREAD_STACK_SIZE (4096 + 2048)
|
||||||
#define ML307_RECV_THREAD_STACK_SIZE (4096 + 2048)
|
#define ML307_RECV_THREAD_STACK_SIZE (4096 + 2048)
|
||||||
#define ML307_LIFE_THREAD_STACK_SIZE (1024)
|
#define ML307_LIFE_THREAD_STACK_SIZE (4096)
|
||||||
#define ML307_THREAD_PRIORITY 25
|
#define ML307_THREAD_PRIORITY 25
|
||||||
#define ML307_THREAD_TICKS 50
|
#define ML307_THREAD_TICKS 50
|
||||||
#define ML307_RECV_THREAD_PRIORITY 24
|
#define ML307_RECV_THREAD_PRIORITY 24
|
||||||
|
@ -1802,61 +1802,48 @@ static void Ml307_Life_Thread_Entry(void *parameter)
|
||||||
result = -RT_ERROR;
|
result = -RT_ERROR;
|
||||||
goto __exit;
|
goto __exit;
|
||||||
}
|
}
|
||||||
LOG_D("AT+MIPCFG=\"encoding\",0,1,1");
|
/*disable sleep mode */
|
||||||
|
if (at_obj_exec_cmd(device->client, resp, "AT+MLPMCFG=\"sleepmode\",0,1") != RT_EOK)
|
||||||
|
{
|
||||||
|
result = -RT_ERROR;
|
||||||
|
goto __exit;
|
||||||
|
}
|
||||||
/*设置包模式*/
|
/*设置包模式*/
|
||||||
if (at_obj_exec_cmd(device->client, resp, "AT+MIPCFG=\"encoding\",0,1,1") != RT_EOK)
|
if (at_obj_exec_cmd(device->client, resp, "AT+MIPCFG=\"encoding\",0,1,1") != RT_EOK)
|
||||||
{
|
{
|
||||||
result = -RT_ERROR;
|
result = -RT_ERROR;
|
||||||
goto __exit;
|
goto __exit;
|
||||||
}
|
}
|
||||||
rt_uint8_t cnt = 0;
|
/*设置包模式*/
|
||||||
/* check signal strength */
|
if (at_obj_exec_cmd(device->client, resp, "AT+MIPCFG=\"autofree\",0,0") != RT_EOK)
|
||||||
for (cnt = 0; cnt < 10; cnt++)
|
|
||||||
{
|
{
|
||||||
if (at_obj_exec_cmd(device->client, resp, "AT+CSQ") == RT_EOK)
|
|
||||||
{
|
|
||||||
int signal_strength = 0, err_rate = 0;
|
|
||||||
|
|
||||||
if (at_resp_parse_line_args_by_kw(resp, "+CSQ:", "+CSQ: %d,%d", &signal_strength, &err_rate) > 0)
|
|
||||||
{
|
|
||||||
if ((signal_strength != 99) && (signal_strength != 0))
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
rt_thread_mdelay(1000);
|
|
||||||
}
|
|
||||||
if (cnt == 10)
|
|
||||||
{
|
|
||||||
LOG_E("%s device signal strength check failed", device->name);
|
|
||||||
result = -RT_ERROR;
|
result = -RT_ERROR;
|
||||||
goto __exit;
|
goto __exit;
|
||||||
}
|
}
|
||||||
/* check the GPRS network is registered */
|
/*设置心跳包*/
|
||||||
for (cnt = 0; cnt < 10; cnt++)
|
if (at_obj_exec_cmd(device->client, resp, "AT+MIPTKA=0,1,120,60,1") != RT_EOK)
|
||||||
{
|
{
|
||||||
if (at_obj_exec_cmd(device->client, resp, "AT+CEREG?") == RT_EOK) // 60s内注册CS业务
|
|
||||||
{
|
|
||||||
int link_stat = 0;
|
|
||||||
|
|
||||||
if (at_resp_parse_line_args_by_kw(resp, "+CEREG:", "+CEREG: %*d,%d", &link_stat) > 0)
|
|
||||||
{
|
|
||||||
if ((link_stat == 1) || (link_stat == 5))
|
|
||||||
{
|
|
||||||
LOG_D("%s device GPRS is registered", device->name);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
rt_thread_mdelay(1000);
|
|
||||||
}
|
|
||||||
if (cnt == 10)
|
|
||||||
{
|
|
||||||
LOG_E("%s device GPRS is register failed", device->name);
|
|
||||||
result = -RT_ERROR;
|
result = -RT_ERROR;
|
||||||
goto __exit;
|
goto __exit;
|
||||||
}
|
}
|
||||||
|
/* Define PDP Context */
|
||||||
|
rt_uint8_t i = 0,
|
||||||
|
for (i = 0; i < 5; i++)
|
||||||
|
{
|
||||||
|
if (at_obj_exec_cmd(client, resp, "AT+CGDCONT=1,\"IPV4V6\",\"cmnet\"") == RT_EOK)
|
||||||
|
{
|
||||||
|
LOG_D("%s device Define PDP Context Success.", device->name);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
rt_thread_mdelay(1000);
|
||||||
|
}
|
||||||
|
if (i == 5)
|
||||||
|
{
|
||||||
|
LOG_E("%s device Define PDP Context failed.", device->name);
|
||||||
|
result = -RT_ERROR;
|
||||||
|
goto __exit;
|
||||||
|
}
|
||||||
|
|
||||||
if (device->class->device_ops->control(device, AT_DEVICE_CTRL_NET_CONN, RT_NULL) == RT_EOK)
|
if (device->class->device_ops->control(device, AT_DEVICE_CTRL_NET_CONN, RT_NULL) == RT_EOK)
|
||||||
{
|
{
|
||||||
LOG_D("重连网络成功\n");
|
LOG_D("重连网络成功\n");
|
||||||
|
|
Loading…
Reference in New Issue