From ba9f87332a1c90eef8922913a6c0f990ec675e92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E9=A9=AC=5F666?= <13089258+pony-six-hundred-and-sixty-six@user.noreply.gitee.com> Date: Fri, 7 Feb 2025 17:21:13 +0800 Subject: [PATCH] v1.0 --- bsp/src/at_device_nt26k.c | 18 +++++++++++------- bsp/src/bsp_nt26k.c | 14 ++++++++++++-- rt-thread/rtconfig.h | 3 ++- 3 files changed, 25 insertions(+), 10 deletions(-) diff --git a/bsp/src/at_device_nt26k.c b/bsp/src/at_device_nt26k.c index 86730a6..f3b1567 100644 --- a/bsp/src/at_device_nt26k.c +++ b/bsp/src/at_device_nt26k.c @@ -90,10 +90,11 @@ static int nt26k_power_on(struct at_device *device) nt26k = (struct at_device_nt26k *)device->user_data; rt_pin_write(nt26k->pwr_en_pin, PIN_LOW); - rt_thread_mdelay(10); + rt_thread_mdelay(1000); rt_pin_write(nt26k->pwr_en_pin, PIN_HIGH); - - return device->class->device_ops->control(device, AT_DEVICE_CTRL_WAKEUP, RT_NULL); + rt_thread_mdelay(1000); + return 0; + // return device->class->device_ops->control(device, AT_DEVICE_CTRL_WAKEUP, RT_NULL); } static rt_err_t nt26k_power_off(struct at_device *device) @@ -230,6 +231,7 @@ static void urc_tcp_recv(struct at_client *client, const char *data, rt_size_t s { rt_memset(nt26k_ops.recv, 0, sizeof(struct Nt26kRecvData)); // 清空结构体 rt_memcpy(nt26k_ops.recv, recv_byte_buf, sizeof(struct Nt26kRecvData)); + nt26k_connect_sever_flag = 1; if ((nt26k_ops.recv->recv_data.event_type == INSTRUCTION_HEART_BEAT) || (nt26k_ops.recv->recv_data.event_type == EVENT_TYPE_POWER_ON)) // 加这个的原因就是如果有指令下发,会出现两个信号量,指令会执行两次,所以排除心跳包才释放信号量 @@ -457,6 +459,7 @@ int nt26k_netdev_set_info(struct netdev *netdev) result = -RT_ENOMEM; goto __exit; } + rt_thread_mdelay(IMEI_Delay()); device->class->device_ops->control(device, AT_DEVICE_CTRL_NET_CONN, RT_NULL); // 打开连接 __exit: if (resp) @@ -782,7 +785,7 @@ static void nt26k_init_thread_entry(void *parameter) struct at_device *device = (struct at_device *)parameter; struct at_client *client = device->client; - resp = at_create_resp(128, 0, rt_tick_from_millisecond(300)); + resp = at_create_resp(128, 0, rt_tick_from_millisecond(1000)); if (resp == RT_NULL) { LOG_E("no memory for resp create."); @@ -791,7 +794,7 @@ static void nt26k_init_thread_entry(void *parameter) } LOG_D("start init %s device.", device->name); - + while (1) { /* power on the nt26k device */ @@ -1072,9 +1075,10 @@ static void nt26k_init_thread_entry(void *parameter) if (result != RT_EOK) { /* power off the nt26k device */ - nt26k_power_off(device); - rt_thread_mdelay(1000); LOG_I("%s device initialize retry...", device->name); + // nt26k_power_off(device); + rt_thread_mdelay(1000); + } } diff --git a/bsp/src/bsp_nt26k.c b/bsp/src/bsp_nt26k.c index 7c43cb0..c5987c3 100644 --- a/bsp/src/bsp_nt26k.c +++ b/bsp/src/bsp_nt26k.c @@ -1481,13 +1481,17 @@ static void Nt26k_Life_Thread_Entry(void *parameter) LOG_D("AT device power on success"); rt_thread_mdelay(RT_TICK_PER_SECOND / 2); /* disable echo */ - at_client_obj_wait_connect(device->client, 5000); + LOG_D("AT"); + at_client_obj_wait_connect(device->client, 10000); + /* disable echo */ + LOG_D("ATE0"); if (at_obj_exec_cmd(device->client, resp, "ATE0") != RT_EOK) { result = -RT_ERROR; goto __exit; } + LOG_D("AT+QICFG=\"dataformat"); /*AT+QICFG="dataformat" 设置收发模式*/ if (at_obj_exec_cmd(device->client, resp, "AT+QICFG=\"dataformat\",%d,%d", AT_NSONMI_MODE_DEFAULT, AT_NSONMI_MODE_DEFAULT) != RT_EOK) { @@ -1496,6 +1500,7 @@ static void Nt26k_Life_Thread_Entry(void *parameter) goto __exit; } /*设置显示模式*/ + LOG_D("AT+QICFG=\"viewmode\",1"); if (at_obj_exec_cmd(device->client, resp, "AT+QICFG=\"viewmode\",1") != RT_EOK) { LOG_E("AT+QICFG=\"viewmode\" error\n"); @@ -1503,18 +1508,21 @@ static void Nt26k_Life_Thread_Entry(void *parameter) goto __exit; } /*设置保活信息*/ + LOG_D("AT+QICFG=\"tcp/keepalive\",1,1000,100,10"); if (at_obj_exec_cmd(device->client, resp, "AT+QICFG=\"tcp/keepalive\",1,1000,100,10") != RT_EOK) { LOG_E("AT+QICFG=\"tcp/keepalive\" error\n"); result = -RT_ETIMEOUT; goto __exit; } + LOG_D("AT+QICFG=\"passiveclosed\",1"); if (at_obj_exec_cmd(device->client, resp, "AT+QICFG=\"passiveclosed\",1") != RT_EOK) { LOG_E("AT+QICFG=\"passiveclosed\" error\n"); result = -RT_ETIMEOUT; goto __exit; } + LOG_D("AT+CGACT=1,1"); if (at_obj_exec_cmd(device->client, resp, "AT+CGACT=1,1") != RT_EOK) { LOG_E("AT+CGACT=1,1 error\n"); @@ -1527,8 +1535,10 @@ static void Nt26k_Life_Thread_Entry(void *parameter) nt26k_conncet_tcp_flag = RT_TRUE; delay_n = 0; nt26k_disconnect_retry_flag = 0; - Nt26k_Send_Event(kNt26kHeartbeatEvent); at_delete_resp(resp); + rt_thread_mdelay(100); + Nt26k_Send_Event(kNt26kHeartbeatEvent); + } else { diff --git a/rt-thread/rtconfig.h b/rt-thread/rtconfig.h index 4662ee6..ca53d9c 100644 --- a/rt-thread/rtconfig.h +++ b/rt-thread/rtconfig.h @@ -155,8 +155,9 @@ #define AT_USING_CLIENT #define AT_CLIENT_NUM_MAX 1 +#define AT_USING_CLI + #ifndef FINSH_USING_AUTH - #define AT_USING_CLI #define AT_PRINT_RAW_CMD #endif