这一版优化了报警和故障逻辑,以及截止日期的逻辑
This commit is contained in:
parent
e55496541d
commit
da3123744e
|
@ -1,3 +1,13 @@
|
||||||
|
/***
|
||||||
|
* @Author: mbw
|
||||||
|
* @Date: 2024-12-30 11:45:44
|
||||||
|
* @LastEditors: mbw && 1600520629@qq.com
|
||||||
|
* @LastEditTime: 2025-01-25 15:00:21
|
||||||
|
* @FilePath: \JT-DT-YD4N02A_RTT_MRS-NT26K\bsp\inc\at_device_nt26k.h
|
||||||
|
* @Description:
|
||||||
|
* @
|
||||||
|
* @Copyright (c) 2025 by ${git_name_email}, All Rights Reserved.
|
||||||
|
*/
|
||||||
#ifndef __AT_DEVICE_NT26K_H__
|
#ifndef __AT_DEVICE_NT26K_H__
|
||||||
#define __AT_DEVICE_NT26K_H__
|
#define __AT_DEVICE_NT26K_H__
|
||||||
|
|
||||||
|
@ -64,6 +74,7 @@ typedef struct __attribute__((packed))
|
||||||
|
|
||||||
extern nt26k_sys_info nt26k;
|
extern nt26k_sys_info nt26k;
|
||||||
extern rt_uint8_t nt26k_init_complate_flag;
|
extern rt_uint8_t nt26k_init_complate_flag;
|
||||||
|
extern volatile rt_uint8_t ntp_flag;
|
||||||
extern struct rt_completion nt26k_init_complate;
|
extern struct rt_completion nt26k_init_complate;
|
||||||
int at_send_data(struct at_device *device, const char *data, rt_size_t size);
|
int at_send_data(struct at_device *device, const char *data, rt_size_t size);
|
||||||
rt_err_t Nt26k_Reset(struct at_device *device);
|
rt_err_t Nt26k_Reset(struct at_device *device);
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
* @Author: mbw
|
* @Author: mbw
|
||||||
* @Date: 2025-01-24 08:40:39
|
* @Date: 2025-01-24 08:40:39
|
||||||
* @LastEditors: mbw && 1600520629@qq.com
|
* @LastEditors: mbw && 1600520629@qq.com
|
||||||
* @LastEditTime: 2025-01-25 14:14:51
|
* @LastEditTime: 2025-01-25 14:49:06
|
||||||
* @FilePath: \JT-DT-YD4N02A_RTT_MRS-NT26K\bsp\inc\bsp_h308.h
|
* @FilePath: \JT-DT-YD4N02A_RTT_MRS-NT26K\bsp\inc\bsp_h308.h
|
||||||
* @Description:
|
* @Description:
|
||||||
* @
|
* @
|
||||||
|
@ -76,7 +76,7 @@ typedef struct __attribute__((packed))
|
||||||
rt_uint8_t checksum; // 校验
|
rt_uint8_t checksum; // 校验
|
||||||
} TsH308Data;
|
} TsH308Data;
|
||||||
|
|
||||||
typedef struct __attribute__((packed))
|
typedef struct
|
||||||
{
|
{
|
||||||
uint8_t end_of_life; // 寿命到期
|
uint8_t end_of_life; // 寿命到期
|
||||||
uint8_t last_life; // 上次状态
|
uint8_t last_life; // 上次状态
|
||||||
|
|
|
@ -49,7 +49,7 @@ char data_buf[AT_CLIENT_RECV_BUFF_LEN] = {0};
|
||||||
nt26k_sys_info nt26k = {0};
|
nt26k_sys_info nt26k = {0};
|
||||||
struct rt_completion nt26k_init_complate;
|
struct rt_completion nt26k_init_complate;
|
||||||
volatile rt_uint8_t socket_id = 0;
|
volatile rt_uint8_t socket_id = 0;
|
||||||
|
volatile rt_uint8_t ntp_flag = 0;
|
||||||
// 将本地时间转换为对应时区时间
|
// 将本地时间转换为对应时区时间
|
||||||
void Time_Zone_Conversion(TsRtcDateTime *timeInfo)
|
void Time_Zone_Conversion(TsRtcDateTime *timeInfo)
|
||||||
{
|
{
|
||||||
|
@ -1059,6 +1059,8 @@ static void nt26k_init_thread_entry(void *parameter)
|
||||||
rtc_dt.hour, rtc_dt.minute, rtc_dt.second); // 设置时间
|
rtc_dt.hour, rtc_dt.minute, rtc_dt.second); // 设置时间
|
||||||
LOG_I("RTC时间: %04d-%02d-%02d %02d:%02d:%02d \n",
|
LOG_I("RTC时间: %04d-%02d-%02d %02d:%02d:%02d \n",
|
||||||
rtc_dt.year, rtc_dt.month, rtc_dt.day, rtc_dt.hour, rtc_dt.minute, rtc_dt.second);
|
rtc_dt.year, rtc_dt.month, rtc_dt.day, rtc_dt.hour, rtc_dt.minute, rtc_dt.second);
|
||||||
|
// 网络时间同步标志
|
||||||
|
ntp_flag = 1;
|
||||||
result = RT_EOK;
|
result = RT_EOK;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1410,8 +1412,17 @@ int Time_Calibration(struct at_device *device)
|
||||||
LOG_I("RTC时间: %04d-%02d-%02d %02d:%02d:%02d \n",
|
LOG_I("RTC时间: %04d-%02d-%02d %02d:%02d:%02d \n",
|
||||||
rtc_dt.year, rtc_dt.month, rtc_dt.day, rtc_dt.hour, rtc_dt.minute, rtc_dt.second);
|
rtc_dt.year, rtc_dt.month, rtc_dt.day, rtc_dt.hour, rtc_dt.minute, rtc_dt.second);
|
||||||
at_delete_resp(resp);
|
at_delete_resp(resp);
|
||||||
|
ntp_flag = 1;
|
||||||
return RT_EOK;
|
return RT_EOK;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ntp_flag = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ntp_flag = 0;
|
||||||
}
|
}
|
||||||
at_delete_resp(resp);
|
at_delete_resp(resp);
|
||||||
return RT_ERROR;
|
return RT_ERROR;
|
||||||
|
|
|
@ -136,8 +136,9 @@ int Get_IotImei (char *buf, rt_size_t len)
|
||||||
|
|
||||||
if ((*(rt_uint8_t *)FLASH_IOT_IMEI_ADDR != 0xE3) && (*(rt_uint8_t *)FLASH_IOT_IMEI_ADDR != 0x39))
|
if ((*(rt_uint8_t *)FLASH_IOT_IMEI_ADDR != 0xE3) && (*(rt_uint8_t *)FLASH_IOT_IMEI_ADDR != 0x39))
|
||||||
{
|
{
|
||||||
char imei_buf[FLASH_IOT_IMEI_LEN]={0};
|
char imei_buf[FLASH_IOT_IMEI_LEN + 1]={0};
|
||||||
Flash_Read(FLASH_IOT_IMEI_ADDR, (rt_uint8_t *)&imei_buf[0], len);
|
Flash_Read(FLASH_IOT_IMEI_ADDR, (rt_uint8_t *)&imei_buf[0], len);
|
||||||
|
imei_buf[len] = '\0';
|
||||||
LOG_D ("read imei: %s", imei_buf);
|
LOG_D ("read imei: %s", imei_buf);
|
||||||
rt_memcpy(buf, imei_buf, len);
|
rt_memcpy(buf, imei_buf, len);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
* @Author: mbw
|
* @Author: mbw
|
||||||
* @Date: 2024-11-14 10:21:04
|
* @Date: 2024-11-14 10:21:04
|
||||||
* @LastEditors: mbw && 1600520629@qq.com
|
* @LastEditors: mbw && 1600520629@qq.com
|
||||||
* @LastEditTime: 2025-01-25 14:34:41
|
* @LastEditTime: 2025-01-25 15:07:34
|
||||||
* @FilePath: \JT-DT-YD4N02A_RTT_MRS-NT26K\bsp\src\bsp_h308.c
|
* @FilePath: \JT-DT-YD4N02A_RTT_MRS-NT26K\bsp\src\bsp_h308.c
|
||||||
* @Description:
|
* @Description:
|
||||||
*
|
*
|
||||||
|
@ -241,8 +241,12 @@ static uint8_t H308_CheckData(void)
|
||||||
// TODO: 寿命检测
|
// TODO: 寿命检测
|
||||||
uint8_t IS_H308_EndOfLife(void)
|
uint8_t IS_H308_EndOfLife(void)
|
||||||
{
|
{
|
||||||
|
if (ntp_flag) // 是否同步网络时间
|
||||||
|
{
|
||||||
|
ntp_flag = 0;
|
||||||
RTC_GetTime();
|
RTC_GetTime();
|
||||||
if (RtcDateTime.year >= 2035) // 至少大于2035年再检测
|
|
||||||
|
if (RtcDateTime.year >= 2035) &&(work_duration >= 6 * 365) // 至少大于2035年且实际使用时长超过6年
|
||||||
{
|
{
|
||||||
if (RTC_GetCounter() >= H308.expiration_seconds)
|
if (RTC_GetCounter() >= H308.expiration_seconds)
|
||||||
{
|
{
|
||||||
|
@ -259,6 +263,12 @@ uint8_t IS_H308_EndOfLife(void)
|
||||||
H308.end_of_life = 0;
|
H308.end_of_life = 0;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
H308.end_of_life = 0;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
return H308.end_of_life;
|
return H308.end_of_life;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,6 @@
|
||||||
#define NT26K_LIFE_THREAD_PRIORITY 26
|
#define NT26K_LIFE_THREAD_PRIORITY 26
|
||||||
#define NT26K_LIFE_THREAD_TICKS 10
|
#define NT26K_LIFE_THREAD_TICKS 10
|
||||||
|
|
||||||
|
|
||||||
// static rt_uint32_t nt26k_status = 0;
|
// static rt_uint32_t nt26k_status = 0;
|
||||||
ALIGN(RT_ALIGN_SIZE)
|
ALIGN(RT_ALIGN_SIZE)
|
||||||
static char nt26k_thread_stack[NT26K_THREAD_STACK_SIZE];
|
static char nt26k_thread_stack[NT26K_THREAD_STACK_SIZE];
|
||||||
|
@ -207,7 +206,6 @@ static void Nt26k_Error_Timer_Cb(void *parameter)
|
||||||
{
|
{
|
||||||
Nt26k_Send_Event(kNt26kPowerOnEvent);
|
Nt26k_Send_Event(kNt26kPowerOnEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int _Pack_Send(struct Nt26k_Ops *ops, char *buf)
|
int _Pack_Send(struct Nt26k_Ops *ops, char *buf)
|
||||||
|
@ -1557,7 +1555,6 @@ static void Nt26k_Life_Thread_Entry(void *parameter)
|
||||||
reboot();
|
reboot();
|
||||||
}
|
}
|
||||||
rt_sem_release(nt26k_disconnect_sem);
|
rt_sem_release(nt26k_disconnect_sem);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue