Explorar o código

添加转发蓝牙数据使能

xuxinyi hai 2 meses
pai
achega
7e71b39311
Modificáronse 3 ficheiros con 9 adicións e 5 borrados
  1. 2 1
      Core/Inc/E52.h
  2. 4 3
      Core/Src/main.c
  3. 3 1
      Core/Src/stm32f1xx_it.c

+ 2 - 1
Core/Inc/E52.h

@@ -18,7 +18,8 @@ typedef struct __attribute__((packed)){
     uint8_t target_addr_L;          // 目标地址低字节         默认FF
     uint8_t powerValue;             //电量                  默认0
     uint8_t workMode;               //工作模式              大概区分,发送模式,接受模式。
-    uint8_t receivingNewDataFlag;       //接收lora新数据
+    // uint8_t receivingNewDataFlag;       //接收lora新数据
+    uint8_t sendBlDataFlag;         //发送蓝牙数据
 } Device_structure;
 
 // 只声明变量,不定义变量,使用extern关键字

+ 4 - 3
Core/Src/main.c

@@ -134,6 +134,7 @@ void Device_Info_Init_Fun() {
   deviceInfo.powerValue = 0;
   deviceInfo.target_addr_H = 0xFF;
   deviceInfo.target_addr_L = 0xFF;
+  deviceInfo.sendBlDataFlag = 0;
 }
 /* USER CODE END 0 */
 
@@ -220,7 +221,7 @@ int main(void)
 
   /* Infinite loop */
   /* USER CODE BEGIN WHILE */
-
+  deviceInfo.sendBlDataFlag = 1;
   while (1)
   {
     /* USER CODE END WHILE */
@@ -280,7 +281,7 @@ int main(void)
     //   HAL_Delay(1000);
     // }
 
-    while (1) {
+    // while (1) {
       // printf("Hello world:%d\r\n",i);
       // //睡眠测试 --
       // i++;
@@ -301,7 +302,7 @@ int main(void)
       // const char *end_msg = "SENDEND\r\n";
       // HAL_UART_Transmit(&huart2, (uint8_t *)end_msg, strlen(end_msg), HAL_MAX_DELAY);
       // HAL_Delay(1000);
-    }
+    // }
   }
   /* USER CODE END 3 */
 }

+ 3 - 1
Core/Src/stm32f1xx_it.c

@@ -345,7 +345,9 @@ void USART3_IRQHandler(void)
     //   HAL_UART_Receive_DMA(&huart3, rx_buf, received_len); // 重新启动
     // }
     if (strncmp((char *)rx_buf, "AT", 2) != 0) {
-      E52_Send_Bl_Data_Fun();
+      if (deviceInfo.sendBlDataFlag == 1) {
+        E52_Send_Bl_Data_Fun();
+      }
     }
 
     memset(rx_buf, 0, received_len);