Explorar o código

中继删除SOS

xuxinyi hai 1 mes
pai
achega
685408235f
Modificáronse 4 ficheiros con 11 adicións e 38 borrados
  1. 1 1
      Core/Inc/E52.h
  2. 1 5
      Core/Src/E52.c
  3. 7 30
      Core/Src/main.c
  4. 2 2
      Core/Src/stm32f1xx_it.c

+ 1 - 1
Core/Inc/E52.h

@@ -106,7 +106,7 @@ typedef struct {
     uint8_t target_addr_H;          // 目标地址高字节         默认FF
     uint8_t target_addr_L;          // 目标地址低字节         默认FF
     uint8_t powerValue;             //电量                  默认0
-    uint8_t isSOS;
+    // uint8_t isSOS;
     // uint8_t receivingNewDataFlag;       //接收lora新数据
 
     //使能蓝牙收发数据

+ 1 - 5
Core/Src/E52.c

@@ -80,11 +80,7 @@ void E52_Send_Bl_Data_Fun( uint8_t *sendData,  uint8_t finishData) {
     SendBlData_structure sendBlData_structure;
     sendBlData_structure.frame_header_H = 0x55;
     sendBlData_structure.frame_header_L = 0xAA;
-    if (!deviceInfo.isSOS) {
-        sendBlData_structure.function_code = 0x02;
-    }else {
-        sendBlData_structure.function_code = 0x04;
-    }
+    sendBlData_structure.function_code = 0x02;
     sendBlData_structure.badge_addr_high = deviceInfo.loraDeviceAddress_H;
     sendBlData_structure.badge_addr_low = deviceInfo.loraDeviceAddress_L;
     memcpy(sendBlData_structure.bl_data, sendData, 8);

+ 7 - 30
Core/Src/main.c

@@ -95,7 +95,6 @@ void Device_Info_Init_Fun() {
   RingBuffer_Init(&deviceInfo.queueLoraCommandData);
 
   deviceInfo.isOnline = FALSE;
-  deviceInfo.isSOS = FALSE;
   deviceInfo.broadcast_type = BROADCAST_ALL;
   deviceInfo.loraDeviceAddress_H = 0xFE; //默认地址高位
   deviceInfo.loraDeviceAddress_L = 0xEF; //默认地址低位
@@ -340,7 +339,7 @@ int main(void)
     // 检查是否接收到"心跳"命令,且设备在线
     printf("设备状态:0x%02X\n", deviceInfo.commandFromCloud);
 
-    schedule_Fun();
+    // schedule_Fun();
     // 心跳:不在线时,每 10 秒发一次
     if (!deviceInfo.isOnline) {
       if (IsTimeElapsed(&hrtc, &Online_struct, 10)) {
@@ -348,13 +347,6 @@ int main(void)
       }
     }
 
-    // SOS:如果超过 20 秒还没释放,自动关闭
-    if (deviceInfo.isSOS) {
-      if (IsTimeElapsed(&hrtc, &SOS_struct, 20)) {
-        deviceInfo.isSOS = FALSE;
-      }
-    }
-
     // IDLE 检测
     if (GET_CMD(deviceInfo.commandFromCloud) == IDLE || GET_STEP(deviceInfo.commandFromCloud) == STEP_INIT) {
       HAL_RTC_GetTime(&hrtc, &IDLE_struct, RTC_FORMAT_BIN);  // 直接更新
@@ -372,7 +364,7 @@ int main(void)
     }
 
     // 03:请求蓝牙数据
-    if (((GET_CMD(deviceInfo.commandFromCloud) == REQUEST_BLUETOOTH_DATA && deviceInfo.isOnline ) || deviceInfo.isSOS))  {
+    if (GET_CMD(deviceInfo.commandFromCloud) == REQUEST_BLUETOOTH_DATA && deviceInfo.isOnline )  {
       switch (GET_STEP(deviceInfo.commandFromCloud)) {
         case REQUEST_BLUETOOTH_DATA_SCAN:
           deviceInfo.BlDataFlag = BL_STOP;
@@ -402,26 +394,11 @@ int main(void)
 
         default:
           // 处理未知步骤
-          if (deviceInfo.isSOS) {
-            // HAL_Delay(1000);
-            deviceInfo.commandFromCloud = COMBINE_CMD_STEP(IDLE, STEP_VERIFY);
-            rx_buf_uart2[0] = 0x55;
-            rx_buf_uart2[1] = 0xBB;
-            rx_buf_uart2[2] = 0x03;
-            rx_buf_uart2[3] = deviceInfo.loraDeviceAddress_H;
-            rx_buf_uart2[4] = deviceInfo.loraDeviceAddress_L;
-            rx_buf_uart2[5] = 0x03;
-            rx_buf_uart2[6] = 0xE8;
-            rx_buf_uart2[7] = 0x00;
-            rx_buf_uart2[8] = 0xFF;
-            rx_buf_uart2[9] = 0xEE;
-          }else {
-            receiveBlDataCount = 0;
-            deviceInfo.timeCount = 0;
-            deviceInfo.forwardBLAndLoraDataDuration = 0;
-            i = 0;
-            deviceInfo.commandFromCloud = COMBINE_CMD_STEP(IDLE, STEP_INIT);
-          }
+          receiveBlDataCount = 0;
+          deviceInfo.timeCount = 0;
+          deviceInfo.forwardBLAndLoraDataDuration = 0;
+          i = 0;
+          deviceInfo.commandFromCloud = COMBINE_CMD_STEP(IDLE, STEP_INIT);
           break;
       }
     }

+ 2 - 2
Core/Src/stm32f1xx_it.c

@@ -420,12 +420,12 @@ void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin) {
     if (HAL_GPIO_ReadPin(SOS_KEY_GPIO_Port, SOS_KEY_Pin) == GPIO_PIN_SET) {
       // 松开(上升沿)
       printf("SOS_KEY 松开\r\n");
-      deviceInfo.isSOS = FALSE;
+      // deviceInfo.isSOS = FALSE;
     } else {
       // 按下(下降沿)
       printf("SOS_KEY 按下\r\n");
       SOS_struct = currentTime;  // 记录上报时间
-      deviceInfo.isSOS = TRUE;
+      // deviceInfo.isSOS = TRUE;
     }
   }
   // ===== JUGE_KEY =====