Pārlūkot izejas kodu

Lora 에 Data 보고하는 기능 추가
RGB 각포트별로 Warning 시 LED 불 켜는 기능 추가
Lora Tx 기능 추가
Lora Buffer 에 Data가 쌓일 때마다 Lora Tx

june9152 6 gadi atpakaļ
vecāks
revīzija
4056fb867e

BIN
Debug/STM32F103_RGB_Controller.bin


BIN
Debug/STM32F103_RGB_Controller.binary


BIN
Debug/STM32F103_RGB_Controller.elf


Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 4552 - 4030
Debug/STM32F103_RGB_Controller.list


Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 603 - 583
Debug/STM32F103_RGB_Controller.map


BIN
Debug/Src/GPIO_SPI.o


BIN
Debug/Src/RGB_Controller.o


+ 9 - 6
Debug/Src/RGB_Controller.su

@@ -1,6 +1,9 @@
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
1
+RGB_Controller.c:10:6:RGB_Response_Func	8	static
2
+RGB_Controller.c:61:6:RGB_Sensor_LED_Alarm_ON	8	static
3
+RGB_Controller.c:99:6:RGB_Sensor_LED_Alarm_OFF	8	static
4
+RGB_Controller.c:138:6:RGB_Alarm_Operate	32	static
5
+RGB_Controller.c:171:9:RGB_DeviceStatusCheck	12	static
6
+RGB_Controller.c:245:9:RGB_BufCal	0	static
7
+RGB_Controller.c:218:6:RGB_Data_Stack	24	static
8
+RGB_Controller.c:154:6:RGB_Alarm_Check	48	static
9
+RGB_Controller.c:262:6:RGB_Controller_Func	120	static

BIN
Debug/Src/RGB_Lora.o


BIN
Debug/Src/SX1276.o


+ 30 - 30
Debug/Src/SX1276.su

@@ -1,30 +1,30 @@
1
-SX1276.c:24:13:SX1276_hw_SetNSS	0	static
2
-SX1276.c:19:13:SX1276_hw_init	8	static
3
-SX1276.c:48:6:SX1276_hw_SPICommand	8	static
4
-SX1276.c:127:6:SX1276_SPIBurstWrite.part.1	24	static
5
-SX1276.c:63:9:SX1276_hw_SPIReadByte	8	static
6
-SX1276.c:73:13:SX1276_hw_DelayMs	0	static
7
-SX1276.c:29:13:SX1276_hw_Reset	8	static
8
-SX1276.c:77:12:SX1276_hw_GetDIO0	8	static
9
-SX1276.c:92:9:SX1276_SPIIDRead	16	static
10
-SX1276.c:85:9:SX1276_SPIRead	0	static
11
-SX1276.c:100:6:SX1276_SPIWrite	16	static
12
-SX1276.c:109:6:SX1276_SPIBurstRead	24	static
13
-SX1276.c:127:6:SX1276_SPIBurstWrite	0	static
14
-SX1276.c:197:6:SX1276_standby	8	static
15
-SX1276.c:202:6:SX1276_sleep	8	static
16
-SX1276.c:207:6:SX1276_entryLoRa	0	static
17
-SX1276.c:146:6:SX1276_config	24	static
18
-SX1276.c:141:6:SX1276_defaultConfig	16	static
19
-SX1276.c:211:6:SX1276_clearLoRaIrq	0	static
20
-SX1276.c:215:5:SX1276_LoRaEntryRx	16	static
21
-SX1276.c:247:9:SX1276_LoRaRxPacket	16	static
22
-SX1276.c:270:5:SX1276_LoRaEntryTx	16	static
23
-SX1276.c:301:5:SX1276_LoRaTxPacket	16	static
24
-SX1276.c:322:6:SX1276_begin	32	static
25
-SX1276.c:333:5:SX1276_transmit	24	static
26
-SX1276.c:341:5:SX1276_receive	0	static
27
-SX1276.c:345:9:SX1276_available	0	static
28
-SX1276.c:349:9:SX1276_read	16	static
29
-SX1276.c:358:9:SX1276_RSSI_LoRa	8	static
30
-SX1276.c:365:9:SX1276_RSSI	8	static
1
+SX1276.c:22:13:SX1276_hw_SetNSS	0	static
2
+SX1276.c:17:13:SX1276_hw_init	8	static
3
+SX1276.c:46:6:SX1276_hw_SPICommand	8	static
4
+SX1276.c:125:6:SX1276_SPIBurstWrite.part.1	24	static
5
+SX1276.c:61:9:SX1276_hw_SPIReadByte	8	static
6
+SX1276.c:71:13:SX1276_hw_DelayMs	0	static
7
+SX1276.c:27:13:SX1276_hw_Reset	8	static
8
+SX1276.c:75:12:SX1276_hw_GetDIO0	8	static
9
+SX1276.c:90:9:SX1276_SPIIDRead	16	static
10
+SX1276.c:83:9:SX1276_SPIRead	0	static
11
+SX1276.c:98:6:SX1276_SPIWrite	16	static
12
+SX1276.c:107:6:SX1276_SPIBurstRead	24	static
13
+SX1276.c:125:6:SX1276_SPIBurstWrite	0	static
14
+SX1276.c:198:6:SX1276_standby	8	static
15
+SX1276.c:203:6:SX1276_sleep	8	static
16
+SX1276.c:208:6:SX1276_entryLoRa	0	static
17
+SX1276.c:147:6:SX1276_config	24	static
18
+SX1276.c:142:6:SX1276_defaultConfig	16	static
19
+SX1276.c:212:6:SX1276_clearLoRaIrq	0	static
20
+SX1276.c:216:5:SX1276_LoRaEntryRx	16	static
21
+SX1276.c:248:9:SX1276_LoRaRxPacket	16	static
22
+SX1276.c:271:5:SX1276_LoRaEntryTx	16	static
23
+SX1276.c:302:5:SX1276_LoRaTxPacket	16	static
24
+SX1276.c:323:6:SX1276_begin	32	static
25
+SX1276.c:334:5:SX1276_transmit	24	static
26
+SX1276.c:342:5:SX1276_receive	0	static
27
+SX1276.c:346:9:SX1276_available	0	static
28
+SX1276.c:350:9:SX1276_read	16	static
29
+SX1276.c:359:9:SX1276_RSSI_LoRa	8	static
30
+SX1276.c:366:9:SX1276_RSSI	8	static

BIN
Debug/Src/main.o


+ 3 - 3
Debug/Src/main.su

@@ -15,6 +15,6 @@ main.c:383:6:test_read	24	static
15 15
 main.c:402:6:Flash_RGB_Data_Write	16	static
16 16
 main.c:415:6:Flash_write	24	static
17 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
18
+main.c:721:6:SystemClock_Config	72	static
19
+main.c:506:5:main	112	static
20
+main.c:995:6:Error_Handler	0	static

BIN
Debug/Src/stm32f1xx_hal_msp.o


BIN
Debug/Src/stm32f1xx_it.o


+ 2 - 0
Inc/RGB_Controller.h

@@ -2,6 +2,8 @@
2 2
 
3 3
 
4 4
 extern void RGB_Controller_Func(uint8_t* data);
5
+extern void RGB_Alarm_Operate(void);
6
+extern void RGB_Sensor_LED_Alarm_OFF(uint8_t id );
5 7
 
6 8
 extern uint8_t SensorID_buf[8];
7 9
 extern uint8_t SensorID_Cnt;

+ 22 - 19
Inc/main.h

@@ -93,6 +93,8 @@ extern uint8_t RGB_SensorIDAutoGet(void);
93 93
 extern void Flash_write(uint8_t*);
94 94
 extern void LoraDataSendSet(uint8_t val);
95 95
 extern uint8_t LoraDataSendGet(void);
96
+extern void Uart2_Data_Send(uint8_t* data,uint8_t size);
97
+extern void Uart1_Data_Send(uint8_t* data,uint8_t size);
96 98
 
97 99
 /* USER CODE END EM */
98 100
 
@@ -107,28 +109,29 @@ extern uint8_t Lora_Buf[100];
107 109
 
108 110
 typedef enum{
109 111
     RGB_Status_Data_Request = 0x01,
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
112
+    RGB_ControllerID_SET ,          //2
113
+    RGB_SensorID_SET ,              //3
114
+    RGB_SensorID_SET_Success,       //4
115
+    RGB_Status_Data_Response ,      //5
116
+    RGB_ControllerLimitSet ,        //6
117
+    RGB_Sensor_Start ,              //7
118
+    RGB_Sensor_Check ,              //8
119
+    RGB_Sensor_Ack,                 //9
120
+    RGB_Reset,                      //10
121
+    RGB_ID_Allocate_Request,        //11
122
+    RGB_Lora_Data_Report,           //12
121 123
 }RGB_CMD_T;
122
-#define     RGB_ControllerID_SET_Length 10 
123
-#define     RGB_SensorID_SET_Length     10 
124
-#define     RGB_SensorDataRequest_Length 7
125
-#define     RGB_SensorIDAutoSetRequest_Length 7
126
-#define     RGB_SensorIDCheckSetRequest_Length 4
124
+#define     RGB_ControllerID_SET_Length         10 
125
+#define     RGB_SensorID_SET_Length             10 
126
+#define     RGB_SensorDataRequest_Length        7
127
+#define     RGB_SensorIDAutoSetRequest_Length   7
128
+#define     RGB_SensorIDCheckSetRequest_Length  4
127 129
 
128 130
 
129
-#define     RGB_SensorDataResponse_Length 15
130
-#define     RGB_SensorDataResponseData_Length RGB_SensorDataResponse_Length - 3
131
-#define     Lora_Max_Amount 60
131
+#define     RGB_SensorDataResponse_Length       15
132
+#define     RGB_SensorDataResponseData_Length   RGB_SensorDataResponse_Length - 3
133
+#define     Lora_Max_Amount                     5
134
+#define     LORA_MAX_DATA_CNT                   Lora_Max_Amount + 3
132 135
 
133 136
 /* USER CODE END EFP */
134 137
 

+ 150 - 15
Src/RGB_Controller.c

@@ -2,6 +2,8 @@
2 2
 
3 3
 void RGB_Response_Func(uint8_t* data);
4 4
 uint8_t RGB_BufCal(uint8_t srcid);
5
+void RGB_Alarm_Operate(void);
6
+void RGB_Data_Stack(uint8_t* rgb_buf);
5 7
 
6 8
 
7 9
 
@@ -53,32 +55,116 @@ uint16_t RGB_SensorBlueLimit_Buf[9]={0,};
53 55
 uint16_t Sensor_red[9] = {0,};
54 56
 uint16_t Sensor_green[9] = {0,};
55 57
 uint16_t Sensor_blue[9] = {0,};    
58
+
59
+uint8_t LED_Alarm[9] = {0,};
60
+void RGB_Sensor_LED_Alarm_ON(uint8_t id ){
61
+    switch(id){
62
+        case 0:// 모든 LED의 전원을 ON
63
+            HAL_GPIO_WritePin(LED_CH1_GPIO_Port,LED_CH1_Pin,GPIO_PIN_RESET);
64
+            HAL_GPIO_WritePin(LED_CH2_GPIO_Port,LED_CH2_Pin,GPIO_PIN_RESET);            
65
+            HAL_GPIO_WritePin(LED_CH3_GPIO_Port,LED_CH3_Pin,GPIO_PIN_RESET);            
66
+            HAL_GPIO_WritePin(LED_CH4_GPIO_Port,LED_CH4_Pin,GPIO_PIN_RESET);
67
+            HAL_GPIO_WritePin(LED_CH5_GPIO_Port,LED_CH5_Pin,GPIO_PIN_RESET);
68
+            HAL_GPIO_WritePin(LED_CH6_GPIO_Port,LED_CH6_Pin,GPIO_PIN_RESET);
69
+            HAL_GPIO_WritePin(LED_CH7_GPIO_Port,LED_CH7_Pin,GPIO_PIN_RESET);
70
+            HAL_GPIO_WritePin(LED_CH8_GPIO_Port,LED_CH8_Pin,GPIO_PIN_RESET);               
71
+            break;
72
+        case 1:
73
+            HAL_GPIO_WritePin(LED_CH1_GPIO_Port,LED_CH1_Pin,GPIO_PIN_RESET);
74
+            break;
75
+        case 2:
76
+            HAL_GPIO_WritePin(LED_CH2_GPIO_Port,LED_CH2_Pin,GPIO_PIN_RESET);
77
+            break;
78
+        case 3:
79
+            HAL_GPIO_WritePin(LED_CH3_GPIO_Port,LED_CH3_Pin,GPIO_PIN_RESET);
80
+            break;
81
+        case 4:
82
+            HAL_GPIO_WritePin(LED_CH4_GPIO_Port,LED_CH4_Pin,GPIO_PIN_RESET);
83
+            break;
84
+        case 5:
85
+            HAL_GPIO_WritePin(LED_CH5_GPIO_Port,LED_CH5_Pin,GPIO_PIN_RESET);
86
+            break;
87
+        case 6:
88
+            HAL_GPIO_WritePin(LED_CH6_GPIO_Port,LED_CH6_Pin,GPIO_PIN_RESET);
89
+            break;
90
+        case 7:
91
+            HAL_GPIO_WritePin(LED_CH7_GPIO_Port,LED_CH7_Pin,GPIO_PIN_RESET);
92
+            break;
93
+        case 8:
94
+            HAL_GPIO_WritePin(LED_CH8_GPIO_Port,LED_CH8_Pin,GPIO_PIN_RESET);
95
+            break;
96
+    }
97
+}
98
+void RGB_Sensor_LED_Alarm_OFF(uint8_t id ){
99
+    switch(id){
100
+        case 0:// 모든 LED의 전원을 OFF
101
+            HAL_GPIO_WritePin(LED_CH1_GPIO_Port,LED_CH1_Pin,GPIO_PIN_SET);
102
+            HAL_GPIO_WritePin(LED_CH2_GPIO_Port,LED_CH2_Pin,GPIO_PIN_SET);            
103
+            HAL_GPIO_WritePin(LED_CH3_GPIO_Port,LED_CH3_Pin,GPIO_PIN_SET);            
104
+            HAL_GPIO_WritePin(LED_CH4_GPIO_Port,LED_CH4_Pin,GPIO_PIN_SET);
105
+            HAL_GPIO_WritePin(LED_CH5_GPIO_Port,LED_CH5_Pin,GPIO_PIN_SET);
106
+            HAL_GPIO_WritePin(LED_CH6_GPIO_Port,LED_CH6_Pin,GPIO_PIN_SET);
107
+            HAL_GPIO_WritePin(LED_CH7_GPIO_Port,LED_CH7_Pin,GPIO_PIN_SET);
108
+            HAL_GPIO_WritePin(LED_CH8_GPIO_Port,LED_CH8_Pin,GPIO_PIN_SET);               
109
+            break;
110
+        case 1:
111
+            HAL_GPIO_WritePin(LED_CH1_GPIO_Port,LED_CH1_Pin,GPIO_PIN_SET);
112
+            break;
113
+        case 2:
114
+            HAL_GPIO_WritePin(LED_CH2_GPIO_Port,LED_CH2_Pin,GPIO_PIN_SET);
115
+            break;
116
+        case 3:
117
+            HAL_GPIO_WritePin(LED_CH3_GPIO_Port,LED_CH3_Pin,GPIO_PIN_SET);
118
+            break;
119
+        case 4:
120
+            HAL_GPIO_WritePin(LED_CH4_GPIO_Port,LED_CH4_Pin,GPIO_PIN_SET);
121
+            break;
122
+        case 5:
123
+            HAL_GPIO_WritePin(LED_CH5_GPIO_Port,LED_CH5_Pin,GPIO_PIN_SET);
124
+            break;
125
+        case 6:
126
+            HAL_GPIO_WritePin(LED_CH6_GPIO_Port,LED_CH6_Pin,GPIO_PIN_SET);
127
+            break;
128
+        case 7:
129
+            HAL_GPIO_WritePin(LED_CH7_GPIO_Port,LED_CH7_Pin,GPIO_PIN_SET);
130
+            break;
131
+        case 8:
132
+            HAL_GPIO_WritePin(LED_CH8_GPIO_Port,LED_CH8_Pin,GPIO_PIN_SET);
133
+            break;
134
+    }
135
+}
136
+
137
+void RGB_Alarm_Operate(void){
138
+    uint8_t temp_warning = 0;
139
+    for(uint8_t i = 1; i <= (SensorID_Cnt); i++){
140
+        if(LED_Alarm[SensorID_buf[i]] == 1){
141
+            HAL_GPIO_WritePin(LED_ALARM_GPIO_Port, LED_ALARM_Pin, GPIO_PIN_SET); //표지 LED  
142
+            RGB_Sensor_LED_Alarm_ON(SensorID_buf[i]);
143
+            temp_warning = 1; 
144
+        }else{
145
+            RGB_Sensor_LED_Alarm_OFF(SensorID_buf[i]);
146
+        }
147
+    }
148
+    if(temp_warning == 0){ // 8개의 Sensor가 전부 정상일 때 만 동작 
149
+        HAL_GPIO_WritePin(LED_ALARM_GPIO_Port, LED_ALARM_Pin, GPIO_PIN_RESET); //표지 LED 
150
+        RGB_Sensor_LED_Alarm_OFF(0); //모든 Sensor가 정상일 때는 LED 가 켜지지 않는다.
151
+    }
152
+}
56 153
 void RGB_Alarm_Check(uint8_t* data){
57
-   
58 154
     Sensor_red[data[bluecell_srcid]] = ((data[bluecell_red_H + 2] << 8)| data[bluecell_red_L + 2]);
59 155
     Sensor_green[data[bluecell_srcid]] = ((data[bluecell_green_H + 2] << 8)| data[bluecell_green_L + 2]);
60 156
     Sensor_blue[data[bluecell_srcid]] = ((data[bluecell_blue_H + 2] << 8)| data[bluecell_blue_L + 2]);  
61 157
 
62
-    uint8_t LED_Alarm = 0;
63 158
     for(uint8_t i = 1; i <= (SensorID_Cnt); i++){
64 159
         if(RGB_SensorRedLimit_Buf[SensorID_buf[i]]  >= Sensor_red[SensorID_buf[i]]
65 160
             || RGB_SensorGreenLimit_Buf[SensorID_buf[i]]  >= Sensor_green[SensorID_buf[i]]
66 161
             || RGB_SensorBlueLimit_Buf[SensorID_buf[i]]  >= Sensor_blue[SensorID_buf[i]]) {
67
-            LED_Alarm = 1;
68
-            break;
162
+            LED_Alarm[SensorID_buf[i]] = 1;
69 163
         }else{
70
-            LED_Alarm = 0;
164
+            LED_Alarm[SensorID_buf[i]] = 0;
71 165
         }
72 166
     }
73
-    if(LED_Alarm == 1){
74
-        HAL_GPIO_WritePin(GPIOB, GPIO_PIN_12, GPIO_PIN_SET);
75
-        HAL_GPIO_WritePin(GPIOA, GPIO_PIN_13, GPIO_PIN_RESET);       
76
-        HAL_GPIO_WritePin(GPIOC, GPIO_PIN_10, GPIO_PIN_SET);       
77
-    }else{
78
-        HAL_GPIO_WritePin(GPIOB, GPIO_PIN_12, GPIO_PIN_RESET);
79
-        HAL_GPIO_WritePin(GPIOA, GPIO_PIN_13, GPIO_PIN_SET);   
80
-        HAL_GPIO_WritePin(GPIOC, GPIO_PIN_10, GPIO_PIN_RESET);       
81
-    }
167
+    RGB_Data_Stack(&LED_Alarm[1]);
82 168
 }
83 169
 
84 170
 uint8_t RGB_DeviceStatusCheck(void){
@@ -92,6 +178,7 @@ uint8_t RGB_DeviceStatusCheck(void){
92 178
 }
93 179
 uint8_t Lora_Buf[100] = {0,};
94 180
 
181
+#if 0 // PYJ.2019.04.14_BEGIN --  //Uart Value Data 
95 182
 void RGB_Data_Stack(uint8_t* rgb_buf){
96 183
     uint8_t mynumcnt = RGB_BufCal(rgb_buf[bluecell_srcid]);
97 184
     Lora_Buf[bluecell_stx]         = 0xbe;
@@ -122,6 +209,54 @@ uint8_t RGB_BufCal(uint8_t srcid){
122 209
     }
123 210
     return ret;
124 211
 }
212
+#else //Uart Flag Data
213
+/*
214
+    현재 Controller 가지고 있는 RGB Sensor ID Check
215
+    현재 비정상적인 동작을 하는 Sensor 에대한 Flag 정보 
216
+*/
217
+void RGB_Data_Stack(uint8_t* rgb_buf){
218
+    memset(&Lora_Buf[0],0x00,8);
219
+    /*********************FIX DATA*************************************/
220
+    Lora_Buf[bluecell_stx]         = 0xbe;
221
+    Lora_Buf[bluecell_srcid + 4]   = 0xeb;
222
+    
223
+    Lora_Buf[bluecell_type]        = RGB_Lora_Data_Report;
224
+    Lora_Buf[bluecell_length]      = Lora_Max_Amount;// RGB Data 5byte
225
+    Lora_Buf[bluecell_srcid]       = MyControllerID;
226
+    /*********************FIX DATA*************************************/
227
+    if(RGB_BufCal(SensorID_buf[1]) == 0){//아무런 Device가 존재 하지않을 때 
228
+        printf("Not Exist Device \n");
229
+        return;
230
+    }
231
+    for(uint8_t i = 1; i <= (SensorID_Cnt); i++){
232
+        Lora_Buf[bluecell_srcid + 1] |= 0x01  << (SensorID_buf[i] - 1);
233
+    }
234
+    for(uint8_t i = 0; i < 8; i++){
235
+        Lora_Buf[bluecell_srcid + 2] |= rgb_buf[i] << i ;
236
+    }
237
+    Lora_Buf[bluecell_srcid + 3]= STH30_CreateCrc(&Lora_Buf[bluecell_type],Lora_Buf[bluecell_length]);
238
+    LoraDataSendSet(1);
239
+}
240
+/*
241
+    RGB_Data_Stack에 Lora에 Data를 보내기 위해 Buffer에 Data를 쌓을 때 
242
+    ID 마다 Location Cnt 
243
+*/
244
+uint8_t RGB_BufCal(uint8_t srcid){
245
+    uint8_t ret = 0;
246
+    switch(srcid){
247
+        case 1:ret = 4;break;
248
+        case 2:ret = 7;break;
249
+        case 3:ret = 10;break;
250
+        case 4:ret = 13;break;
251
+        case 5:ret = 16;break;
252
+        case 6:ret = 29;break;
253
+        case 7:ret = 32;break;
254
+        case 8:ret = 35;break;      
255
+    }
256
+    return ret;
257
+}
258
+
259
+#endif // PYJ.2019.04.14_END -- 
125 260
 uint8_t datalosscnt[9] = {0,};
126 261
 void RGB_Controller_Func(uint8_t* data){
127 262
 	RGB_CMD_T type = data[bluecell_type];
@@ -153,12 +288,12 @@ void RGB_Controller_Func(uint8_t* data){
153 288
             break;
154 289
         case RGB_Status_Data_Response:
155 290
             datalosscnt[data[bluecell_srcid]] = 0;
156
-            RGB_Data_Stack(&data[0]);
157 291
             data[bluecell_length] += 1;// Device On OFF status  Send byte
158 292
             data[bluecell_srcid + 9]  = RGB_DeviceStatusCheck();// Device On OFF status  Send byte
159 293
             memcpy(&Result_buf[bluecell_stx],&data[bluecell_stx],data[bluecell_length] + 3);
160 294
             Result_buf[5]   = STH30_CreateCrc(&Result_buf[bluecell_type],Result_buf[bluecell_length]);
161 295
             RGB_Alarm_Check(&data[bluecell_stx]);
296
+           
162 297
             break;
163 298
         case RGB_ControllerLimitSet:
164 299
             memcpy(&Result_buf[bluecell_stx],&data[bluecell_stx],data[bluecell_length] + 3);

+ 3 - 2
Src/SX1276.c

@@ -9,8 +9,6 @@
9 9
 #include "SX1276.h"
10 10
 #include <string.h>
11 11
 
12
-//#include "gpio.h"
13
-//#include "spi.h"
14 12
 
15 13
 //////////////////////////////////
16 14
 // logic
@@ -132,9 +130,12 @@ void SX1276_SPIBurstWrite(SX1276_t * module, uint8_t addr, uint8_t* txBuf,
132 130
 	} else {
133 131
 		SX1276_hw_SetNSS(module->hw, 0);
134 132
 		SX1276_hw_SPICommand(module->hw, addr | 0x80);
133
+//        printf("Test Data:");
135 134
 		for (i = 0; i < length; i++) {
136 135
 			SX1276_hw_SPICommand(module->hw, txBuf[i]);
136
+//            printf("%02x ",txBuf[i]);
137 137
 		}
138
+//        printf("\n");
138 139
 		SX1276_hw_SetNSS(module->hw, 1);
139 140
 	}
140 141
 }

+ 60 - 7
Src/main.c

@@ -485,6 +485,7 @@ void Flash_InitRead(void) // 쓰기함수
485 485
 
486 486
 
487 487
 #endif // PYJ.2019.03.19_END -- 
488
+
488 489
 SX1276_hw_t SX1276_hw;
489 490
 SX1276_t SX1276;
490 491
 
@@ -493,8 +494,8 @@ int ret;
493 494
 
494 495
 char buffer[100];
495 496
 
496
-int message;
497 497
 int message_length;
498
+int message;
498 499
 
499 500
 /* USER CODE END 0 */
500 501
 
@@ -570,24 +571,76 @@ int main(void)
570 571
    SX1276_begin(&SX1276, SX1276_917MHZ, SX1276_POWER_17DBM, SX1276_LORA_SF_8,
571 572
            SX1276_LORA_BW_20_8KHZ, 10);
572 573
    printf("Done configuring LoRaModule\r\n");
574
+   master = 0;
573 575
    if (master == 1) {
574
-       ret = SX1276_LoRaEntryTx(&SX1276, 65, 2000);
576
+       ret = SX1276_LoRaEntryTx(&SX1276, LORA_MAX_DATA_CNT, 2000);
575 577
    } else {
576
-       ret = SX1276_LoRaEntryRx(&SX1276, 65, 2000);
578
+       ret = SX1276_LoRaEntryRx(&SX1276, LORA_MAX_DATA_CNT, 2000);
577 579
    }
578 580
    
579 581
 
580 582
   while (1)
581 583
   {
582 584
 #if 1 // PYJ.2019.04.11_BEGIN -- 
585
+    RGB_Alarm_Operate();//LED ALARM CHECK
586
+
587
+#if 1 // PYJ.2019.04.14_BEGIN -- 
583 588
     if(LoraDataSendGet() == 1){
584 589
         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
590
+        memcpy(&buffer[0],&Lora_Buf[0],LORA_MAX_DATA_CNT);
591
+        message_length = Lora_Max_Amount + 3;////RGB Data 60byte + stx + etx + crc
587 592
         ret = SX1276_LoRaEntryTx(&SX1276, message_length, 2000);
588
-        ret = SX1276_LoRaTxPacket(&SX1276, (uint8_t *) buffer, message_length, 2000);
593
+        ret = SX1276_LoRaTxPacket(&SX1276, &buffer[0], message_length, 2000);
594
+//        printf("Tx data  :");
595
+//        for(uint8_t i = 0; i < message_length;i++ )
596
+//        printf("%02x ",buffer[i]);
597
+//        printf("\n");
598
+    }else {
599
+            HAL_Delay(1);
600
+           ret = SX1276_LoRaRxPacket(&SX1276);
601
+           if (ret > 0) {
602
+               SX1276_read(&SX1276, &buffer[0], ret);
603
+               printf("Received Data : ");
604
+               for(uint8_t i = 0; i < ret; i++)
605
+               printf("%02x ",  buffer[i]);
606
+               printf("\n");
607
+           }
608
+       
609
+       }
610
+#else
611
+    if (master == 1) {
612
+        printf("Master ...\r\n");
613
+        HAL_Delay(2500);
614
+        printf("Sending package...\r\n");
615
+    
616
+        message_length = sprintf(buffer, "Hello %d", message);
617
+        ret = SX1276_LoRaEntryTx(&SX1276, message_length, 2000);
618
+        printf("Entry: %d\r\n", ret);
619
+    
620
+        printf("Sending %s\r\n", buffer);
621
+        ret = SX1276_LoRaTxPacket(&SX1276, (uint8_t *) buffer, message_length,
622
+                2000);
589 623
         message += 1;
624
+    
625
+        printf("Transmission: %d\r\n", ret);
626
+        printf("Package sent...\r\n");
627
+    
628
+    } else {
629
+        printf("Slave ...\r\n");
630
+        HAL_Delay(1000);
631
+        printf("Receiving package...\r\n");
632
+    
633
+        ret = SX1276_LoRaRxPacket(&SX1276);
634
+        printf("Received: %d\r\n", ret);
635
+        if (ret > 0) {
636
+            SX1276_read(&SX1276, (uint8_t *) buffer, ret);
637
+            printf("Content (%d): %s\r\n", ret, buffer);
638
+        }
639
+        printf("Package received ...\r\n");
640
+    
590 641
     }
642
+
643
+#endif // PYJ.2019.04.14_END -- 
591 644
     uartdatarecv = UartDataRecvGet(); 
592 645
     if(uartdatarecv != 0){
593 646
         if(uartdatarecv == 1){
@@ -638,7 +691,7 @@ int main(void)
638 691
                     SensorID = 0;
639 692
                 }else{
640 693
                     RGB_Sensor_PowerOnOff(IDAutoSetRequest_data[4]);
641
-                    HAL_Delay(1500);
694
+                    HAL_Delay(500);
642 695
                     RGB_Controller_Func(&IDAutoSetRequest_data[bluecell_stx]);
643 696
                     HAL_Delay(500);
644 697
                 }