May 2021 test

Dependencies:   sx128x sx12xx_hal

Revision:
1:6a3a48d657a9
Parent:
0:b6ec8db2edbf
Child:
2:bf201940a9db
--- a/main.cpp	Tue Aug 22 10:16:06 2017 -0700
+++ b/main.cpp	Thu Aug 31 23:14:55 2017 +0000
@@ -17,20 +17,28 @@
         rfsw = 0;
 }
 /**********************************************************************/
-DigitalOut pc_3(PC_3);
+DigitalOut pc3(PC_3);
+DigitalOut pc2(PC_2);
+DigitalOut pc6(PC_6);
+DigitalOut pc8(PC_8);
+DigitalOut* pin; 
 Timeout to;
 
-#define PIN_ASSERT_us       200000
-#define CMD_ALARM       0x01
+#define PIN_ASSERT_us       500000
+
+#define CMD_PC2       0x02
+#define CMD_PC3       0x03
+#define CMD_PC6       0x06
+#define CMD_PC8       0x08
 
 void alarm_pin_clr()
 {
-    pc_3 = 0;
+    pin->write(0);
 }
 
 void alarm_pin_set()
 {
-    pc_3 = 1;
+    pin->write(1);
     to.attach_us(&alarm_pin_clr, PIN_ASSERT_us);
 }
 
@@ -66,7 +74,9 @@
     rx_crc += radio.rx_buf[6];
     //printf("%u) crc rx:%04x, calc:%04x\r\n", lora.RegRxNbBytes, rx_crc, crc);
     if (crc == rx_crc) {
-        if (radio.rx_buf[0] == CMD_ALARM) {
+        uint8_t c = radio.rx_buf[0];
+        //if (radio.rx_buf[0] == CMD_ALARM)
+        if (c == CMD_PC2 || c == CMD_PC3 || c == CMD_PC6 || c == CMD_PC8) {
             unsigned delay;
             delay = radio.rx_buf[1];
             delay <<= 8;
@@ -75,6 +85,12 @@
             delay += radio.rx_buf[3];
             delay <<= 8;
             delay += radio.rx_buf[4];
+            switch (c) {
+                case CMD_PC2: pin = &pc2; break;
+                case CMD_PC3: pin = &pc3; break;
+                case CMD_PC6: pin = &pc6; break;
+                case CMD_PC8: pin = &pc8; break;
+            }
             to.attach_us(&alarm_pin_set, delay);
             printf("delay:%u\r\n", delay);
         } else