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.

Committer:
Wayne Roberts
Date:
Wed May 23 11:23:43 2018 -0700
Revision:
7:882d2e6d3056
Parent:
5:53cd6c24a4ab
update to current lorawan library

Who changed what in which revision?

UserRevisionLine numberNew contents of line
wroberts@semtech.com 5:53cd6c24a4ab 1 #include "LoRaMac1v1.h"
Wayne Roberts 0:62e456e60083 2 #include "LoRaMacString.h"
Wayne Roberts 0:62e456e60083 3
Wayne Roberts 0:62e456e60083 4 void
Wayne Roberts 0:62e456e60083 5 Mlme_to_string(Mlme_t mlme, char* dst)
Wayne Roberts 0:62e456e60083 6 {
Wayne Roberts 0:62e456e60083 7 const char* ptr = NULL;
Wayne Roberts 0:62e456e60083 8
Wayne Roberts 0:62e456e60083 9 switch (mlme) {
Wayne Roberts 0:62e456e60083 10 case MLME_NONE: ptr = "NONE"; break;
Wayne Roberts 0:62e456e60083 11 case MLME_LINK_CHECK: ptr = "LINK_CHECK"; break;
Wayne Roberts 0:62e456e60083 12 case MLME_SWITCH_CLASS: ptr = "SWITCH_CLASS"; break;
Wayne Roberts 0:62e456e60083 13 case MLME_PING_SLOT_INFO: ptr = "PING_SLOT_INFO"; break;
Wayne Roberts 0:62e456e60083 14 case MLME_BEACON_TIMING: ptr = "BEACON_TIMING"; break;
Wayne Roberts 0:62e456e60083 15 case MLME_BEACON_ACQUISITION: ptr = "BEACON_ACQUISITION"; break;
Wayne Roberts 0:62e456e60083 16 case MLME_TIME_REQ: ptr = "TIME_REQ"; break;
Wayne Roberts 0:62e456e60083 17 case MLME_BEACON: ptr = "BEACON"; break;
Wayne Roberts 0:62e456e60083 18 case MLME_TXCW: ptr = "TXCW"; break;
Wayne Roberts 0:62e456e60083 19 #ifdef LORAWAN_JOIN_EUI
Wayne Roberts 0:62e456e60083 20 case MLME_JOIN: ptr = "JOIN"; break;
Wayne Roberts 0:62e456e60083 21 case MLME_REJOIN_0: ptr = "REJOIN_0"; break;
Wayne Roberts 0:62e456e60083 22 case MLME_REJOIN_1: ptr = "REJOIN_1"; break;
Wayne Roberts 0:62e456e60083 23 case MLME_REJOIN_2: ptr = "REJOIN_2"; break;
Wayne Roberts 0:62e456e60083 24 #endif
Wayne Roberts 0:62e456e60083 25 }
Wayne Roberts 0:62e456e60083 26
Wayne Roberts 0:62e456e60083 27 if (ptr != NULL)
Wayne Roberts 0:62e456e60083 28 strcpy(dst, ptr);
Wayne Roberts 0:62e456e60083 29 }
Wayne Roberts 0:62e456e60083 30
Wayne Roberts 0:62e456e60083 31 void
Wayne Roberts 0:62e456e60083 32 LoRaMacEventInfoStatus_to_string(LoRaMacEventInfoStatus_t status, char* dst)
Wayne Roberts 0:62e456e60083 33 {
Wayne Roberts 0:62e456e60083 34 const char* ptr = NULL;
Wayne Roberts 0:62e456e60083 35
Wayne Roberts 0:62e456e60083 36 switch (status) {
Wayne Roberts 0:62e456e60083 37
Wayne Roberts 0:62e456e60083 38 case LORAMAC_EVENT_INFO_STATUS_OK: ptr = "OK"; break;
Wayne Roberts 7:882d2e6d3056 39 case LORAMAC_EVENT_INFO_STATUS_CHANNEL_BUSY: ptr = "CHANNEL_BUSY"; break;
Wayne Roberts 0:62e456e60083 40 case LORAMAC_EVENT_INFO_STATUS_INCR_FAIL: ptr = "INCR_FAIL"; break;
Wayne Roberts 0:62e456e60083 41 case LORAMAC_EVENT_INFO_STATUS_MLMEREQ: ptr = "MLMEREQ"; break;
Wayne Roberts 0:62e456e60083 42 case LORAMAC_EVENT_INFO_STATUS_UNKNOWN_MTYPE: ptr = "UNKNOWN_MTYPE"; break;
Wayne Roberts 0:62e456e60083 43 case LORAMAC_EVENT_INFO_STATUS_SENDING: ptr = "SENDING"; break;
Wayne Roberts 0:62e456e60083 44 case LORAMAC_EVENT_INFO_STATUS_MCPSREQ: ptr = "MCPSREQ"; break;
Wayne Roberts 0:62e456e60083 45 case LORAMAC_EVENT_INFO_STATUS_TX_TIMEOUT: ptr = "TX_TIMEOUT"; break;
Wayne Roberts 0:62e456e60083 46 case LORAMAC_EVENT_INFO_STATUS_RX2_TIMEOUT: ptr = "RX2_TIMEOUT"; break;
Wayne Roberts 0:62e456e60083 47 case LORAMAC_EVENT_INFO_STATUS_RX2_ERROR: ptr = "RX2_ERROR"; break;
Wayne Roberts 0:62e456e60083 48 #ifdef LORAWAN_JOIN_EUI
Wayne Roberts 0:62e456e60083 49 case LORAMAC_EVENT_INFO_STATUS_JOIN_FAIL: ptr = "JOIN_FAIL"; break;
Wayne Roberts 0:62e456e60083 50 case LORAMAC_EVENT_INFO_STATUS_JOINNONCE: ptr = "JOINNONCE"; break;
Wayne Roberts 0:62e456e60083 51 #endif
Wayne Roberts 0:62e456e60083 52 case LORAMAC_EVENT_INFO_STATUS_DOWNLINK_REPEATED: ptr = "DOWNLINK_REPEATED"; break;
Wayne Roberts 0:62e456e60083 53 case LORAMAC_EVENT_INFO_STATUS_TX_DR_PAYLOAD_SIZE_ERROR: ptr = "TX_DR_PAYLOAD_SIZE_ERROR"; break;
Wayne Roberts 0:62e456e60083 54 case LORAMAC_EVENT_INFO_STATUS_DOWNLINK_TOO_MANY_FRAMES_LOSS: ptr = "DOWNLINK_TOO_MANY_FRAMES_LOSS"; break;
Wayne Roberts 0:62e456e60083 55 case LORAMAC_EVENT_INFO_STATUS_ADDRESS_FAIL: ptr = "ADDRESS_FAIL"; break;
Wayne Roberts 0:62e456e60083 56 case LORAMAC_EVENT_INFO_STATUS_MIC_FAIL: ptr = "MIC_FAIL"; break;
Wayne Roberts 0:62e456e60083 57 case LORAMAC_EVENT_INFO_STATUS_MULTICAST_FAIL: ptr = "MULTICAST_FAIL"; break;
Wayne Roberts 0:62e456e60083 58 case LORAMAC_EVENT_INFO_STATUS_BEACON_LOCKED: ptr = "BEACON_LOCKED"; break;
Wayne Roberts 0:62e456e60083 59 case LORAMAC_EVENT_INFO_STATUS_BEACON_LOST: ptr = "BEACON_LOST"; break;
Wayne Roberts 0:62e456e60083 60 case LORAMAC_EVENT_INFO_STATUS_BEACON_NOT_FOUND: ptr = "BEACON_NOT_FOUND"; break;
Wayne Roberts 0:62e456e60083 61 case LORAMAC_EVENT_INFO_STATUS_NO_APPKEY: ptr = "NO_APPKEY"; break;
Wayne Roberts 0:62e456e60083 62 case LORAMAC_EVENT_INFO_BAD_RX_DELAY: ptr = "BAD_RX_DELAY"; break;
Wayne Roberts 0:62e456e60083 63 }
Wayne Roberts 0:62e456e60083 64
Wayne Roberts 0:62e456e60083 65 if (ptr != NULL)
Wayne Roberts 0:62e456e60083 66 strcpy(dst, ptr);
Wayne Roberts 0:62e456e60083 67 }
Wayne Roberts 0:62e456e60083 68
Wayne Roberts 0:62e456e60083 69 void
Wayne Roberts 0:62e456e60083 70 LoRaMacStatus_to_string(LoRaMacStatus_t status, char* dst)
Wayne Roberts 0:62e456e60083 71 {
Wayne Roberts 0:62e456e60083 72 const char* ptr = NULL;
Wayne Roberts 0:62e456e60083 73
Wayne Roberts 0:62e456e60083 74 switch (status) {
Wayne Roberts 0:62e456e60083 75 case LORAMAC_STATUS_OK: ptr = "OK"; break;
dudmuck 1:3c1d13a0489e 76 case LORAMAC_STATUS_LSE: ptr = "LSE"; break;
Wayne Roberts 4:72b8fdc9878e 77 case LORAMAC_STATUS_WAITING_FOR_TXSTART: ptr = "WAIT_TXSTART"; break;
Wayne Roberts 4:72b8fdc9878e 78 case LORAMAC_STATUS_WAITING_FOR_TXDONE: ptr = "WAIT_TXDONE"; break;
Wayne Roberts 4:72b8fdc9878e 79 case LORAMAC_STATUS_WAITING_FOR_RX1: ptr = "WAIT_RX1"; break;
Wayne Roberts 4:72b8fdc9878e 80 case LORAMAC_STATUS_WAITING_FOR_RX2: ptr = "WAIT_RX2"; break;
Wayne Roberts 0:62e456e60083 81 case LORAMAC_STATUS_BUSY_UPCONF: ptr = "BUSY_UPCONF"; break;
Wayne Roberts 0:62e456e60083 82 case LORAMAC_STATUS_SERVICE_UNKNOWN: ptr = "SERVICE_UNKNOWN"; break;
Wayne Roberts 0:62e456e60083 83 case LORAMAC_STATUS_PARAMETER_INVALID: ptr = "PARAMETER_INVALID"; break;
Wayne Roberts 0:62e456e60083 84 case LORAMAC_STATUS_FREQUENCY_INVALID: ptr = "FREQUENCY_INVALID"; break;
Wayne Roberts 0:62e456e60083 85 case LORAMAC_STATUS_DATARATE_INVALID: ptr = "DATARATE_INVALID"; break;
Wayne Roberts 0:62e456e60083 86 case LORAMAC_STATUS_FREQ_AND_DR_INVALID: ptr = "FREQ_AND_DR_INVALID"; break;
Wayne Roberts 0:62e456e60083 87 #ifdef LORAWAN_JOIN_EUI
Wayne Roberts 0:62e456e60083 88 case LORAMAC_STATUS_NO_NETWORK_JOINED: ptr = "NO_NETWORK_JOINED"; break;
Wayne Roberts 0:62e456e60083 89 #endif
Wayne Roberts 0:62e456e60083 90 case LORAMAC_STATUS_LENGTH_ERROR: ptr = "LENGTH_ERROR"; break;
Wayne Roberts 0:62e456e60083 91 case LORAMAC_STATUS_MAC_CMD_LENGTH_ERROR: ptr = "MAC_CMD_LENGTH_ERROR"; break;
Wayne Roberts 0:62e456e60083 92 case LORAMAC_STATUS_DEVICE_OFF: ptr = "DEVICE_OFF"; break;
Wayne Roberts 0:62e456e60083 93 case LORAMAC_STATUS_EEPROM_FAIL: ptr = "EEPROM_FAIL"; break;
Wayne Roberts 0:62e456e60083 94 }
Wayne Roberts 0:62e456e60083 95 if (ptr != NULL)
Wayne Roberts 0:62e456e60083 96 strcpy(dst, ptr);
Wayne Roberts 0:62e456e60083 97 }