This commit is contained in:
小马_666 2025-02-07 17:21:13 +08:00
parent c7114700ff
commit ba9f87332a
3 changed files with 25 additions and 10 deletions

View File

@ -90,10 +90,11 @@ static int nt26k_power_on(struct at_device *device)
nt26k = (struct at_device_nt26k *)device->user_data; nt26k = (struct at_device_nt26k *)device->user_data;
rt_pin_write(nt26k->pwr_en_pin, PIN_LOW); 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); rt_pin_write(nt26k->pwr_en_pin, PIN_HIGH);
rt_thread_mdelay(1000);
return device->class->device_ops->control(device, AT_DEVICE_CTRL_WAKEUP, RT_NULL); 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) 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_memset(nt26k_ops.recv, 0, sizeof(struct Nt26kRecvData)); // 清空结构体
rt_memcpy(nt26k_ops.recv, recv_byte_buf, 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) || if ((nt26k_ops.recv->recv_data.event_type == INSTRUCTION_HEART_BEAT) ||
(nt26k_ops.recv->recv_data.event_type == EVENT_TYPE_POWER_ON)) (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; result = -RT_ENOMEM;
goto __exit; goto __exit;
} }
rt_thread_mdelay(IMEI_Delay());
device->class->device_ops->control(device, AT_DEVICE_CTRL_NET_CONN, RT_NULL); // 打开连接 device->class->device_ops->control(device, AT_DEVICE_CTRL_NET_CONN, RT_NULL); // 打开连接
__exit: __exit:
if (resp) if (resp)
@ -782,7 +785,7 @@ static void nt26k_init_thread_entry(void *parameter)
struct at_device *device = (struct at_device *)parameter; struct at_device *device = (struct at_device *)parameter;
struct at_client *client = device->client; 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) if (resp == RT_NULL)
{ {
LOG_E("no memory for resp create."); LOG_E("no memory for resp create.");
@ -1072,9 +1075,10 @@ static void nt26k_init_thread_entry(void *parameter)
if (result != RT_EOK) if (result != RT_EOK)
{ {
/* power off the nt26k device */ /* power off the nt26k device */
nt26k_power_off(device);
rt_thread_mdelay(1000);
LOG_I("%s device initialize retry...", device->name); LOG_I("%s device initialize retry...", device->name);
// nt26k_power_off(device);
rt_thread_mdelay(1000);
} }
} }

View File

@ -1481,13 +1481,17 @@ static void Nt26k_Life_Thread_Entry(void *parameter)
LOG_D("AT device power on success"); LOG_D("AT device power on success");
rt_thread_mdelay(RT_TICK_PER_SECOND / 2); rt_thread_mdelay(RT_TICK_PER_SECOND / 2);
/* disable echo */ /* disable echo */
at_client_obj_wait_connect(device->client, 5000); LOG_D("AT");
at_client_obj_wait_connect(device->client, 10000);
/* disable echo */ /* disable echo */
LOG_D("ATE0");
if (at_obj_exec_cmd(device->client, resp, "ATE0") != RT_EOK) if (at_obj_exec_cmd(device->client, resp, "ATE0") != RT_EOK)
{ {
result = -RT_ERROR; result = -RT_ERROR;
goto __exit; goto __exit;
} }
LOG_D("AT+QICFG=\"dataformat");
/*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) 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; goto __exit;
} }
/*设置显示模式*/ /*设置显示模式*/
LOG_D("AT+QICFG=\"viewmode\",1");
if (at_obj_exec_cmd(device->client, resp, "AT+QICFG=\"viewmode\",1") != RT_EOK) if (at_obj_exec_cmd(device->client, resp, "AT+QICFG=\"viewmode\",1") != RT_EOK)
{ {
LOG_E("AT+QICFG=\"viewmode\" error\n"); LOG_E("AT+QICFG=\"viewmode\" error\n");
@ -1503,18 +1508,21 @@ static void Nt26k_Life_Thread_Entry(void *parameter)
goto __exit; 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) 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"); LOG_E("AT+QICFG=\"tcp/keepalive\" error\n");
result = -RT_ETIMEOUT; result = -RT_ETIMEOUT;
goto __exit; goto __exit;
} }
LOG_D("AT+QICFG=\"passiveclosed\",1");
if (at_obj_exec_cmd(device->client, resp, "AT+QICFG=\"passiveclosed\",1") != RT_EOK) if (at_obj_exec_cmd(device->client, resp, "AT+QICFG=\"passiveclosed\",1") != RT_EOK)
{ {
LOG_E("AT+QICFG=\"passiveclosed\" error\n"); LOG_E("AT+QICFG=\"passiveclosed\" error\n");
result = -RT_ETIMEOUT; result = -RT_ETIMEOUT;
goto __exit; goto __exit;
} }
LOG_D("AT+CGACT=1,1");
if (at_obj_exec_cmd(device->client, resp, "AT+CGACT=1,1") != RT_EOK) if (at_obj_exec_cmd(device->client, resp, "AT+CGACT=1,1") != RT_EOK)
{ {
LOG_E("AT+CGACT=1,1 error\n"); 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; nt26k_conncet_tcp_flag = RT_TRUE;
delay_n = 0; delay_n = 0;
nt26k_disconnect_retry_flag = 0; nt26k_disconnect_retry_flag = 0;
Nt26k_Send_Event(kNt26kHeartbeatEvent);
at_delete_resp(resp); at_delete_resp(resp);
rt_thread_mdelay(100);
Nt26k_Send_Event(kNt26kHeartbeatEvent);
} }
else else
{ {

View File

@ -155,8 +155,9 @@
#define AT_USING_CLIENT #define AT_USING_CLIENT
#define AT_CLIENT_NUM_MAX 1 #define AT_CLIENT_NUM_MAX 1
#ifndef FINSH_USING_AUTH
#define AT_USING_CLI #define AT_USING_CLI
#ifndef FINSH_USING_AUTH
#define AT_PRINT_RAW_CMD #define AT_PRINT_RAW_CMD
#endif #endif