Example of using the mDot UDK with the X-NUCLEO-IKS01A1 shield
Dependencies: mDot_X_NUCLEO_IKS01A1 libmDot-dev-mbed5-deprecated
Hardware
Hardware List
- Multiconnect mDot with programming header (MTDOT-xxx-X1P)
- Multiconnect mDot Developer kit (MTUDK2-ST-MDOT) or SocketModem and Dragonfly Developer kit (MTUDK2-ST-CELL)
- Motion MEMS and environmental sensor expansion board for STM32 Nucleo X-NUCLEO-IKS01A1
Setup
- Install the mDot on the developer board.
- Install the IKS01A1 on the developer board.
- If using a MTUDK-ST-CELL (white board) plug in the AC power adapter
- Connect the microusb power to your development PC
- if using a MTUDK-ST-CELL there are 2 microusb ports. Use the one closest to the serial port.
Your developer board should look like the following:
Software
This example program uses LoRa utility functions from Dot-Examples and the IKS01A1 library from ST Micro.
LoRa Configuration
Senet
By default this program is configured to connect to the Senet network. To connect to Senet you will need to register your mDot's Node ID with the Senet developer portal and change the network_key array in main.cpp.
Others
To connect to a different LoRa gateway change the arrays network_id and network_key. If you are using passphrases, edit the strings network_name and network_key, uncomment the function "update_ota_config_name_phrase" and comment out the function "update_ota_config_id_key".
RadioEvent.h@11:1425f2e65663, 2017-02-14 (annotated)
- Committer:
- pferland
- Date:
- Tue Feb 14 20:36:21 2017 +0000
- Revision:
- 11:1425f2e65663
- Parent:
- 0:9e88a9018fc0
Updated libmDot-dev to latest
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
pferland | 0:9e88a9018fc0 | 1 | #ifndef __RADIO_EVENT_H__ |
pferland | 0:9e88a9018fc0 | 2 | #define __RADIO_EVENT_H__ |
pferland | 0:9e88a9018fc0 | 3 | |
pferland | 0:9e88a9018fc0 | 4 | #include "dot_util.h" |
pferland | 0:9e88a9018fc0 | 5 | #include "mDotEvent.h" |
pferland | 0:9e88a9018fc0 | 6 | |
pferland | 0:9e88a9018fc0 | 7 | class RadioEvent : public mDotEvent |
pferland | 0:9e88a9018fc0 | 8 | { |
pferland | 0:9e88a9018fc0 | 9 | |
pferland | 0:9e88a9018fc0 | 10 | public: |
pferland | 0:9e88a9018fc0 | 11 | RadioEvent() {} |
pferland | 0:9e88a9018fc0 | 12 | |
pferland | 0:9e88a9018fc0 | 13 | virtual ~RadioEvent() {} |
pferland | 0:9e88a9018fc0 | 14 | |
pferland | 0:9e88a9018fc0 | 15 | /*! |
pferland | 0:9e88a9018fc0 | 16 | * MAC layer event callback prototype. |
pferland | 0:9e88a9018fc0 | 17 | * |
pferland | 0:9e88a9018fc0 | 18 | * \param [IN] flags Bit field indicating the MAC events occurred |
pferland | 0:9e88a9018fc0 | 19 | * \param [IN] info Details about MAC events occurred |
pferland | 0:9e88a9018fc0 | 20 | */ |
pferland | 0:9e88a9018fc0 | 21 | virtual void MacEvent(LoRaMacEventFlags* flags, LoRaMacEventInfo* info) { |
pferland | 0:9e88a9018fc0 | 22 | |
pferland | 0:9e88a9018fc0 | 23 | if (mts::MTSLog::getLogLevel() == mts::MTSLog::TRACE_LEVEL) { |
pferland | 0:9e88a9018fc0 | 24 | std::string msg = "OK"; |
pferland | 0:9e88a9018fc0 | 25 | switch (info->Status) { |
pferland | 0:9e88a9018fc0 | 26 | case LORAMAC_EVENT_INFO_STATUS_ERROR: |
pferland | 0:9e88a9018fc0 | 27 | msg = "ERROR"; |
pferland | 0:9e88a9018fc0 | 28 | break; |
pferland | 0:9e88a9018fc0 | 29 | case LORAMAC_EVENT_INFO_STATUS_TX_TIMEOUT: |
pferland | 0:9e88a9018fc0 | 30 | msg = "TX_TIMEOUT"; |
pferland | 0:9e88a9018fc0 | 31 | break; |
pferland | 0:9e88a9018fc0 | 32 | case LORAMAC_EVENT_INFO_STATUS_RX_TIMEOUT: |
pferland | 0:9e88a9018fc0 | 33 | msg = "RX_TIMEOUT"; |
pferland | 0:9e88a9018fc0 | 34 | break; |
pferland | 0:9e88a9018fc0 | 35 | case LORAMAC_EVENT_INFO_STATUS_RX_ERROR: |
pferland | 0:9e88a9018fc0 | 36 | msg = "RX_ERROR"; |
pferland | 0:9e88a9018fc0 | 37 | break; |
pferland | 0:9e88a9018fc0 | 38 | case LORAMAC_EVENT_INFO_STATUS_JOIN_FAIL: |
pferland | 0:9e88a9018fc0 | 39 | msg = "JOIN_FAIL"; |
pferland | 0:9e88a9018fc0 | 40 | break; |
pferland | 0:9e88a9018fc0 | 41 | case LORAMAC_EVENT_INFO_STATUS_DOWNLINK_FAIL: |
pferland | 0:9e88a9018fc0 | 42 | msg = "DOWNLINK_FAIL"; |
pferland | 0:9e88a9018fc0 | 43 | break; |
pferland | 0:9e88a9018fc0 | 44 | case LORAMAC_EVENT_INFO_STATUS_ADDRESS_FAIL: |
pferland | 0:9e88a9018fc0 | 45 | msg = "ADDRESS_FAIL"; |
pferland | 0:9e88a9018fc0 | 46 | break; |
pferland | 0:9e88a9018fc0 | 47 | case LORAMAC_EVENT_INFO_STATUS_MIC_FAIL: |
pferland | 0:9e88a9018fc0 | 48 | msg = "MIC_FAIL"; |
pferland | 0:9e88a9018fc0 | 49 | break; |
pferland | 0:9e88a9018fc0 | 50 | default: |
pferland | 0:9e88a9018fc0 | 51 | break; |
pferland | 0:9e88a9018fc0 | 52 | } |
pferland | 0:9e88a9018fc0 | 53 | logTrace("Event: %s", msg.c_str()); |
pferland | 0:9e88a9018fc0 | 54 | |
pferland | 0:9e88a9018fc0 | 55 | logTrace("Flags Tx: %d Rx: %d RxData: %d RxSlot: %d LinkCheck: %d JoinAccept: %d", |
pferland | 0:9e88a9018fc0 | 56 | flags->Bits.Tx, flags->Bits.Rx, flags->Bits.RxData, flags->Bits.RxSlot, flags->Bits.LinkCheck, flags->Bits.JoinAccept); |
pferland | 0:9e88a9018fc0 | 57 | logTrace("Info: Status: %d ACK: %d Retries: %d TxDR: %d RxPort: %d RxSize: %d RSSI: %d SNR: %d Energy: %d Margin: %d Gateways: %d", |
pferland | 0:9e88a9018fc0 | 58 | info->Status, info->TxAckReceived, info->TxNbRetries, info->TxDatarate, info->RxPort, info->RxBufferSize, |
pferland | 0:9e88a9018fc0 | 59 | info->RxRssi, info->RxSnr, info->Energy, info->DemodMargin, info->NbGateways); |
pferland | 0:9e88a9018fc0 | 60 | } |
pferland | 0:9e88a9018fc0 | 61 | |
pferland | 0:9e88a9018fc0 | 62 | if (flags->Bits.Rx) { |
pferland | 0:9e88a9018fc0 | 63 | |
pferland | 0:9e88a9018fc0 | 64 | logDebug("Rx %d bytes", info->RxBufferSize); |
pferland | 0:9e88a9018fc0 | 65 | if (info->RxBufferSize > 0) { |
pferland | 0:9e88a9018fc0 | 66 | // print RX data as hexadecimal |
pferland | 0:9e88a9018fc0 | 67 | //printf("Rx data: %s\r\n", mts::Text::bin2hexString(info->RxBuffer, info->RxBufferSize).c_str()); |
pferland | 0:9e88a9018fc0 | 68 | |
pferland | 0:9e88a9018fc0 | 69 | // print RX data as string |
pferland | 0:9e88a9018fc0 | 70 | std::string rx((const char*)info->RxBuffer, info->RxBufferSize); |
pferland | 0:9e88a9018fc0 | 71 | printf("Rx data: %s\r\n", rx.c_str()); |
pferland | 0:9e88a9018fc0 | 72 | } |
pferland | 0:9e88a9018fc0 | 73 | } |
pferland | 0:9e88a9018fc0 | 74 | } |
pferland | 0:9e88a9018fc0 | 75 | }; |
pferland | 0:9e88a9018fc0 | 76 | |
pferland | 0:9e88a9018fc0 | 77 | #endif |
pferland | 0:9e88a9018fc0 | 78 |