From a4200d2e9d0e27c8d6759464e7542c89fd025eaa 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: Wed, 22 Jan 2025 13:33:38 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BA=86=E9=87=8D=E8=BF=9E?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.cproject | 2 +-
.project | 2 +-
.settings/language.settings.xml | 13 +++-
.template | 11 +--
JT-DT-YD4N02A_RTT_MRS-4G.launch | 114 ++++++++++++++++----------------
applications/main.c | 4 +-
bsp/inc/bsp_nt26k.h | 2 +-
bsp/src/at_device_nt26k.c | 3 +-
bsp/src/bsp_h308.c | 34 +++++-----
bsp/src/bsp_nt26k.c | 32 +++++----
rt-thread/rtconfig.h | 8 +--
11 files changed, 113 insertions(+), 112 deletions(-)
diff --git a/.cproject b/.cproject
index c253b18..9da49e2 100644
--- a/.cproject
+++ b/.cproject
@@ -648,4 +648,4 @@
-
\ No newline at end of file
+
diff --git a/.project b/.project
index 76bc70e..e9a17f9 100644
--- a/.project
+++ b/.project
@@ -31,4 +31,4 @@
-
\ No newline at end of file
+
diff --git a/.settings/language.settings.xml b/.settings/language.settings.xml
index 6e7a706..aaddc48 100644
--- a/.settings/language.settings.xml
+++ b/.settings/language.settings.xml
@@ -5,7 +5,18 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/.template b/.template
index 106833f..12d75d1 100644
--- a/.template
+++ b/.template
@@ -4,20 +4,15 @@ Series=CH32V307
RTOS=NoneOS
MCU=CH32V307RVT6
Link=WCH-Link
-PeripheralVersion============1.4
-Description============ROM(byte): 256K, SRAM(byte): 64K, CHIP PINS: 64, GPIO PORTS: 51.\nWCH CH32V3 series of mainstream MCUs covers the needs of a large variety of applications in the industrial,medical and consumer markets. High performance with first-class peripherals and low-power,low-voltage operation is paired with a high level of integration at accessible prices with a simple architecture and easy-to-use tools.
+PeripheralVersion=============1.4
+Description=============ROM(byte): 256K, SRAM(byte): 64K, CHIP PINS: 64, GPIO PORTS: 51.\nWCH CH32V3 series of mainstream MCUs covers the needs of a large variety of applications in the industrial,medical and consumer markets. High performance with first-class peripherals and low-power,low-voltage operation is paired with a high level of integration at accessible prices with a simple architecture and easy-to-use tools.
Mcu Type=CH32V30x
Address=0x08000000
Target Path=obj\JT-DT-YD4N02A_RTT_MRS-4G.hex
-Exe Path=
-Exe Arguments=
CLKSpeed=1
-DebugInterfaceMode=0
+DebugInterfaceMode=-1
Erase All=true
Program=true
Verify=true
Reset=true
SDIPrintf=false
-Disable Power Output=false
-Clear CodeFlash=false
-Disable Code-Protect=false
\ No newline at end of file
diff --git a/JT-DT-YD4N02A_RTT_MRS-4G.launch b/JT-DT-YD4N02A_RTT_MRS-4G.launch
index aa24d59..a885e48 100644
--- a/JT-DT-YD4N02A_RTT_MRS-4G.launch
+++ b/JT-DT-YD4N02A_RTT_MRS-4G.launch
@@ -1,62 +1,62 @@
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
+
-
\ No newline at end of file
+
diff --git a/applications/main.c b/applications/main.c
index 23e8d34..b8f2360 100644
--- a/applications/main.c
+++ b/applications/main.c
@@ -461,8 +461,8 @@ int main(void)
{
Flash_Write_Record(kRecordSensoEndOfLife);
}
- // LED_Y_END_OF_LIFE;
- Send_Laser_Alarm_Event(kNormalDetectionEvents);
+ LED_Y_END_OF_LIFE;
+ // Send_Laser_Alarm_Event(kNormalDetectionEvents);
}
}
}
diff --git a/bsp/inc/bsp_nt26k.h b/bsp/inc/bsp_nt26k.h
index 997c8a9..b9c7ae3 100644
--- a/bsp/inc/bsp_nt26k.h
+++ b/bsp/inc/bsp_nt26k.h
@@ -202,7 +202,7 @@ struct Nt26k_Ops
extern struct Nt26k_Ops nt26k_ops;
extern rt_sem_t nt26k_recv_sem;
-extern rt_sem_t nt26k_recv_heart_sem;
+extern rt_sem_t nt26k_recv_msg_sem;
extern rt_sem_t nt26k_disconnect_sem;
extern rt_uint8_t nt26k_conncet_tcp_flag;
extern rt_uint8_t nt26k_connect_sever_flag;
diff --git a/bsp/src/at_device_nt26k.c b/bsp/src/at_device_nt26k.c
index 670ce55..1b517ab 100644
--- a/bsp/src/at_device_nt26k.c
+++ b/bsp/src/at_device_nt26k.c
@@ -231,11 +231,12 @@ static void urc_tcp_recv(struct at_client *client, const char *data, rt_size_t s
(nt26k_ops.recv->recv_data.event_type == EVENT_TYPE_POWER_ON))
// 加这个的原因就是如果有指令下发,会出现两个信号量,指令会执行两次,所以排除心跳包才释放信号量
{
- rt_sem_release(nt26k_recv_heart_sem);// 接收到的是心跳包
+ rt_sem_release(nt26k_recv_msg_sem);// 接收到的是心跳包
}
else
{
rt_sem_release(nt26k_recv_sem);
+ rt_sem_release(nt26k_recv_msg_sem);// 接收到的是心跳包
}
}
else
diff --git a/bsp/src/bsp_h308.c b/bsp/src/bsp_h308.c
index 583d485..05eb030 100644
--- a/bsp/src/bsp_h308.c
+++ b/bsp/src/bsp_h308.c
@@ -34,18 +34,17 @@ static rt_uint8_t uart4_rx_rb_data[UART4_RX_RB_LENGTH];
static rt_sem_t uart4_rx_ok_sem;
-// static rt_timer_t uart4_rx_timer;
-static struct rt_timer uart4_rx_timer1;
+static struct rt_timer uart4_rx_timer;
uint8_t sensor_rx_count = 0; // 接收缓冲区中,已经收到的数据包数量
-
+uint8_t sensor_rx_flag = 0; // 接收缓冲区中,已经收到的数据包数量
TsH308 H308 = {0};
void _UART4_RxTimeout(void *parameter)
{
+ sensor_rx_flag = 0;
rt_sem_release(uart4_rx_ok_sem);
- // rt_timer_stop(uart4_rx_timer);
- rt_timer_stop(&uart4_rx_timer1);
+ rt_timer_stop(&uart4_rx_timer);
}
static uint8_t H308_XorChecksum(char *str, int len)
@@ -232,10 +231,10 @@ uint8_t IS_H308_EndOfLife(void)
H308.end_of_life = 1;
}
}
- // else
- // {
- // H308.end_of_life = 0;
- // }
+ else
+ {
+ H308.end_of_life = 0;
+ }
return H308.end_of_life;
}
@@ -367,13 +366,8 @@ int BSP_H308_Init(void)
}
// TODO:这里改的静态
- rt_timer_init(&uart4_rx_timer1, "_UART4_RxTimeout", _UART4_RxTimeout, RT_NULL, 200, RT_TIMER_FLAG_PERIODIC);
- // rt_timer_start(&uart4_rx_timer1);
- // uart4_rx_timer = rt_timer_create("_UART4_RxTimeout", _UART4_RxTimeout, RT_NULL, 200, RT_TIMER_FLAG_PERIODIC);
- // if (uart4_rx_timer == RT_NULL)
- // {
- // LOG_E("uart4_rx_timer create failed");
- // }
+ rt_timer_init(&uart4_rx_timer, "_UART4_RxTimeout", _UART4_RxTimeout, RT_NULL, 100, RT_TIMER_FLAG_PERIODIC);
+
UART4_Init();
rt_err_t ret = rt_thread_init(&h308_thread,
"h308_thread",
@@ -407,9 +401,11 @@ void UART4_IRQHandler(void)
{
uint8_t temp = USART_ReceiveData(UART4);
lwrb_write(&uart4_rx_rb, &temp, 1);
- // sensor_rx_count++;
- // rt_timer_start(uart4_rx_timer);
- rt_timer_start(&uart4_rx_timer1);
+ if (sensor_rx_flag == 0)
+ {
+ sensor_rx_flag = 1;
+ rt_timer_start(&uart4_rx_timer);
+ }
}
rt_interrupt_leave();
diff --git a/bsp/src/bsp_nt26k.c b/bsp/src/bsp_nt26k.c
index 3708ef6..c98dc5b 100644
--- a/bsp/src/bsp_nt26k.c
+++ b/bsp/src/bsp_nt26k.c
@@ -61,7 +61,7 @@ static struct rt_thread nt26k_life_thread;
struct rt_event at_device_event;
rt_sem_t nt26k_recv_sem;
-rt_sem_t nt26k_recv_heart_sem; // 用于接收心跳信号
+rt_sem_t nt26k_recv_msg_sem; // 用于接收信号
rt_sem_t nt26k_disconnect_sem;
static rt_timer_t nt26k_timer; // 上报心跳
static rt_timer_t nt26k_upload_timer; // 更新本地时间定时器
@@ -767,6 +767,7 @@ const Nt26kEventInfo nt26k_event_info[] = {
int Nt26k_Process_Events(Nt26kEvent nt26k_recv_event, struct at_device *device, void *param)
{
rt_uint8_t max_retry_count = (rt_uint8_t)Flash_Get_SysCfg(kIotRetryId);
+ LOG_D("max_retry_count:%d\n", max_retry_count);
struct Nt26k_Ops *nt26k_ops = (struct Nt26k_Ops *)param;
const Nt26kEventInfo *event = RT_NULL;
@@ -804,20 +805,17 @@ int Nt26k_Process_Events(Nt26kEvent nt26k_recv_event, struct at_device *device,
}
else
{
- if ((rt_strcmp(event->event_name, "定时心跳事件") == RT_EOK) || (rt_strcmp(event->event_name, "上电心跳事件") == RT_EOK)) // 定时心跳是有回应的
+ if (rt_sem_take(nt26k_recv_msg_sem, 5000) == RT_EOK)
{
- if (rt_sem_take(nt26k_recv_heart_sem, 5000) == RT_EOK)
- {
- LOG_D("收到心跳回复\n");
- nt26k_connect_sever_flag = 1;
- return RT_EOK; // 函数执行完毕,返回0
- }
- else
- {
- // 收不到说明在平台未注册,此时nt26k_connect_sever_flag 为0,但nt26k_conncet_tcp_flag = 1;此时不发起重连,等待事件触发就行
- nt26k_connect_sever_flag = 0;
- continue;
- }
+ LOG_D("收到回复\n");
+ nt26k_connect_sever_flag = 1;
+ return RT_EOK; // 函数执行完毕,返回0
+ }
+ else
+ {
+ // 收不到说明在平台未注册,此时nt26k_connect_sever_flag 为0,但nt26k_conncet_tcp_flag = 1;此时不发起重连,等待事件触发就行
+ nt26k_connect_sever_flag = 0;
+ return RT_EOK;
}
}
if (rt_strcmp(event->event_name, "掉电事件") == RT_EOK)
@@ -1574,10 +1572,10 @@ int BSP_Nt26k_Thread_Init(void)
{
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)
+ nt26k_recv_msg_sem = rt_sem_create("nt26k_recv_heart", 0, RT_IPC_FLAG_PRIO);
+ if (nt26k_recv_msg_sem == RT_NULL)
{
- LOG_E("nt26k_recv_heart_sem create failed");
+ LOG_E("nt26k_recv_msg_sem create failed");
}
nt26k_disconnect_sem = rt_sem_create("nt26k_life", 0, RT_IPC_FLAG_PRIO);
if (nt26k_disconnect_sem == RT_NULL)
diff --git a/rt-thread/rtconfig.h b/rt-thread/rtconfig.h
index 2a19a0b..1100317 100644
--- a/rt-thread/rtconfig.h
+++ b/rt-thread/rtconfig.h
@@ -15,8 +15,8 @@
/*使用动态日志及密码功能时,需开启宏 FINSH_USING_AUTH ULOG_USING_FILTER ENABLE_LOG_ALL ULOG_OUTPUT_LVL = 7 以及设置ulog.c 1522行 输出等级为0*/
/**/
-#define FINSH_USING_AUTH //开启终端密码登录功能
-#define ULOG_USING_FILTER //开启动态修改日志等级 默认修改在ulog.c 1522行
+// #define FINSH_USING_AUTH //开启终端密码登录功能
+// #define ULOG_USING_FILTER //开启动态修改日志等级 默认修改在ulog.c 1522行
#define ENABLE_LOG_ALL
#define TEST_ENABLE //打开所有的终端测试程序
@@ -156,10 +156,10 @@
#define AT_USING_CLIENT
#define AT_CLIENT_NUM_MAX 1
-#ifdef FINSH_USING_AUTH
+// #ifdef FINSH_USING_AUTH
#define AT_USING_CLI
#define AT_PRINT_RAW_CMD
-#endif
+// #endif
#define AT_CMD_MAX_LEN 256
#define AT_SW_VERSION_NUM 0x10301