Ottawa Bootcamp Publish

Dependencies:   SX127x lorawan1v1

Committer:
dudmuck
Date:
Thu Mar 01 17:29:50 2018 +0000
Revision:
1:3c1d13a0489e
Parent:
0:62e456e60083
Child:
4:72b8fdc9878e
halt program if failed to initialize

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Wayne Roberts 0:62e456e60083 1 #include "LoRaMac.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 0:62e456e60083 39 case LORAMAC_EVENT_INFO_STATUS_INCR_FAIL: ptr = "INCR_FAIL"; break;
Wayne Roberts 0:62e456e60083 40 case LORAMAC_EVENT_INFO_STATUS_MLMEREQ: ptr = "MLMEREQ"; break;
Wayne Roberts 0:62e456e60083 41 case LORAMAC_EVENT_INFO_STATUS_UNKNOWN_MTYPE: ptr = "UNKNOWN_MTYPE"; break;
Wayne Roberts 0:62e456e60083 42 case LORAMAC_EVENT_INFO_STATUS_SENDING: ptr = "SENDING"; break;
Wayne Roberts 0:62e456e60083 43 case LORAMAC_EVENT_INFO_STATUS_MCPSREQ: ptr = "MCPSREQ"; break;
Wayne Roberts 0:62e456e60083 44 case LORAMAC_EVENT_INFO_STATUS_TX_TIMEOUT: ptr = "TX_TIMEOUT"; break;
Wayne Roberts 0:62e456e60083 45 case LORAMAC_EVENT_INFO_STATUS_RX2_TIMEOUT: ptr = "RX2_TIMEOUT"; break;
Wayne Roberts 0:62e456e60083 46 case LORAMAC_EVENT_INFO_STATUS_RX2_ERROR: ptr = "RX2_ERROR"; break;
Wayne Roberts 0:62e456e60083 47 #ifdef LORAWAN_JOIN_EUI
Wayne Roberts 0:62e456e60083 48 case LORAMAC_EVENT_INFO_STATUS_JOIN_FAIL: ptr = "JOIN_FAIL"; break;
Wayne Roberts 0:62e456e60083 49 case LORAMAC_EVENT_INFO_STATUS_JOINNONCE: ptr = "JOINNONCE"; break;
Wayne Roberts 0:62e456e60083 50 #endif
Wayne Roberts 0:62e456e60083 51 case LORAMAC_EVENT_INFO_STATUS_DOWNLINK_REPEATED: ptr = "DOWNLINK_REPEATED"; break;
Wayne Roberts 0:62e456e60083 52 case LORAMAC_EVENT_INFO_STATUS_TX_DR_PAYLOAD_SIZE_ERROR: ptr = "TX_DR_PAYLOAD_SIZE_ERROR"; break;
Wayne Roberts 0:62e456e60083 53 case LORAMAC_EVENT_INFO_STATUS_DOWNLINK_TOO_MANY_FRAMES_LOSS: ptr = "DOWNLINK_TOO_MANY_FRAMES_LOSS"; break;
Wayne Roberts 0:62e456e60083 54 case LORAMAC_EVENT_INFO_STATUS_ADDRESS_FAIL: ptr = "ADDRESS_FAIL"; break;
Wayne Roberts 0:62e456e60083 55 case LORAMAC_EVENT_INFO_STATUS_MIC_FAIL: ptr = "MIC_FAIL"; break;
Wayne Roberts 0:62e456e60083 56 case LORAMAC_EVENT_INFO_STATUS_MULTICAST_FAIL: ptr = "MULTICAST_FAIL"; break;
Wayne Roberts 0:62e456e60083 57 case LORAMAC_EVENT_INFO_STATUS_BEACON_LOCKED: ptr = "BEACON_LOCKED"; break;
Wayne Roberts 0:62e456e60083 58 case LORAMAC_EVENT_INFO_STATUS_BEACON_LOST: ptr = "BEACON_LOST"; break;
Wayne Roberts 0:62e456e60083 59 case LORAMAC_EVENT_INFO_STATUS_BEACON_NOT_FOUND: ptr = "BEACON_NOT_FOUND"; break;
Wayne Roberts 0:62e456e60083 60 case LORAMAC_EVENT_INFO_STATUS_NO_APPKEY: ptr = "NO_APPKEY"; break;
Wayne Roberts 0:62e456e60083 61 case LORAMAC_EVENT_INFO_BAD_RX_DELAY: ptr = "BAD_RX_DELAY"; break;
Wayne Roberts 0:62e456e60083 62 }
Wayne Roberts 0:62e456e60083 63
Wayne Roberts 0:62e456e60083 64 if (ptr != NULL)
Wayne Roberts 0:62e456e60083 65 strcpy(dst, ptr);
Wayne Roberts 0:62e456e60083 66 }
Wayne Roberts 0:62e456e60083 67
Wayne Roberts 0:62e456e60083 68 void
Wayne Roberts 0:62e456e60083 69 LoRaMacStatus_to_string(LoRaMacStatus_t status, char* dst)
Wayne Roberts 0:62e456e60083 70 {
Wayne Roberts 0:62e456e60083 71 const char* ptr = NULL;
Wayne Roberts 0:62e456e60083 72
Wayne Roberts 0:62e456e60083 73 switch (status) {
Wayne Roberts 0:62e456e60083 74 case LORAMAC_STATUS_OK: ptr = "OK"; break;
dudmuck 1:3c1d13a0489e 75 case LORAMAC_STATUS_LSE: ptr = "LSE"; break;
Wayne Roberts 0:62e456e60083 76 case LORAMAC_STATUS_IN_PROGRESS: ptr = "LORAMAC_STATUS_IN_PROGRESS"; break;
Wayne Roberts 0:62e456e60083 77 case LORAMAC_STATUS_BUSY_UPCONF: ptr = "BUSY_UPCONF"; break;
Wayne Roberts 0:62e456e60083 78 case LORAMAC_STATUS_SERVICE_UNKNOWN: ptr = "SERVICE_UNKNOWN"; break;
Wayne Roberts 0:62e456e60083 79 case LORAMAC_STATUS_PARAMETER_INVALID: ptr = "PARAMETER_INVALID"; break;
Wayne Roberts 0:62e456e60083 80 case LORAMAC_STATUS_FREQUENCY_INVALID: ptr = "FREQUENCY_INVALID"; break;
Wayne Roberts 0:62e456e60083 81 case LORAMAC_STATUS_DATARATE_INVALID: ptr = "DATARATE_INVALID"; break;
Wayne Roberts 0:62e456e60083 82 case LORAMAC_STATUS_FREQ_AND_DR_INVALID: ptr = "FREQ_AND_DR_INVALID"; break;
Wayne Roberts 0:62e456e60083 83 #ifdef LORAWAN_JOIN_EUI
Wayne Roberts 0:62e456e60083 84 case LORAMAC_STATUS_NO_NETWORK_JOINED: ptr = "NO_NETWORK_JOINED"; break;
Wayne Roberts 0:62e456e60083 85 #endif
Wayne Roberts 0:62e456e60083 86 case LORAMAC_STATUS_LENGTH_ERROR: ptr = "LENGTH_ERROR"; break;
Wayne Roberts 0:62e456e60083 87 case LORAMAC_STATUS_MAC_CMD_LENGTH_ERROR: ptr = "MAC_CMD_LENGTH_ERROR"; break;
Wayne Roberts 0:62e456e60083 88 case LORAMAC_STATUS_DEVICE_OFF: ptr = "DEVICE_OFF"; break;
Wayne Roberts 0:62e456e60083 89 case LORAMAC_STATUS_EEPROM_FAIL: ptr = "EEPROM_FAIL"; break;
Wayne Roberts 0:62e456e60083 90 }
Wayne Roberts 0:62e456e60083 91 if (ptr != NULL)
Wayne Roberts 0:62e456e60083 92 strcpy(dst, ptr);
Wayne Roberts 0:62e456e60083 93 }