Browse Source

修改网络模组串口出现数组越界的问题

龙三郎 7 months ago
parent
commit
3cbeb5266a
4 changed files with 10 additions and 47 deletions
  1. 0 44
      Drivers/CONFIG.h
  2. 8 1
      Drivers/Modules/At_Module.c
  3. 1 1
      Drivers/Modules/bc260y/Bc260y_Regist.c
  4. 1 1
      User/main.c

+ 0 - 44
Drivers/CONFIG.h

@@ -1,44 +0,0 @@
-#ifndef __CONFIG_H
-#define __CONFIG_H
-#include <stdint.h>
-
-
-#define DEBUG 1 // Debug开关 1是开,0是关
-
-// 测试环境
-#define TEST_ENV 1
-// 生产环境
-//#define PROD_ENV 1
-
-
-
-//#define EC800M 1 //4G开关,不能数字开头
-//#define BC260Y 1  // NB
-#define ESP32 1		//WiFi
-//#define AIWB2	1	//WIFI_AIWB2-32S
-
-
-
-
-// 何龙祥的配置
-//睡眠相关IO配置 
-#define WAKE_GPIO_RCC RCC_APB2Periph_GPIOA
-#define WAKE_GPIO GPIOA
-#define WAKE_GPIO_Pin GPIO_Pin_6 // 睡眠的引脚
-//flash相关配置
-#define FLASH_SIZE 64
-#define FLASH_SAVE_ADDR 0X0800F800
-
-
-
-// 刘艳斌的配置
-//睡眠相关IO配置
-//#define WAKE_GPIO_RCC RCC_APB2Periph_GPIOE
-//#define WAKE_GPIO GPIOE
-//#define WAKE_GPIO_Pin GPIO_Pin_5 // 睡眠的引脚
-////flash相关配置
-//#define FLASH_SIZE 512
-//#define SAVE_ADDR 0X0807E000
-
-
-#endif

+ 8 - 1
Drivers/Modules/At_Module.c

@@ -8,12 +8,14 @@
 #include "Log_Module.h"
 #include "CONFIG.h"
 
+#define LENGTH 1024
+
 
 // AT指令
 struct AT_Struct
 {
 	enum AT_Status status;
-	uint8_t result[1024];
+	uint8_t result[LENGTH];
 	uint16_t result_length;
 };
 static struct AT_Struct at_Struct = {
@@ -26,6 +28,11 @@ void USART2_IRQHandler(void)
 	if(USART_GetFlagStatus(USART2, USART_IT_RXNE) == SET)
 	{
 		uint8_t RxData = USART_ReceiveData(USART2);
+		// 判断数组写入长度,防止过界
+		if(at_Struct.result_length >= (LENGTH-1))
+		{
+			at_Struct.result_length = 0;
+		}
 		// 写入缓存
 		at_Struct.result[at_Struct.result_length++] = RxData;
 		

+ 1 - 1
Drivers/Modules/bc260y/Bc260y_Regist.c

@@ -28,7 +28,7 @@ static struct TUORENIOT_RegistRequestStruct regist_request = {
 	.networkProtocol = 1,
 	.productId = "1dbfd476b7nm2",
 	.deviceId = "3431228A1936013C",
-	.userId = "1000",
+	.userId = "1226",
 	.sim = "",
 };
 

+ 1 - 1
User/main.c

@@ -27,7 +27,7 @@
 
 
 // 6365736869303036
-uint8_t mcu_id[8] = "ceshi006";
+uint8_t mcu_id[8] = "ceshi007";
 
 // ¼ÆÊ±Æ÷
 static struct TIMER_Struct timer;