diff --git a/.vscode/settings.json b/.vscode/settings.json index accf815..fba611a 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -69,7 +69,12 @@ "ch32v30x.h": "c", "lwutil.h": "c", "ch32v30x_adc.h": "c", - "bsp_wdg.h": "c" + "bsp_wdg.h": "c", + "inet.h": "c", + "netdev.h": "c", + "at.h": "c", + "spi-bit-ops.h": "c", + "signal.h": "c" }, "commentTranslate.multiLineMerge": true, "C_Cpp.errorSquiggles": "disabled" diff --git a/README.md b/README.md index bb583ae..9725c96 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,4 @@ -# 一、版本更新内容 -## v1.0 完成基本功能和物联网功能 -## v1.1 增加了修改服务器地址的功能,增加了物联网接收部分CRC值校验功能## -## v1.6 增加了当上电失败时不发送其他事件的功能,以及掉电关闭模组功能,快速关机的功能 -## v1.7 增加了报警和报警恢复,故障和故障恢复发送失败不断重试的功能 +# 一、版本更新内容(V 1.2) +## 当前的版本,修复了以下问题: + -上传数据时的iccid 和imsi 顺序错误问题,以及在数据写入flash时,将IMSI写成LMEI的问题。 diff --git a/applications/main.c b/applications/main.c index 3e68a0c..4ead194 100644 --- a/applications/main.c +++ b/applications/main.c @@ -2,7 +2,7 @@ * @Author: mbw * @Date: 2024-10-23 17:14:16 * @LastEditors: mbw && 1600520629@qq.com - * @LastEditTime: 2025-02-21 10:17:35 + * @LastEditTime: 2025-03-28 10:58:16 * @FilePath: \JT-DT-YD4N02A_RTT_MRS-NT26K\applications\main.c * @Descrt_thread_ * @@ -43,6 +43,16 @@ struct rt_timer work_cnt_timer; rt_timer_t led_state_timer; +struct rt_timer alarm_emv_timer; + + +void Alarm_Emv_Timer_Callback(void *parameter) +{ + EMV_CLOSE_VALVE; +} + + + void Send_Laser_Alarm_Event(AlarmEvent event_type); static void Set_Event(AlarmEvent event_type) @@ -128,49 +138,6 @@ int _Self_Check_Mode(void) return RT_EOK; } -#if 0 -void Preheat_Sensor(rt_uint32_t timeout_counter) -{ -// 定义超时时间,单位为毫秒 -#define TIMEOUT_MS 15000 - - timeout_counter += 10; // 每次递归增加10毫秒 - - if (H308.Data.checksum != 0) - { - BEEP_PREAT_OK; - LED_STOP(r); - LED_STOP(g); - LED_STOP(y); - LOG_D("预热完成"); - BEEP_PREAT_OK; - Send_Laser_Alarm_Event(kNormalDetectionEvents); - } - else if (IS_H308_EndOfLife()) // 如果寿命到期,预热完成后直接到寿命过期状态 - { - LED_STOP(r); - LED_STOP(g); - LED_STOP(y); - BEEP_PREAT_OK; - Send_Laser_Alarm_Event(kSensorFailureEvent); - } - else if ((timeout_counter >= TIMEOUT_MS) && (H308.Data.checksum == 0)) - { - LED_STOP(r); - LED_STOP(g); - LED_STOP(y); - BEEP_PREAT_OK; - LOG_D("预热完成,传感器故障"); - Send_Laser_Alarm_Event(kFaultEvent); // 传感器故障 - } - else - { - rt_thread_mdelay(10); - Preheat_Sensor(timeout_counter); - } -} -#endif - void Work_Cnt_Timer_Callback(void *parameter) { work_duration++; @@ -187,6 +154,7 @@ void Work_Cnt_Timer_Callback(void *parameter) int main(void) { #define WORK_TIMER_CNT (1000 * 60 * 60 * 24) +#define ALARM_EMV_TIMER_CNT (1000 * 6) rt_err_t result = RT_EINVAL; rt_uint32_t received_event; @@ -221,7 +189,12 @@ int main(void) RT_NULL, WORK_TIMER_CNT, RT_TIMER_FLAG_PERIODIC); - rt_timer_start(&work_cnt_timer); + rt_timer_init(&alarm_emv_timer, + "alarm_emv_timer", + Alarm_Emv_Timer_Callback, + RT_NULL, + ALARM_EMV_TIMER_CNT, + RT_TIMER_FLAG_ONE_SHOT); // 检测上电/掉电复位标志 if (RCC_GetFlagStatus(RCC_FLAG_PORRST) != RESET) // TODO:这块超级电容会造成掉电重启,并且标志是上电复位,只能通过其超级电容造成复位时事件创建失败进行判断,不治本 { @@ -344,8 +317,7 @@ int main(void) #if (IOT_MODULE_SWITCH == 1) Nt26k_Send_Event(kNt26kAlarmEvent); #endif - rt_thread_mdelay(6000); - EMV_CLOSE_VALVE; + rt_timer_start(&alarm_emv_timer); } else if (received_event & Get_Sys_Event_Flag(kAlarmRcyEvent)) // 报警恢复 { diff --git a/bsp/inc/at_device_nt26k.h b/bsp/inc/at_device_nt26k.h index 96966c2..176714c 100644 --- a/bsp/inc/at_device_nt26k.h +++ b/bsp/inc/at_device_nt26k.h @@ -2,7 +2,7 @@ * @Author: mbw * @Date: 2024-12-30 11:45:44 * @LastEditors: mbw && 1600520629@qq.com - * @LastEditTime: 2025-01-25 15:00:21 + * @LastEditTime: 2025-03-17 13:29:41 * @FilePath: \JT-DT-YD4N02A_RTT_MRS-NT26K\bsp\inc\at_device_nt26k.h * @Description: * @ @@ -63,8 +63,8 @@ struct at_device_nt26k typedef struct __attribute__((packed)) { uint8_t imei[15]; - uint8_t iccid[20]; uint8_t imsi[15]; + uint8_t iccid[20]; uint8_t rssi; // RSSI uint8_t rsrp; // RSRP uint8_t rsrq; // RSRQ diff --git a/bsp/inc/bsp_nt26k.h b/bsp/inc/bsp_nt26k.h index a73a0e8..a6afb6b 100644 --- a/bsp/inc/bsp_nt26k.h +++ b/bsp/inc/bsp_nt26k.h @@ -133,8 +133,8 @@ struct __attribute__((packed)) DataBody uint8_t hw; // 硬件版本 uint8_t sw; // 软件版本 uint8_t imei[15]; // 设备编号(IMEI) - uint8_t iccid[20]; // ICCID uint8_t imsi[15]; // IMSI + uint8_t iccid[20]; // ICCID uint8_t rssi; // RSSI uint8_t rsrp; // RSRP uint8_t rsrq; // RSRQ diff --git a/bsp/src/at_device_nt26k.c b/bsp/src/at_device_nt26k.c index 2deb667..82743ff 100644 --- a/bsp/src/at_device_nt26k.c +++ b/bsp/src/at_device_nt26k.c @@ -2,7 +2,7 @@ * @Author : stark1898y 1658608470@qq.com * @Date : 2024-09-04 13:33:49 * @LastEditors: mbw && 1600520629@qq.com - * @LastEditTime: 2025-03-17 11:43:44 + * @LastEditTime: 2025-03-17 16:02:22 * @FilePath: \JT-DT-YD4N02A_RTT_MRS-NT26K\bsp\src\at_device_nt26k.c * @Description : * @@ -1005,8 +1005,8 @@ static void nt26k_init_thread_entry(void *parameter) else { // 已经写入了,将其赋值给结构体 - rt_memset((char *)nt26k.imsi, 0, NT26K_IMSI_LEN); - Get_IotImsi((char *)&nt26k.imsi[0], NT26K_IMSI_LEN);//这块原来写错了,写成饿了IMEI,所以发上去的也是IMEI号码 + rt_memset((char *)nt26k.imsi, 0, FLASH_IOT_IMSI_LEN); + Get_IotImsi((char *)&nt26k.imsi[0], FLASH_IOT_IMSI_LEN);//这块原来写错了,写成饿了IMEI,所以发上去的也是IMEI号码 } /* check signal strength */ for (i = 0; i < CSQ_RETRY; i++) diff --git a/bsp/src/bsp_h308.c b/bsp/src/bsp_h308.c index d35b641..eb9cfd2 100644 --- a/bsp/src/bsp_h308.c +++ b/bsp/src/bsp_h308.c @@ -2,7 +2,7 @@ * @Author: mbw * @Date: 2024-11-14 10:21:04 * @LastEditors: mbw && 1600520629@qq.com - * @LastEditTime: 2025-02-17 11:17:13 + * @LastEditTime: 2025-03-25 10:14:38 * @FilePath: \JT-DT-YD4N02A_RTT_MRS-NT26K\bsp\src\bsp_h308.c * @Description: * @@ -428,6 +428,7 @@ int BSP_H308_Init(void) } INIT_COMPONENT_EXPORT(BSP_H308_Init); + void UART4_IRQHandler(void) __attribute__((interrupt("WCH-Interrupt-fast"))); void UART4_IRQHandler(void) { diff --git a/bsp/src/bsp_hr.c b/bsp/src/bsp_hr.c index 87cbda2..e918077 100644 --- a/bsp/src/bsp_hr.c +++ b/bsp/src/bsp_hr.c @@ -147,26 +147,32 @@ TsFrameData *HR_GetFrameData(const rt_uint8_t *p_src, const rt_uint8_t src_len) return get_buffer; } -rt_uint8_t HR_GenerateRawFrame(TsRawFrameData *pRawData, rt_uint8_t c1, TeFrameC2 c2, const rt_uint8_t *p_src, rt_uint8_t src_len) +uint8_t HR_GenerateRawFrame(TsRawFrameData *pRawData, uint8_t c1, TeFrameC2 c2, const uint8_t *p_src, uint8_t src_len) { pRawData->len = src_len + 6; - rt_memset(pRawData->buf, 0, sizeof(pRawData->buf)); + memset(pRawData->buf, 0, sizeof(pRawData->buf)); pRawData->buf[0] = FRAME_HEADER; pRawData->buf[1] = c1; pRawData->buf[2] = c2; pRawData->buf[3] = src_len; - rt_memmove(&pRawData->buf[4], p_src, src_len); - + if ((c2 != kNumOfRecords) && (c2 != kGetCurrentTime)) + { + pRawData->buf[4] = c1; + memmove(&pRawData->buf[5], p_src, src_len); + } + else + { + memmove(&pRawData->buf[4], p_src, src_len); + } + // 从帧起始符开始到校验码之前所有字节的和的模256 // ,即各字节不计超过255的溢出值的二进制算术和。 pRawData->buf[pRawData->len - 2] = HR_CheckSum(&pRawData->buf[0], pRawData->len - 2); pRawData->buf[pRawData->len - 1] = FRAME_TAIL; - - // LOG_HEX("HrRawData", 16, &pRawData->buf[0], pRawData->len); - + return RT_EOK; } diff --git a/packages/FlexibleButton-2.0.1/flexible_button.h b/packages/FlexibleButton-2.0.1/flexible_button.h index 7fee963..2dabba6 100644 --- a/packages/FlexibleButton-2.0.1/flexible_button.h +++ b/packages/FlexibleButton-2.0.1/flexible_button.h @@ -43,7 +43,7 @@ #include "stdint.h" -#define FLEX_BTN_SCAN_FREQ_HZ 40 // How often flex_button_scan () is called +#define FLEX_BTN_SCAN_FREQ_HZ 20 // How often flex_button_scan () is called #define FLEX_MS_TO_SCAN_CNT(ms) (ms / (1000 / FLEX_BTN_SCAN_FREQ_HZ)) // /* Multiple clicks interval, default 300ms */ #define MAX_MULTIPLE_CLICKS_INTERVAL (FLEX_MS_TO_SCAN_CNT(300))