Stable version of the mDot library for mbed 5. This version of the library is suitable for deployment scenarios. See lastest commit message for version of mbed-os library that has been tested against.
Dependents: mdot_two_way unh-hackathon-example unh-hackathon-example-raw TelitSensorToCloud ... more
Fork of libmDot-dev-mbed5-deprecated by
The Dot library provides a LoRaWan certified stack for LoRa communication using MultiTech mDot and xDot devices. The stack is compatible with mbed 5.
The name of the repository can be used to determine which device the stack was compiled for and if it's a development or production-ready build:
- libmDot-mbed5 -> production-ready build for mDot
- libmDot-dev-mbed5 -> development build for mDot
- libxDot-mbed5 -> production-ready build for xDot
- libxDot-dev-mbed5 -> development build for xDot
A changelog for the Dot library can be found here.
The Dot library version and the version of mbed-os it was compiled against can both be found in the commit message for that revision of the Dot library. Building your application with the same version of mbed-os as what was used to build the Dot library is highly recommended!
The Dot-Examples repository demonstrates how to use the Dot library in a custom application.
The mDot and xDot platform pages have lots of platform specific information and document potential issues, gotchas, etc, and provide instructions for getting started with development. Please take a look at the platform page before starting development as they should answer many questions you will have.
FOTA
Full FOTA support is only available with mDot, xDot does not have the required external flash. xDot can use the FOTA example to dynamically join a multicast session only. After joining the multicast session the received Fragmentation packets could be handed to a host MCU for processing and at completion the firmware can be loaded into the xDot using the bootloader and y-modem. See xDot Developer Guide.
- Add the following code to allow Fota to use the Dot instance
main.cpp
// Initialize FOTA singleton Fota::getInstance(dot);
- Add fragmentation handling the the PacketRx event
RadioEvent.h
virtual void PacketRx(uint8_t port, uint8_t *payload, uint16_t size, int16_t rssi, int8_t snr, lora::DownlinkControl ctrl, uint8_t slot, uint8_t retries, uint32_t address, bool dupRx) { mDotEvent::PacketRx(port, payload, size, rssi, snr, ctrl, slot, retries, address, dupRx); #if ACTIVE_EXAMPLE == FOTA_EXAMPLE if(port == 200 || port == 201 || port == 202) { Fota::getInstance()->processCmd(payload, port, size); } #endif }
A definition is needed to enable Fragmentation support on mDot and save fragments to flash. This should not be defined for xDot and will result in a compiler error.
mbed_app.json
{ "macros": [ "FOTA=1" ] }
The FOTA implementation has a few differences from the LoRaWAN Protocol
- Fragmentation Indexing starts at 0
- McKEKey is 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
- Start Time is a count-down in seconds to start of session
Diff: mDot.h
- Revision:
- 6:390fc83d588d
- Parent:
- 5:0bfe6a650513
- Child:
- 7:683dba5d576f
--- a/mDot.h Tue Jul 07 14:32:54 2015 -0500 +++ b/mDot.h Thu Jul 16 16:41:08 2015 -0500 @@ -1,9 +1,4 @@ -/************************************************ - * MultiTech MTDOT Library - * Copyright (c) 2015 MultiTech Systems - * - * See LICENSE file for license information - ***********************************************/ +// TODO: add license header #ifndef MDOT_H #define MDOT_H @@ -47,10 +42,10 @@ uint8_t getActivityLedState(); void blinkActivityLed(void) { - if (_activity_led) { - int val = _activity_led->read(); - _activity_led->write(!val); - } + if (_activity_led) { + int val = _activity_led->read(); + _activity_led->write(!val); + } } mDot(const mDot&); @@ -67,9 +62,9 @@ static const uint32_t _baud_rates[]; uint8_t _activity_led_state; Ticker _tick; - DigitalOut* _activity_led; - bool _activity_led_enable; - PinName _activity_led_pin; + DigitalOut* _activity_led; + bool _activity_led_enable; + PinName _activity_led_pin; bool _activity_led_external; uint16_t _linkFailCount; @@ -116,6 +111,10 @@ FSB_ALL, FSB_1, FSB_2, FSB_3, FSB_4, FSB_5, FSB_6, FSB_7, FSB_8 }; + enum JoinByteOrder { + LSB, MSB + }; + typedef struct { uint32_t Up; uint32_t Down; @@ -201,34 +200,34 @@ /** Get the current log level for the library * @returns current log level */ - uint8_t getLogLevel(); + uint8_t getLogLevel(); + + /** Enable or disable the activity LED. + * @param enable true to enable the LED, false to disable + */ + void setActivityLedEnable(const bool& enable); - /** Enable or disable the activity LED. - * @param enable true to enable the LED, false to disable - */ - void setActivityLedEnable(const bool& enable); - - /** Find out if the activity LED is enabled - * @returns true if activity LED is enabled, false if disabled - */ - bool getActivityLedEnable(); - - /** Use a different pin for the activity LED. - * The default is XBEE_RSSI. - * @param pin the new pin to use - */ - void setActivityLedPin(const PinName& pin); - + /** Find out if the activity LED is enabled + * @returns true if activity LED is enabled, false if disabled + */ + bool getActivityLedEnable(); + + /** Use a different pin for the activity LED. + * The default is XBEE_RSSI. + * @param pin the new pin to use + */ + void setActivityLedPin(const PinName& pin); + /** Use an external DigitalOut object for the activity LED. * The pointer must stay valid! * @param pin the DigitalOut object to use */ void setActivityLedPin(DigitalOut* pin); - - /** Find out what pin the activity LED is on - * @returns the pin the activity LED is using - */ - PinName getActivityLedPin(); + + /** Find out what pin the activity LED is on + * @returns the pin the activity LED is using + */ + PinName getActivityLedPin(); /** Get list of channel frequencies currently in use * @returns vector of channels currently in use @@ -360,6 +359,16 @@ */ std::vector<uint8_t> getNetworkKey(); + /** Set join byte order + * @param order 0:LSB 1:MSB + */ + uint32_t setJoinByteOrder(uint8_t order); + + /** Get join byte order + * @returns byte order to use in joins 0:LSB 1:MSB + */ + uint8_t getJoinByteOrder(); + /** Attempt to join network * retries according to configuration set by setJoinRetries() * @returns MDOT_OK if success @@ -580,6 +589,8 @@ */ int32_t recv(std::vector<uint8_t>& data); + void openRxWindow(uint32_t timeout); + /** Ping * status will be MDOT_OK if ping succeeded * @returns ping_response struct containing status, RSSI, and SNR @@ -690,6 +701,7 @@ uint64_t crc64(uint64_t crc, const unsigned char *s, uint64_t l); // MTS_RADIO_DEBUG_COMMANDS + void sendContinuous(); int32_t setDeviceId(const std::vector<uint8_t>& id); int32_t setFrequencyBand(const uint8_t& band); bool saveProtectedConfig(); @@ -699,6 +711,8 @@ void eraseFlash(); mdot_stats getStats(); + void resetStats(); + private: mdot_stats _stats;