From d106740b60bd60d23ec3d318cb8a6a7b16633aab Mon Sep 17 00:00:00 2001 From: WXK <287788329@qq.com> Date: 星期三, 31 一月 2024 15:17:31 +0800 Subject: [PATCH] v2.3修改因为改了频率可能会出现的bug --- FML/lora.c | 109 +++++++++++++++++++++++++++++++++++++----------------- 1 files changed, 75 insertions(+), 34 deletions(-) diff --git a/FML/lora.c b/FML/lora.c index 1814982..4f87a02 100644 --- a/FML/lora.c +++ b/FML/lora.c @@ -264,7 +264,11 @@ * Return : * Author : hido.ltd *******************************************************************************/ - +extern void delay_ms(uint32_t nTimer) ; +extern uint8_t lora_sendfinal_rx_bag_flag; +uint8_t flag_lorainit=1; +uint8_t fengming_time,fengming_flag; +extern uint32_t lora_sendfinal_rx_time; void Lora_Poll(void) { HIDO_UINT8 u8Byte = 0; @@ -274,42 +278,79 @@ { Lora_RecvByte(u8Byte); lora_rxbuf[lora_rxbufnum++]=u8Byte; - if(lora_rxbuf[lora_rxbufnum-1]==0xAA) + if(lora_rxbuf[0]==0x55&&lora_rxbuf[1]==0xAA&&lora_rxbuf[9]==0x55&&lora_rxbuf[10]==0xAA) { - if(lora_rxbuf[lora_rxbufnum-2]==0x55) - { - memset(&lora_rxbuf,0,sizeof(lora_rxbuf)); - lora_rxbufnum=0; - } - } - memcpy(&lora_recv_devid,&lora_rxbuf[2],2); - if(lora_recv_devid==dev_id) - { - if(lora_rxbuf[4]==0x01&&lora_rxbuf[5]==0x00&&lora_rxbuf[6]==0x01)//接收GPS回复的OK - { - memset(&lora_rxbuf,0,sizeof(lora_rxbuf)); - lora_rxbufnum=0; - lora_sendfinalbag_flag=0; - } - if(lora_rxbuf[4]==0x02)//接收下发修改GPS开关时间参数 - { - memcpy(&lora_recv_gpstime,&lora_rxbuf[5],2); - g_com_map[GPS_ONTIME]=lora_recv_gpstime; - save_com_map_to_flash(); - delay_ms(100); - NVIC_SystemReset(); - } - if(lora_rxbuf[4]==0x03)//接收下发修改静止休眠时间参数 - { - memcpy(&lora_recv_gpstime,&lora_rxbuf[5],2); - g_com_map[NOMOVESLEEP_TIME]=lora_recv_gpstime; - save_com_map_to_flash(); - delay_ms(100); - NVIC_SystemReset(); + memcpy(&lora_recv_devid,&lora_rxbuf[4],2); + if(lora_recv_devid==dev_id) + { + if(lora_rxbuf[6]==0x01&&lora_rxbuf[7]==0x01&&lora_rxbuf[8]==0x00)//接收GPS回复的OK + { + lora_sendfinal_rx_time=0; + lora_sendfinalbag_flag=0; + lora_sendfinal_rx_bag_flag=0; + HIDO_Debug("收到GPS的OK\r\n"); + memset(&lora_rxbuf,0,sizeof(lora_rxbuf)); + lora_rxbufnum=0; + } + if(lora_rxbuf[6]==0x02)//接收下发修改GPS开关时间参数 + { + memcpy(&lora_recv_gpstime,&lora_rxbuf[7],2); + if(lora_recv_gpstime<=60) + lora_recv_gpstime=60; + g_com_map[GPS_ONTIME]=lora_recv_gpstime; + save_com_map_to_flash(); + HIDO_Debug("收到修改GPS开关时间:%d\r\n",lora_recv_gpstime); + delay_ms(100); + NVIC_SystemReset(); + } + if(lora_rxbuf[6]==0x03)//接收下发修改静止休眠时间参数 + { + memcpy(&lora_recv_gpstime,&lora_rxbuf[7],2); + if(lora_recv_gpstime<=10) + lora_recv_gpstime=10; + g_com_map[NOMOVESLEEP_TIME]=lora_recv_gpstime; + save_com_map_to_flash(); + HIDO_Debug("收到修改静止休眠时间:%d\r\n",lora_recv_gpstime); + delay_ms(100); + NVIC_SystemReset(); + } + if(lora_rxbuf[6]==0x05)//接收下发修改uwb工作时间参数 + { + memcpy(&lora_recv_gpstime,&lora_rxbuf[7],2); + if(lora_recv_gpstime<1000||lora_recv_gpstime>10000) + lora_recv_gpstime=10000; + g_com_map[COM_INTERVAL]=lora_recv_gpstime; + save_com_map_to_flash(); + HIDO_Debug("收到修改静止休眠时间:%d\r\n",lora_recv_gpstime); + delay_ms(100); + NVIC_SystemReset(); + } + if(lora_rxbuf[6]==0x04)//接收下发蜂鸣 + { + memcpy(&lora_recv_gpstime,&lora_rxbuf[7],2); + if(lora_recv_gpstime<=10) + {lora_recv_gpstime=10;} + if(lora_recv_gpstime>100) + {lora_recv_gpstime=100;} + fengming_time=lora_recv_gpstime; + fengming_flag=1 ; + lora_sendfinalbag_flag=0; + lora_sendfinal_rx_bag_flag=0; + lora_sendfinal_rx_time=0; + memset(&lora_rxbuf,0,sizeof(lora_rxbuf)); + lora_rxbufnum=0; + } + } + + } - } - } } + if(Lora_IsIdle() == HIDO_TRUE&&flag_lorainit) + { + memset(&lora_rxbuf,0,sizeof(lora_rxbuf)); + flag_lorainit=0; + lora_rxbufnum=0; + } } /******************************************************************************* -- Gitblit v1.9.3