LoRaWAN demo application using grove peripherals generating Cayenne LPP

Dependencies:   lorawan1v1

radio chip selection

Radio chip driver is not included, because two options are available.
If you're using SX1272 or SX1276, then import sx127x driver into your program.
if you're using SX1261 or SX1262, then import sx126x driver into your program.
If you're using NAmote72 or Murata discovery, then you must import only sx127x driver.

Grove peripherals -> Cayenne demo

Read LoRaWAN-1.1 page for configuration instructions.

This project adds support for Murata discovery board, in addition to LoRa shields on NUCLEO boards.

Use with sx1272 shield with grove peripherals connected:

D8 D9: ButtonRX TXA3 A4: TempSense
D6 D7:SCL SDA : LEDA1 A2: Pot

Button

Sends two different payload types: short press (under 1 sec)
long press: held down > 1 sec.

serial console keys

115200bps, 8N1
Enter key not used
Keys '0' to '3': cayenne channel number
'0': pot (rotary sensor)
'1': temperature
'2': digital out
'3': analog out

DevEUI configuration

For use on networks which force you to use DevEUI defined by network, comment out HardwareIDtoDevEUI().
HardwareIDtoDevEUI() obtains DevEUI from the CPU unique hardware serial number. However, some networks may force you to use their DevEUI value.

Revision:
8:efe6002910df
Parent:
6:795461780e10
--- a/sensorDemoVT100.cpp	Wed May 23 11:23:43 2018 -0700
+++ b/sensorDemoVT100.cpp	Mon Jul 23 13:19:35 2018 -0700
@@ -193,10 +193,17 @@
 uint8_t c_ch;
 us_timestamp_t buttonStartAt;
 #ifdef TARGET_DISCO_L072CZ_LRWAN1
-PwmOut pwm(PA_0);
-#elif defined(TARGET_FF_ARDUINO)
-PwmOut pwm(PB_11);
-#endif /* TARGET_DISCO_L072CZ_LRWAN1 */
+    PwmOut pwm(PA_0);
+    #define _PWM_
+#elif defined(TARGET_FF_ARDUINO) && defined(TARGET_FAMILY_STM32)
+    PwmOut pwm(PB_11);
+    #define _PWM_
+#elif defined(TARGET_NRF52_DK)
+    //PwmOut pwm(P0_0);
+    #undef _PWM_
+#else
+    #error define_PWM_pin_for_this_target
+#endif /* */
 volatile int cayenne_ack_ch;
 
 /*!
@@ -333,7 +340,9 @@
                 break;
             case CAYENNE_CH_AOUT:
                 AppData[gAppDataSize++] = LPP_ANALOG_OUTPUT;
+#ifdef _PWM_
                 u16 = pwm.read() * 100;
+#endif /* _PWM_ */
                 AppData[gAppDataSize++] = u16 >> 8;
                 AppData[gAppDataSize++] = u16;
                 break;
@@ -347,7 +356,9 @@
                 break;
             case CAYENNE_CH_AOUT:
                 AppData[gAppDataSize++] = LPP_ANALOG_OUTPUT;
+#ifdef _PWM_
                 u16 = pwm.read() * 100;
+#endif /* _PWM_ */
                 AppData[gAppDataSize++] = u16 >> 8;
                 AppData[gAppDataSize++] = u16;
                 break;
@@ -620,7 +631,9 @@
                     dout_downlink = true;
                     break;
                 case CAYENNE_CH_AOUT:
+#ifdef _PWM_
                     pwm.write(val / 100.0);
+#endif /* _PWM_ */
                     break;
                 default:
                     break;
@@ -931,7 +944,10 @@
 
     vt.SetCursorPos(ROW_MLME_IND, 1);
     Mlme_to_string(MlmeIndication->MlmeIndication, str);
-    vt.printf("MlmeIndication %s %08x ", str, RCC->CSR);
+    vt.printf("MlmeIndication %s ", str);
+#ifdef TARGET_STM32
+    vt.printf(" %08x ", RCC->CSR);
+#endif /* TARGET_STM32 */
     LoRaMacEventInfoStatus_to_string(MlmeIndication->Status, str);
     if (MlmeIndication->Status != LORAMAC_EVENT_INFO_STATUS_OK)
         vt.printf("\e[31m%s \e[0m \e[K", str);
@@ -1138,7 +1154,9 @@
                     for (;;) asm("nop");
                 }
                 
+#ifdef _PWM_
                 pwm.period(1.0 / 60);
+#endif /* _PWM_ */
                 cayenne_ack_ch = -1;
                 c_ch = 0xff;
                 button_pin.mode(PullDown);