将保活每隔30min钟3重新启动一下
This commit is contained in:
parent
0ef073439e
commit
5e5ecc7d30
|
@ -2,7 +2,7 @@
|
||||||
* @Author: mbw
|
* @Author: mbw
|
||||||
* @Date: 2024-10-23 17:14:16
|
* @Date: 2024-10-23 17:14:16
|
||||||
* @LastEditors: mbw && 1600520629@qq.com
|
* @LastEditors: mbw && 1600520629@qq.com
|
||||||
* @LastEditTime: 2025-01-09 14:50:14
|
* @LastEditTime: 2025-01-09 15:41:13
|
||||||
* @FilePath: \JT-DT-YD4N02A_RTT_MRS-NT26K\applications\main.c
|
* @FilePath: \JT-DT-YD4N02A_RTT_MRS-NT26K\applications\main.c
|
||||||
* @Descrt_thread_
|
* @Descrt_thread_
|
||||||
*
|
*
|
||||||
|
@ -348,6 +348,7 @@ int main(void)
|
||||||
else if (received_event & Get_Sys_Event_Flag(kFaultEvent)) // 故障
|
else if (received_event & Get_Sys_Event_Flag(kFaultEvent)) // 故障
|
||||||
{
|
{
|
||||||
LOG_D("故障模式");
|
LOG_D("故障模式");
|
||||||
|
|
||||||
if (Flash_GetNum_Records(kRecordSensoEndOfLife) != 1)//当设备失效时,只上报设备失效的故障,其他故障不上报
|
if (Flash_GetNum_Records(kRecordSensoEndOfLife) != 1)//当设备失效时,只上报设备失效的故障,其他故障不上报
|
||||||
{
|
{
|
||||||
SysControl.last_status = SysControl.status;
|
SysControl.last_status = SysControl.status;
|
||||||
|
|
|
@ -202,6 +202,7 @@ struct Nt26k_Ops
|
||||||
|
|
||||||
extern struct Nt26k_Ops nt26k_ops;
|
extern struct Nt26k_Ops nt26k_ops;
|
||||||
extern rt_sem_t nt26k_recv_sem;
|
extern rt_sem_t nt26k_recv_sem;
|
||||||
|
extern rt_sem_t nt26k_recv_heart_sem;
|
||||||
extern rt_sem_t nt26k_disconnect_sem;
|
extern rt_sem_t nt26k_disconnect_sem;
|
||||||
extern rt_uint8_t nt26k_conncet_tcp_flag;
|
extern rt_uint8_t nt26k_conncet_tcp_flag;
|
||||||
extern rt_uint8_t nt26k_disconnect_pdp_flag;
|
extern rt_uint8_t nt26k_disconnect_pdp_flag;
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
* @Author : stark1898y 1658608470@qq.com
|
* @Author : stark1898y 1658608470@qq.com
|
||||||
* @Date : 2024-09-04 13:33:49
|
* @Date : 2024-09-04 13:33:49
|
||||||
* @LastEditors: mbw && 1600520629@qq.com
|
* @LastEditors: mbw && 1600520629@qq.com
|
||||||
* @LastEditTime: 2025-01-08 17:33:11
|
* @LastEditTime: 2025-01-10 09:35:07
|
||||||
* @FilePath: \JT-DT-YD4N02A_RTT_MRS-4G\bsp\src\at_device_nt26k.c
|
* @FilePath: \JT-DT-YD4N02A_RTT_MRS-NT26K\bsp\src\at_device_nt26k.c
|
||||||
* @Description :
|
* @Description :
|
||||||
*
|
*
|
||||||
* Copyright (c) 2024 by yzy, All Rights Reserved.
|
* Copyright (c) 2024 by yzy, All Rights Reserved.
|
||||||
|
@ -218,6 +218,11 @@ static void urc_tcp_recv(struct at_client *client, const char *data, rt_size_t s
|
||||||
{
|
{
|
||||||
rt_sem_release(nt26k_recv_sem);
|
rt_sem_release(nt26k_recv_sem);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// 接收到的是心跳包
|
||||||
|
rt_sem_release(nt26k_recv_heart_sem);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -378,28 +383,8 @@ int at_send_data(struct at_device *device, const char *data, rt_size_t size)
|
||||||
int nt26k_check_link_status(struct at_device *device)
|
int nt26k_check_link_status(struct at_device *device)
|
||||||
{
|
{
|
||||||
at_response_t resp = RT_NULL;
|
at_response_t resp = RT_NULL;
|
||||||
struct at_device_nt26k *nt26k = RT_NULL;
|
|
||||||
int result = -RT_ERROR;
|
int result = -RT_ERROR;
|
||||||
|
|
||||||
nt26k = (struct at_device_nt26k *)device->user_data;
|
|
||||||
if (!nt26k->power_status) // power off
|
|
||||||
{
|
|
||||||
LOG_D("the power is off,power on device");
|
|
||||||
device->class->device_ops->control(device, AT_DEVICE_CTRL_POWER_ON, RT_NULL); // 开启设备
|
|
||||||
}
|
|
||||||
if (nt26k->sleep_status) // is sleep status
|
|
||||||
{
|
|
||||||
if (nt26k->pwr_key_pin != -1)
|
|
||||||
{
|
|
||||||
rt_pin_write(nt26k->pwr_key_pin, PIN_LOW);
|
|
||||||
rt_thread_mdelay(100);
|
|
||||||
rt_pin_write(nt26k->pwr_key_pin, PIN_HIGH);
|
|
||||||
rt_thread_mdelay(100);
|
|
||||||
|
|
||||||
rt_pin_write(nt26k->pwr_key_pin, PIN_LOW);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
resp = at_create_resp(64, 0, rt_tick_from_millisecond(300));
|
resp = at_create_resp(64, 0, rt_tick_from_millisecond(300));
|
||||||
if (resp == RT_NULL)
|
if (resp == RT_NULL)
|
||||||
{
|
{
|
||||||
|
@ -420,15 +405,10 @@ int nt26k_check_link_status(struct at_device *device)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (at_obj_exec_cmd(device->client, resp, "AT+QICFG=\"tcp/keepalive\",1,1800,50,5") != RT_EOK)//保活期为最大30min,故30min重设一下
|
||||||
if (nt26k->sleep_status) // is sleep status
|
|
||||||
{
|
{
|
||||||
if (at_obj_exec_cmd(device->client, resp, "AT+CPSMS=1,,,,\"00100010\"") != RT_EOK)
|
result = -RT_ERROR;
|
||||||
{
|
|
||||||
LOG_D("startup entry into sleep fail.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
at_delete_resp(resp);
|
at_delete_resp(resp);
|
||||||
|
|
||||||
return (result);
|
return (result);
|
||||||
|
@ -484,7 +464,7 @@ __exit:
|
||||||
*/
|
*/
|
||||||
static void nt26k_check_link_status_entry(void *parameter)
|
static void nt26k_check_link_status_entry(void *parameter)
|
||||||
{
|
{
|
||||||
#define NT26K_LINK_DELAY_TIME (60 * RT_TICK_PER_SECOND)
|
#define NT26K_LINK_DELAY_TIME (30 * 60 * RT_TICK_PER_SECOND)
|
||||||
|
|
||||||
#define NT26K_LINK_STATUS_OK 1
|
#define NT26K_LINK_STATUS_OK 1
|
||||||
|
|
||||||
|
@ -512,6 +492,7 @@ static void nt26k_check_link_status_entry(void *parameter)
|
||||||
{
|
{
|
||||||
netdev_low_level_set_link_status(netdev, (NT26K_LINK_STATUS_OK == link_status));
|
netdev_low_level_set_link_status(netdev, (NT26K_LINK_STATUS_OK == link_status));
|
||||||
}
|
}
|
||||||
|
|
||||||
rt_thread_delay(NT26K_LINK_DELAY_TIME);
|
rt_thread_delay(NT26K_LINK_DELAY_TIME);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -862,7 +843,7 @@ static void nt26k_init_thread_entry(void *parameter)
|
||||||
goto __exit;
|
goto __exit;
|
||||||
}
|
}
|
||||||
/*设置保活信息*/
|
/*设置保活信息*/
|
||||||
if (at_obj_exec_cmd(device->client, resp, "AT+QICFG=\"tcp/keepalive\",1,1800,100,3") != RT_EOK)
|
if (at_obj_exec_cmd(device->client, resp, "AT+QICFG=\"tcp/keepalive\",1,1800,50,5") != RT_EOK)
|
||||||
{
|
{
|
||||||
result = -RT_ERROR;
|
result = -RT_ERROR;
|
||||||
goto __exit;
|
goto __exit;
|
||||||
|
@ -1107,7 +1088,7 @@ static void nt26k_init_thread_entry(void *parameter)
|
||||||
/* set network interface device status and address information */
|
/* set network interface device status and address information */
|
||||||
nt26k_netdev_set_info(device->netdev);
|
nt26k_netdev_set_info(device->netdev);
|
||||||
/* check and create link staus sync thread */
|
/* check and create link staus sync thread */
|
||||||
// nt26k_netdev_check_link_status(device->netdev);
|
nt26k_netdev_check_link_status(device->netdev);
|
||||||
LOG_I("%s device network initialize success.", device->name);
|
LOG_I("%s device network initialize success.", device->name);
|
||||||
rt_completion_done(&nt26k_init_complate); // 通知初始化完成
|
rt_completion_done(&nt26k_init_complate); // 通知初始化完成
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
* @Author: mbw
|
* @Author: mbw
|
||||||
* @Date: 2024-10-09 08:42:14
|
* @Date: 2024-10-09 08:42:14
|
||||||
* @LastEditors: mbw && 1600520629@qq.com
|
* @LastEditors: mbw && 1600520629@qq.com
|
||||||
* @LastEditTime: 2025-01-09 09:39:59
|
* @LastEditTime: 2025-01-10 09:03:13
|
||||||
* @FilePath: \JT-DT-YD4N02A_RTT_MRS-4G\bsp\src\bsp_nt26k.c
|
* @FilePath: \JT-DT-YD4N02A_RTT_MRS-NT26K\bsp\src\bsp_nt26k.c
|
||||||
* @Description:
|
* @Description:
|
||||||
*
|
*
|
||||||
* Copyright (c) 2024 by ${git_name_email}, All Rights Reserved.
|
* Copyright (c) 2024 by ${git_name_email}, All Rights Reserved.
|
||||||
|
@ -60,6 +60,7 @@ static struct rt_thread nt26k_life_thread;
|
||||||
|
|
||||||
struct rt_event at_device_event;
|
struct rt_event at_device_event;
|
||||||
rt_sem_t nt26k_recv_sem;
|
rt_sem_t nt26k_recv_sem;
|
||||||
|
rt_sem_t nt26k_recv_heart_sem;// 用于接收心跳信号
|
||||||
rt_sem_t nt26k_disconnect_sem;
|
rt_sem_t nt26k_disconnect_sem;
|
||||||
static rt_timer_t nt26k_timer; // 上报心跳
|
static rt_timer_t nt26k_timer; // 上报心跳
|
||||||
static rt_timer_t nt26k_upload_timer; // 更新本地时间定时器
|
static rt_timer_t nt26k_upload_timer; // 更新本地时间定时器
|
||||||
|
@ -795,7 +796,25 @@ int Nt26k_Process_Events (Nt26kEvent nt26k_recv_event, struct at_device *device,
|
||||||
LOG_E ("nt26k send cmd failed\n");
|
LOG_E ("nt26k send cmd failed\n");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return RT_EOK; // 函数执行完毕,返回0
|
{
|
||||||
|
if (rt_strcmp (event->event_name, "定时心跳事件") == RT_EOK)//定时心跳是有回应的
|
||||||
|
{
|
||||||
|
if (rt_sem_take(nt26k_recv_heart_sem, 5000) == RT_EOK)
|
||||||
|
{
|
||||||
|
LOG_D ("收到心跳回复\n");
|
||||||
|
return RT_EOK; // 函数执行完毕,返回0
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LOG_E ("nt26k send cmd failed\n");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return RT_EOK; // 函数执行完毕,返回0
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1484,7 +1503,11 @@ int BSP_Nt26k_Thread_Init (void)
|
||||||
{
|
{
|
||||||
LOG_E ("nt26k_recv_sem create failed");
|
LOG_E ("nt26k_recv_sem create failed");
|
||||||
}
|
}
|
||||||
|
nt26k_recv_heart_sem = rt_sem_create ("nt26k_recv_heart", 0, RT_IPC_FLAG_PRIO);
|
||||||
|
if (nt26k_recv_heart_sem == RT_NULL)
|
||||||
|
{
|
||||||
|
LOG_E ("nt26k_recv_heart_sem create failed");
|
||||||
|
}
|
||||||
nt26k_disconnect_sem = rt_sem_create ("nt26k_life", 0, RT_IPC_FLAG_PRIO);
|
nt26k_disconnect_sem = rt_sem_create ("nt26k_life", 0, RT_IPC_FLAG_PRIO);
|
||||||
if (nt26k_disconnect_sem == RT_NULL)
|
if (nt26k_disconnect_sem == RT_NULL)
|
||||||
{
|
{
|
||||||
|
|
|
@ -510,11 +510,11 @@ int rt_hw_usart_init(void)
|
||||||
uart_obj[i].serial.ops = &ch32_uart_ops;
|
uart_obj[i].serial.ops = &ch32_uart_ops;
|
||||||
uart_obj[i].serial.config = config;
|
uart_obj[i].serial.config = config;
|
||||||
|
|
||||||
if (uart_obj[i].config->name == "uart1")
|
if (rt_memcmp(uart_obj[i].config->name, "uart1", rt_strlen("uart1")) == 0)
|
||||||
{
|
{
|
||||||
uart_obj[i].serial.config.baud_rate = BAUD_RATE_115200;
|
uart_obj[i].serial.config.baud_rate = BAUD_RATE_115200;
|
||||||
}
|
}
|
||||||
else if (uart_obj[i].config->name == "uart2")
|
else if (rt_memcmp(uart_obj[i].config->name, "uart2", rt_strlen("uart2")) == 0)
|
||||||
{
|
{
|
||||||
// BAUD_RATE_921600下串口终端 方向键有问题
|
// BAUD_RATE_921600下串口终端 方向键有问题
|
||||||
uart_obj[i].serial.config.baud_rate = BAUD_RATE_460800;
|
uart_obj[i].serial.config.baud_rate = BAUD_RATE_460800;
|
||||||
|
|
Loading…
Reference in New Issue