Преглед на файлове

PA 부스터 프로토콜 추가
Lora Init 함수 추가
상태 요청 받으면 Data 발신 하도록 수정
최초 Power on 시 나오는 printf 문 제거
최초 Power on 시 GUI Data 요청 못하도록 수정

june9152 преди 6 години
родител
ревизия
3abf667128

+ 1 - 1
.settings/language.settings.xml

@@ -4,7 +4,7 @@
4 4
 		<extension point="org.eclipse.cdt.core.LanguageSettingsProvider">
5 5
 			<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
6 6
 			<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
7
-			<provider class="com.atollic.truestudio.mbs.GCCSpecsDetectorAtollicArm" console="false" env-hash="252364546433938101" id="com.atollic.truestudio.mbs.provider" keep-relative-paths="false" name="Atollic ARM Tools Language Settings" parameter="${COMMAND} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
7
+			<provider class="com.atollic.truestudio.mbs.GCCSpecsDetectorAtollicArm" console="false" env-hash="157605811251204298" id="com.atollic.truestudio.mbs.provider" keep-relative-paths="false" name="Atollic ARM Tools Language Settings" parameter="${COMMAND} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
8 8
 				<language-scope id="org.eclipse.cdt.core.gcc"/>
9 9
 				<language-scope id="org.eclipse.cdt.core.g++"/>
10 10
 			</provider>

BIN
Debug/STM32F103_RGB_Controller.bin


BIN
Debug/STM32F103_RGB_Controller.binary


BIN
Debug/STM32F103_RGB_Controller.elf


Файловите разлики са ограничени, защото са твърде много
+ 797 - 799
Debug/STM32F103_RGB_Controller.hex


Файловите разлики са ограничени, защото са твърде много
+ 4887 - 4738
Debug/STM32F103_RGB_Controller.list


Файловите разлики са ограничени, защото са твърде много
+ 630 - 626
Debug/STM32F103_RGB_Controller.map


BIN
Debug/Src/GPIO_SPI.o


BIN
Debug/Src/M24C32.o


BIN
Debug/Src/RGB_Controller.o


+ 13 - 13
Debug/Src/RGB_Controller.su

@@ -1,13 +1,13 @@
1
-RGB_Controller.c:44:10:RGB_Limit_Address_Check	0	static
2
-RGB_Controller.c:58:10:RGB_Location_Address_Check	0	static
3
-RGB_Controller.c:17:6:RGB_Data_Init	48	static
4
-RGB_Controller.c:73:6:RGB_Response_Func	32	static
5
-RGB_Controller.c:143:6:RGB_Sensor_LED_Alarm_ON	8	static
6
-RGB_Controller.c:181:6:RGB_Sensor_LED_Alarm_OFF	8	static
7
-RGB_Controller.c:220:6:RGB_Alarm_Operate	32	static
8
-RGB_Controller.c:263:9:RGB_DeviceStatusCheck	12	static
9
-RGB_Controller.c:336:9:RGB_BufCal	0	static
10
-RGB_Controller.c:310:6:RGB_Data_Stack	24	static
11
-RGB_Controller.c:236:6:RGB_Alarm_Check	48	static
12
-RGB_Controller.c:350:9:RGB_LimitData_Get	0	static
13
-RGB_Controller.c:363:6:RGB_Controller_Func	120	static
1
+RGB_Controller.c:59:10:RGB_Limit_Address_Check	0	static
2
+RGB_Controller.c:73:10:RGB_Location_Address_Check	0	static
3
+RGB_Controller.c:23:6:RGB_Data_Init	48	static
4
+RGB_Controller.c:88:6:RGB_Response_Func	32	static
5
+RGB_Controller.c:170:6:RGB_Sensor_LED_Alarm_ON	8	static
6
+RGB_Controller.c:208:6:RGB_Sensor_LED_Alarm_OFF	8	static
7
+RGB_Controller.c:247:6:RGB_Alarm_Operate	32	static
8
+RGB_Controller.c:290:9:RGB_DeviceStatusCheck	12	static
9
+RGB_Controller.c:363:9:RGB_BufCal	0	static
10
+RGB_Controller.c:337:6:RGB_Data_Stack	24	static
11
+RGB_Controller.c:263:6:RGB_Alarm_Check	48	static
12
+RGB_Controller.c:377:9:RGB_LimitData_Get	0	static
13
+RGB_Controller.c:391:6:RGB_Controller_Func	120	static

BIN
Debug/Src/RGB_Lora.o


BIN
Debug/Src/SX1276.o


+ 18 - 17
Debug/Src/SX1276.su

@@ -11,20 +11,21 @@ SX1276.c:83:9:SX1276_SPIRead	0	static
11 11
 SX1276.c:98:6:SX1276_SPIWrite	16	static
12 12
 SX1276.c:107:6:SX1276_SPIBurstRead	24	static
13 13
 SX1276.c:125:6:SX1276_SPIBurstWrite	0	static
14
-SX1276.c:200:6:SX1276_standby	8	static
15
-SX1276.c:205:6:SX1276_sleep	8	static
16
-SX1276.c:210:6:SX1276_entryLoRa	0	static
17
-SX1276.c:147:6:SX1276_config	32	static
18
-SX1276.c:142:6:SX1276_defaultConfig	24	static
19
-SX1276.c:214:6:SX1276_clearLoRaIrq	0	static
20
-SX1276.c:218:5:SX1276_LoRaEntryRx	16	static
21
-SX1276.c:250:9:SX1276_LoRaRxPacket	16	static
22
-SX1276.c:273:5:SX1276_LoRaEntryTx	16	static
23
-SX1276.c:304:5:SX1276_LoRaTxPacket	16	static
24
-SX1276.c:325:6:SX1276_begin	32	static
25
-SX1276.c:337:5:SX1276_transmit	24	static
26
-SX1276.c:345:5:SX1276_receive	0	static
27
-SX1276.c:349:9:SX1276_available	0	static
28
-SX1276.c:353:9:SX1276_read	16	static
29
-SX1276.c:362:9:SX1276_RSSI_LoRa	8	static
30
-SX1276.c:369:9:SX1276_RSSI	8	static
14
+SX1276.c:215:6:SX1276_set_power	0	static
15
+SX1276.c:281:6:SX1276_standby	8	static
16
+SX1276.c:286:6:SX1276_sleep	8	static
17
+SX1276.c:291:6:SX1276_entryLoRa	0	static
18
+SX1276.c:226:6:SX1276_config	32	static
19
+SX1276.c:221:6:SX1276_defaultConfig	32	static
20
+SX1276.c:295:6:SX1276_clearLoRaIrq	0	static
21
+SX1276.c:299:5:SX1276_LoRaEntryRx	16	static
22
+SX1276.c:331:9:SX1276_LoRaRxPacket	16	static
23
+SX1276.c:357:5:SX1276_LoRaEntryTx	16	static
24
+SX1276.c:388:5:SX1276_LoRaTxPacket	16	static
25
+SX1276.c:409:6:SX1276_begin	40	static
26
+SX1276.c:422:5:SX1276_transmit	24	static
27
+SX1276.c:430:5:SX1276_receive	0	static
28
+SX1276.c:434:9:SX1276_available	0	static
29
+SX1276.c:438:9:SX1276_read	16	static
30
+SX1276.c:447:9:SX1276_RSSI_LoRa	8	static
31
+SX1276.c:454:9:SX1276_RSSI	8	static

BIN
Debug/Src/main.o


+ 21 - 20
Debug/Src/main.su

@@ -1,20 +1,21 @@
1
-main.c:139:6:HAL_UART_RxCpltCallback	4	static
2
-main.c:184:6:HAL_TIM_PeriodElapsedCallback	0	static
3
-main.c:194:6:LoraDataSendSet	0	static
4
-main.c:197:9:LoraDataSendGet	0	static
5
-main.c:201:6:UartDataRecvSet	0	static
6
-main.c:204:9:UartDataRecvGet	0	static
7
-main.c:207:6:RGB_SensorIDAutoSet	0	static
8
-main.c:210:9:RGB_SensorIDAutoGet	0	static
9
-main.c:214:6:Uart2_Data_Send	0	static
10
-main.c:217:6:Uart1_Data_Send	0	static
11
-main.c:221:5:_write	8	static
12
-main.c:257:6:Uart_dataCheck	24	static
13
-main.c:289:6:RGB_Sensor_PowerOnOff	8	static
14
-main.c:443:6:test_read	24	static
15
-main.c:462:6:Flash_RGB_Data_Write	16	static
16
-main.c:475:6:Flash_write	24	static
17
-main.c:528:6:Flash_InitRead	12	static
18
-main.c:766:6:SystemClock_Config	72	static
19
-main.c:567:5:main	312	static
20
-main.c:1053:6:Error_Handler	0	static
1
+main.c:144:6:HAL_UART_RxCpltCallback	4	static
2
+main.c:189:6:HAL_TIM_PeriodElapsedCallback	0	static
3
+main.c:199:6:LoraDataSendSet	0	static
4
+main.c:202:9:LoraDataSendGet	0	static
5
+main.c:206:6:UartDataRecvSet	0	static
6
+main.c:209:9:UartDataRecvGet	0	static
7
+main.c:212:6:RGB_SensorIDAutoSet	0	static
8
+main.c:215:9:RGB_SensorIDAutoGet	0	static
9
+main.c:219:6:Uart2_Data_Send	0	static
10
+main.c:222:6:Uart1_Data_Send	0	static
11
+main.c:226:5:_write	8	static
12
+main.c:262:6:Uart_dataCheck	24	static
13
+main.c:294:6:RGB_Sensor_PowerOnOff	40	static
14
+main.c:452:6:test_read	24	static
15
+main.c:471:6:Flash_RGB_Data_Write	16	static
16
+main.c:484:6:Flash_write	24	static
17
+main.c:537:6:Flash_InitRead	12	static
18
+main.c:581:6:Lora_Initialize	32	static
19
+main.c:761:6:SystemClock_Config	72	static
20
+main.c:613:5:main	304	static
21
+main.c:1048:6:Error_Handler	0	static

BIN
Debug/Src/stm32f1xx_hal_msp.o


BIN
Debug/Src/stm32f1xx_it.o


+ 7 - 0
Inc/RGB_Controller.h

@@ -1,3 +1,6 @@
1
+#ifndef __RGB_CONTROLLER_H
2
+#define __RGB_CONTROLLER_H
3
+
1 4
 #include "main.h"
2 5
 
3 6
 
@@ -18,3 +21,7 @@ uint16_t RGB_SensorBlueLimit_Buf[9];
18 21
 
19 22
 extern uint8_t Lora_Buf[100];
20 23
 
24
+
25
+
26
+#endif
27
+

+ 29 - 13
Inc/SX1276.h

@@ -228,13 +228,30 @@ static const uint8_t SX1276_Frequency[14][3] = {
228 228
 #define SX1276_POWER_14DBM		2
229 229
 #define SX1276_POWER_11DBM		3
230 230
 
231
-static const uint8_t SX1276_Power[4] = { 0xFF, //20dbm
232
-		0xFC, //17dbm
233
-		0xF9, //14dbm
234
-		0xF6, //11dbm
235
-		};
236
-
237
-
231
+static const uint8_t SX1276_Power[4] = { 
232
+    0xFF, //20dbm
233
+    0xFC, //17dbm
234
+    0xF9, //14dbm
235
+    0xF6, //11dbm
236
+};
237
+typedef enum{
238
+    SX1276_0dBm = 0,
239
+    SX1276_1dBm,
240
+    SX1276_2dBm,
241
+    SX1276_3dBm,
242
+    SX1276_4dBm,
243
+    SX1276_5dBm,
244
+    SX1276_6dBm,
245
+    SX1276_7dBm,
246
+    SX1276_8dBm,
247
+    SX1276_9dBm,
248
+    SX1276_10dBm,
249
+    SX1276_11dBm,
250
+    SX1276_12dBm,
251
+    SX1276_13dBm,
252
+    SX1276_14dBm,    
253
+    SX1276_15dBm,        
254
+}SX1276_dBm_t;
238 255
 typedef enum{
239 256
  SX1276_LORA_SF_6		=0,
240 257
  SX1276_LORA_SF_7		=1,
@@ -303,10 +320,9 @@ typedef struct {
303 320
 	uint8_t LoRa_Rate;
304 321
 	uint8_t LoRa_BW;
305 322
 	uint8_t LoRa_Lna;    
323
+	uint8_t LoRa_Pa_boost;        
306 324
 	uint8_t packetLength;
307
-
308 325
 	SX1276_Status_t status;
309
-
310 326
 	uint8_t rxBuffer[SX1276_MAX_PACKET];
311 327
 	uint8_t readBytes;
312 328
 } SX1276_t;
@@ -315,8 +331,8 @@ typedef struct {
315 331
 	uint8_t power;
316 332
 	uint8_t LoRa_Rate;
317 333
 	uint8_t LoRa_BW;
318
-	uint8_t LoRa_Lna;    
319
-	uint8_t packetLength;
334
+	uint8_t LoRa_Lna; 
335
+    uint8_t LoRa_Pa_boost;       
320 336
 } Default_SX1276_t;
321 337
 
322 338
 
@@ -340,7 +356,7 @@ void SX1276_SPIBurstWrite(SX1276_t * module, uint8_t addr, uint8_t *txBuf,
340 356
 void SX1276_DIO0_InterruptHandler(SX1276_t * module);
341 357
 
342 358
 void SX1276_config(SX1276_t * module, uint8_t frequency, uint8_t power,
343
-		uint8_t LoRa_Rate, uint8_t LoRa_BW,uint8_t LoRa_Lna);
359
+		uint8_t LoRa_Rate, uint8_t LoRa_BW,uint8_t LoRa_Lna,uint8_t LoRa_PaBoost);
344 360
 void SX1276_defaultConfig(SX1276_t * module);
345 361
 
346 362
 void SX1276_entryLoRa(SX1276_t * module);
@@ -355,7 +371,7 @@ int SX1276_LoRaTxPacket(SX1276_t * module, uint8_t *txBuf, uint8_t length,
355 371
 		uint32_t timeout);
356 372
 
357 373
 void SX1276_begin(SX1276_t * module, uint8_t frequency, uint8_t power,
358
-		uint8_t LoRa_Rate, uint8_t LoRa_BW, uint8_t packetLength,uint8_t LoRa_Lna);
374
+        uint8_t LoRa_Rate, uint8_t LoRa_BW, uint8_t packetLength,uint8_t LoRa_Lna,uint8_t LoRa_PaBoost);
359 375
 
360 376
 int SX1276_transmit(SX1276_t * module, uint8_t *txBuf, uint8_t length,
361 377
 		uint32_t timeout);

+ 13 - 9
Inc/main.h

@@ -52,12 +52,12 @@ extern "C" {
52 52
 
53 53
 /* Private includes ----------------------------------------------------------*/
54 54
 /* USER CODE BEGIN Includes */
55
-#include "sth30_crc.h"
56
-#include <string.h>
57
-#include "RGB_Controller.h"
58
-#include "core_cm3.h"
59 55
 #include <stdint.h>
56
+#include <string.h>
57
+
58
+#include "sth30_crc.h"
60 59
 #include "SX1276.h"
60
+#include "RGB_Controller.h"
61 61
 /* USER CODE END Includes */
62 62
 
63 63
 /* Exported types ------------------------------------------------------------*/
@@ -102,6 +102,7 @@ extern void LoraDataSendSet(uint8_t val);
102 102
 extern uint8_t LoraDataSendGet(void);
103 103
 extern void Uart2_Data_Send(uint8_t* data,uint8_t size);
104 104
 extern void Uart1_Data_Send(uint8_t* data,uint8_t size);
105
+extern void Lora_Initialize(void);
105 106
 
106 107
 /* USER CODE END EM */
107 108
 
@@ -114,7 +115,8 @@ extern uint8_t MyControllerID;
114 115
 extern uint8_t  SensorID;
115 116
 extern uint8_t Lora_Buf[100];
116 117
 extern I2C_HandleTypeDef hi2c2;
117
-extern Default_SX1276_t Default_SX1276;
118
+
119
+
118 120
 
119 121
 typedef enum{
120 122
     RGB_Status_Data_Request = 0x01,
@@ -140,7 +142,9 @@ typedef enum{
140 142
     RGB_Lora_DataRequest,           //21
141 143
     RGB_Lora_DataResponse,          //22
142 144
     RGB_Lora_ConfigSet,             //23
143
-    RGB_Lora_ConfigGet,             //24    
145
+    RGB_Lora_ConfigGet,             //24
146
+    RGB_Controller_Init_Start        ,  // = 25;
147
+    RGB_Controller_Init_End           ,   //= 26;    
144 148
 }RGB_CMD_T;
145 149
 typedef struct{
146 150
     uint8_t Request_stx;
@@ -233,11 +237,11 @@ typedef struct{
233 237
 /* Lora */
234 238
 #define RGB_LORA_FREQ_ADDRESS        RGB8_LOCATION_ADDRESS      + 50
235 239
 #define RGB_LORA_PABOOST_ADDRESS     RGB_LORA_FREQ_ADDRESS      + 1
236
-#define RGB_LORA_BANDWIDTH_ADDRESS   RGB_LORA_PABOOST_ADDRESS   + 1
240
+#define RGB_LORA_SF_ADDRESS          RGB_LORA_PABOOST_ADDRESS   + 1
241
+#define RGB_LORA_BANDWIDTH_ADDRESS   RGB_LORA_SF_ADDRESS        + 1
237 242
 #define RGB_LORA_LNA_ADDRESS         RGB_LORA_BANDWIDTH_ADDRESS + 1
238
-#define RGB_LORA_SF_ADDRESS          RGB_LORA_SF_ADDRESS        + 1
239 243
 
240
-#define Reserved_ADDRESS             RGB_LORA_SF_ADDRESS        + 1
244
+#define Reserved_ADDRESS             RGB_LORA_LNA_ADDRESS       + 1
241 245
 
242 246
 
243 247
 

+ 42 - 10
Src/RGB_Controller.c

@@ -1,4 +1,9 @@
1
+
2
+
1 3
 #include "RGB_Controller.h"
4
+extern Default_SX1276_t Default_SX1276;
5
+extern SX1276_t SX1276;
6
+extern SX1276_hw_t SX1276_hw;
2 7
 
3 8
 void RGB_Response_Func(uint8_t* data);
4 9
 uint8_t RGB_BufCal(uint8_t srcid);
@@ -14,6 +19,7 @@ uint16_t RGB_SensorBlueLimit_Buf[9]={0,};
14 19
 uint8_t LED_Alarm[9] = {0,};
15 20
 uint8_t RGB_Location_Buf[9][50] = {0};
16 21
 
22
+
17 23
 void RGB_Data_Init(void){
18 24
     MyControllerID = M24C32_Data_Read(&hi2c2,MY_ID_ADDRESS);
19 25
   
@@ -39,11 +45,15 @@ void RGB_Data_Init(void){
39 45
         printf("RGB_SensorGreenLimit_Buf[%d]  :  %04x\n",i,RGB_SensorGreenLimit_Buf[i]);
40 46
         printf("RGB_SensorBlueLimit_Buf[%d]   :  %04x\n",i,RGB_SensorBlueLimit_Buf[i]);    
41 47
     }
42
-        Default_SX1276.frequency = 
43
-    Default_SX1276.power     = 
44
-    Default_SX1276.LoRa_Rate = 
45
-    Default_SX1276.LoRa_BW   = 
46
-    Default_SX1276.LoRa_Lna  = 
48
+    if(M24C32_Data_Read(&hi2c2,RGB_LORA_FREQ_ADDRESS) == 0xFF){
49
+        /*NOP*/
50
+    }else{
51
+        Default_SX1276.frequency = M24C32_Data_Read(&hi2c2,RGB_LORA_FREQ_ADDRESS);
52
+        Default_SX1276.power     = M24C32_Data_Read(&hi2c2,RGB_LORA_PABOOST_ADDRESS);
53
+        Default_SX1276.LoRa_Rate = M24C32_Data_Read(&hi2c2,RGB_LORA_SF_ADDRESS);
54
+        Default_SX1276.LoRa_BW   = M24C32_Data_Read(&hi2c2,RGB_LORA_BANDWIDTH_ADDRESS);
55
+        Default_SX1276.LoRa_Lna  = M24C32_Data_Read(&hi2c2,RGB_LORA_LNA_ADDRESS);
56
+    }
47 57
 
48 58
 }
49 59
 uint16_t RGB_Limit_Address_Check(uint8_t id){
@@ -141,10 +151,16 @@ for(uint8_t i = 0; i < 10; i++){
141 151
                  return;
142 152
              break;
143 153
         case RGB_Lora_ConfigSet:
154
+            data[bluecell_type] = RGB_Lora_ConfigGet;
155
+            Default_SX1276.frequency     = data[3];
156
+            Default_SX1276.LoRa_Pa_boost = data[4];
157
+            Default_SX1276.LoRa_Rate     = data[5];
158
+            Default_SX1276.LoRa_BW       = data[6];    
159
+            Default_SX1276.LoRa_Lna      = data[7];        
160
+            Lora_Initialize();
144 161
             M24C32_Data_Write(&hi2c2,&data[bluecell_srcid],RGB_LORA_FREQ_ADDRESS,data[bluecell_length] - 2); // EEPROM Controller ID Save 
145
-            break;
146 162
         case RGB_Lora_ConfigGet:
147
-
163
+            Uart1_Data_Send(data,data[bluecell_length] + 3);
148 164
             break;             
149 165
          default:break;
150 166
     }
@@ -370,14 +386,18 @@ uint8_t RGB_LimitData_Get(uint8_t id){
370 386
 uint8_t datalosscnt[9] = {0,};
371 387
 
372 388
 
389
+static uint8_t temp_sensorid;
373 390
 void RGB_Controller_Func(uint8_t* data){
374 391
 	RGB_CMD_T type = data[bluecell_type];
375
-  
376 392
    // static uint8_t temp_sensorid;
377 393
     uint8_t Result_buf[100] = {0,};
378 394
     uint8_t i = 0;
379 395
     switch(type){
380
-        case RGB_Status_Data_Request:           
396
+        case RGB_Status_Data_Request:          
397
+            data[bluecell_srcid + 1] = SensorID_buf[temp_sensorid++];
398
+            if(temp_sensorid > (SensorID_Cnt)){
399
+                temp_sensorid = 0;
400
+            }    
381 401
             datalosscnt[data[bluecell_srcid + 1]]++;
382 402
             if(datalosscnt[data[bluecell_srcid + 1]] > 3 && data[bluecell_srcid + 1] != 0){
383 403
                 RGB_SensorIDAutoSet(1);
@@ -396,6 +416,7 @@ void RGB_Controller_Func(uint8_t* data){
396 416
             Result_buf[5]  = STH30_CreateCrc(&Result_buf[bluecell_type],Result_buf[bluecell_length]);
397 417
             break;
398 418
         case RGB_SensorID_SET_Success:
419
+            printf("Recognize %d Sensor\n",data[bluecell_length + 1]);
399 420
             SensorID_Cnt++;
400 421
             SensorID_buf[SensorID_Cnt] = data[bluecell_length + 1];
401 422
             break;
@@ -455,10 +476,21 @@ void RGB_Controller_Func(uint8_t* data){
455 476
             Result_buf[bluecell_type] = RGB_Lora_DataResponse;
456 477
             break;
457 478
         case RGB_Lora_ConfigSet:
479
+            SX1276_hw_Reset(&SX1276_hw);
458 480
             memcpy(&Result_buf[bluecell_stx],&data[bluecell_stx],data[bluecell_length] + 3);
481
+            data[(data[bluecell_length] + 3)]=STH30_CreateCrc(&Result_buf[bluecell_type],Result_buf[bluecell_length]);
459 482
             break;
460 483
         case RGB_Lora_ConfigGet:
461
-
484
+            Result_buf[bluecell_stx]         = 0xbe;
485
+            Result_buf[bluecell_type]        = RGB_ControllerLimitGet;
486
+            Result_buf[bluecell_length]      = 7;
487
+            Result_buf[bluecell_srcid + 0]   = SX1276.frequency;
488
+            Result_buf[bluecell_srcid + 1]   = SX1276.LoRa_Pa_boost;            
489
+            Result_buf[bluecell_srcid + 2]   = SX1276.LoRa_BW;
490
+            Result_buf[bluecell_srcid + 3]   = SX1276.LoRa_Rate;
491
+            Result_buf[bluecell_srcid + 4]   = SX1276.LoRa_Lna;
492
+            Result_buf[bluecell_srcid + 5]   = STH30_CreateCrc(&Result_buf[bluecell_type],Result_buf[bluecell_length]);
493
+            Result_buf[bluecell_srcid + 6]   = 0xeb;
462 494
             break;
463 495
         default:
464 496
             break;

+ 88 - 3
Src/SX1276.c

@@ -138,14 +138,93 @@ void SX1276_SPIBurstWrite(SX1276_t * module, uint8_t addr, uint8_t* txBuf,
138 138
 //        printf("\n");
139 139
 		SX1276_hw_SetNSS(module->hw, 1);
140 140
 	}
141
+}
142
+        /*
143
+  RegPaConfig - 0x09
144
+  PaSelect    Mode                                  Power Range     Pout Formula
145
+  0           PA_HF or PA_LF on RFO_HF or RFO_LF    -4 to +15dBm    Pout=Pmax-(15-OutputPower), Pmax=10.8+0.6*MaxPower [dBm]
146
+  1           PA_HP on PA_BOOST, any frequency      +2 to +17dBm    Pout=17-(15-OutputPower) [dBm]
147
+  PA_LF option doesn't seem to transmit anything. Not connected on these boards, perhaps?
148
+  Use only PA_BOOST mode.
149
+  
150
+  PA_LF   Pmax              
151
+  Pout    0     1     2     3     4     5     6     7
152
+  0       -4.2  -3.6  -3    -2.4  -1.8  -1.2  -0.6  0
153
+  1       -3.2  -2.6  -2    -1.4  -0.8  -0.2  0.4   1
154
+  2       -2.2  -1.6  -1    -0.4  0.2   0.8   1.4   2
155
+  3       -1.2  -0.6  0     0.6   1.2   1.8   2.4   3
156
+  4       -0.2  0.4   1     1.6   2.2   2.8   3.4   4
157
+  5       0.8   1.4   2     2.6   3.2   3.8   4.4   5
158
+  6       1.8   2.4   3     3.6   4.2   4.8   5.4   6
159
+  7       2.8   3.4   4     4.6   5.2   5.8   6.4   7
160
+  8       3.8   4.4   5     5.6   6.2   6.8   7.4   8
161
+  9       4.8   5.4   6     6.6   7.2   7.8   8.4   9
162
+  10      5.8   6.4   7     7.6   8.2   8.8   9.4   10
163
+  11      6.8   7.4   8     8.6   9.2   9.8   10.4  11
164
+  12      7.8   8.4   9     9.6   10.2  10.8  11.4  12
165
+  13      8.8   9.4   10    10.6  11.2  11.8  12.4  13
166
+  14      9.8   10.4  11    11.6  12.2  12.8  13.4  14
167
+  15      10.8  11.4  12    12.6  13.2  13.8  14.4  15  [dBm]
168
+  
169
+  PA_BOOST 
170
+  Pout  OutputPower
171
+  0     2 dBm
172
+  1     3 dBm
173
+  2     4 dBm
174
+  3     5 dBm
175
+  4     6 dBm
176
+  5     7 dBm
177
+  6     8 dBm
178
+  7     9 dBm
179
+  8     10 dBm
180
+  9     11 dBm
181
+  10    12 dBm
182
+  11    13 dBm
183
+  12    14 dBm
184
+  13    15 dBm
185
+  14    16 dBm
186
+  15    17 dBm
187
+  
188
+  PaSelect
189
+    0 RFO pin. Maximum power of +14 dBm 
190
+    1 PA_BOOST pin. Maximum power of +20 dBm
191
+  MaxPower
192
+    Select max output power: Pmax=10.8+0.6*MaxPower [dBm]
193
+  OutputPower
194
+    Pout=Pmax-(15-OutputPower) if PaSelect = 0 (RFO pins) 
195
+    Pout=17-(15-OutputPower) if PaSelect = 1 (PA_BOOST pin)
196
+  PA_HF and PA_LF are high efficiency amplifiers capable of yielding RF power programmable in 1 dB steps
197
+  from -4 to +14dBm directly into a 50 ohm load with low current consumption. PA_LF covers the lower bands
198
+  (up to 525 MHz), whilst PA_HF will cover the upper bands (from 860 MHz).
199
+  PA_HP (High Power), connected to the PA_BOOST pin, covers all frequency bands that the chip addresses.
200
+  It permits continuous operation at up to +17 dBm and duty cycled operation at up to +20dBm.
201
+  RegOcp - 0x0B
202
+  OcpTrim   IMAX            Imax Formula
203
+  0 to 15   45 to 120 mA    45 + 5*OcpTrim [mA]
204
+  16 to 27  130 to 240 mA   -30 + 10*OcpTrim [mA]
205
+  27+       240 mA          240 mA
206
+  
207
+  The power amplifiers of RFM95/96/97/98(W) are protected against current over supply in adverse RF load
208
+  conditions by the over current protection block. The current limiter value is controlled by the OcpTrim 
209
+  bits in RegOcp.
210
+  Imax sets a limit on the current drain of the Power Amplifier only, hence the maximum current drain of the 
211
+  RFM96/77/78 is equal to Imax + IFS.
212
+  Default 100mA changed to 240mA.
213
+*/
214
+
215
+void SX1276_set_power(SX1276_t * module)
216
+{
217
+//    SX1276_SPIWrite(LR_RegPaConfig, (PaSelect << 7) | ((MaxPower & 0x07) << 4) | (OutputPower & 0x0F));
218
+    SX1276_SPIWrite(module,LR_RegPaConfig, (module->LoRa_Pa_boost << 7) | ((0x07) << 4) | (module->power & 0x0F));
219
+    //RFO -> 0 ~ 15 / PA_BOOST -> 2 ~ 17
141 220
 }
142 221
 void SX1276_defaultConfig(SX1276_t * module) {
143 222
 	SX1276_config(module, module->frequency, module->power, module->LoRa_Rate,
144
-			module->LoRa_BW,module->LoRa_Lna);
223
+			module->LoRa_BW,module->LoRa_Lna,module->LoRa_Pa_boost);
145 224
 }
146 225
 
147 226
 void SX1276_config(SX1276_t * module, uint8_t frequency, uint8_t power,
148
-		uint8_t LoRa_Rate, uint8_t LoRa_BW,uint8_t LoRa_Lna) {
227
+		uint8_t LoRa_Rate, uint8_t LoRa_BW,uint8_t LoRa_Lna,uint8_t LoRa_PaBoost) {
149 228
 	SX1276_sleep(module); //Change modem mode Must in Sleep mode
150 229
 	SX1276_hw_DelayMs(15);
151 230
 
@@ -160,6 +239,8 @@ void SX1276_config(SX1276_t * module, uint8_t frequency, uint8_t power,
160 239
 
161 240
 	SX1276_SPIWrite(module, LR_RegOcp, 0x0B);			//RegOcp,Close Ocp
162 241
 //	SX1276_SPIWrite(module, LR_RegLna, 0x20);		//RegLNA,High & LNA Enable
242
+    SX1276_set_power(module);
243
+
163 244
     SX1276_SPIWrite(module, LR_RegLna, LoRa_Lna);       //RegLNA,High & LNA Enable
164 245
 
165 246
 	if (SX1276_SpreadFactor[LoRa_Rate] == 6) {	//SFactor=6
@@ -270,6 +351,9 @@ uint8_t SX1276_LoRaRxPacket(SX1276_t * module) {
270 351
 	return module->readBytes;
271 352
 }
272 353
 
354
+
355
+
356
+
273 357
 int SX1276_LoRaEntryTx(SX1276_t * module, uint8_t length, uint32_t timeout) {
274 358
 	uint8_t addr;
275 359
 	uint8_t temp;
@@ -323,7 +407,7 @@ int SX1276_LoRaTxPacket(SX1276_t * module, uint8_t* txBuffer, uint8_t length,
323 407
 }
324 408
 
325 409
 void SX1276_begin(SX1276_t * module, uint8_t frequency, uint8_t power,
326
-		uint8_t LoRa_Rate, uint8_t LoRa_BW, uint8_t packetLength,uint8_t LoRa_Lna) {
410
+		uint8_t LoRa_Rate, uint8_t LoRa_BW, uint8_t packetLength,uint8_t LoRa_Lna,uint8_t LoRa_PaBoost) {
327 411
 	SX1276_hw_init(module->hw);
328 412
 	module->frequency       = frequency;
329 413
 	module->power           = power;
@@ -331,6 +415,7 @@ void SX1276_begin(SX1276_t * module, uint8_t frequency, uint8_t power,
331 415
 	module->LoRa_BW         = LoRa_BW;
332 416
 	module->packetLength    = packetLength;
333 417
     module->LoRa_Lna        = LoRa_Lna;
418
+    module->LoRa_Pa_boost   = LoRa_PaBoost;
334 419
 	SX1276_defaultConfig(module);
335 420
 }
336 421
 

+ 82 - 102
Src/main.c

@@ -97,6 +97,11 @@ uint8_t buf[buf_size] = {0,};
97 97
 uint8_t buf1[buf_size] = {0,};
98 98
 uint8_t buf2[buf_size] = {0,};
99 99
 
100
+Default_SX1276_t Default_SX1276;
101
+SX1276_hw_t SX1276_hw;
102
+SX1276_t SX1276;
103
+
104
+
100 105
 
101 106
 
102 107
 uint8_t MyControllerID = 0;
@@ -259,7 +264,7 @@ void Uart_dataCheck(uint8_t* Que_Buf,uint8_t* cnt){
259 264
     etError crccheck = 0;
260 265
 #if 0
261 266
     for(uint8_t i = 0; i < (* cnt); i++){
262
-        printf("%02x ",buf[i]);
267
+        printf("%02x ",*Que_Buf[i]);
263 268
     }
264 269
         printf("\r\n");
265 270
 #endif  
@@ -287,7 +292,9 @@ void Uart_dataCheck(uint8_t* Que_Buf,uint8_t* cnt){
287 292
 
288 293
 #endif // PYJ.2019.04.19_END -- 
289 294
 void RGB_Sensor_PowerOnOff(uint8_t id){
290
-    printf("%d Power ON \r\n",id);
295
+    uint8_t SensorSerchStart_cmd[5] = {0xbe,RGB_Controller_Init_Start,2,STH30_CreateCrc(&SensorSerchStart_cmd[bluecell_type],SensorSerchStart_cmd[bluecell_length]),0xeb};
296
+    uint8_t SensorSerchEnd_cmd[5] = {0xbe,RGB_Controller_Init_End,2,STH30_CreateCrc(&SensorSerchEnd_cmd[bluecell_type],SensorSerchEnd_cmd[bluecell_length]),0xeb};
297
+//    printf("%d Power ON \r\n",id);
291 298
 
292 299
     switch(id){
293 300
         case 0:
@@ -301,6 +308,7 @@ void RGB_Sensor_PowerOnOff(uint8_t id){
301 308
             HAL_GPIO_WritePin(SENSOR_EN8_GPIO_Port,SENSOR_EN8_Pin,GPIO_PIN_SET);   
302 309
             break;
303 310
         case 1:
311
+            Uart1_Data_Send(&SensorSerchStart_cmd[bluecell_stx], SensorSerchStart_cmd[bluecell_length] + 3);
304 312
             HAL_GPIO_WritePin(SENSOR_EN1_GPIO_Port,SENSOR_EN1_Pin,GPIO_PIN_RESET);
305 313
             HAL_Delay(50);
306 314
             HAL_GPIO_WritePin(SENSOR_EN1_GPIO_Port,SENSOR_EN1_Pin,GPIO_PIN_SET);
@@ -383,6 +391,7 @@ void RGB_Sensor_PowerOnOff(uint8_t id){
383 391
 
384 392
             break;
385 393
         case 8:
394
+            Uart1_Data_Send(&SensorSerchEnd_cmd[bluecell_stx], SensorSerchEnd_cmd[bluecell_length] + 3);
386 395
             HAL_GPIO_WritePin(SENSOR_EN1_GPIO_Port,SENSOR_EN1_Pin,GPIO_PIN_SET);
387 396
             HAL_GPIO_WritePin(SENSOR_EN2_GPIO_Port,SENSOR_EN2_Pin,GPIO_PIN_SET);        
388 397
             HAL_GPIO_WritePin(SENSOR_EN3_GPIO_Port,SENSOR_EN3_Pin,GPIO_PIN_SET);   
@@ -546,8 +555,8 @@ void Flash_InitRead(void) // ?
546 555
 
547 556
 #endif // PYJ.2019.03.19_END -- 
548 557
 
549
-SX1276_hw_t SX1276_hw;
550
-SX1276_t SX1276;
558
+
559
+
551 560
 Default_SX1276_t Default_SX1276 = 
552 561
 {
553 562
     SX1276_917MHZ,
@@ -556,6 +565,7 @@ Default_SX1276_t Default_SX1276 =
556 565
     SX1276_LORA_BW_20_8KHZ,
557 566
     10,
558 567
     SX1276_LORA_G1,
568
+    SX1276_15dBm,
559 569
 };
560 570
 
561 571
 
@@ -568,7 +578,28 @@ int message_length;
568 578
 int message;
569 579
 
570 580
 
571
-
581
+void Lora_Initialize(void){
582
+
583
+    SX1276_hw.dio0.port = SX1276_DIO0_GPIO_Port;
584
+    SX1276_hw.dio0.pin = SX1276_DIO0_Pin;
585
+    SX1276_hw.nss.port = GPIOA;
586
+    SX1276_hw.nss.pin = GPIO_PIN_15;
587
+    SX1276_hw.reset.port = SX1276_RESET_GPIO_Port;
588
+    SX1276_hw.reset.pin = SX1276_RESET_Pin;
589
+    // SX1276_hw.spi = &hspi3;
590
+    SX1276.hw = &SX1276_hw;
591
+//    printf("Configuring LoRa module\r\n");
592
+    SX1276_begin(&SX1276, Default_SX1276.frequency, Default_SX1276.power,
593
+    Default_SX1276.LoRa_Rate,Default_SX1276.LoRa_BW, 10,Default_SX1276.LoRa_Lna,Default_SX1276.LoRa_Pa_boost);
594
+
595
+//    printf("Done configuring LoRaModule\r\n");
596
+    master = 0;
597
+    if (master == 1) {
598
+        ret = SX1276_LoRaEntryTx(&SX1276, LORA_MAX_DATA_CNT, 2000);
599
+    } else {
600
+        ret = SX1276_LoRaEntryRx(&SX1276, LORA_MAX_DATA_CNT, 2000);
601
+    }
602
+}
572 603
 
573 604
 
574 605
 
@@ -582,10 +613,12 @@ int message;
582 613
 int main(void)
583 614
 {
584 615
   /* USER CODE BEGIN 1 */
585
-  uint8_t StatusRequest_data[RGB_SensorDataRequest_Length] = {0xbe,RGB_Status_Data_Request,RGB_SensorDataRequest_Length - 3,MyControllerID,SensorID,STH30_CreateCrc(&StatusRequest_data[bluecell_type],StatusRequest_data[bluecell_length]),0xeb};
586
-  uint8_t IDAutoSetRequest_data[RGB_SensorIDAutoSetRequest_Length] = {0xbe,RGB_SensorID_SET,RGB_SensorIDAutoSetRequest_Length - 3,MyControllerID,SensorID,STH30_CreateCrc(&IDAutoSetRequest_data[bluecell_type],IDAutoSetRequest_data[bluecell_length]),0xeb};  
587
-  uint8_t temp_sensorid = 0;
588
-  uint8_t uartdatarecv= 0;
616
+    uint8_t SensorSerchStart_cmd[5] = {0xbe,RGB_Controller_Init_Start,2,STH30_CreateCrc(&SensorSerchStart_cmd[bluecell_type],SensorSerchStart_cmd[bluecell_length]),0xeb};
617
+    uint8_t StatusRequest_data[RGB_SensorDataRequest_Length]         = {0xbe,RGB_Status_Data_Request,RGB_SensorDataRequest_Length - 3,MyControllerID,SensorID,STH30_CreateCrc(&StatusRequest_data[bluecell_type],StatusRequest_data[bluecell_length]),0xeb};
618
+    uint8_t IDAutoSetRequest_data[RGB_SensorIDAutoSetRequest_Length] = {0xbe,RGB_SensorID_SET,RGB_SensorIDAutoSetRequest_Length - 3,MyControllerID,SensorID,STH30_CreateCrc(&IDAutoSetRequest_data[bluecell_type],IDAutoSetRequest_data[bluecell_length]),0xeb};  
619
+    uint8_t cnt1 = 0,cnt2=0,uartdatarecv = 0;
620
+    uint8_t data1[100]= {0,};
621
+    uint8_t data2[100]= {0,};
589 622
   /* USER CODE END 1 */
590 623
 
591 624
   /* MCU Configuration--------------------------------------------------------*/
@@ -616,59 +649,26 @@ int main(void)
616 649
   MX_NVIC_Init();
617 650
   /* USER CODE BEGIN 2 */
618 651
   HAL_TIM_Base_Start_IT(&htim6);
652
+  RGB_SensorIDAutoSet(1);
619 653
   HAL_UART_Receive_DMA(&huart1, rx1_data, 1);
620 654
   HAL_UART_Receive_IT(&huart2, &rx2_data[0],1);
621 655
   setbuf(stdout, NULL); // \n ?�„ ? �?�„ ?–„ë§? 
622
-#if 1 // PYJ.2019.03.04_BEGIN -- 
656
+   Uart1_Data_Send(&SensorSerchStart_cmd[bluecell_stx], SensorSerchStart_cmd[bluecell_length] + 3);
657
+#if 0 // PYJ.2019.03.04_BEGIN -- 
623 658
       printf("****************************************\r\n");
624 659
       printf("RGB Project\r\n");
625 660
       printf("Build at %s %s\r\n", __DATE__, __TIME__);
626 661
       printf("Copyright (c) 2019. BLUECELL\r\n");
627 662
       printf("****************************************\r\n");
628 663
 #endif // PYJ.2019.03.04_END -- 
629
-  RGB_SensorIDAutoSet(1);
630 664
   Flash_InitRead();
631 665
   RGB_Data_Init();
666
+  Lora_Initialize();
632 667
   /* USER CODE END 2 */
633 668
 
634 669
   /* Infinite loop */
635 670
   /* USER CODE BEGIN WHILE */
636
-  //initialize LoRa module
637
-   SX1276_hw.dio0.port = SX1276_DIO0_GPIO_Port;
638
-   SX1276_hw.dio0.pin = SX1276_DIO0_Pin;
639
-   SX1276_hw.nss.port = GPIOA;
640
-   SX1276_hw.nss.pin = GPIO_PIN_15;
641
-   SX1276_hw.reset.port = SX1276_RESET_GPIO_Port;
642
-   SX1276_hw.reset.pin = SX1276_RESET_Pin;
643
-  // SX1276_hw.spi = &hspi3;
644
-   SX1276.hw = &SX1276_hw;
645
-
646 671
 
647
-    
648
-   printf("Configuring LoRa module\r\n");
649
-   SX1276_begin(&SX1276, Default_SX1276.frequency, Default_SX1276.power, Default_SX1276.LoRa_Rate,
650
-           Default_SX1276.LoRa_BW, 10,Default_SX1276.LoRa_Lna);
651
-   printf("Done configuring LoRaModule\r\n");
652
-   master = 0;
653
-   if (master == 1) {
654
-       ret = SX1276_LoRaEntryTx(&SX1276, LORA_MAX_DATA_CNT, 2000);
655
-   } else {
656
-       ret = SX1276_LoRaEntryRx(&SX1276, LORA_MAX_DATA_CNT, 2000);
657
-   }
658
-#if 0 // PYJ.2019.04.16_BEGIN -- 
659
-   for(uint8_t i = 0; i < 100; i++){
660
-    Test_data[i] = i;
661
-    M24C32_Data_Write(&hi2c2,&Test_data[i],(uint16_t)i,1);
662
-   }
663
-   
664
-   for(uint8_t i = 0; i < 100; i++){
665
-    printf("%d \n",M24C32_Data_Read(&hi2c2,(uint16_t)i));
666
-   }
667
-#endif // PYJ.2019.04.16_END -- 
668
-     
669
-    uint8_t data1[100]= {0,};
670
-    uint8_t data2[100]= {0,};
671
-    uint8_t uartrecv1=0,uartrecv2=0,cnt1 = 0,cnt2=0;
672 672
   while (1)
673 673
   {
674 674
      if(LoraTxTimerCnt > LORA_TIMER_CNT){
@@ -692,12 +692,11 @@ int main(void)
692 692
            ret = SX1276_LoRaRxPacket(&SX1276);
693 693
            if (ret > 0) {
694 694
                SX1276_read(&SX1276, &buffer[0], ret);
695
-               printf("Received Data : ");
696
-               for(uint8_t i = 0; i < ret; i++)
697
-               printf("%02x ",  buffer[i]);
698
-               printf("\n");
699
-               
700 695
                Uart_dataCheck(&buffer[bluecell_stx],&ret);
696
+//               printf("Received Data : ");
697
+//               for(uint8_t i = 0; i < ret; i++)
698
+//               printf("%02x ",  buffer[i]);
699
+//               printf("\n");
701 700
            }
702 701
        }
703 702
     
@@ -705,67 +704,48 @@ int main(void)
705 704
         data1[cnt1++] = buf1[count_out1++];
706 705
         if(count_out1 >= 100){ count_out1 = 0; }
707 706
         UartTimerCnt = 0;
708
-//        uartrecv1 = 1;
709 707
         UartDataRecvSet(1);
710 708
     }
711 709
     if(count_in2 != count_out2){ // <------- 
712 710
          data2[cnt2++] = buf2[count_out2++];
713 711
          if(count_out2 >= 100){ count_out2 = 0; }
714 712
          UartTimerCnt = 0;
715
-//         uartrecv2 = 1;
716 713
          UartDataRecvSet(2);
717
-
718 714
     }
719
-#if 0 // PYJ.2019.04.19_BEGIN -- 
720
-    uartdatarecv = UartDataRecvGet(); 
721
-    if(uartdatarecv != 0){
722
-        if(uartdatarecv == 1){
723
-            Uart_dataCheck(data1,&count_in1);
724
-        }else if(uartdatarecv == 2){
725
-            Uart_dataCheck(data2,&count_in2);
726
-        }  
727
-        UartDataRecvSet(0);
728
-    }
729
-#endif // PYJ.2019.04.19_END -- 
730
-    uartdatarecv = UartDataRecvGet(); 
731
-
732
-    if(uartdatarecv == 1 && UartTimerCnt > 100){
733
-        cnt1 = 0;
734
-        UartDataRecvSet(0);
735
-        Uart_dataCheck(&data1[0],&count_in1);
736
-        memset(&data1[0],0,100);
737
-    }
738
-    if(uartdatarecv == 2 && UartTimerCnt > 100){
739
-        cnt2 = 0;
740
-        UartDataRecvSet(0);
741
-        Uart_dataCheck(&data2[0],&count_in2);
742
-        memset(&data2[0],0,100);
743
-    }
744
-    else{
745
-        if(LedTimerCnt > 500){
746
-            if(RGB_SensorIDAutoGet() == 1){
747
-                if(SensorID == 0){memset(&SensorID_buf[0],0x00,8);SensorID_Cnt = 0;}
748
-                IDAutoSetRequest_data[bluecell_srcid + 1] = ++SensorID;//DST ID
749
-                if(IDAutoSetRequest_data[bluecell_srcid + 1] > 8){
750
-                    RGB_SensorIDAutoSet(0);
751
-                    RGB_Sensor_PowerOnOff(0);
752
-                    SensorID = 0;
753
-                }else{
754
-                    RGB_Sensor_PowerOnOff(IDAutoSetRequest_data[4]);
755
-                    HAL_Delay(75);
756
-                    RGB_Controller_Func(&IDAutoSetRequest_data[bluecell_stx]);
757
-                }
758
-            }
759
-            else{
760
-                StatusRequest_data[bluecell_srcid + 1] = SensorID_buf[temp_sensorid++];
761
-                if(temp_sensorid > (SensorID_Cnt)){
762
-                    temp_sensorid = 0;
763
-                }
764
-                RGB_Controller_Func(&StatusRequest_data[bluecell_stx]);
715
+        uartdatarecv = UartDataRecvGet(); 
716
+        if(uartdatarecv == 1 && UartTimerCnt > 100){
717
+            cnt1 = 0;
718
+            UartDataRecvSet(0);
719
+            Uart_dataCheck(&data1[0],&count_in1);
720
+            memset(&data1[0],0,100);
721
+        }
722
+        if(uartdatarecv == 2 && UartTimerCnt > 100){
723
+            cnt2 = 0;
724
+            UartDataRecvSet(0);
725
+            Uart_dataCheck(&data2[0],&count_in2);
726
+            memset(&data2[0],0,100);
727
+        }
728
+    
729
+    if(LedTimerCnt > 500){
730
+        if(RGB_SensorIDAutoGet() == 1){
731
+            if(SensorID == 0){memset(&SensorID_buf[0],0x00,8);SensorID_Cnt = 0;}
732
+            IDAutoSetRequest_data[bluecell_srcid + 1] = ++SensorID;//DST ID
733
+            if(IDAutoSetRequest_data[bluecell_srcid + 1] > 8){
734
+                RGB_SensorIDAutoSet(0);
735
+                RGB_Sensor_PowerOnOff(0);
736
+                SensorID = 0;
737
+            }else{
738
+                RGB_Sensor_PowerOnOff(IDAutoSetRequest_data[4]);
739
+                HAL_Delay(100);
740
+                RGB_Controller_Func(&IDAutoSetRequest_data[bluecell_stx]);
765 741
             }
766
-            HAL_GPIO_TogglePin(GPIOC,GPIO_PIN_15);
767
-            LedTimerCnt = 0;
768 742
         }
743
+       /* else{
744
+
745
+//            RGB_Controller_Func(&StatusRequest_data[bluecell_stx]);
746
+        }*/
747
+        HAL_GPIO_TogglePin(GPIOC,GPIO_PIN_15);
748
+        LedTimerCnt = 0;
769 749
     }
770 750
     /* USER CODE END WHILE */
771 751