Explorar o código

Uart data Receive 시 Lora Data Send 할 수 있도록 설정
매 데이터가 들어올때마다 Data를 Send 함

june9152 %!s(int64=6) %!d(string=hai) anos
pai
achega
9f8a74b324

BIN=BIN
Debug/STM32F103_RGB_Controller.bin


BIN=BIN
Debug/STM32F103_RGB_Controller.binary


BIN=BIN
Debug/STM32F103_RGB_Controller.elf


A diferenza do arquivo foi suprimida porque é demasiado grande
+ 3973 - 3768
Debug/STM32F103_RGB_Controller.list


A diferenza do arquivo foi suprimida porque é demasiado grande
+ 543 - 522
Debug/STM32F103_RGB_Controller.map


BIN=BIN
Debug/Src/GPIO_SPI.o


BIN=BIN
Debug/Src/RGB_Controller.o


+ 6 - 4
Debug/Src/RGB_Controller.su

@@ -1,4 +1,6 @@
1
-RGB_Controller.c:7:6:RGB_Response_Func	8	static
2
-RGB_Controller.c:56:6:RGB_Alarm_Check	32	static
3
-RGB_Controller.c:84:9:RGB_DeviceStatusCheck	12	static
4
-RGB_Controller.c:94:6:RGB_Controller_Func	120	static
1
+RGB_Controller.c:8:6:RGB_Response_Func	8	static
2
+RGB_Controller.c:57:6:RGB_Alarm_Check	32	static
3
+RGB_Controller.c:85:9:RGB_DeviceStatusCheck	12	static
4
+RGB_Controller.c:112:9:RGB_BufCal	0	static
5
+RGB_Controller.c:96:6:RGB_Data_Stack	8	static
6
+RGB_Controller.c:127:6:RGB_Controller_Func	120	static

BIN=BIN
Debug/Src/RGB_Lora.o


BIN=BIN
Debug/Src/SX1276.o


BIN=BIN
Debug/Src/main.o


+ 20 - 18
Debug/Src/main.su

@@ -1,18 +1,20 @@
1
-main.c:117:6:HAL_UART_RxCpltCallback	8	static
2
-main.c:157:6:HAL_TIM_PeriodElapsedCallback	0	static
3
-main.c:167:6:UartDataRecvSet	0	static
4
-main.c:170:9:UartDataRecvGet	0	static
5
-main.c:173:6:RGB_SensorIDAutoSet	0	static
6
-main.c:176:9:RGB_SensorIDAutoGet	0	static
7
-main.c:180:6:Uart2_Data_Send	0	static
8
-main.c:183:6:Uart1_Data_Send	0	static
9
-main.c:187:5:_write	8	static
10
-main.c:192:6:Uart_dataCheck	24	static
11
-main.c:221:6:RGB_Sensor_PowerOnOff	8	static
12
-main.c:375:6:test_read	24	static
13
-main.c:394:6:Flash_RGB_Data_Write	16	static
14
-main.c:407:6:Flash_write	24	static
15
-main.c:460:6:Flash_InitRead	12	static
16
-main.c:652:6:SystemClock_Config	72	static
17
-main.c:497:5:main	112	static
18
-main.c:926:6:Error_Handler	0	static
1
+main.c:119:6:HAL_UART_RxCpltCallback	8	static
2
+main.c:159:6:HAL_TIM_PeriodElapsedCallback	0	static
3
+main.c:168:6:LoraDataSendSet	0	static
4
+main.c:171:9:LoraDataSendGet	0	static
5
+main.c:175:6:UartDataRecvSet	0	static
6
+main.c:178:9:UartDataRecvGet	0	static
7
+main.c:181:6:RGB_SensorIDAutoSet	0	static
8
+main.c:184:9:RGB_SensorIDAutoGet	0	static
9
+main.c:188:6:Uart2_Data_Send	0	static
10
+main.c:191:6:Uart1_Data_Send	0	static
11
+main.c:195:5:_write	8	static
12
+main.c:200:6:Uart_dataCheck	24	static
13
+main.c:229:6:RGB_Sensor_PowerOnOff	8	static
14
+main.c:383:6:test_read	24	static
15
+main.c:402:6:Flash_RGB_Data_Write	16	static
16
+main.c:415:6:Flash_write	24	static
17
+main.c:468:6:Flash_InitRead	12	static
18
+main.c:667:6:SystemClock_Config	72	static
19
+main.c:505:5:main	112	static
20
+main.c:941:6:Error_Handler	0	static

BIN=BIN
Debug/Src/stm32f1xx_hal_msp.o


BIN=BIN
Debug/Src/stm32f1xx_it.o


+ 1 - 0
Inc/RGB_Controller.h

@@ -11,4 +11,5 @@ uint16_t RGB_SensorRedLimit_Buf[9];
11 11
 uint16_t RGB_SensorGreenLimit_Buf[9];
12 12
 uint16_t RGB_SensorBlueLimit_Buf[9];
13 13
 
14
+extern uint8_t Lora_Buf[100];
14 15
 

+ 29 - 23
Inc/main.h

@@ -64,19 +64,19 @@ extern "C" {
64 64
 /* USER CODE BEGIN ET */
65 65
 
66 66
 typedef enum{ //LIMIT SET enum
67
-    blucell_stx = 0,
68
-    blucell_type,
69
-    blucell_length,
70
-    blucell_srcid,
71
-    blucell_red_H,
72
-    blucell_red_L,    
73
-    blucell_green_H,
74
-    blucell_green_L,    
75
-    blucell_blue_H,
76
-    blucell_blue_L,    
77
-    blucell_dstid,
78
-    blucell_crc,
79
-    blucell_etx,
67
+    bluecell_stx = 0,
68
+    bluecell_type,
69
+    bluecell_length,
70
+    bluecell_srcid,
71
+    bluecell_red_H,
72
+    bluecell_red_L,    
73
+    bluecell_green_H,
74
+    bluecell_green_L,    
75
+    bluecell_blue_H,
76
+    bluecell_blue_L,    
77
+    bluecell_dstid,
78
+    bluecell_crc,
79
+    bluecell_etx,
80 80
 }RGB_Protocol_t;    
81 81
 /* USER CODE END ET */
82 82
 
@@ -91,6 +91,8 @@ extern void Uart3_Data_Send(uint8_t* data,uint8_t size);
91 91
 extern void RGB_SensorIDAutoSet(uint8_t set);
92 92
 extern uint8_t RGB_SensorIDAutoGet(void);
93 93
 extern void Flash_write(uint8_t*);
94
+extern void LoraDataSendSet(uint8_t val);
95
+extern uint8_t LoraDataSendGet(void);
94 96
 
95 97
 /* USER CODE END EM */
96 98
 
@@ -101,19 +103,21 @@ void Error_Handler(void);
101 103
 
102 104
 extern uint8_t MyControllerID;
103 105
 extern uint8_t  SensorID;
106
+extern uint8_t Lora_Buf[100];
104 107
 
105 108
 typedef enum{
106 109
     RGB_Status_Data_Request = 0x01,
107
-    RGB_ControllerID_SET ,
108
-    RGB_SensorID_SET ,
109
-    RGB_SensorID_SET_Success,   
110
-    RGB_Status_Data_Response ,    
111
-    RGB_ControllerLimitSet ,  
112
-    RGB_Sensor_Start ,    
113
-    RGB_Sensor_Check ,
114
-    RGB_Sensor_Ack,  
115
-    RGB_Reset,
116
-    RGB_ID_Allocate_Request,
110
+    RGB_ControllerID_SET ,   //2
111
+    RGB_SensorID_SET ,          //3
112
+    RGB_SensorID_SET_Success,   //4
113
+    RGB_Status_Data_Response ,    //5
114
+    RGB_ControllerLimitSet ,  //6
115
+    RGB_Sensor_Start ,    //7
116
+    RGB_Sensor_Check ,//8
117
+    RGB_Sensor_Ack,  //9
118
+    RGB_Reset,//a
119
+    RGB_ID_Allocate_Request,//b
120
+    RGB_Lora_Data_Report,//c
117 121
 }RGB_CMD_T;
118 122
 #define     RGB_ControllerID_SET_Length 10 
119 123
 #define     RGB_SensorID_SET_Length     10 
@@ -124,6 +128,8 @@ typedef enum{
124 128
 
125 129
 #define     RGB_SensorDataResponse_Length 15
126 130
 #define     RGB_SensorDataResponseData_Length RGB_SensorDataResponse_Length - 3
131
+#define     Lora_Max_Amount 60
132
+
127 133
 /* USER CODE END EFP */
128 134
 
129 135
 /* Private defines -----------------------------------------------------------*/

+ 62 - 28
Src/RGB_Controller.c

@@ -1,11 +1,12 @@
1 1
 #include "RGB_Controller.h"
2 2
 
3 3
 void RGB_Response_Func(uint8_t* data);
4
+uint8_t RGB_BufCal(uint8_t srcid);
4 5
 
5 6
 
6 7
 
7 8
 void RGB_Response_Func(uint8_t* data){

8
-	RGB_CMD_T type = data[blucell_type];
9
+	RGB_CMD_T type = data[bluecell_type];
9 10
 #if 0
10 11
 for(uint8_t i = 0; i < 10; i++){
11 12
             printf("%02x ",data[i]);
@@ -25,7 +26,7 @@ for(uint8_t i = 0; i < 10; i++){
25 26
             Uart1_Data_Send(data,RGB_SensorDataResponse_Length);
26 27
             break;
27 28
         case RGB_ControllerLimitSet:
28
-            Uart1_Data_Send(data,data[blucell_length] + 3);
29
+            Uart1_Data_Send(data,data[bluecell_length] + 3);
29 30
             Flash_write(&data[0]);
30 31
             break;
31 32
         case RGB_Sensor_Start:    
@@ -33,7 +34,7 @@ for(uint8_t i = 0; i < 10; i++){
33 34
             Uart2_Data_Send(data,RGB_SensorIDAutoSetRequest_Length);
34 35
             break;
35 36
         case RGB_Sensor_Ack:
36
-            Uart2_Data_Send(data,data[blucell_length] + 3);
37
+            Uart2_Data_Send(data,data[bluecell_length] + 3);
37 38
             break;
38 39
         case RGB_Reset:
39 40
         case RGB_SensorID_SET_Success:
@@ -54,9 +55,9 @@ uint16_t Sensor_green[9] = {0,};
54 55
 uint16_t Sensor_blue[9] = {0,};    
55 56
 void RGB_Alarm_Check(uint8_t* data){
56 57
    
57
-    Sensor_red[data[blucell_srcid]] = ((data[blucell_red_H + 2] << 8)| data[blucell_red_L + 2]);
58
-    Sensor_green[data[blucell_srcid]] = ((data[blucell_green_H + 2] << 8)| data[blucell_green_L + 2]);
59
-    Sensor_blue[data[blucell_srcid]] = ((data[blucell_blue_H + 2] << 8)| data[blucell_blue_L + 2]);  
58
+    Sensor_red[data[bluecell_srcid]] = ((data[bluecell_red_H + 2] << 8)| data[bluecell_red_L + 2]);
59
+    Sensor_green[data[bluecell_srcid]] = ((data[bluecell_green_H + 2] << 8)| data[bluecell_green_L + 2]);
60
+    Sensor_blue[data[bluecell_srcid]] = ((data[bluecell_blue_H + 2] << 8)| data[bluecell_blue_L + 2]);  
60 61
 
61 62
     uint8_t LED_Alarm = 0;
62 63
     for(uint8_t i = 1; i <= (SensorID_Cnt); i++){
@@ -89,49 +90,82 @@ uint8_t RGB_DeviceStatusCheck(void){
89 90
     }
90 91
     return ret;
91 92
 }
93
+uint8_t Lora_Buf[100] = {0,};
94
+
95
+void RGB_Data_Stack(uint8_t* rgb_buf){
96
+    uint8_t mynumcnt = RGB_BufCal(rgb_buf[bluecell_srcid]);
97
+    Lora_Buf[bluecell_stx]         = 0xbe;
98
+    Lora_Buf[bluecell_type]        = RGB_Lora_Data_Report;
99
+    Lora_Buf[bluecell_length]      = Lora_Max_Amount + 2; //length 1byte + type 1byte + RGB Data 60byte
100
+    Lora_Buf[bluecell_srcid]       = MyControllerID;
101
+    Lora_Buf[mynumcnt]             = rgb_buf[bluecell_srcid];
102
+    Lora_Buf[mynumcnt + 1]         = rgb_buf[bluecell_red_H + 2];
103
+    Lora_Buf[mynumcnt + 2]         = rgb_buf[bluecell_red_L + 2];
104
+    Lora_Buf[mynumcnt + 3]         = rgb_buf[bluecell_green_H + 2];
105
+    Lora_Buf[mynumcnt + 4]         = rgb_buf[bluecell_green_L + 2];
106
+    Lora_Buf[mynumcnt + 5]         = rgb_buf[bluecell_blue_H + 2];
107
+    Lora_Buf[mynumcnt + 6]         = rgb_buf[bluecell_blue_L + 2];
108
+    LoraDataSendSet(1);
109
+}
110
+
111
+uint8_t RGB_BufCal(uint8_t srcid){
112
+    uint8_t ret = 0;
113
+    switch(srcid){
114
+        case 1:ret = 4;break;
115
+        case 2:ret = 11;break;
116
+        case 3:ret = 18;break;
117
+        case 4:ret = 25;break;
118
+        case 5:ret = 32;break;
119
+        case 6:ret = 39;break;
120
+        case 7:ret = 46;break;
121
+        case 8:ret = 53;break;      
122
+    }
123
+    return ret;
124
+}
92 125
 uint8_t datalosscnt[9] = {0,};
93 126
 void RGB_Controller_Func(uint8_t* data){
94
-	RGB_CMD_T type = data[blucell_type];
127
+	RGB_CMD_T type = data[bluecell_type];
95 128
    // static uint8_t temp_sensorid;
96 129
     uint8_t Result_buf[100] = {0,};
97 130
     switch(type){
98 131
         case RGB_Status_Data_Request:           
99
-            datalosscnt[data[blucell_srcid + 1]]++;
100
-            if(datalosscnt[data[blucell_srcid + 1]] > 3 && data[blucell_srcid + 1] != 0){
132
+            datalosscnt[data[bluecell_srcid + 1]]++;
133
+            if(datalosscnt[data[bluecell_srcid + 1]] > 3 && data[bluecell_srcid + 1] != 0){
101 134
                 RGB_SensorIDAutoSet(1);
102 135
                 memset(&SensorID_buf[0],0x00,8);
103 136
             }
104
-            data[5]   = STH30_CreateCrc(&data[blucell_type],data[blucell_length]);
105
-            memcpy(&Result_buf[blucell_stx],&data[blucell_stx],RGB_SensorDataRequest_Length);
137
+            data[5]   = STH30_CreateCrc(&data[bluecell_type],data[bluecell_length]);
138
+            memcpy(&Result_buf[bluecell_stx],&data[bluecell_stx],RGB_SensorDataRequest_Length);
106 139
             break;
107 140
         case RGB_ControllerID_SET:        
108
-            memcpy(&Result_buf[blucell_stx],&data[blucell_stx],data[blucell_length] + 3);
109
-            Result_buf[7] = data[blucell_srcid]; // �긽��諛⑹쓽 SRC ID�뒗 �굹�쓽 DST ID�씠�떎.
141
+            memcpy(&Result_buf[bluecell_stx],&data[bluecell_stx],data[bluecell_length] + 3);
142
+            Result_buf[7] = data[bluecell_srcid]; // �긽��諛⑹쓽 SRC ID�뒗 �굹�쓽 DST ID�씠�떎.
110 143
             MyControllerID = Result_buf[7] = data[7];//�긽��諛⑹쓽 DST ID �뒗 �굹�쓽 ID �씠�떎.
111 144
             break;
112 145
         case RGB_SensorID_SET:        
113 146
             RGB_SensorIDAutoSet(1);
114
-            memcpy(&Result_buf[blucell_stx],&data[blucell_stx],data[blucell_length] + 3);
115
-            Result_buf[5]   = STH30_CreateCrc(&Result_buf[blucell_type],Result_buf[blucell_length]);
147
+            memcpy(&Result_buf[bluecell_stx],&data[bluecell_stx],data[bluecell_length] + 3);
148
+            Result_buf[5]   = STH30_CreateCrc(&Result_buf[bluecell_type],Result_buf[bluecell_length]);
116 149
             break;
117 150
         case RGB_SensorID_SET_Success:
118 151
             SensorID_Cnt++;
119
-            SensorID_buf[SensorID_Cnt] = data[blucell_length + 1];
152
+            SensorID_buf[SensorID_Cnt] = data[bluecell_length + 1];
120 153
             break;
121 154
         case RGB_Status_Data_Response:
122
-            datalosscnt[data[blucell_srcid]] = 0;
123
-            data[blucell_length] += 1;// Device On OFF status  Send byte
124
-            data[blucell_srcid + 9]  = RGB_DeviceStatusCheck();// Device On OFF status  Send byte
125
-            memcpy(&Result_buf[blucell_stx],&data[blucell_stx],data[blucell_length] + 3);
126
-            Result_buf[5]   = STH30_CreateCrc(&Result_buf[blucell_type],Result_buf[blucell_length]);
127
-            RGB_Alarm_Check(&data[blucell_stx]);
155
+            datalosscnt[data[bluecell_srcid]] = 0;
156
+            RGB_Data_Stack(&data[0]);
157
+            data[bluecell_length] += 1;// Device On OFF status  Send byte
158
+            data[bluecell_srcid + 9]  = RGB_DeviceStatusCheck();// Device On OFF status  Send byte
159
+            memcpy(&Result_buf[bluecell_stx],&data[bluecell_stx],data[bluecell_length] + 3);
160
+            Result_buf[5]   = STH30_CreateCrc(&Result_buf[bluecell_type],Result_buf[bluecell_length]);
161
+            RGB_Alarm_Check(&data[bluecell_stx]);
128 162
             break;
129 163
         case RGB_ControllerLimitSet:
130
-            memcpy(&Result_buf[blucell_stx],&data[blucell_stx],data[blucell_length] + 3);
131
-            RGB_SensorRedLimit_Buf[data[blucell_dstid]]   = ((data[blucell_red_H] << 8) |data[blucell_red_L]);
132
-            RGB_SensorGreenLimit_Buf[data[blucell_dstid]] = ((data[blucell_green_H] << 8) |data[blucell_green_L]);
133
-            RGB_SensorBlueLimit_Buf[data[blucell_dstid]]  = ((data[blucell_blue_H] << 8) |data[blucell_blue_L]);        
134
-            Result_buf[blucell_crc]   = STH30_CreateCrc(&Result_buf[blucell_type],Result_buf[blucell_length]);
164
+            memcpy(&Result_buf[bluecell_stx],&data[bluecell_stx],data[bluecell_length] + 3);
165
+            RGB_SensorRedLimit_Buf[data[bluecell_dstid]]   = ((data[bluecell_red_H] << 8) |data[bluecell_red_L]);
166
+            RGB_SensorGreenLimit_Buf[data[bluecell_dstid]] = ((data[bluecell_green_H] << 8) |data[bluecell_green_L]);
167
+            RGB_SensorBlueLimit_Buf[data[bluecell_dstid]]  = ((data[bluecell_blue_H] << 8) |data[bluecell_blue_L]);        
168
+            Result_buf[bluecell_crc]   = STH30_CreateCrc(&Result_buf[bluecell_type],Result_buf[bluecell_length]);
135 169
             break;
136 170
         case RGB_Reset:
137 171
             NVIC_SystemReset();
@@ -143,7 +177,7 @@ void RGB_Controller_Func(uint8_t* data){
143 177
         break;
144 178
     }
145 179
   
146
-    RGB_Response_Func(&Result_buf[blucell_stx]);
180
+    RGB_Response_Func(&Result_buf[bluecell_stx]);
147 181
     return;
148 182
 }
149 183
 

+ 36 - 20
Src/main.c

@@ -81,6 +81,8 @@ uint8_t count_in3 = 0, count_out = 0;
81 81
 
82 82
 
83 83
 uint8_t UartDataisReved;
84
+uint8_t LoraDataSend;
85
+
84 86
 uint8_t RGB_SensorIDAutoset = 0;
85 87
 
86 88
 volatile uint32_t UartTimerCnt = 0;
@@ -121,7 +123,7 @@ void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
121 123
         buf[count_in1] = rx1_data[0];//(uint8_t)USART2->DR;
122 124
 //        printf("data %02x \r\n",rx1_data[0]);
123 125
         if(buf[count_in1++] == 0xEB){
124
-            if(buf[blucell_length] == (count_in1 - 3))
126
+            if(buf[bluecell_length] == (count_in1 - 3))
125 127
                 UartDataRecvSet(1);
126 128
             else
127 129
                 count_in1 = 0;
@@ -133,7 +135,7 @@ void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
133 135
         buf[count_in2] = rx2_data[0];//(uint8_t)USART2->DR;
134 136
 //        if(buf[count_in++] == 0xEB)UartDataRecvSet(1);
135 137
         if(buf[count_in2++] == 0xEB){
136
-            if(buf[blucell_length] == (count_in2 - 3))
138
+            if(buf[bluecell_length] == (count_in2 - 3))
137 139
                 UartDataRecvSet(2);
138 140
             else
139 141
                 count_in1 = 0;
@@ -163,6 +165,12 @@ void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
163 165
         
164 166
     }
165 167
 }
168
+void LoraDataSendSet(uint8_t val){
169
+    LoraDataSend = val;
170
+}
171
+uint8_t LoraDataSendGet(void){
172
+    return LoraDataSend;
173
+}
166 174
 
167 175
 void UartDataRecvSet(uint8_t val){
168 176
     UartDataisReved = val;
@@ -199,15 +207,15 @@ void Uart_dataCheck(uint8_t* cnt){
199 207
         printf("\r\n");
200 208
 #endif  
201 209
 
202
-    crccheck = STH30_CheckCrc(&buf[blucell_type],buf[blucell_length],buf[buf[blucell_length] + 1]);
210
+    crccheck = STH30_CheckCrc(&buf[bluecell_type],buf[bluecell_length],buf[buf[bluecell_length] + 1]);
203 211
     if(crccheck == CHECKSUM_ERROR){
204 212
         for(uint8_t i = 0; i < (*cnt); i++){
205 213
             printf("%02x ",buf[i]);
206 214
         }
207
-        printf("Original CRC : %02x RecvCRC : %02x \r\n",crccheck,buf[buf[blucell_length] + 1]);
215
+        printf("Original CRC : %02x RecvCRC : %02x \r\n",crccheck,buf[buf[bluecell_length] + 1]);
208 216
     }
209 217
     else if(crccheck == NO_ERROR){
210
-        RGB_Controller_Func(&buf[blucell_stx]);
218
+        RGB_Controller_Func(&buf[bluecell_stx]);
211 219
     }
212 220
     else{
213 221
          printf("What Happen?\r\n");
@@ -395,9 +403,9 @@ void Flash_RGB_Data_Write(uint32_t Addr,uint8_t* data){
395 403
 
396 404
     uint16_t temp_Red = 0,temp_Green = 0,temp_Blue = 0;
397 405
 
398
-    temp_Red  = ((data[blucell_red_H] << 8)   |data[blucell_red_L]);     //R
399
-    temp_Green= ((data[blucell_green_H] << 8) |data[blucell_green_L]);  //G
400
-    temp_Blue = ((data[blucell_blue_H] << 8)  |data[blucell_blue_L]);   //B
406
+    temp_Red  = ((data[bluecell_red_H] << 8)   |data[bluecell_red_L]);     //R
407
+    temp_Green= ((data[bluecell_green_H] << 8) |data[bluecell_green_L]);  //G
408
+    temp_Blue = ((data[bluecell_blue_H] << 8)  |data[bluecell_blue_L]);   //B
401 409
 
402 410
     HAL_FLASH_Program(FLASH_TYPEPROGRAM_HALFWORD,Addr + 0 ,   (uint16_t)temp_Red);
403 411
     HAL_FLASH_Program(FLASH_TYPEPROGRAM_HALFWORD,Addr + 2 ,   (uint16_t)temp_Green);
@@ -425,7 +433,7 @@ void Flash_write(uint8_t* data) // 쓰기함수
425 433
 //        printf("Erase Success \r\n");
426 434
 //    }
427 435
   
428
-    switch(data[blucell_dstid]){
436
+    switch(data[bluecell_dstid]){
429 437
         case 1:
430 438
             Address += 0;
431 439
             break;
@@ -452,7 +460,7 @@ void Flash_write(uint8_t* data) // 쓰기함수
452 460
             break;            
453 461
 
454 462
     }
455
-    Flash_RGB_Data_Write(Address,&data[blucell_stx]);
463
+    Flash_RGB_Data_Write(Address,&data[bluecell_stx]);
456 464
     HAL_FLASH_Lock(); // lock 잠그기
457 465
     __HAL_RCC_TIM7_CLK_ENABLE(); // 매인타이머를 재시작합니다
458 466
 
@@ -483,7 +491,7 @@ SX1276_t SX1276;
483 491
 int master;
484 492
 int ret;
485 493
 
486
-char buffer[64];
494
+char buffer[100];
487 495
 
488 496
 int message;
489 497
 int message_length;
@@ -497,8 +505,8 @@ int message_length;
497 505
 int main(void)
498 506
 {
499 507
   /* USER CODE BEGIN 1 */
500
-  uint8_t StatusRequest_data[RGB_SensorDataRequest_Length] = {0xbe,RGB_Status_Data_Request,RGB_SensorDataRequest_Length - 3,MyControllerID,SensorID,STH30_CreateCrc(&StatusRequest_data[blucell_type],StatusRequest_data[blucell_length]),0xeb};
501
-  uint8_t IDAutoSetRequest_data[RGB_SensorIDAutoSetRequest_Length] = {0xbe,RGB_SensorID_SET,RGB_SensorIDAutoSetRequest_Length - 3,MyControllerID,SensorID,STH30_CreateCrc(&IDAutoSetRequest_data[blucell_type],IDAutoSetRequest_data[blucell_length]),0xeb};  
508
+  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};
509
+  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};  
502 510
   uint8_t temp_sensorid = 0;
503 511
   uint8_t uartdatarecv= 0;
504 512
   /* USER CODE END 1 */
@@ -563,15 +571,23 @@ int main(void)
563 571
            SX1276_LORA_BW_20_8KHZ, 10);
564 572
    printf("Done configuring LoRaModule\r\n");
565 573
    if (master == 1) {
566
-       ret = SX1276_LoRaEntryTx(&SX1276, 16, 2000);
574
+       ret = SX1276_LoRaEntryTx(&SX1276, 65, 2000);
567 575
    } else {
568
-       ret = SX1276_LoRaEntryRx(&SX1276, 16, 2000);
576
+       ret = SX1276_LoRaEntryRx(&SX1276, 65, 2000);
569 577
    }
570 578
    
571 579
 
572 580
   while (1)
573 581
   {
574 582
 #if 1 // PYJ.2019.04.11_BEGIN -- 
583
+    if(LoraDataSendGet() == 1){
584
+        LoraDataSendSet(0);
585
+        memcpy(,&Lora_Buf[0]);
586
+        message_length = Lora_Max_Amount + 2 + 3;////length 1byte + type 1byte + RGB Data 60byte + stx + etx + crc
587
+        ret = SX1276_LoRaEntryTx(&SX1276, message_length, 2000);
588
+        ret = SX1276_LoRaTxPacket(&SX1276, (uint8_t *) buffer, message_length, 2000);
589
+        message += 1;
590
+    }
575 591
     uartdatarecv = UartDataRecvGet(); 
576 592
     if(uartdatarecv != 0){
577 593
         if(uartdatarecv == 1){
@@ -615,24 +631,24 @@ int main(void)
615 631
         if(LedTimerCnt > 500){
616 632
             if(RGB_SensorIDAutoGet() == 1){
617 633
                 if(SensorID == 0){memset(&SensorID_buf[0],0x00,8);SensorID_Cnt = 0;}
618
-                IDAutoSetRequest_data[blucell_srcid + 1] = ++SensorID;//DST ID
619
-                if(IDAutoSetRequest_data[blucell_srcid + 1] > 8){
634
+                IDAutoSetRequest_data[bluecell_srcid + 1] = ++SensorID;//DST ID
635
+                if(IDAutoSetRequest_data[bluecell_srcid + 1] > 8){
620 636
                     RGB_SensorIDAutoSet(0);
621 637
                     RGB_Sensor_PowerOnOff(0);
622 638
                     SensorID = 0;
623 639
                 }else{
624 640
                     RGB_Sensor_PowerOnOff(IDAutoSetRequest_data[4]);
625 641
                     HAL_Delay(1500);
626
-                    RGB_Controller_Func(&IDAutoSetRequest_data[blucell_stx]);
642
+                    RGB_Controller_Func(&IDAutoSetRequest_data[bluecell_stx]);
627 643
                     HAL_Delay(500);
628 644
                 }
629 645
             }
630 646
             else{
631
-                StatusRequest_data[blucell_srcid + 1] = SensorID_buf[temp_sensorid++];
647
+                StatusRequest_data[bluecell_srcid + 1] = SensorID_buf[temp_sensorid++];
632 648
                 if(temp_sensorid > (SensorID_Cnt)){
633 649
                     temp_sensorid = 0;
634 650
                 }
635
-                 RGB_Controller_Func(&StatusRequest_data[blucell_stx]);
651
+                 RGB_Controller_Func(&StatusRequest_data[bluecell_stx]);
636 652
             }
637 653
             HAL_GPIO_TogglePin(GPIOC,GPIO_PIN_15);
638 654
             LedTimerCnt = 0;