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
Mote.h@74:8b02b1a9a1b6, 2020-03-25 (annotated)
- Committer:
- jreiss
- Date:
- Wed Mar 25 17:06:41 2020 +0000
- Revision:
- 74:8b02b1a9a1b6
- Parent:
- 72:b1e07ec1c30d
Remove old ARMCC archive, only ARMC6 is available.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Mike Fiore |
16:b630e18103e5 | 1 | /** __ ___ ____ _ ______ __ ____ __ ____ |
Mike Fiore |
16:b630e18103e5 | 2 | * / |/ /_ __/ / /_(_)__/_ __/__ ____/ / / __/_ _____ / /____ __ _ ___ / _/__ ____ |
Mike Fiore |
16:b630e18103e5 | 3 | * / /|_/ / // / / __/ /___// / / -_) __/ _ \ _\ \/ // (_-</ __/ -_) ' \(_-< _/ // _ \/ __/ __ |
Mike Fiore |
16:b630e18103e5 | 4 | * /_/ /_/\_,_/_/\__/_/ /_/ \__/\__/_//_/ /___/\_, /___/\__/\__/_/_/_/___/ /___/_//_/\__/ /_/ |
Mike Fiore |
16:b630e18103e5 | 5 | * Copyright (C) 2015 by Multi-Tech Systems /___/ |
Mike Fiore |
16:b630e18103e5 | 6 | * |
Mike Fiore |
16:b630e18103e5 | 7 | * |
Mike Fiore |
16:b630e18103e5 | 8 | * @author Jason Reiss |
Mike Fiore |
16:b630e18103e5 | 9 | * @date 10-31-2015 |
Mike Fiore |
16:b630e18103e5 | 10 | * @brief lora::Mote provides a user level class that abstracts the complexity of the Mac layer |
Mike Fiore |
16:b630e18103e5 | 11 | * |
Mike Fiore |
16:b630e18103e5 | 12 | * @details |
Mike Fiore |
16:b630e18103e5 | 13 | * |
Mike Fiore |
16:b630e18103e5 | 14 | */ |
Mike Fiore |
16:b630e18103e5 | 15 | |
Mike Fiore |
16:b630e18103e5 | 16 | #ifndef __LORA_MOTE_H__ |
Mike Fiore |
16:b630e18103e5 | 17 | #define __LORA_MOTE_H__ |
Mike Fiore |
16:b630e18103e5 | 18 | |
Jenkins@KEILDM1.dc.multitech.prv | 65:acc0468b9aec | 19 | #include "mbed.h" |
Jenkins@KEILDM1.dc.multitech.prv | 65:acc0468b9aec | 20 | #include "mbed_events.h" |
Jenkins@KEILDM1.dc.multitech.prv | 65:acc0468b9aec | 21 | |
Mike Fiore |
16:b630e18103e5 | 22 | #include "MacEvents.h" |
Jenkins@KEILDM1.dc.multitech.prv | 65:acc0468b9aec | 23 | |
Mike Fiore |
16:b630e18103e5 | 24 | #include <vector> |
Mike Fiore |
16:b630e18103e5 | 25 | |
Mike Fiore |
16:b630e18103e5 | 26 | class SxRadio; |
Mike Fiore |
16:b630e18103e5 | 27 | class SxRadio1272; |
Mike Fiore |
16:b630e18103e5 | 28 | |
Mike Fiore |
16:b630e18103e5 | 29 | namespace lora { |
Mike Fiore |
16:b630e18103e5 | 30 | |
Mike Fiore |
16:b630e18103e5 | 31 | class Mac; |
Mike Fiore |
16:b630e18103e5 | 32 | class ChannelPlan; |
Mike Fiore |
16:b630e18103e5 | 33 | |
Mike Fiore |
16:b630e18103e5 | 34 | class MoteEvents: public MacEvents { |
Mike Fiore |
16:b630e18103e5 | 35 | |
Mike Fiore |
16:b630e18103e5 | 36 | /** |
Jenkins@KEILDM1.dc.multitech.prv | 64:64982192a2af | 37 | * Fired at start of TX |
Jenkins@KEILDM1.dc.multitech.prv | 64:64982192a2af | 38 | */ |
Jenkins@KEILDM1.dc.multitech.prv | 64:64982192a2af | 39 | virtual void TxStart(void); |
Jenkins@KEILDM1.dc.multitech.prv | 64:64982192a2af | 40 | |
Jenkins@KEILDM1.dc.multitech.prv | 64:64982192a2af | 41 | /** |
Mike Fiore |
16:b630e18103e5 | 42 | * Fired at end of TX |
Mike Fiore |
16:b630e18103e5 | 43 | * @param dr datarate used for TX |
Mike Fiore |
16:b630e18103e5 | 44 | */ |
Mike Fiore |
16:b630e18103e5 | 45 | virtual void TxDone(uint8_t dr); |
Mike Fiore |
16:b630e18103e5 | 46 | |
Mike Fiore |
16:b630e18103e5 | 47 | /** |
Mike Fiore |
16:b630e18103e5 | 48 | * Fired if TX timed out |
Mike Fiore |
16:b630e18103e5 | 49 | */ |
Mike Fiore |
16:b630e18103e5 | 50 | virtual void TxTimeout(void); |
Mike Fiore |
16:b630e18103e5 | 51 | |
Mike Fiore |
16:b630e18103e5 | 52 | /** |
Mike Fiore |
16:b630e18103e5 | 53 | * Fired when JoinAccept message is received and MIC is validated |
Mike Fiore |
16:b630e18103e5 | 54 | * @param payload received bytes |
Mike Fiore |
16:b630e18103e5 | 55 | * @param size number of received bytes |
Mike Fiore |
16:b630e18103e5 | 56 | * @param rssi of received packet |
Mike Fiore |
16:b630e18103e5 | 57 | * @param snr of received packet |
Mike Fiore |
16:b630e18103e5 | 58 | */ |
Jenkins@KEILDM1.dc.multitech.prv | 70:0c5b5b02d17b | 59 | virtual void JoinAccept(uint8_t *payload, uint16_t size, int16_t rssi, int16_t snr); |
Mike Fiore |
16:b630e18103e5 | 60 | |
Mike Fiore |
16:b630e18103e5 | 61 | /** |
Mike Fiore |
16:b630e18103e5 | 62 | * Fired when JoinAccept message is received and MIC is not valid |
Mike Fiore |
16:b630e18103e5 | 63 | * @param payload received bytes |
Mike Fiore |
16:b630e18103e5 | 64 | * @param size number of received bytes |
Mike Fiore |
16:b630e18103e5 | 65 | * @param rssi of received packet |
Mike Fiore |
16:b630e18103e5 | 66 | * @param snr of received packet |
Mike Fiore |
16:b630e18103e5 | 67 | */ |
Jenkins@KEILDM1.dc.multitech.prv | 70:0c5b5b02d17b | 68 | virtual void JoinFailed(uint8_t *payload, uint16_t size, int16_t rssi, int16_t snr); |
Mike Fiore |
16:b630e18103e5 | 69 | |
Mike Fiore |
16:b630e18103e5 | 70 | /** |
Jenkins@KEILDM1.dc.multitech.prv | 64:64982192a2af | 71 | * Fired when packet is received and MIC is valid |
Mike Fiore |
16:b630e18103e5 | 72 | * @param port of packet |
Mike Fiore |
16:b630e18103e5 | 73 | * @param payload received bytes |
Mike Fiore |
16:b630e18103e5 | 74 | * @param size number of received bytes |
Mike Fiore |
16:b630e18103e5 | 75 | * @param rssi of received packet |
Mike Fiore |
16:b630e18103e5 | 76 | * @param snr of received packet |
Mike Fiore |
16:b630e18103e5 | 77 | * @param ctrl Downlink control field of packet |
Mike Fiore |
16:b630e18103e5 | 78 | * @param slot rx window packet was received |
Mike Fiore |
16:b630e18103e5 | 79 | * @param retries number of attempts before ack was received |
Jenkins@KEILDM1.dc.multitech.prv | 64:64982192a2af | 80 | * @param address of the end device |
Jenkins@KEILDM1.dc.multitech.prv | 64:64982192a2af | 81 | * @param dupRx set if this packet has already been received |
Mike Fiore |
16:b630e18103e5 | 82 | */ |
Jenkins@KEILDM1.dc.multitech.prv | 70:0c5b5b02d17b | 83 | virtual void PacketRx(uint8_t port, uint8_t *payload, uint16_t size, int16_t rssi, int16_t snr, lora::DownlinkControl ctrl, uint8_t slot, uint8_t retries = 0, uint32_t address = 0, bool dupRx=false); |
Mike Fiore |
16:b630e18103e5 | 84 | |
Mike Fiore |
16:b630e18103e5 | 85 | /** |
Mike Fiore |
16:b630e18103e5 | 86 | * Fired when radio has received a packet, packet is not validated |
Mike Fiore |
16:b630e18103e5 | 87 | * @param payload received bytes |
Mike Fiore |
16:b630e18103e5 | 88 | * @param size number of received bytes |
Mike Fiore |
16:b630e18103e5 | 89 | * @param rssi of received packet |
Mike Fiore |
16:b630e18103e5 | 90 | * @param snr of received packet |
Mike Fiore |
16:b630e18103e5 | 91 | * @param ctrl Downlink control field of packet |
Mike Fiore |
16:b630e18103e5 | 92 | * @param slot rx window packet was received |
Mike Fiore |
16:b630e18103e5 | 93 | */ |
Jenkins@KEILDM1.dc.multitech.prv | 70:0c5b5b02d17b | 94 | virtual void RxDone(uint8_t *payload, uint16_t size, int16_t rssi, int16_t snr, lora::DownlinkControl ctrl, uint8_t slot); |
Mike Fiore |
16:b630e18103e5 | 95 | |
Mike Fiore |
16:b630e18103e5 | 96 | /** |
Jenkins@KEILDM1.dc.multitech.prv | 65:acc0468b9aec | 97 | * Fired when a beacon is received |
Jenkins@KEILDM1.dc.multitech.prv | 65:acc0468b9aec | 98 | * @param beacon_data parsed from the beacon payload |
Jenkins@KEILDM1.dc.multitech.prv | 65:acc0468b9aec | 99 | * @param rssi of received beacon |
Jenkins@KEILDM1.dc.multitech.prv | 65:acc0468b9aec | 100 | * @param snr of received beacon |
Jenkins@KEILDM1.dc.multitech.prv | 65:acc0468b9aec | 101 | */ |
Jenkins@KEILDM1.dc.multitech.prv | 70:0c5b5b02d17b | 102 | virtual void BeaconRx(const BeaconData_t& beacon_data, int16_t rssi, int16_t snr); |
Jenkins@KEILDM1.dc.multitech.prv | 65:acc0468b9aec | 103 | |
Jenkins@KEILDM1.dc.multitech.prv | 65:acc0468b9aec | 104 | /** |
Jenkins@KEILDM1.dc.multitech.prv | 65:acc0468b9aec | 105 | * Fired upon losing beacon synchronization (120 minutes elapsed from last beacon reception) |
Jenkins@KEILDM1.dc.multitech.prv | 65:acc0468b9aec | 106 | */ |
Jenkins@KEILDM1.dc.multitech.prv | 65:acc0468b9aec | 107 | virtual void BeaconLost(); |
Jenkins@KEILDM1.dc.multitech.prv | 65:acc0468b9aec | 108 | |
Jenkins@KEILDM1.dc.multitech.prv | 65:acc0468b9aec | 109 | /** |
Mike Fiore |
16:b630e18103e5 | 110 | * Fired if rx window times out |
Mike Fiore |
16:b630e18103e5 | 111 | * @param slot rx window that timed out |
Mike Fiore |
16:b630e18103e5 | 112 | */ |
Mike Fiore |
16:b630e18103e5 | 113 | virtual void RxTimeout(uint8_t slot); |
Mike Fiore |
16:b630e18103e5 | 114 | |
Mike Fiore |
16:b630e18103e5 | 115 | /** |
Mike Fiore |
16:b630e18103e5 | 116 | * Fired if rx CRC error |
Mike Fiore |
16:b630e18103e5 | 117 | * @param slot rx window that errored |
Mike Fiore |
16:b630e18103e5 | 118 | */ |
Mike Fiore |
16:b630e18103e5 | 119 | virtual void RxError(uint8_t slot); |
Mike Fiore |
16:b630e18103e5 | 120 | |
Mike Fiore |
16:b630e18103e5 | 121 | /** |
Mike Fiore |
16:b630e18103e5 | 122 | * Fired if pong packet is received |
Mike Fiore |
16:b630e18103e5 | 123 | * @param m_rssi of received packet at mote |
Mike Fiore |
16:b630e18103e5 | 124 | * @param m_snr of received packet at mote |
Mike Fiore |
16:b630e18103e5 | 125 | * @param s_rssi of received packet at server |
Mike Fiore |
16:b630e18103e5 | 126 | * @param s_snr of received packet at server |
Mike Fiore |
16:b630e18103e5 | 127 | */ |
Jenkins@KEILDM1.dc.multitech.prv | 70:0c5b5b02d17b | 128 | virtual void Pong(int16_t m_rssi, int16_t m_snr, int16_t s_rssi, int16_t s_snr); |
Mike Fiore |
16:b630e18103e5 | 129 | |
Mike Fiore |
16:b630e18103e5 | 130 | /** |
Mike Fiore |
16:b630e18103e5 | 131 | * Fired if network link check answer is received |
Mike Fiore |
16:b630e18103e5 | 132 | * @param m_rssi of received packet at mote |
Mike Fiore |
16:b630e18103e5 | 133 | * @param m_snr of received packet at mote |
Mike Fiore |
16:b630e18103e5 | 134 | * @param s_snr margin of received packet at server |
Mike Fiore |
16:b630e18103e5 | 135 | * @param s_gateways number of gateways reporting the packet |
Mike Fiore |
16:b630e18103e5 | 136 | */ |
Jenkins@KEILDM1.dc.multitech.prv | 70:0c5b5b02d17b | 137 | virtual void NetworkLinkCheck(int16_t m_rssi, int16_t m_snr, int16_t s_snr, uint8_t s_gateways); |
Mike Fiore |
16:b630e18103e5 | 138 | |
Mike Fiore |
16:b630e18103e5 | 139 | /** |
Jenkins@KEILDM1.dc.multitech.prv | 65:acc0468b9aec | 140 | * Fired upon receiving a server time answer |
Jenkins@KEILDM1.dc.multitech.prv | 65:acc0468b9aec | 141 | * @param seconds from the GPS epoch |
Jenkins@KEILDM1.dc.multitech.prv | 65:acc0468b9aec | 142 | * @param sub_seconds from the GPS epoch |
Jenkins@KEILDM1.dc.multitech.prv | 65:acc0468b9aec | 143 | */ |
Jenkins@KEILDM1.dc.multitech.prv | 65:acc0468b9aec | 144 | virtual void ServerTime(uint32_t seconds, uint8_t sub_seconds); |
Jenkins@KEILDM1.dc.multitech.prv | 65:acc0468b9aec | 145 | |
Jenkins@KEILDM1.dc.multitech.prv | 65:acc0468b9aec | 146 | /** |
Mike Fiore |
16:b630e18103e5 | 147 | * Callback to for device to measure the battery level and report to server |
Mike Fiore |
16:b630e18103e5 | 148 | * @return battery level 0-255, 0 - external power, 1-254 level min-max, 255 device unable to measure battery |
Mike Fiore |
16:b630e18103e5 | 149 | */ |
Mike Fiore |
16:b630e18103e5 | 150 | virtual uint8_t MeasureBattery(); |
Jenkins@KEILDM1.dc.multitech.prv | 26:17479e0039f6 | 151 | |
Jenkins@KEILDM1.dc.multitech.prv | 26:17479e0039f6 | 152 | /** |
Jenkins@KEILDM1.dc.multitech.prv | 26:17479e0039f6 | 153 | * Fired when ack attempts are exhausted and RxTimeout or RxError occur |
Jenkins@KEILDM1.dc.multitech.prv | 26:17479e0039f6 | 154 | * @param retries number of attempts to resend the packet |
Jenkins@KEILDM1.dc.multitech.prv | 26:17479e0039f6 | 155 | */ |
Jenkins@KEILDM1.dc.multitech.prv | 26:17479e0039f6 | 156 | virtual void MissedAck(uint8_t retries); |
Mike Fiore |
16:b630e18103e5 | 157 | }; |
Mike Fiore |
16:b630e18103e5 | 158 | |
Mike Fiore |
16:b630e18103e5 | 159 | class Mote { |
Mike Fiore |
16:b630e18103e5 | 160 | public: |
Jenkins@KEILDM1.dc.multitech.prv | 60:7985b4783af9 | 161 | Mote(Settings* settings, ChannelPlan* plan); |
Mike Fiore |
16:b630e18103e5 | 162 | virtual ~Mote(); |
Mike Fiore |
16:b630e18103e5 | 163 | |
Mike Fiore |
16:b630e18103e5 | 164 | /** |
Jenkins@KEILDM1.dc.multitech.prv | 60:7985b4783af9 | 165 | * MTS LoRa version |
Jenkins@KEILDM1.dc.multitech.prv | 60:7985b4783af9 | 166 | * @return string containing version information |
Jenkins@KEILDM1.dc.multitech.prv | 60:7985b4783af9 | 167 | */ |
Jenkins@KEILDM1.dc.multitech.prv | 60:7985b4783af9 | 168 | const char* getId(); |
Jenkins@KEILDM1.dc.multitech.prv | 60:7985b4783af9 | 169 | |
Jenkins@KEILDM1.dc.multitech.prv | 60:7985b4783af9 | 170 | /** |
Jenkins@KEILDM1.dc.multitech.prv | 72:b1e07ec1c30d | 171 | * MAC version |
Jenkins@KEILDM1.dc.multitech.prv | 72:b1e07ec1c30d | 172 | * |
Jenkins@KEILDM1.dc.multitech.prv | 72:b1e07ec1c30d | 173 | * @return string containing version information of supported LoRaWAN MAC Version |
Jenkins@KEILDM1.dc.multitech.prv | 72:b1e07ec1c30d | 174 | */ |
Jenkins@KEILDM1.dc.multitech.prv | 72:b1e07ec1c30d | 175 | const char* getMACVersion(); |
Jenkins@KEILDM1.dc.multitech.prv | 72:b1e07ec1c30d | 176 | |
Jenkins@KEILDM1.dc.multitech.prv | 72:b1e07ec1c30d | 177 | /** |
Mike Fiore |
16:b630e18103e5 | 178 | * Indicator for network session join status |
Mike Fiore |
16:b630e18103e5 | 179 | * @return true if joined to network |
Mike Fiore |
16:b630e18103e5 | 180 | */ |
Mike Fiore |
16:b630e18103e5 | 181 | bool Joined(); |
Mike Fiore |
16:b630e18103e5 | 182 | |
Mike Fiore |
16:b630e18103e5 | 183 | /** |
Mike Fiore |
16:b630e18103e5 | 184 | * Send join request |
Mike Fiore |
16:b630e18103e5 | 185 | * @return LORA_OK if request was sent |
Mike Fiore |
16:b630e18103e5 | 186 | */ |
Mike Fiore |
16:b630e18103e5 | 187 | uint8_t Join(); |
Mike Fiore |
16:b630e18103e5 | 188 | |
Mike Fiore |
16:b630e18103e5 | 189 | /** |
Mike Fiore |
16:b630e18103e5 | 190 | * Send a packet |
Mike Fiore |
16:b630e18103e5 | 191 | * @param port to send packet |
Mike Fiore |
16:b630e18103e5 | 192 | * @param payload of packet |
Mike Fiore |
16:b630e18103e5 | 193 | * @param size in bytes |
Mike Fiore |
16:b630e18103e5 | 194 | * @return LORA_OK if successful |
Mike Fiore |
16:b630e18103e5 | 195 | * @return LORA_MAX_PAYLOAD_EXCEEDED if payload size exceeds datarate maximum |
Mike Fiore |
16:b630e18103e5 | 196 | * @return LORA_NO_CHANS_ENABLED if there is not an available channel that supports the current datarate |
Mike Fiore |
16:b630e18103e5 | 197 | * @return LORA_LINK_BUSY if link was busy |
Mike Fiore |
16:b630e18103e5 | 198 | * @return LORA_RADIO_BUSY if radio was busy |
Mike Fiore |
16:b630e18103e5 | 199 | * @return LORA_BUFFER_FULL if mac commands filled the packet, client should resend the packet |
Mike Fiore |
16:b630e18103e5 | 200 | */ |
Mike Fiore |
16:b630e18103e5 | 201 | uint8_t Send(uint8_t port, const uint8_t* payload, uint8_t size); |
Mike Fiore |
16:b630e18103e5 | 202 | |
Mike Fiore |
16:b630e18103e5 | 203 | /** |
Mike Fiore |
16:b630e18103e5 | 204 | * Configure the channel plan |
Jenkins@KEILDM1.dc.multitech.prv | 60:7985b4783af9 | 205 | * @param plan pointer to ChannelPlan object |
Mike Fiore |
16:b630e18103e5 | 206 | * @return LORA_OK |
Mike Fiore |
16:b630e18103e5 | 207 | */ |
Jenkins@KEILDM1.dc.multitech.prv | 60:7985b4783af9 | 208 | uint8_t SetChannelPlan(ChannelPlan* plan); |
Jenkins@KEILDM1.dc.multitech.prv | 60:7985b4783af9 | 209 | |
Jenkins@KEILDM1.dc.multitech.prv | 64:64982192a2af | 210 | |
Jenkins@KEILDM1.dc.multitech.prv | 60:7985b4783af9 | 211 | Settings* GetSettings(); |
Mike Fiore |
16:b630e18103e5 | 212 | |
Mike Fiore |
16:b630e18103e5 | 213 | /** |
Mike Fiore |
16:b630e18103e5 | 214 | * Get the channel mask of currently enabled channels |
Mike Fiore |
16:b630e18103e5 | 215 | * @return vector containing channel bit masks |
Mike Fiore |
16:b630e18103e5 | 216 | */ |
Mike Fiore |
16:b630e18103e5 | 217 | std::vector<uint16_t> GetChannelMask(); |
Mike Fiore |
16:b630e18103e5 | 218 | |
Mike Fiore |
16:b630e18103e5 | 219 | /** |
Mike Fiore |
16:b630e18103e5 | 220 | * Set a 16 bit channel mask with index |
Mike Fiore |
16:b630e18103e5 | 221 | * @param index of mask to set 0:0-15, 1:16-31 ... |
Mike Fiore |
16:b630e18103e5 | 222 | * @param mask 16 bit mask of enabled channels |
Mike Fiore |
16:b630e18103e5 | 223 | * @return true |
Mike Fiore |
16:b630e18103e5 | 224 | */ |
Mike Fiore |
16:b630e18103e5 | 225 | virtual uint8_t SetChannelMask(uint8_t index, uint16_t mask); |
Mike Fiore |
16:b630e18103e5 | 226 | |
Mike Fiore |
16:b630e18103e5 | 227 | /** |
Jenkins@KEILDM1.dc.multitech.prv | 60:7985b4783af9 | 228 | * Set the current frequency sub band for hybrid operation 1-8 else 0 for 64 channel operation |
Jenkins@KEILDM1.dc.multitech.prv | 60:7985b4783af9 | 229 | * @param sub_band 0-8 |
Mike Fiore |
16:b630e18103e5 | 230 | */ |
Jenkins@KEILDM1.dc.multitech.prv | 60:7985b4783af9 | 231 | uint8_t SetFrequencySubBand(uint8_t sub_band); |
Mike Fiore |
16:b630e18103e5 | 232 | |
Mike Fiore |
16:b630e18103e5 | 233 | /** |
Jenkins@KEILDM1.dc.multitech.prv | 60:7985b4783af9 | 234 | * Get the current frequency sub band |
Jenkins@KEILDM1.dc.multitech.prv | 60:7985b4783af9 | 235 | * @return sub band 0-8 |
Mike Fiore |
16:b630e18103e5 | 236 | */ |
Jenkins@KEILDM1.dc.multitech.prv | 60:7985b4783af9 | 237 | uint8_t GetFrequencySubBand(); |
Mike Fiore |
16:b630e18103e5 | 238 | |
Mike Fiore |
16:b630e18103e5 | 239 | /** |
Mike Fiore |
16:b630e18103e5 | 240 | * Add a channel to the channel plan |
Jenkins@KEILDM1.dc.multitech.prv | 60:7985b4783af9 | 241 | * EU868, AS923 and KR920 allows additional channels to be added |
Mike Fiore |
16:b630e18103e5 | 242 | * Channels 0-2 are fixed default channels |
Mike Fiore |
16:b630e18103e5 | 243 | * |
Mike Fiore |
16:b630e18103e5 | 244 | * @param index of the channel |
Mike Fiore |
16:b630e18103e5 | 245 | * @param frequency of the channel or 0 to remove channel |
Mike Fiore |
16:b630e18103e5 | 246 | * @param range of datarates allowed by the channel |
Mike Fiore |
16:b630e18103e5 | 247 | * @return LORA_OK if channel was added |
Mike Fiore |
16:b630e18103e5 | 248 | */ |
Mike Fiore |
16:b630e18103e5 | 249 | uint8_t AddChannel(uint8_t index, uint32_t frequency, lora::DatarateRange range); |
Mike Fiore |
16:b630e18103e5 | 250 | |
Mike Fiore |
16:b630e18103e5 | 251 | /** |
Jenkins@KEILDM1.dc.multitech.prv | 60:7985b4783af9 | 252 | * Add a downlink channel to the channel plan |
Jenkins@KEILDM1.dc.multitech.prv | 60:7985b4783af9 | 253 | * EU868, AS923 and KR920 allows downlink channels to be added |
Jenkins@KEILDM1.dc.multitech.prv | 60:7985b4783af9 | 254 | * |
Jenkins@KEILDM1.dc.multitech.prv | 60:7985b4783af9 | 255 | * @param index of the channel |
Jenkins@KEILDM1.dc.multitech.prv | 60:7985b4783af9 | 256 | * @param frequency of the channel or 0 to remove channel |
Jenkins@KEILDM1.dc.multitech.prv | 60:7985b4783af9 | 257 | * @return LORA_OK if channel was added |
Jenkins@KEILDM1.dc.multitech.prv | 60:7985b4783af9 | 258 | */ |
Jenkins@KEILDM1.dc.multitech.prv | 60:7985b4783af9 | 259 | uint8_t AddDownlinkChannel(uint8_t index, uint32_t frequency); |
Jenkins@KEILDM1.dc.multitech.prv | 60:7985b4783af9 | 260 | |
Jenkins@KEILDM1.dc.multitech.prv | 60:7985b4783af9 | 261 | /** |
Mike Fiore |
16:b630e18103e5 | 262 | * Set network mode |
Mike Fiore |
16:b630e18103e5 | 263 | * Choose Public LoRaWAN mode or Private Multitech mode |
Mike Fiore |
16:b630e18103e5 | 264 | * |
Mike Fiore |
16:b630e18103e5 | 265 | * Public mode uses 0x34 sync word with 5/6 second join windows |
Mike Fiore |
16:b630e18103e5 | 266 | * Private mode uses 0x12 sync word with 1/2 second join windows |
Jenkins@KEILDM1.dc.multitech.prv | 60:7985b4783af9 | 267 | * US915/AU915 Rx1 and Rx2 are fixed per frequency sub band setting |
Mike Fiore |
16:b630e18103e5 | 268 | * |
Mike Fiore |
16:b630e18103e5 | 269 | * @param mode public or private |
Mike Fiore |
16:b630e18103e5 | 270 | * @return LORA_OK |
Mike Fiore |
16:b630e18103e5 | 271 | */ |
Mike Fiore |
16:b630e18103e5 | 272 | uint8_t SetNetworkMode(uint8_t mode); |
Mike Fiore |
16:b630e18103e5 | 273 | |
Mike Fiore |
16:b630e18103e5 | 274 | /** |
Mike Fiore |
16:b630e18103e5 | 275 | * Get a pointer to the mac layer |
Mike Fiore |
16:b630e18103e5 | 276 | * @return Mac mac |
Mike Fiore |
16:b630e18103e5 | 277 | */ |
Mike Fiore |
16:b630e18103e5 | 278 | Mac* GetMac(); |
Mike Fiore |
16:b630e18103e5 | 279 | |
Mike Fiore |
16:b630e18103e5 | 280 | /** |
Mike Fiore |
16:b630e18103e5 | 281 | * Get a pointer to the radio |
Mike Fiore |
16:b630e18103e5 | 282 | * Can be used to read radio registers or get a random value based on RSSI |
Mike Fiore |
16:b630e18103e5 | 283 | * |
Mike Fiore |
16:b630e18103e5 | 284 | * @return SxRadio pointer |
Mike Fiore |
16:b630e18103e5 | 285 | */ |
Mike Fiore |
16:b630e18103e5 | 286 | SxRadio* GetRadio(); |
Mike Fiore |
16:b630e18103e5 | 287 | |
Mike Fiore |
16:b630e18103e5 | 288 | /** |
Mike Fiore |
16:b630e18103e5 | 289 | * Get the current statistics for the device |
Mike Fiore |
16:b630e18103e5 | 290 | * @return Statistics |
Mike Fiore |
16:b630e18103e5 | 291 | */ |
Mike Fiore |
16:b630e18103e5 | 292 | Statistics& GetStats(); |
Mike Fiore |
16:b630e18103e5 | 293 | |
Mike Fiore |
16:b630e18103e5 | 294 | /** |
Jenkins@KEILDM1.dc.multitech.prv | 60:7985b4783af9 | 295 | * Reset the current statistics for the device |
Jenkins@KEILDM1.dc.multitech.prv | 60:7985b4783af9 | 296 | */ |
Jenkins@KEILDM1.dc.multitech.prv | 60:7985b4783af9 | 297 | void ResetStats(); |
Jenkins@KEILDM1.dc.multitech.prv | 60:7985b4783af9 | 298 | |
Jenkins@KEILDM1.dc.multitech.prv | 60:7985b4783af9 | 299 | /** |
Mike Fiore |
16:b630e18103e5 | 300 | * Get time on air with current settings for provided payload bytes |
Mike Fiore |
16:b630e18103e5 | 301 | * 13 overhead bytes will be added to payload |
Mike Fiore |
16:b630e18103e5 | 302 | * @param bytes of payload data |
Mike Fiore |
16:b630e18103e5 | 303 | * @return time-on-air in ms |
Mike Fiore |
16:b630e18103e5 | 304 | */ |
Mike Fiore |
16:b630e18103e5 | 305 | uint32_t GetTimeOnAir(uint8_t bytes); |
Mike Fiore |
16:b630e18103e5 | 306 | |
Mike Fiore |
16:b630e18103e5 | 307 | /** |
Jenkins@KEILDM1.dc.multitech.prv | 60:7985b4783af9 | 308 | * Get time off air required to adhere to duty-cycle limitations |
Jenkins@KEILDM1.dc.multitech.prv | 60:7985b4783af9 | 309 | * @return time-off-air in ms |
Jenkins@KEILDM1.dc.multitech.prv | 60:7985b4783af9 | 310 | */ |
Jenkins@KEILDM1.dc.multitech.prv | 60:7985b4783af9 | 311 | uint32_t GetTimeOffAir(); |
Jenkins@KEILDM1.dc.multitech.prv | 60:7985b4783af9 | 312 | |
Jenkins@KEILDM1.dc.multitech.prv | 60:7985b4783af9 | 313 | /** |
Mike Fiore |
16:b630e18103e5 | 314 | * Call before setting device in sleep mode to place radio in sleep |
Mike Fiore |
16:b630e18103e5 | 315 | */ |
Mike Fiore |
16:b630e18103e5 | 316 | void Sleep(); |
Mike Fiore |
16:b630e18103e5 | 317 | |
Mike Fiore |
16:b630e18103e5 | 318 | protected: |
Mike Fiore |
16:b630e18103e5 | 319 | SxRadio1272* _radio; |
Mike Fiore |
16:b630e18103e5 | 320 | Settings* _settings; |
Mike Fiore |
16:b630e18103e5 | 321 | Mac* _mac; |
Mike Fiore |
16:b630e18103e5 | 322 | |
Mike Fiore |
16:b630e18103e5 | 323 | private: |
Mike Fiore |
16:b630e18103e5 | 324 | ChannelPlan* _plan; |
Mike Fiore |
16:b630e18103e5 | 325 | MoteEvents _events; |
Jenkins@KEILDM1.dc.multitech.prv | 65:acc0468b9aec | 326 | |
Jenkins@KEILDM1.dc.multitech.prv | 65:acc0468b9aec | 327 | // Event queue objects for timing events |
Jenkins@KEILDM1.dc.multitech.prv | 65:acc0468b9aec | 328 | EventQueue _evtQueue; |
Jenkins@KEILDM1.dc.multitech.prv | 65:acc0468b9aec | 329 | Thread _dispatch_thread; |
Mike Fiore |
16:b630e18103e5 | 330 | }; |
Mike Fiore |
16:b630e18103e5 | 331 | |
Mike Fiore |
16:b630e18103e5 | 332 | } |
Mike Fiore |
16:b630e18103e5 | 333 | #endif |