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 MultiTech

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:

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
Committer:
Jenkins@KEILDM1.dc.multitech.prv
Date:
Fri Nov 08 09:34:58 2019 -0600
Revision:
71:ae3afc16ec3e
Parent:
70:0c5b5b02d17b
Child:
72:b1e07ec1c30d
mdot-library revision 3.2.5 and mbed-os revision mbed-os-5.13.4

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 1 /**********************************************************************
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 2 * COPYRIGHT 2015 MULTI-TECH SYSTEMS, INC.
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 3 *
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 4 * Redistribution and use in source and binary forms, with or without modification,
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 5 * are permitted provided that the following conditions are met:
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 6 * 1. Redistributions of source code must retain the above copyright notice,
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 7 * this list of conditions and the following disclaimer.
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 8 * 2. Redistributions in binary form must reproduce the above copyright notice,
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 9 * this list of conditions and the following disclaimer in the documentation
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 10 * and/or other materials provided with the distribution.
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 11 * 3. Neither the name of MULTI-TECH SYSTEMS, INC. nor the names of its contributors
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 12 * may be used to endorse or promote products derived from this software
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 13 * without specific prior written permission.
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 14 *
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 16 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 18 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 21 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 22 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 23 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 25 *
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 26 ******************************************************************************
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 27 */
mfiore 0:c62615f15125 28
mfiore 0:c62615f15125 29 #ifndef MDOT_H
mfiore 0:c62615f15125 30 #define MDOT_H
mfiore 0:c62615f15125 31
mfiore 0:c62615f15125 32 #include "mbed.h"
mfiore 0:c62615f15125 33 #include "rtos.h"
Mike Fiore 16:b630e18103e5 34 #include "Mote.h"
mfiore 0:c62615f15125 35 #include <vector>
mfiore 0:c62615f15125 36 #include <map>
mfiore 0:c62615f15125 37 #include <string>
mfiore 0:c62615f15125 38
Mike Fiore 12:54f9cac9d690 39 class mDotEvent;
mfiore 0:c62615f15125 40 class LoRaConfig;
mfiore 0:c62615f15125 41
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 42
mfiore 0:c62615f15125 43 class mDot {
Mike Fiore 16:b630e18103e5 44 friend class mDotEvent;
mfiore 0:c62615f15125 45
mfiore 0:c62615f15125 46 private:
mfiore 0:c62615f15125 47
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 48 mDot(lora::ChannelPlan* plan);
mfiore 0:c62615f15125 49 ~mDot();
mfiore 0:c62615f15125 50
Mike Fiore 16:b630e18103e5 51 void initLora();
Mike Fiore 16:b630e18103e5 52
mfiore 0:c62615f15125 53 void setLastError(const std::string& str);
mfiore 0:c62615f15125 54
mfiore 0:c62615f15125 55 static bool validateBaudRate(const uint32_t& baud);
mfiore 0:c62615f15125 56 static bool validateFrequencySubBand(const uint8_t& band);
mfiore 0:c62615f15125 57 bool validateDataRate(const uint8_t& dr);
mfiore 0:c62615f15125 58
mfiore 0:c62615f15125 59 int32_t joinBase(const uint32_t& retries);
mfiore 0:c62615f15125 60 int32_t sendBase(const std::vector<uint8_t>& data, const bool& confirmed = false, const bool& blocking = true, const bool& highBw = false);
mfiore 0:c62615f15125 61 void waitForPacket();
mfiore 0:c62615f15125 62 void waitForLinkCheck();
mfiore 0:c62615f15125 63
Jenkins@KEILDM1.dc.multitech.prv 69:e22889c7eaa9 64
Jenkins@KEILDM1.dc.multitech.prv 69:e22889c7eaa9 65 MBED_DEPRECATED("Will be removed in dotlib 3.3.0")
Jenkins@KEILDM1.dc.multitech.prv 69:e22889c7eaa9 66 void setActivityLedState(const uint8_t& state);
Jenkins@KEILDM1.dc.multitech.prv 69:e22889c7eaa9 67
Jenkins@KEILDM1.dc.multitech.prv 69:e22889c7eaa9 68 MBED_DEPRECATED("Will be removed in dotlib 3.3.0")
Jenkins@KEILDM1.dc.multitech.prv 69:e22889c7eaa9 69 uint8_t getActivityLedState();
Jenkins@KEILDM1.dc.multitech.prv 69:e22889c7eaa9 70
Jenkins@KEILDM1.dc.multitech.prv 69:e22889c7eaa9 71 MBED_DEPRECATED("Will be removed in dotlib 3.3.0")
Jenkins@KEILDM1.dc.multitech.prv 69:e22889c7eaa9 72 void blinkActivityLed(void) {
Jenkins@KEILDM1.dc.multitech.prv 69:e22889c7eaa9 73 if (_activity_led) {
Jenkins@KEILDM1.dc.multitech.prv 69:e22889c7eaa9 74 int val = _activity_led->read();
Jenkins@KEILDM1.dc.multitech.prv 69:e22889c7eaa9 75 _activity_led->write(!val);
Jenkins@KEILDM1.dc.multitech.prv 69:e22889c7eaa9 76 }
Jenkins@KEILDM1.dc.multitech.prv 69:e22889c7eaa9 77 }
Jenkins@KEILDM1.dc.multitech.prv 69:e22889c7eaa9 78
mfiore 0:c62615f15125 79 mDot(const mDot&);
mfiore 0:c62615f15125 80 mDot& operator=(const mDot&);
mfiore 0:c62615f15125 81
Mike Fiore 7:683dba5d576f 82 uint32_t RTC_ReadBackupRegister(uint32_t RTC_BKP_DR);
Mike Fiore 7:683dba5d576f 83 void RTC_WriteBackupRegister(uint32_t RTC_BKP_DR, uint32_t Data);
Mike Fiore 7:683dba5d576f 84
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 85 void RTC_DisableWakeupTimer();
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 86 void RTC_EnableWakeupTimer();
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 87
Mike Fiore 12:54f9cac9d690 88 void enterStopMode(const uint32_t& interval, const uint8_t& wakeup_mode = RTC_ALARM);
Mike Fiore 12:54f9cac9d690 89 void enterStandbyMode(const uint32_t& interval, const uint8_t& wakeup_mode = RTC_ALARM);
Mike Fiore 12:54f9cac9d690 90
mfiore 0:c62615f15125 91 static mDot* _instance;
mfiore 0:c62615f15125 92
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 93 lora::Mote* _mote;
mfiore 0:c62615f15125 94 LoRaConfig* _config;
Mike Fiore 16:b630e18103e5 95 lora::Settings _settings;
Mike Fiore 16:b630e18103e5 96 mDotEvent* _events;
Mike Fiore 16:b630e18103e5 97
mfiore 0:c62615f15125 98 std::string _last_error;
mfiore 0:c62615f15125 99 static const uint32_t _baud_rates[];
Jenkins@KEILDM1.dc.multitech.prv 69:e22889c7eaa9 100 uint8_t _activity_led_state; //deprecated will be removed
Jenkins@KEILDM1.dc.multitech.prv 69:e22889c7eaa9 101 Ticker _tick;
Jenkins@KEILDM1.dc.multitech.prv 69:e22889c7eaa9 102 DigitalOut* _activity_led; //deprecated will be removed
Jenkins@KEILDM1.dc.multitech.prv 69:e22889c7eaa9 103 bool _activity_led_enable; //deprecated will be removed
Jenkins@KEILDM1.dc.multitech.prv 69:e22889c7eaa9 104 PinName _activity_led_pin; //deprecated will be removed
Jenkins@KEILDM1.dc.multitech.prv 69:e22889c7eaa9 105 bool _activity_led_external; //deprecated will be removed
jreiss 9:ec2fffe31793 106 uint8_t _linkFailCount;
Mike Fiore 7:683dba5d576f 107 uint8_t _class;
Mike Fiore 7:683dba5d576f 108 InterruptIn* _wakeup;
Mike Fiore 7:683dba5d576f 109 PinName _wakeup_pin;
mfiore 0:c62615f15125 110
mfiore 0:c62615f15125 111 typedef enum {
Jason Reiss 10:27dafba9fe19 112 OFF,
Jason Reiss 10:27dafba9fe19 113 ON,
Jason Reiss 10:27dafba9fe19 114 BLINK,
mfiore 0:c62615f15125 115 } state;
mfiore 0:c62615f15125 116
mfiore 0:c62615f15125 117 public:
mfiore 0:c62615f15125 118
Jenkins@KEILDM1.dc.multitech.prv 19:f3a46d2bb9b3 119 #if defined(TARGET_MTS_MDOT_F411RE)
mfiore 0:c62615f15125 120 typedef enum {
Mike Fiore 7:683dba5d576f 121 FM_APPEND = (1 << 0),
Mike Fiore 7:683dba5d576f 122 FM_TRUNC = (1 << 1),
Mike Fiore 7:683dba5d576f 123 FM_CREAT = (1 << 2),
Mike Fiore 7:683dba5d576f 124 FM_RDONLY = (1 << 3),
Mike Fiore 7:683dba5d576f 125 FM_WRONLY = (1 << 4),
Mike Fiore 7:683dba5d576f 126 FM_RDWR = (FM_RDONLY | FM_WRONLY),
Mike Fiore 7:683dba5d576f 127 FM_DIRECT = (1 << 5)
Mike Fiore 7:683dba5d576f 128 } FileMode;
Jenkins@KEILDM1.dc.multitech.prv 19:f3a46d2bb9b3 129 #endif /* TARGET_MTS_MDOT_F411RE */
Mike Fiore 7:683dba5d576f 130
Mike Fiore 7:683dba5d576f 131 typedef enum {
mfiore 0:c62615f15125 132 MDOT_OK = 0,
mfiore 0:c62615f15125 133 MDOT_INVALID_PARAM = -1,
mfiore 0:c62615f15125 134 MDOT_TX_ERROR = -2,
mfiore 0:c62615f15125 135 MDOT_RX_ERROR = -3,
mfiore 0:c62615f15125 136 MDOT_JOIN_ERROR = -4,
mfiore 0:c62615f15125 137 MDOT_TIMEOUT = -5,
mfiore 0:c62615f15125 138 MDOT_NOT_JOINED = -6,
mfiore 0:c62615f15125 139 MDOT_ENCRYPTION_DISABLED = -7,
mfiore 0:c62615f15125 140 MDOT_NO_FREE_CHAN = -8,
Mike Fiore 12:54f9cac9d690 141 MDOT_TEST_MODE = -9,
Mike Fiore 12:54f9cac9d690 142 MDOT_NO_ENABLED_CHAN = -10,
Mike Fiore 12:54f9cac9d690 143 MDOT_AGGREGATED_DUTY_CYCLE = -11,
Jenkins@KEILDM1.dc.multitech.prv 43:ba29a595814e 144 MDOT_MAX_PAYLOAD_EXCEEDED = -12,
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 145 MDOT_LBT_CHANNEL_BUSY = -13,
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 146 MDOT_NOT_IDLE = -14,
mfiore 0:c62615f15125 147 MDOT_ERROR = -1024,
mfiore 0:c62615f15125 148 } mdot_ret_code;
mfiore 0:c62615f15125 149
mfiore 0:c62615f15125 150 enum JoinMode {
Mike Fiore 16:b630e18103e5 151 MANUAL = 0,
Jason Reiss 10:27dafba9fe19 152 OTA,
Mike Fiore 12:54f9cac9d690 153 AUTO_OTA,
Mike Fiore 12:54f9cac9d690 154 PEER_TO_PEER
mfiore 0:c62615f15125 155 };
mfiore 0:c62615f15125 156
mfiore 0:c62615f15125 157 enum Mode {
Jason Reiss 10:27dafba9fe19 158 COMMAND_MODE,
Jason Reiss 10:27dafba9fe19 159 SERIAL_MODE
mfiore 0:c62615f15125 160 };
mfiore 0:c62615f15125 161
mfiore 0:c62615f15125 162 enum RX_Output {
Jason Reiss 10:27dafba9fe19 163 HEXADECIMAL,
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 164 BINARY,
Jenkins@KEILDM1.dc.multitech.prv 69:e22889c7eaa9 165 EXTENDED
mfiore 0:c62615f15125 166 };
mfiore 0:c62615f15125 167
mfiore 0:c62615f15125 168 enum DataRates {
Mike Fiore 12:54f9cac9d690 169 DR0,
Mike Fiore 12:54f9cac9d690 170 DR1,
Mike Fiore 12:54f9cac9d690 171 DR2,
Mike Fiore 12:54f9cac9d690 172 DR3,
Mike Fiore 12:54f9cac9d690 173 DR4,
Mike Fiore 12:54f9cac9d690 174 DR5,
Mike Fiore 12:54f9cac9d690 175 DR6,
Mike Fiore 12:54f9cac9d690 176 DR7,
Mike Fiore 12:54f9cac9d690 177 DR8,
Mike Fiore 12:54f9cac9d690 178 DR9,
Mike Fiore 12:54f9cac9d690 179 DR10,
Mike Fiore 12:54f9cac9d690 180 DR11,
Mike Fiore 12:54f9cac9d690 181 DR12,
Mike Fiore 12:54f9cac9d690 182 DR13,
Mike Fiore 12:54f9cac9d690 183 DR14,
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 184 DR15
mfiore 0:c62615f15125 185 };
mfiore 0:c62615f15125 186
mfiore 0:c62615f15125 187 enum FrequencySubBands {
Jason Reiss 10:27dafba9fe19 188 FSB_ALL,
Jason Reiss 10:27dafba9fe19 189 FSB_1,
Jason Reiss 10:27dafba9fe19 190 FSB_2,
Jason Reiss 10:27dafba9fe19 191 FSB_3,
Jason Reiss 10:27dafba9fe19 192 FSB_4,
Jason Reiss 10:27dafba9fe19 193 FSB_5,
Jason Reiss 10:27dafba9fe19 194 FSB_6,
Jason Reiss 10:27dafba9fe19 195 FSB_7,
Jason Reiss 10:27dafba9fe19 196 FSB_8
mfiore 0:c62615f15125 197 };
mfiore 0:c62615f15125 198
Mike Fiore 7:683dba5d576f 199 enum wakeup_mode {
Jason Reiss 10:27dafba9fe19 200 RTC_ALARM,
Jason Reiss 10:27dafba9fe19 201 INTERRUPT,
Jason Reiss 10:27dafba9fe19 202 RTC_ALARM_OR_INTERRUPT
Mike Fiore 7:683dba5d576f 203 };
Mike Fiore 7:683dba5d576f 204
jreiss 9:ec2fffe31793 205 enum UserBackupRegs {
Jason Reiss 10:27dafba9fe19 206 UBR0,
Jason Reiss 10:27dafba9fe19 207 UBR1,
Jason Reiss 10:27dafba9fe19 208 UBR2,
Jason Reiss 10:27dafba9fe19 209 UBR3,
Jason Reiss 10:27dafba9fe19 210 UBR4,
Jason Reiss 10:27dafba9fe19 211 UBR5,
Jason Reiss 10:27dafba9fe19 212 UBR6,
Jason Reiss 10:27dafba9fe19 213 UBR7,
Jason Reiss 10:27dafba9fe19 214 UBR8,
Jason Reiss 10:27dafba9fe19 215 UBR9
Jenkins@KEILDM1.dc.multitech.prv 19:f3a46d2bb9b3 216 #if defined (TARGET_XDOT_L151CC)
Jenkins@KEILDM1.dc.multitech.prv 19:f3a46d2bb9b3 217 ,UBR10,
Jenkins@KEILDM1.dc.multitech.prv 19:f3a46d2bb9b3 218 UBR11,
Jenkins@KEILDM1.dc.multitech.prv 19:f3a46d2bb9b3 219 UBR12,
Jenkins@KEILDM1.dc.multitech.prv 19:f3a46d2bb9b3 220 UBR13,
Jenkins@KEILDM1.dc.multitech.prv 19:f3a46d2bb9b3 221 UBR14,
Jenkins@KEILDM1.dc.multitech.prv 19:f3a46d2bb9b3 222 UBR15,
Jenkins@KEILDM1.dc.multitech.prv 19:f3a46d2bb9b3 223 UBR16,
Jenkins@KEILDM1.dc.multitech.prv 19:f3a46d2bb9b3 224 UBR17,
Jenkins@KEILDM1.dc.multitech.prv 19:f3a46d2bb9b3 225 UBR18,
Jenkins@KEILDM1.dc.multitech.prv 19:f3a46d2bb9b3 226 UBR19,
Jenkins@KEILDM1.dc.multitech.prv 19:f3a46d2bb9b3 227 UBR20,
Jenkins@KEILDM1.dc.multitech.prv 19:f3a46d2bb9b3 228 UBR21
Jenkins@KEILDM1.dc.multitech.prv 19:f3a46d2bb9b3 229 #endif /* TARGET_XDOT_L151CC */
jreiss 9:ec2fffe31793 230 };
jreiss 9:ec2fffe31793 231
Jenkins@KEILDM1.dc.multitech.prv 19:f3a46d2bb9b3 232 #if defined(TARGET_MTS_MDOT_F411RE)
Mike Fiore 7:683dba5d576f 233 typedef struct {
Mike Fiore 7:683dba5d576f 234 int16_t fd;
Mike Fiore 16:b630e18103e5 235 char name[33];
Mike Fiore 7:683dba5d576f 236 uint32_t size;
Mike Fiore 7:683dba5d576f 237 } mdot_file;
Jenkins@KEILDM1.dc.multitech.prv 19:f3a46d2bb9b3 238 #endif /* TARGET_MTS_MDOT_F411RE */
Mike Fiore 7:683dba5d576f 239
mfiore 0:c62615f15125 240 typedef struct {
mfiore 0:c62615f15125 241 uint32_t Up;
mfiore 0:c62615f15125 242 uint32_t Down;
mfiore 0:c62615f15125 243 uint32_t Joins;
mfiore 0:c62615f15125 244 uint32_t JoinFails;
mfiore 0:c62615f15125 245 uint32_t MissedAcks;
Mike Fiore 16:b630e18103e5 246 uint32_t CRCErrors;
mfiore 0:c62615f15125 247 } mdot_stats;
mfiore 0:c62615f15125 248
mfiore 0:c62615f15125 249 typedef struct {
mfiore 0:c62615f15125 250 int16_t last;
mfiore 0:c62615f15125 251 int16_t min;
mfiore 0:c62615f15125 252 int16_t max;
mfiore 0:c62615f15125 253 int16_t avg;
mfiore 0:c62615f15125 254 } rssi_stats;
mfiore 0:c62615f15125 255
mfiore 0:c62615f15125 256 typedef struct {
Mike Fiore 11:d8464345e1f1 257 int16_t last;
Mike Fiore 11:d8464345e1f1 258 int16_t min;
Mike Fiore 11:d8464345e1f1 259 int16_t max;
Mike Fiore 11:d8464345e1f1 260 int16_t avg;
mfiore 0:c62615f15125 261 } snr_stats;
mfiore 0:c62615f15125 262
mfiore 0:c62615f15125 263 typedef struct {
mfiore 0:c62615f15125 264 bool status;
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 265 uint8_t dBm;
mfiore 0:c62615f15125 266 uint32_t gateways;
mfiore 0:c62615f15125 267 std::vector<uint8_t> payload;
mfiore 0:c62615f15125 268 } link_check;
mfiore 0:c62615f15125 269
mfiore 0:c62615f15125 270 typedef struct {
mfiore 0:c62615f15125 271 int32_t status;
mfiore 0:c62615f15125 272 int16_t rssi;
mfiore 0:c62615f15125 273 int16_t snr;
mfiore 0:c62615f15125 274 } ping_response;
mfiore 0:c62615f15125 275
mfiore 0:c62615f15125 276 static std::string JoinModeStr(uint8_t mode);
mfiore 0:c62615f15125 277 static std::string ModeStr(uint8_t mode);
mfiore 0:c62615f15125 278 static std::string RxOutputStr(uint8_t format);
mfiore 0:c62615f15125 279 static std::string DataRateStr(uint8_t rate);
mfiore 0:c62615f15125 280 static std::string FrequencyBandStr(uint8_t band);
mfiore 0:c62615f15125 281 static std::string FrequencySubBandStr(uint8_t band);
mfiore 0:c62615f15125 282
Jenkins@KEILDM1.dc.multitech.prv 19:f3a46d2bb9b3 283 #if defined(TARGET_MTS_MDOT_F411RE)
jreiss 9:ec2fffe31793 284 uint32_t UserRegisters[10];
Jenkins@KEILDM1.dc.multitech.prv 19:f3a46d2bb9b3 285 #else
Jenkins@KEILDM1.dc.multitech.prv 19:f3a46d2bb9b3 286 uint32_t UserRegisters[22];
Jenkins@KEILDM1.dc.multitech.prv 19:f3a46d2bb9b3 287 #endif /* TARGET_MTS_MDOT_F411RE */
jreiss 9:ec2fffe31793 288
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 289 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 290 * Get a handle to the singleton object
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 291 * @param plan the channel plan to use
mfiore 0:c62615f15125 292 * @returns pointer to mDot object
mfiore 0:c62615f15125 293 */
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 294 static mDot* getInstance(lora::ChannelPlan* plan);
mfiore 0:c62615f15125 295
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 296 /**
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 297 * Can only be used after a dot has
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 298 * configured with a plan
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 299 * @returns pointer to mDot object
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 300 */
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 301 static mDot* getInstance();
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 302
Mike Fiore 12:54f9cac9d690 303 void setEvents(mDotEvent* events);
Mike Fiore 12:54f9cac9d690 304
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 305 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 306 *
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 307 * Get library version information
mfiore 0:c62615f15125 308 * @returns string containing library version information
mfiore 0:c62615f15125 309 */
mfiore 0:c62615f15125 310 std::string getId();
mfiore 0:c62615f15125 311
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 312 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 313 * Get MTS LoRa version information
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 314 * @returns string containing MTS LoRa version information
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 315 */
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 316 std::string getMtsLoraId();
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 317
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 318 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 319 * Perform a soft reset of the system
mfiore 0:c62615f15125 320 */
mfiore 0:c62615f15125 321 void resetCpu();
mfiore 0:c62615f15125 322
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 323 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 324 * Reset config to factory default
mfiore 0:c62615f15125 325 */
mfiore 0:c62615f15125 326 void resetConfig();
mfiore 0:c62615f15125 327
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 328 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 329 * Save config data to non volatile memory
mfiore 0:c62615f15125 330 * @returns true if success, false if failure
mfiore 0:c62615f15125 331 */
mfiore 0:c62615f15125 332 bool saveConfig();
mfiore 0:c62615f15125 333
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 334 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 335 * Set the log level for the library
mfiore 0:c62615f15125 336 * options are:
mfiore 0:c62615f15125 337 * NONE_LEVEL - logging is off at this level
mfiore 0:c62615f15125 338 * FATAL_LEVEL - only critical errors will be reported
mfiore 0:c62615f15125 339 * ERROR_LEVEL
mfiore 0:c62615f15125 340 * WARNING_LEVEL
mfiore 0:c62615f15125 341 * INFO_LEVEL
mfiore 0:c62615f15125 342 * DEBUG_LEVEL
mfiore 0:c62615f15125 343 * TRACE_LEVEL - every detail will be reported
mfiore 0:c62615f15125 344 * @param level the level to log at
mfiore 0:c62615f15125 345 * @returns MDOT_OK if success
mfiore 0:c62615f15125 346 */
mfiore 0:c62615f15125 347 int32_t setLogLevel(const uint8_t& level);
mfiore 0:c62615f15125 348
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 349 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 350 * Get the current log level for the library
mfiore 0:c62615f15125 351 * @returns current log level
mfiore 0:c62615f15125 352 */
Mike Fiore 6:390fc83d588d 353 uint8_t getLogLevel();
Mike Fiore 6:390fc83d588d 354
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 355 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 356 * Seed pseudo RNG in LoRaMac layer, uses random value from radio RSSI reading by default
Mike Fiore 12:54f9cac9d690 357 * @param seed for RNG
Mike Fiore 12:54f9cac9d690 358 */
Mike Fiore 12:54f9cac9d690 359 void seedRandom(uint32_t seed);
Mike Fiore 12:54f9cac9d690 360
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 361 /**
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 362 * @returns true if MAC command answers are ready to be sent
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 363 */
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 364 bool hasMacCommands();
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 365
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 366
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 367 uint8_t setChannelPlan(lora::ChannelPlan* plan);
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 368
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 369 lora::Settings* getSettings();
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 370
Jenkins@KEILDM1.dc.multitech.prv 69:e22889c7eaa9 371 MBED_DEPRECATED("Will be removed in dotlib 3.3.0")
Jenkins@KEILDM1.dc.multitech.prv 69:e22889c7eaa9 372 void setActivityLedEnable(const bool& enable);
Jenkins@KEILDM1.dc.multitech.prv 69:e22889c7eaa9 373
Jenkins@KEILDM1.dc.multitech.prv 69:e22889c7eaa9 374 MBED_DEPRECATED("Will be removed in dotlib 3.3.0")
Jenkins@KEILDM1.dc.multitech.prv 69:e22889c7eaa9 375 bool getActivityLedEnable();
Jenkins@KEILDM1.dc.multitech.prv 69:e22889c7eaa9 376
Jenkins@KEILDM1.dc.multitech.prv 69:e22889c7eaa9 377 MBED_DEPRECATED("Will be removed in dotlib 3.3.0")
Jenkins@KEILDM1.dc.multitech.prv 69:e22889c7eaa9 378 void setActivityLedPin(const PinName& pin);
Jenkins@KEILDM1.dc.multitech.prv 69:e22889c7eaa9 379
Jenkins@KEILDM1.dc.multitech.prv 69:e22889c7eaa9 380 MBED_DEPRECATED("Will be removed in dotlib 3.3.0")
Jenkins@KEILDM1.dc.multitech.prv 69:e22889c7eaa9 381 void setActivityLedPin(DigitalOut* pin);
Jenkins@KEILDM1.dc.multitech.prv 69:e22889c7eaa9 382
Jenkins@KEILDM1.dc.multitech.prv 69:e22889c7eaa9 383 MBED_DEPRECATED("Will be removed in dotlib 3.3.0")
Jenkins@KEILDM1.dc.multitech.prv 69:e22889c7eaa9 384 PinName getActivityLedPin();
Jenkins@KEILDM1.dc.multitech.prv 69:e22889c7eaa9 385
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 386 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 387 * Returns boolean indicative of start-up from standby mode
Mike Fiore 12:54f9cac9d690 388 * @returns true if dot woke from standby
Mike Fiore 12:54f9cac9d690 389 */
Mike Fiore 12:54f9cac9d690 390 bool getStandbyFlag();
Mike Fiore 12:54f9cac9d690 391
Mike Fiore 16:b630e18103e5 392 std::vector<uint16_t> getChannelMask();
Mike Fiore 16:b630e18103e5 393
Mike Fiore 16:b630e18103e5 394 int32_t setChannelMask(uint8_t offset, uint16_t mask);
Mike Fiore 16:b630e18103e5 395
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 396 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 397 * Add a channel
Mike Fiore 12:54f9cac9d690 398 * @returns MDOT_OK
Mike Fiore 12:54f9cac9d690 399 */
Mike Fiore 12:54f9cac9d690 400 int32_t addChannel(uint8_t index, uint32_t frequency, uint8_t datarateRange);
Mike Fiore 12:54f9cac9d690 401
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 402 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 403 * Add a downlink channel
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 404 * @returns MDOT_OK
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 405 */
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 406 int32_t addDownlinkChannel(uint8_t index, uint32_t frequency);
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 407
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 408 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 409 * Get list of channel frequencies currently in use
mfiore 0:c62615f15125 410 * @returns vector of channels currently in use
mfiore 0:c62615f15125 411 */
mfiore 0:c62615f15125 412 std::vector<uint32_t> getChannels();
mfiore 0:c62615f15125 413
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 414 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 415 * Get list of downlink channel frequencies currently in use
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 416 * @returns vector of channels currently in use
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 417 */
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 418 std::vector<uint32_t> getDownlinkChannels();
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 419
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 420 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 421 * Get list of channel datarate ranges currently in use
Mike Fiore 12:54f9cac9d690 422 * @returns vector of datarate ranges currently in use
Mike Fiore 12:54f9cac9d690 423 */
Mike Fiore 12:54f9cac9d690 424 std::vector<uint8_t> getChannelRanges();
Mike Fiore 12:54f9cac9d690 425
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 426 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 427 * Get list of channel frequencies in config file to be used as session defaults
Mike Fiore 12:54f9cac9d690 428 * @returns vector of channels in config file
Mike Fiore 12:54f9cac9d690 429 */
Mike Fiore 12:54f9cac9d690 430 std::vector<uint32_t> getConfigChannels();
Mike Fiore 12:54f9cac9d690 431
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 432 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 433 * Get list of channel datarate ranges in config file to be used as session defaults
Mike Fiore 12:54f9cac9d690 434 * @returns vector of datarate ranges in config file
Mike Fiore 12:54f9cac9d690 435 */
Mike Fiore 12:54f9cac9d690 436 std::vector<uint8_t> getConfigChannelRanges();
Mike Fiore 12:54f9cac9d690 437
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 438 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 439 * Get default frequency band
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 440 * @returns frequency band the device was manufactured for
mfiore 0:c62615f15125 441 */
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 442 uint8_t getDefaultFrequencyBand();
mfiore 0:c62615f15125 443
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 444 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 445 * Set frequency sub band
mfiore 0:c62615f15125 446 * only applicable if frequency band is set for United States (FB_915)
Jason Reiss 10:27dafba9fe19 447 * sub band 0 will allow the radio to use all 64 channels
mfiore 0:c62615f15125 448 * sub band 1 - 8 will allow the radio to use the 8 channels in that sub band
mfiore 0:c62615f15125 449 * for use with Conduit gateway and MTAC_LORA, use sub bands 1 - 8, not sub band 0
mfiore 0:c62615f15125 450 * @param band the sub band to use (0 - 8)
mfiore 0:c62615f15125 451 * @returns MDOT_OK if success
mfiore 0:c62615f15125 452 */
mfiore 0:c62615f15125 453 int32_t setFrequencySubBand(const uint8_t& band);
mfiore 0:c62615f15125 454
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 455 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 456 * Get frequency sub band
mfiore 0:c62615f15125 457 * @returns frequency sub band currently in use
mfiore 0:c62615f15125 458 */
mfiore 0:c62615f15125 459 uint8_t getFrequencySubBand();
mfiore 0:c62615f15125 460
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 461 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 462 * Get frequency band
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 463 * @returns frequency band (channel plan) currently in use
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 464 */
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 465 uint8_t getFrequencyBand();
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 466
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 467 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 468 * Get channel plan name
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 469 * @returns name of channel plan currently in use
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 470 */
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 471 std::string getChannelPlanName();
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 472
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 473 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 474 * Get the datarate currently in use within the MAC layer
Mike Fiore 12:54f9cac9d690 475 * returns 0-15
Mike Fiore 12:54f9cac9d690 476 */
Mike Fiore 12:54f9cac9d690 477 uint8_t getSessionDataRate();
Mike Fiore 12:54f9cac9d690 478
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 479
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 480 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 481 * Get the current max EIRP used in the channel plan
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 482 * May be changed by the network server
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 483 * returns 0-36
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 484 */
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 485 uint8_t getSessionMaxEIRP();
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 486
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 487 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 488 * Set the current max EIRP used in the channel plan
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 489 * May be changed by the network server
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 490 * accepts 0-36
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 491 */
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 492 void setSessionMaxEIRP(uint8_t max);
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 493
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 494 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 495 * Get the current downlink dwell time used in the channel plan
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 496 * May be changed by the network server
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 497 * returns 0-1
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 498 */
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 499 uint8_t getSessionDownlinkDwelltime();
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 500
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 501 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 502 * Set the current downlink dwell time used in the channel plan
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 503 * May be changed by the network server
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 504 * accepts 0-1
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 505 */
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 506 void setSessionDownlinkDwelltime(uint8_t dwell);
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 507
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 508 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 509 * Get the current uplink dwell time used in the channel plan
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 510 * May be changed by the network server
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 511 * returns 0-1
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 512 */
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 513 uint8_t getSessionUplinkDwelltime();
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 514
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 515 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 516 * Set the current uplink dwell time used in the channel plan
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 517 * May be changed by the network server
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 518 * accepts 0-1
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 519 */
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 520 void setSessionUplinkDwelltime(uint8_t dwell);
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 521
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 522 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 523 * Set the current downlink dwell time used in the channel plan
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 524 * May be changed by the network server
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 525 * accepts 0-1
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 526 */
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 527 uint32_t getListenBeforeTalkTime(uint8_t ms);
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 528
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 529 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 530 * Set the current downlink dwell time used in the channel plan
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 531 * May be changed by the network server
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 532 * accepts 0-1
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 533 */
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 534 void setListenBeforeTalkTime(uint32_t ms);
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 535
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 536 /**
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 537 * Set public network mode
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 538 * 0:PRIVATE_MTS, 1:PUBLIC_LORAWAN, 2:PRIVATE_LORAWAN
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 539 * PRIVATE_MTS - Sync Word 0x12, US/AU Downlink frequencies per Frequency Sub Band
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 540 * PUBLIC_LORAWAN - Sync Word 0x34
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 541 * PRIVATE_LORAWAN - Sync Word 0x12
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 542 *
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 543 * The default Join Delay is 5 seconds
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 544 * The default Join Delay for PRIVATE_MTS was 1 second in the previous release
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 545 * The Join Delay must be changed independently of Public Network setting
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 546 *
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 547 * @see lora::NetworkType
mfiore 0:c62615f15125 548 * @returns MDOT_OK if success
mfiore 0:c62615f15125 549 */
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 550 int32_t setPublicNetwork(const uint8_t& val);
mfiore 0:c62615f15125 551
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 552 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 553 * Get public network mode
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 554 *
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 555 * The default Join Delay is 5 seconds
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 556 * The default Join Delay for PRIVATE_MTS was 1 second in the previous release
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 557 * The Join Delay must be changed independently of Public Network setting
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 558 *
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 559 * @see lora:NetworkType
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 560 * @returns 0:PRIVATE_MTS, 1:PUBLIC_LORAWAN, 2:PRIVATE_LORAWAN
mfiore 0:c62615f15125 561 */
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 562 uint8_t getPublicNetwork();
mfiore 0:c62615f15125 563
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 564 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 565 * Get the device ID
mfiore 0:c62615f15125 566 * @returns vector containing the device ID (size 8)
mfiore 0:c62615f15125 567 */
mfiore 0:c62615f15125 568 std::vector<uint8_t> getDeviceId();
mfiore 0:c62615f15125 569
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 570 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 571 * Get the device port to be used for lora application data (1-223)
Jason Reiss 10:27dafba9fe19 572 * @returns port
Jason Reiss 10:27dafba9fe19 573 */
Jason Reiss 10:27dafba9fe19 574 uint8_t getAppPort();
Jason Reiss 10:27dafba9fe19 575
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 576 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 577 * Set the device port to be used for lora application data (1-223)
Jason Reiss 10:27dafba9fe19 578 * @returns MDOT_OK if success
Jason Reiss 10:27dafba9fe19 579 */
Jason Reiss 10:27dafba9fe19 580 int32_t setAppPort(uint8_t port);
Jason Reiss 10:27dafba9fe19 581
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 582 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 583 * Set the device class A, B or C
Jason Reiss 10:27dafba9fe19 584 * @returns MDOT_OK if success
Jason Reiss 10:27dafba9fe19 585 */
Jason Reiss 10:27dafba9fe19 586 int32_t setClass(std::string newClass);
Jason Reiss 10:27dafba9fe19 587
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 588 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 589 * Get the device class A, B or C
Jason Reiss 10:27dafba9fe19 590 * @returns MDOT_OK if success
Jason Reiss 10:27dafba9fe19 591 */
Jason Reiss 10:27dafba9fe19 592 std::string getClass();
Jason Reiss 10:27dafba9fe19 593
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 594 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 595 * Get the max packet length with current settings
Jason Reiss 10:27dafba9fe19 596 * @returns max packet length
Jason Reiss 10:27dafba9fe19 597 */
Jason Reiss 10:27dafba9fe19 598 uint8_t getMaxPacketLength();
Jason Reiss 10:27dafba9fe19 599
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 600 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 601 * Set network address
mfiore 0:c62615f15125 602 * for use with MANUAL network join mode, will be assigned in OTA & AUTO_OTA modes
mfiore 0:c62615f15125 603 * @param addr a vector of 4 bytes
mfiore 0:c62615f15125 604 * @returns MDOT_OK if success
mfiore 0:c62615f15125 605 */
mfiore 0:c62615f15125 606 int32_t setNetworkAddress(const std::vector<uint8_t>& addr);
mfiore 0:c62615f15125 607
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 608 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 609 * Get network address
mfiore 0:c62615f15125 610 * @returns vector containing network address (size 4)
mfiore 0:c62615f15125 611 */
mfiore 0:c62615f15125 612 std::vector<uint8_t> getNetworkAddress();
mfiore 0:c62615f15125 613
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 614 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 615 * Set network session key
mfiore 0:c62615f15125 616 * for use with MANUAL network join mode, will be assigned in OTA & AUTO_OTA modes
mfiore 0:c62615f15125 617 * @param key a vector of 16 bytes
mfiore 0:c62615f15125 618 * @returns MDOT_OK if success
mfiore 0:c62615f15125 619 */
mfiore 0:c62615f15125 620 int32_t setNetworkSessionKey(const std::vector<uint8_t>& key);
mfiore 0:c62615f15125 621
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 622 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 623 * Get network session key
mfiore 0:c62615f15125 624 * @returns vector containing network session key (size 16)
mfiore 0:c62615f15125 625 */
mfiore 0:c62615f15125 626 std::vector<uint8_t> getNetworkSessionKey();
mfiore 0:c62615f15125 627
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 628 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 629 * Set data session key
mfiore 0:c62615f15125 630 * for use with MANUAL network join mode, will be assigned in OTA & AUTO_OTA modes
mfiore 0:c62615f15125 631 * @param key a vector of 16 bytes
mfiore 0:c62615f15125 632 * @returns MDOT_OK if success
mfiore 0:c62615f15125 633 */
mfiore 0:c62615f15125 634 int32_t setDataSessionKey(const std::vector<uint8_t>& key);
mfiore 0:c62615f15125 635
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 636 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 637 * Get data session key
mfiore 0:c62615f15125 638 * @returns vector containing data session key (size 16)
mfiore 0:c62615f15125 639 */
mfiore 0:c62615f15125 640 std::vector<uint8_t> getDataSessionKey();
mfiore 0:c62615f15125 641
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 642 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 643 * Set network name
mfiore 0:c62615f15125 644 * for use with OTA & AUTO_OTA network join modes
mfiore 0:c62615f15125 645 * generates network ID (crc64 of name) automatically
mfiore 0:c62615f15125 646 * @param name a string of of at least 8 bytes and no more than 128 bytes
mfiore 0:c62615f15125 647 * @return MDOT_OK if success
mfiore 0:c62615f15125 648 */
mfiore 0:c62615f15125 649 int32_t setNetworkName(const std::string& name);
mfiore 0:c62615f15125 650
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 651 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 652 * Get network name
mfiore 0:c62615f15125 653 * @return string containing network name (size 8 to 128)
mfiore 0:c62615f15125 654 */
mfiore 0:c62615f15125 655 std::string getNetworkName();
mfiore 0:c62615f15125 656
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 657 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 658 * Set network ID
mfiore 0:c62615f15125 659 * for use with OTA & AUTO_OTA network join modes
mfiore 0:c62615f15125 660 * setting network ID via this function sets network name to empty
mfiore 0:c62615f15125 661 * @param id a vector of 8 bytes
mfiore 0:c62615f15125 662 * @returns MDOT_OK if success
mfiore 0:c62615f15125 663 */
mfiore 0:c62615f15125 664 int32_t setNetworkId(const std::vector<uint8_t>& id);
mfiore 0:c62615f15125 665
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 666 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 667 * Get network ID
mfiore 0:c62615f15125 668 * @returns vector containing network ID (size 8)
mfiore 0:c62615f15125 669 */
mfiore 0:c62615f15125 670 std::vector<uint8_t> getNetworkId();
mfiore 0:c62615f15125 671
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 672 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 673 * Set network passphrase
mfiore 0:c62615f15125 674 * for use with OTA & AUTO_OTA network join modes
mfiore 0:c62615f15125 675 * generates network key (cmac of passphrase) automatically
mfiore 0:c62615f15125 676 * @param name a string of of at least 8 bytes and no more than 128 bytes
mfiore 0:c62615f15125 677 * @return MDOT_OK if success
mfiore 0:c62615f15125 678 */
mfiore 0:c62615f15125 679 int32_t setNetworkPassphrase(const std::string& passphrase);
mfiore 0:c62615f15125 680
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 681 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 682 * Get network passphrase
mfiore 0:c62615f15125 683 * @return string containing network passphrase (size 8 to 128)
mfiore 0:c62615f15125 684 */
mfiore 0:c62615f15125 685 std::string getNetworkPassphrase();
mfiore 0:c62615f15125 686
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 687 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 688 * Set network key
mfiore 0:c62615f15125 689 * for use with OTA & AUTO_OTA network join modes
mfiore 0:c62615f15125 690 * setting network key via this function sets network passphrase to empty
mfiore 0:c62615f15125 691 * @param id a vector of 16 bytes
mfiore 0:c62615f15125 692 * @returns MDOT_OK if success
mfiore 0:c62615f15125 693 */
mfiore 0:c62615f15125 694 int32_t setNetworkKey(const std::vector<uint8_t>& id);
mfiore 0:c62615f15125 695
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 696 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 697 * Get network key
mfiore 0:c62615f15125 698 * @returns a vector containing network key (size 16)
mfiore 0:c62615f15125 699 */
mfiore 0:c62615f15125 700 std::vector<uint8_t> getNetworkKey();
mfiore 0:c62615f15125 701
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 702 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 703 * Set lorawan application EUI
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 704 * equivalent to setNetworkId
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 705 * @param eui application EUI (size 8)
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 706 */
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 707 int32_t setAppEUI(const uint8_t* eui);
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 708
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 709 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 710 * Get lorawan application EUI
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 711 * equivalent to getNetworkId
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 712 * @returns vector containing application EUI (size 8)
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 713 */
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 714 const uint8_t* getAppEUI();
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 715
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 716 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 717 * Set lorawan application key
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 718 * equivalent to setNetworkKey
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 719 * @param eui application key (size 16)
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 720 */
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 721 int32_t setAppKey(const uint8_t* key);
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 722
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 723 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 724 * Set lorawan application key
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 725 * equivalent to getNetworkKey
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 726 * @returns eui application key (size 16)
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 727 */
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 728 const uint8_t* getAppKey();
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 729
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 730 /**
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 731 * Add a multicast session address and keys
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 732 * Downlink counter is set to 0
Jenkins@KEILDM1.dc.multitech.prv 69:e22889c7eaa9 733 * Up to 3 MULTICAST_SESSIONS can be set
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 734 */
Jenkins@KEILDM1.dc.multitech.prv 69:e22889c7eaa9 735 int32_t setMulticastSession(uint8_t index, uint32_t addr, const uint8_t* nsk, const uint8_t* dsk);
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 736
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 737 /**
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 738 * Set a multicast session counter
Jenkins@KEILDM1.dc.multitech.prv 69:e22889c7eaa9 739 * Up to 3 MULTICAST_SESSIONS can be set
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 740 */
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 741 int32_t setMulticastDownlinkCounter(uint8_t index, uint32_t count);
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 742
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 743 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 744 * Attempt to join network
Mike Fiore 12:54f9cac9d690 745 * each attempt will be made with a random datarate up to the configured datarate
Mike Fiore 12:54f9cac9d690 746 * JoinRequest backoff between tries is enforced to 1% for 1st hour, 0.1% for 1-10 hours and 0.01% after 10 hours
Mike Fiore 12:54f9cac9d690 747 * Check getNextTxMs() for time until next join attempt can be made
mfiore 0:c62615f15125 748 * @returns MDOT_OK if success
mfiore 0:c62615f15125 749 */
mfiore 0:c62615f15125 750 int32_t joinNetwork();
mfiore 0:c62615f15125 751
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 752 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 753 * Attempts to join network once
mfiore 0:c62615f15125 754 * @returns MDOT_OK if success
mfiore 0:c62615f15125 755 */
mfiore 0:c62615f15125 756 int32_t joinNetworkOnce();
mfiore 0:c62615f15125 757
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 758 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 759 * Resets current network session, essentially disconnecting from the network
mfiore 0:c62615f15125 760 * has no effect for MANUAL network join mode
mfiore 0:c62615f15125 761 */
mfiore 0:c62615f15125 762 void resetNetworkSession();
mfiore 0:c62615f15125 763
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 764 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 765 * Restore saved network session from flash
Mike Fiore 12:54f9cac9d690 766 * has no effect for MANUAL network join mode
Mike Fiore 12:54f9cac9d690 767 */
Mike Fiore 12:54f9cac9d690 768 void restoreNetworkSession();
Mike Fiore 12:54f9cac9d690 769
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 770 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 771 * Save current network session to flash
Mike Fiore 12:54f9cac9d690 772 * has no effect for MANUAL network join mode
Mike Fiore 12:54f9cac9d690 773 */
Mike Fiore 12:54f9cac9d690 774 void saveNetworkSession();
Mike Fiore 12:54f9cac9d690 775
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 776 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 777 * Set number of times joining will retry each sub-band before changing
jreiss 17:306ffaa5d79b 778 * to the next subband in US915 and AU915
mfiore 0:c62615f15125 779 * @param retries must be between 0 - 255
mfiore 0:c62615f15125 780 * @returns MDOT_OK if success
mfiore 0:c62615f15125 781 */
mfiore 0:c62615f15125 782 int32_t setJoinRetries(const uint8_t& retries);
mfiore 0:c62615f15125 783
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 784 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 785 * Get number of times joining will retry each sub-band
mfiore 0:c62615f15125 786 * @returns join retries (0 - 255)
mfiore 0:c62615f15125 787 */
mfiore 0:c62615f15125 788 uint8_t getJoinRetries();
mfiore 0:c62615f15125 789
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 790 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 791 * Set network join mode
mfiore 0:c62615f15125 792 * MANUAL: set network address and session keys manually
mfiore 0:c62615f15125 793 * OTA: User sets network name and passphrase, then attempts to join
mfiore 0:c62615f15125 794 * AUTO_OTA: same as OTA, but network sessions can be saved and restored
mfiore 0:c62615f15125 795 * @param mode MANUAL, OTA, or AUTO_OTA
mfiore 0:c62615f15125 796 * @returns MDOT_OK if success
mfiore 0:c62615f15125 797 */
mfiore 0:c62615f15125 798 int32_t setJoinMode(const uint8_t& mode);
mfiore 0:c62615f15125 799
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 800 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 801 * Get network join mode
mfiore 0:c62615f15125 802 * @returns MANUAL, OTA, or AUTO_OTA
mfiore 0:c62615f15125 803 */
mfiore 0:c62615f15125 804 uint8_t getJoinMode();
mfiore 0:c62615f15125 805
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 806 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 807 * Get network join status
mfiore 0:c62615f15125 808 * @returns true if currently joined to network
mfiore 0:c62615f15125 809 */
mfiore 0:c62615f15125 810 bool getNetworkJoinStatus();
mfiore 0:c62615f15125 811
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 812 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 813 * Do a network link check
mfiore 0:c62615f15125 814 * application data may be returned in response to a network link check command
mfiore 0:c62615f15125 815 * @returns link_check structure containing success, dBm above noise floor, gateways in range, and packet payload
mfiore 0:c62615f15125 816 */
mfiore 0:c62615f15125 817 link_check networkLinkCheck();
mfiore 0:c62615f15125 818
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 819 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 820 * Set network link check count to perform automatic link checks every count packets
mfiore 0:c62615f15125 821 * only applicable if ACKs are disabled
mfiore 0:c62615f15125 822 * @param count must be between 0 - 255
mfiore 0:c62615f15125 823 * @returns MDOT_OK if success
mfiore 0:c62615f15125 824 */
mfiore 0:c62615f15125 825 int32_t setLinkCheckCount(const uint8_t& count);
mfiore 0:c62615f15125 826
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 827 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 828 * Get network link check count
mfiore 0:c62615f15125 829 * @returns count (0 - 255)
mfiore 0:c62615f15125 830 */
mfiore 0:c62615f15125 831 uint8_t getLinkCheckCount();
mfiore 0:c62615f15125 832
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 833 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 834 * Set network link check threshold, number of link check failures or missed acks to tolerate
mfiore 0:c62615f15125 835 * before considering network connection lost
mfiore 0:c62615f15125 836 * @pararm count must be between 0 - 255
mfiore 0:c62615f15125 837 * @returns MDOT_OK if success
mfiore 0:c62615f15125 838 */
mfiore 0:c62615f15125 839 int32_t setLinkCheckThreshold(const uint8_t& count);
mfiore 0:c62615f15125 840
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 841 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 842 * Get network link check threshold
mfiore 0:c62615f15125 843 * @returns threshold (0 - 255)
mfiore 0:c62615f15125 844 */
mfiore 0:c62615f15125 845 uint8_t getLinkCheckThreshold();
mfiore 0:c62615f15125 846
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 847 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 848 * Get/set number of failed link checks in the current session
Mike Fiore 12:54f9cac9d690 849 * @returns count (0 - 255)
Mike Fiore 12:54f9cac9d690 850 */
Mike Fiore 12:54f9cac9d690 851 uint8_t getLinkFailCount();
Mike Fiore 12:54f9cac9d690 852 int32_t setLinkFailCount(uint8_t count);
Mike Fiore 12:54f9cac9d690 853
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 854 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 855 * Set UpLinkCounter number of packets sent to the gateway during this network session (sequence number)
Mike Fiore 12:54f9cac9d690 856 * @returns MDOT_OK
Mike Fiore 12:54f9cac9d690 857 */
Mike Fiore 12:54f9cac9d690 858 int32_t setUpLinkCounter(uint32_t count);
Mike Fiore 12:54f9cac9d690 859
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 860 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 861 * Get UpLinkCounter
mfiore 0:c62615f15125 862 * @returns number of packets sent to the gateway during this network session (sequence number)
mfiore 0:c62615f15125 863 */
mfiore 0:c62615f15125 864 uint32_t getUpLinkCounter();
mfiore 0:c62615f15125 865
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 866 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 867 * Set UpLinkCounter number of packets sent by the gateway during this network session (sequence number)
Mike Fiore 12:54f9cac9d690 868 * @returns MDOT_OK
Mike Fiore 12:54f9cac9d690 869 */
Mike Fiore 12:54f9cac9d690 870 int32_t setDownLinkCounter(uint32_t count);
Mike Fiore 12:54f9cac9d690 871
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 872 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 873 * Get DownLinkCounter
Mike Fiore 12:54f9cac9d690 874 * @returns number of packets sent by the gateway during this network session (sequence number)
Mike Fiore 12:54f9cac9d690 875 */
Mike Fiore 12:54f9cac9d690 876 uint32_t getDownLinkCounter();
Mike Fiore 12:54f9cac9d690 877
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 878 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 879 * Enable/disable AES encryption
mfiore 0:c62615f15125 880 * AES encryption must be enabled for use with Conduit gateway and MTAC_LORA card
mfiore 0:c62615f15125 881 * @param on true for AES encryption to be enabled
mfiore 0:c62615f15125 882 * @returns MDOT_OK if success
mfiore 0:c62615f15125 883 */
mfiore 0:c62615f15125 884 int32_t setAesEncryption(const bool& on);
mfiore 0:c62615f15125 885
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 886 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 887 * Get AES encryption
mfiore 0:c62615f15125 888 * @returns true if AES encryption is enabled
mfiore 0:c62615f15125 889 */
mfiore 0:c62615f15125 890 bool getAesEncryption();
mfiore 0:c62615f15125 891
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 892 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 893 * Get RSSI stats
Mike Fiore 11:d8464345e1f1 894 * @returns rssi_stats struct containing last, min, max, and avg RSSI in dB
mfiore 0:c62615f15125 895 */
mfiore 0:c62615f15125 896 rssi_stats getRssiStats();
mfiore 0:c62615f15125 897
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 898 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 899 * Get SNR stats
Mike Fiore 11:d8464345e1f1 900 * @returns snr_stats struct containing last, min, max, and avg SNR in cB
mfiore 0:c62615f15125 901 */
mfiore 0:c62615f15125 902 snr_stats getSnrStats();
mfiore 0:c62615f15125 903
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 904 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 905 * Get ms until next free channel
mfiore 0:c62615f15125 906 * only applicable for European models, US models return 0
mfiore 0:c62615f15125 907 * @returns time (ms) until a channel is free to use for transmitting
mfiore 0:c62615f15125 908 */
mfiore 0:c62615f15125 909 uint32_t getNextTxMs();
mfiore 0:c62615f15125 910
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 911 /**
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 912 * Get available bytes for payload
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 913 * @returns bytes
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 914 */
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 915 uint8_t getNextTxMaxSize();
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 916
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 917 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 918 * Get join delay in seconds
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 919 * Defaults to 5 seconds
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 920 * Must match join delay setting of the network server
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 921 *
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 922 * The default Join Delay is 5 seconds
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 923 * The default Join Delay for PRIVATE_MTS was 1 second in the previous release
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 924 *
Jason Reiss 10:27dafba9fe19 925 * @returns number of seconds before join accept message is expected
Jason Reiss 10:27dafba9fe19 926 */
Jason Reiss 10:27dafba9fe19 927 uint8_t getJoinDelay();
Jason Reiss 10:27dafba9fe19 928
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 929 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 930 * Set join delay in seconds
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 931 * Defaults to 5 seconds
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 932 * Must match join delay setting of the network server
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 933 *
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 934 * The default Join Delay is 5 seconds
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 935 * The default Join Delay for PRIVATE_MTS was 1 second in the previous release
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 936 *
Jason Reiss 10:27dafba9fe19 937 * @param delay number of seconds before join accept message is expected
Jason Reiss 10:27dafba9fe19 938 * @return MDOT_OK if success
Jason Reiss 10:27dafba9fe19 939 */
Jason Reiss 10:27dafba9fe19 940 uint32_t setJoinDelay(uint8_t delay);
Jason Reiss 10:27dafba9fe19 941
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 942 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 943 * Get join Rx1 datarate offset
Mike Fiore 16:b630e18103e5 944 * defaults to 0
Mike Fiore 16:b630e18103e5 945 * @returns offset
Mike Fiore 16:b630e18103e5 946 */
Mike Fiore 16:b630e18103e5 947 uint8_t getJoinRx1DataRateOffset();
Mike Fiore 16:b630e18103e5 948
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 949 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 950 * Set join Rx1 datarate offset
Mike Fiore 16:b630e18103e5 951 * @param offset for datarate
Mike Fiore 16:b630e18103e5 952 * @return MDOT_OK if success
Mike Fiore 16:b630e18103e5 953 */
Mike Fiore 16:b630e18103e5 954 uint32_t setJoinRx1DataRateOffset(uint8_t offset);
Mike Fiore 16:b630e18103e5 955
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 956 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 957 * Get join Rx2 datarate
Mike Fiore 16:b630e18103e5 958 * defaults to US:DR8, AU:DR8, EU:DR0
Mike Fiore 16:b630e18103e5 959 * @returns datarate
Mike Fiore 16:b630e18103e5 960 */
Mike Fiore 16:b630e18103e5 961 uint8_t getJoinRx2DataRate();
Mike Fiore 16:b630e18103e5 962
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 963 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 964 * Set join Rx2 datarate
Mike Fiore 16:b630e18103e5 965 * @param datarate
Mike Fiore 16:b630e18103e5 966 * @return MDOT_OK if success
Mike Fiore 16:b630e18103e5 967 */
Mike Fiore 16:b630e18103e5 968 uint32_t setJoinRx2DataRate(uint8_t datarate);
Mike Fiore 16:b630e18103e5 969
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 970 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 971 * Get join Rx2 frequency
Mike Fiore 16:b630e18103e5 972 * defaults US:923.3, AU:923.3, EU:869.525
Mike Fiore 16:b630e18103e5 973 * @returns frequency
Mike Fiore 16:b630e18103e5 974 */
Mike Fiore 16:b630e18103e5 975 uint32_t getJoinRx2Frequency();
Mike Fiore 16:b630e18103e5 976
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 977 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 978 * Set join Rx2 frequency
Mike Fiore 16:b630e18103e5 979 * @param frequency
Mike Fiore 16:b630e18103e5 980 * @return MDOT_OK if success
Mike Fiore 16:b630e18103e5 981 */
Mike Fiore 16:b630e18103e5 982 uint32_t setJoinRx2Frequency(uint32_t frequency);
Mike Fiore 16:b630e18103e5 983
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 984 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 985 * Get rx delay in seconds
Jason Reiss 10:27dafba9fe19 986 * Defaults to 1 second
Jason Reiss 10:27dafba9fe19 987 * @returns number of seconds before response message is expected
Jason Reiss 10:27dafba9fe19 988 */
Jason Reiss 10:27dafba9fe19 989 uint8_t getRxDelay();
Jason Reiss 10:27dafba9fe19 990
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 991 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 992 * Set rx delay in seconds
Jason Reiss 10:27dafba9fe19 993 * Defaults to 1 second
Jason Reiss 10:27dafba9fe19 994 * @param delay number of seconds before response message is expected
Jason Reiss 10:27dafba9fe19 995 * @return MDOT_OK if success
Jason Reiss 10:27dafba9fe19 996 */
Jason Reiss 10:27dafba9fe19 997 uint32_t setRxDelay(uint8_t delay);
Jason Reiss 10:27dafba9fe19 998
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 999 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1000 * Get preserve session to save network session info through reset or power down in AUTO_OTA mode
Jason Reiss 10:27dafba9fe19 1001 * Defaults to off
Jason Reiss 10:27dafba9fe19 1002 * @returns true if enabled
Jason Reiss 10:27dafba9fe19 1003 */
Jason Reiss 10:27dafba9fe19 1004 bool getPreserveSession();
Jason Reiss 10:27dafba9fe19 1005
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1006 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1007 * Set preserve session to save network session info through reset or power down in AUTO_OTA mode
Jason Reiss 10:27dafba9fe19 1008 * Defaults to off
Jason Reiss 10:27dafba9fe19 1009 * @param enable
Jason Reiss 10:27dafba9fe19 1010 * @return MDOT_OK if success
Jason Reiss 10:27dafba9fe19 1011 */
Jason Reiss 10:27dafba9fe19 1012 uint32_t setPreserveSession(bool enable);
Jason Reiss 10:27dafba9fe19 1013
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1014 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1015 * Get data pending
mfiore 0:c62615f15125 1016 * only valid after sending data to the gateway
mfiore 0:c62615f15125 1017 * @returns true if server has available packet(s)
mfiore 0:c62615f15125 1018 */
mfiore 0:c62615f15125 1019 bool getDataPending();
mfiore 0:c62615f15125 1020
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1021 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1022 * Get ack requested
Mike Fiore 16:b630e18103e5 1023 * only valid after sending data to the gateway
Mike Fiore 16:b630e18103e5 1024 * @returns true if server has requested ack
Mike Fiore 16:b630e18103e5 1025 */
Mike Fiore 16:b630e18103e5 1026 bool getAckRequested();
Mike Fiore 16:b630e18103e5 1027
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1028 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1029 * Get is transmitting indicator
mfiore 0:c62615f15125 1030 * @returns true if currently transmitting
mfiore 0:c62615f15125 1031 */
mfiore 0:c62615f15125 1032 bool getIsTransmitting();
mfiore 0:c62615f15125 1033
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1034 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1035 * Get is idle indicator
Mike Fiore 16:b630e18103e5 1036 * @returns true if not currently transmitting, waiting or receiving
Mike Fiore 16:b630e18103e5 1037 */
Mike Fiore 16:b630e18103e5 1038 bool getIsIdle();
Mike Fiore 16:b630e18103e5 1039
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1040 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1041 * Set TX data rate
mfiore 0:c62615f15125 1042 * data rates affect maximum payload size
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 1043 * @param dr DR0-DR7 for Europe, DR0-DR4 for United States
mfiore 0:c62615f15125 1044 * @returns MDOT_OK if success
mfiore 0:c62615f15125 1045 */
mfiore 0:c62615f15125 1046 int32_t setTxDataRate(const uint8_t& dr);
mfiore 0:c62615f15125 1047
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1048 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1049 * Get TX data rate
Mike Fiore 11:d8464345e1f1 1050 * @returns current TX data rate (DR0-DR15)
mfiore 0:c62615f15125 1051 */
mfiore 0:c62615f15125 1052 uint8_t getTxDataRate();
mfiore 0:c62615f15125 1053
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1054 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1055 * Get a random value from the radio based on RSSI
Mike Fiore 12:54f9cac9d690 1056 * @returns randome value
Mike Fiore 12:54f9cac9d690 1057 */
Mike Fiore 12:54f9cac9d690 1058 uint32_t getRadioRandom();
Mike Fiore 12:54f9cac9d690 1059
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1060 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1061 * Get data rate spreading factor and bandwidth
Mike Fiore 11:d8464345e1f1 1062 * EU868 Datarates
Mike Fiore 11:d8464345e1f1 1063 * ---------------
Mike Fiore 11:d8464345e1f1 1064 * DR0 - SF12BW125
Mike Fiore 11:d8464345e1f1 1065 * DR1 - SF11BW125
Mike Fiore 11:d8464345e1f1 1066 * DR2 - SF10BW125
Mike Fiore 11:d8464345e1f1 1067 * DR3 - SF9BW125
Mike Fiore 11:d8464345e1f1 1068 * DR4 - SF8BW125
Mike Fiore 11:d8464345e1f1 1069 * DR5 - SF7BW125
Mike Fiore 11:d8464345e1f1 1070 * DR6 - SF7BW250
Mike Fiore 11:d8464345e1f1 1071 * DR7 - FSK
Mike Fiore 11:d8464345e1f1 1072 *
Mike Fiore 11:d8464345e1f1 1073 * US915 Datarates
Mike Fiore 11:d8464345e1f1 1074 * ---------------
Mike Fiore 11:d8464345e1f1 1075 * DR0 - SF10BW125
Mike Fiore 11:d8464345e1f1 1076 * DR1 - SF9BW125
Mike Fiore 11:d8464345e1f1 1077 * DR2 - SF8BW125
Mike Fiore 11:d8464345e1f1 1078 * DR3 - SF7BW125
Mike Fiore 11:d8464345e1f1 1079 * DR4 - SF8BW500
Mike Fiore 11:d8464345e1f1 1080 *
jreiss 17:306ffaa5d79b 1081 * AU915 Datarates
jreiss 17:306ffaa5d79b 1082 * ---------------
Jenkins@KEILDM1.dc.multitech.prv 70:0c5b5b02d17b 1083 * DR0 - SF12BW125
Jenkins@KEILDM1.dc.multitech.prv 70:0c5b5b02d17b 1084 * DR1 - SF11BW125
Jenkins@KEILDM1.dc.multitech.prv 70:0c5b5b02d17b 1085 * DR2 - SF10BW125
Jenkins@KEILDM1.dc.multitech.prv 70:0c5b5b02d17b 1086 * DR3 - SF9BW125
Jenkins@KEILDM1.dc.multitech.prv 70:0c5b5b02d17b 1087 * DR4 - SF8BW125
Jenkins@KEILDM1.dc.multitech.prv 70:0c5b5b02d17b 1088 * DR5 - SF7BW125
Jenkins@KEILDM1.dc.multitech.prv 70:0c5b5b02d17b 1089 * DR6 - SF8BW500
jreiss 17:306ffaa5d79b 1090 *
Mike Fiore 11:d8464345e1f1 1091 * @returns spreading factor and bandwidth
Mike Fiore 11:d8464345e1f1 1092 */
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1093 std::string getDataRateDetails(uint8_t rate);
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1094
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1095 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1096 * Set TX power output of radio before antenna gain, default: 14 dBm
Mike Fiore 12:54f9cac9d690 1097 * actual output power may be limited by local regulations for the chosen frequency
mfiore 0:c62615f15125 1098 * power affects maximum range
mfiore 0:c62615f15125 1099 * @param power 2 dBm - 20 dBm
mfiore 0:c62615f15125 1100 * @returns MDOT_OK if success
mfiore 0:c62615f15125 1101 */
mfiore 0:c62615f15125 1102 int32_t setTxPower(const uint32_t& power);
mfiore 0:c62615f15125 1103
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1104 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1105 * Get TX power
mfiore 0:c62615f15125 1106 * @returns TX power (2 dBm - 20 dBm)
mfiore 0:c62615f15125 1107 */
mfiore 0:c62615f15125 1108 uint32_t getTxPower();
mfiore 0:c62615f15125 1109
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1110 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1111 * Get configured gain of installed antenna, default: +3 dBi
Mike Fiore 11:d8464345e1f1 1112 * @returns gain of antenna in dBi
Mike Fiore 11:d8464345e1f1 1113 */
Mike Fiore 11:d8464345e1f1 1114 int8_t getAntennaGain();
Mike Fiore 11:d8464345e1f1 1115
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1116 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1117 * Set configured gain of installed antenna, default: +3 dBi
Mike Fiore 11:d8464345e1f1 1118 * @param gain -127 dBi - 128 dBi
Mike Fiore 11:d8464345e1f1 1119 * @returns MDOT_OK if success
Mike Fiore 11:d8464345e1f1 1120 */
Mike Fiore 11:d8464345e1f1 1121 int32_t setAntennaGain(int8_t gain);
Mike Fiore 11:d8464345e1f1 1122
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1123 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1124 * Enable/disable TX waiting for rx windows
mfiore 0:c62615f15125 1125 * when enabled, send calls will block until a packet is received or RX timeout
mfiore 0:c62615f15125 1126 * @param enable set to true if expecting responses to transmitted packets
mfiore 0:c62615f15125 1127 * @returns MDOT_OK if success
mfiore 0:c62615f15125 1128 */
mfiore 0:c62615f15125 1129 int32_t setTxWait(const bool& enable);
mfiore 0:c62615f15125 1130
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1131 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1132 * Get TX wait
mfiore 0:c62615f15125 1133 * @returns true if TX wait is enabled
mfiore 0:c62615f15125 1134 */
mfiore 0:c62615f15125 1135 bool getTxWait();
mfiore 0:c62615f15125 1136
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1137 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1138 * Cancel pending rx windows
Mike Fiore 16:b630e18103e5 1139 */
Mike Fiore 16:b630e18103e5 1140 void cancelRxWindow();
Mike Fiore 16:b630e18103e5 1141
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1142 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1143 * Get time on air
mfiore 0:c62615f15125 1144 * @returns the amount of time (in ms) it would take to send bytes bytes based on current configuration
mfiore 0:c62615f15125 1145 */
mfiore 0:c62615f15125 1146 uint32_t getTimeOnAir(uint8_t bytes);
mfiore 0:c62615f15125 1147
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1148 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1149 * Get min frequency
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1150 * @returns minimum frequency based on current channel plan
mfiore 0:c62615f15125 1151 */
mfiore 0:c62615f15125 1152 uint32_t getMinFrequency();
mfiore 0:c62615f15125 1153
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1154 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1155 * Get max frequency
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1156 * @returns maximum frequency based on current channel plan
mfiore 0:c62615f15125 1157 */
mfiore 0:c62615f15125 1158 uint32_t getMaxFrequency();
mfiore 0:c62615f15125 1159
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1160 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1161 * Get min datarate
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1162 * @returns minimum datarate based on current channel plan
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1163 */
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1164 uint8_t getMinDatarate();
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1165
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1166 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1167 * Get max datarate
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1168 * @returns maximum datarate based on current channel plan
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1169 */
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1170 uint8_t getMaxDatarate();
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1171
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1172 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1173 * Get min datarate offset
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1174 * @returns minimum datarate offset based on current channel plan
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1175 */
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1176 uint8_t getMinDatarateOffset();
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1177
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1178 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1179 * Get max datarate offset
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1180 * @returns maximum datarate based on current channel plan
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1181 */
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1182 uint8_t getMaxDatarateOffset();
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1183
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1184 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1185 * Get min datarate
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1186 * @returns minimum datarate based on current channel plan
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1187 */
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1188 uint8_t getMinRx2Datarate();
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1189
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1190 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1191 * Get max rx2 datarate
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1192 * @returns maximum rx2 datarate based on current channel plan
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1193 */
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1194 uint8_t getMaxRx2Datarate();
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1195
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1196 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1197 * Get max tx power
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1198 * @returns maximum tx power based on current channel plan
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1199 */
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1200 uint8_t getMaxTxPower();
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1201
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1202 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1203 * Get min tx power
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1204 * @returns minimum tx power based on current channel plan
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1205 */
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1206 uint8_t getMinTxPower();
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1207
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1208 /**
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 1209 * Set ping slot periodicity
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 1210 * Specify the the number of ping slots in a given beacon interval
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 1211 * Note: Must switch back to class A for the change to take effect
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 1212 * @param exp - number_of_pings = 2^(7 - exp) where 0 <= exp <= 7
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 1213 * @returns MDOT_OK if success
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 1214 */
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 1215 uint32_t setPingPeriodicity(uint8_t exp);
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 1216
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 1217 /**
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 1218 * Get ping slot periodicity
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 1219 * @returns exp = 7 - log2(number_of_pings)
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 1220 */
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 1221 uint8_t getPingPeriodicity();
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 1222
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 1223 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1224 *
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1225 * get/set adaptive data rate
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1226 * configure data rates and power levels based on signal to noise of packets received at gateway
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1227 * true == adaptive data rate is on
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1228 * set function returns MDOT_OK if success
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1229 */
Mike Fiore 12:54f9cac9d690 1230 int32_t setAdr(const bool& on);
Mike Fiore 12:54f9cac9d690 1231 bool getAdr();
Mike Fiore 12:54f9cac9d690 1232
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1233 /**
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 1234 * Set the ADR ACK Limit
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 1235 * @param limit - ADR ACK limit
Jenkins@KEILDM1.dc.multitech.prv 70:0c5b5b02d17b 1236 * @returns MDOT_OK if success
mfiore 0:c62615f15125 1237 */
Jenkins@KEILDM1.dc.multitech.prv 70:0c5b5b02d17b 1238 int32_t setAdrAckLimit(uint8_t limit);
mfiore 0:c62615f15125 1239
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1240 /**
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 1241 * Get the ADR ACK Limit
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 1242 * @returns ADR ACK limit
mfiore 0:c62615f15125 1243 */
Jenkins@KEILDM1.dc.multitech.prv 70:0c5b5b02d17b 1244 uint8_t getAdrAckLimit();
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 1245
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 1246 /**
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 1247 * Set the ADR ACK Delay
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 1248 * @param delay - ADR ACK delay
Jenkins@KEILDM1.dc.multitech.prv 70:0c5b5b02d17b 1249 * @returns MDOT_OK if success
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 1250 */
Jenkins@KEILDM1.dc.multitech.prv 70:0c5b5b02d17b 1251 int32_t setAdrAckDelay(uint8_t delay);
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 1252
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 1253 /**
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 1254 * Get the ADR ACK Delay
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 1255 * @returns ADR ACK delay
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 1256 */
Jenkins@KEILDM1.dc.multitech.prv 70:0c5b5b02d17b 1257 uint8_t getAdrAckDelay();
mfiore 0:c62615f15125 1258
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1259 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1260 * Enable/disable CRC checking of packets
mfiore 0:c62615f15125 1261 * CRC checking must be enabled for use with Conduit gateway and MTAC_LORA card
mfiore 0:c62615f15125 1262 * @param on set to true to enable CRC checking
mfiore 0:c62615f15125 1263 * @returns MDOT_OK if success
mfiore 0:c62615f15125 1264 */
mfiore 0:c62615f15125 1265 int32_t setCrc(const bool& on);
mfiore 0:c62615f15125 1266
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1267 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1268 * Get CRC checking
mfiore 0:c62615f15125 1269 * @returns true if CRC checking is enabled
mfiore 0:c62615f15125 1270 */
mfiore 0:c62615f15125 1271 bool getCrc();
mfiore 0:c62615f15125 1272
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1273 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1274 * Set ack
mfiore 0:c62615f15125 1275 * @param retries 0 to disable acks, otherwise 1 - 8
mfiore 0:c62615f15125 1276 * @returns MDOT_OK if success
mfiore 0:c62615f15125 1277 */
mfiore 0:c62615f15125 1278 int32_t setAck(const uint8_t& retries);
mfiore 0:c62615f15125 1279
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1280 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1281 * Get ack
mfiore 0:c62615f15125 1282 * @returns 0 if acks are disabled, otherwise retries (1 - 8)
mfiore 0:c62615f15125 1283 */
mfiore 0:c62615f15125 1284 uint8_t getAck();
mfiore 0:c62615f15125 1285
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1286 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1287 * Set number of packet repeats for unconfirmed frames
Mike Fiore 12:54f9cac9d690 1288 * @param repeat 0 or 1 for no repeats, otherwise 2-15
Mike Fiore 12:54f9cac9d690 1289 * @returns MDOT_OK if success
Mike Fiore 12:54f9cac9d690 1290 */
Mike Fiore 12:54f9cac9d690 1291 int32_t setRepeat(const uint8_t& repeat);
Mike Fiore 12:54f9cac9d690 1292
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1293 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1294 * Get number of packet repeats for unconfirmed frames
Mike Fiore 12:54f9cac9d690 1295 * @returns 0 or 1 if no repeats, otherwise 2-15
Mike Fiore 12:54f9cac9d690 1296 */
Mike Fiore 12:54f9cac9d690 1297 uint8_t getRepeat();
Mike Fiore 12:54f9cac9d690 1298
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1299 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1300 * Send data to the gateway
mfiore 0:c62615f15125 1301 * validates data size (based on spreading factor)
mfiore 0:c62615f15125 1302 * @param data a vector of up to 242 bytes (may be less based on spreading factor)
mfiore 0:c62615f15125 1303 * @returns MDOT_OK if packet was sent successfully (ACKs disabled), or if an ACK was received (ACKs enabled)
mfiore 0:c62615f15125 1304 */
mfiore 0:c62615f15125 1305 int32_t send(const std::vector<uint8_t>& data, const bool& blocking = true, const bool& highBw = false);
mfiore 0:c62615f15125 1306
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1307 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1308 * Inject mac command
Mike Fiore 16:b630e18103e5 1309 * @param data a vector containing mac commands
Mike Fiore 16:b630e18103e5 1310 * @returns MDOT_OK
Mike Fiore 16:b630e18103e5 1311 */
Mike Fiore 16:b630e18103e5 1312 int32_t injectMacCommand(const std::vector<uint8_t>& data);
Mike Fiore 16:b630e18103e5 1313
Mike Fiore 16:b630e18103e5 1314 /**
Mike Fiore 16:b630e18103e5 1315 * Clear MAC command buffer to be sent in next uplink
Mike Fiore 16:b630e18103e5 1316 * @returns MDOT_OK
Mike Fiore 16:b630e18103e5 1317 */
Mike Fiore 16:b630e18103e5 1318 int32_t clearMacCommands();
Mike Fiore 16:b630e18103e5 1319
Mike Fiore 16:b630e18103e5 1320 /**
Mike Fiore 16:b630e18103e5 1321 * Get MAC command buffer to be sent in next uplink
Mike Fiore 16:b630e18103e5 1322 * @returns command bytes
Mike Fiore 16:b630e18103e5 1323 */
Mike Fiore 16:b630e18103e5 1324 std::vector<uint8_t> getMacCommands();
Mike Fiore 16:b630e18103e5 1325
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1326 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1327 * Fetch data received from the gateway
mfiore 0:c62615f15125 1328 * this function only checks to see if a packet has been received - it does not open a receive window
mfiore 0:c62615f15125 1329 * send() must be called before recv()
mfiore 0:c62615f15125 1330 * @param data a vector to put the received data into
mfiore 0:c62615f15125 1331 * @returns MDOT_OK if packet was successfully received
mfiore 0:c62615f15125 1332 */
mfiore 0:c62615f15125 1333 int32_t recv(std::vector<uint8_t>& data);
mfiore 0:c62615f15125 1334
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1335 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1336 * Ping
mfiore 0:c62615f15125 1337 * status will be MDOT_OK if ping succeeded
mfiore 0:c62615f15125 1338 * @returns ping_response struct containing status, RSSI, and SNR
mfiore 0:c62615f15125 1339 */
mfiore 0:c62615f15125 1340 ping_response ping();
mfiore 0:c62615f15125 1341
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1342 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1343 * Get return code string
mfiore 0:c62615f15125 1344 * @returns string containing a description of the given error code
mfiore 0:c62615f15125 1345 */
mfiore 0:c62615f15125 1346 static std::string getReturnCodeString(const int32_t& code);
mfiore 0:c62615f15125 1347
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1348 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1349 * Get last error
mfiore 0:c62615f15125 1350 * @returns string explaining the last error that occured
mfiore 0:c62615f15125 1351 */
mfiore 0:c62615f15125 1352 std::string getLastError();
mfiore 0:c62615f15125 1353
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1354 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1355 * Go to sleep
Jason Reiss 10:27dafba9fe19 1356 * @param interval the number of seconds to sleep before waking up if wakeup_mode == RTC_ALARM or RTC_ALARM_OR_INTERRUPT, else ignored
Jason Reiss 10:27dafba9fe19 1357 * @param wakeup_mode RTC_ALARM, INTERRUPT, RTC_ALARM_OR_INTERRUPT
Mike Fiore 7:683dba5d576f 1358 * if RTC_ALARM the real time clock is configured to wake the device up after the specified interval
Mike Fiore 7:683dba5d576f 1359 * if INTERRUPT the device will wake up on the rising edge of the interrupt pin
Jason Reiss 10:27dafba9fe19 1360 * if RTC_ALARM_OR_INTERRUPT the device will wake on the first event to occur
Mike Fiore 7:683dba5d576f 1361 * @param deepsleep if true go into deep sleep mode (lowest power, all memory and registers are lost, peripherals turned off)
Mike Fiore 7:683dba5d576f 1362 * else go into sleep mode (low power, memory and registers are maintained, peripherals stay on)
Mike Fiore 7:683dba5d576f 1363 *
Jenkins@KEILDM1.dc.multitech.prv 19:f3a46d2bb9b3 1364 * For the MDOT
Jenkins@KEILDM1.dc.multitech.prv 19:f3a46d2bb9b3 1365 * in sleep mode, the device can be woken up on an XBEE_DI (2-8) pin or by the RTC alarm
Jenkins@KEILDM1.dc.multitech.prv 19:f3a46d2bb9b3 1366 * in deepsleep mode, the device can only be woken up using the WKUP pin (PA0, XBEE_DIO7) or by the RTC alarm
Jenkins@KEILDM1.dc.multitech.prv 19:f3a46d2bb9b3 1367 * For the XDOT
Jenkins@KEILDM1.dc.multitech.prv 19:f3a46d2bb9b3 1368 * in sleep mode, the device can be woken up on GPIO (0-3), UART1_RX, WAKE or by the RTC alarm
Jenkins@KEILDM1.dc.multitech.prv 19:f3a46d2bb9b3 1369 * in deepsleep mode, the device can only be woken up using the WKUP pin (PA0, WAKE) or by the RTC alarm
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 1370 * @returns MDOT_OK on success
Mike Fiore 7:683dba5d576f 1371 */
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 1372 int32_t sleep(const uint32_t& interval, const uint8_t& wakeup_mode = RTC_ALARM, const bool& deepsleep = true);
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 1373
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 1374 /**
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 1375 * Set auto sleep mode
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 1376 * Auto sleep mode will automatically put the MCU to sleep after tx and in between receive windows
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 1377 * Note: The MCU will go into a stop mode sleep in between rx windows. This means that
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 1378 * peripherals such as timers will not function during the sleep intervals.
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 1379 * @param enable - Flag to enable auto sleep mode
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 1380 */
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 1381 void setAutoSleep(bool enable);
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 1382
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 1383 /**
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 1384 * Get auto sleep mode
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 1385 * @returns 0 if sleep mode is disabled, 1 if it is enabled
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 1386 */
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 1387 uint8_t getAutoSleep();
Mike Fiore 7:683dba5d576f 1388
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1389 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1390 * Set wake pin
Jenkins@KEILDM1.dc.multitech.prv 19:f3a46d2bb9b3 1391 * @param pin the pin to use to wake the device from sleep mode
Jenkins@KEILDM1.dc.multitech.prv 19:f3a46d2bb9b3 1392 * For MDOT, XBEE_DI (2-8)
Jenkins@KEILDM1.dc.multitech.prv 19:f3a46d2bb9b3 1393 * For XDOT, GPIO (0-3), UART1_RX, or WAKE
Mike Fiore 7:683dba5d576f 1394 */
Mike Fiore 7:683dba5d576f 1395 void setWakePin(const PinName& pin);
Mike Fiore 7:683dba5d576f 1396
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1397 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1398 * Get wake pin
Jenkins@KEILDM1.dc.multitech.prv 19:f3a46d2bb9b3 1399 * @returns the pin to use to wake the device from sleep mode
Jenkins@KEILDM1.dc.multitech.prv 19:f3a46d2bb9b3 1400 * For MDOT, XBEE_DI (2-8)
Jenkins@KEILDM1.dc.multitech.prv 19:f3a46d2bb9b3 1401 * For XDOT, GPIO (0-3), UART1_RX, or WAKE
Mike Fiore 7:683dba5d576f 1402 */
Mike Fiore 7:683dba5d576f 1403 PinName getWakePin();
Mike Fiore 7:683dba5d576f 1404
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1405 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1406 * Write data in a user backup register
Jenkins@KEILDM1.dc.multitech.prv 19:f3a46d2bb9b3 1407 * @param register one of UBR0 through UBR9 for MDOT, one of UBR0 through UBR21 for XDOT
jreiss 9:ec2fffe31793 1408 * @param data user data to back up
jreiss 9:ec2fffe31793 1409 * @returns true if success
jreiss 9:ec2fffe31793 1410 */
jreiss 9:ec2fffe31793 1411 bool writeUserBackupRegister(uint32_t reg, uint32_t data);
jreiss 9:ec2fffe31793 1412
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1413 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1414 * Read data in a user backup register
Jenkins@KEILDM1.dc.multitech.prv 19:f3a46d2bb9b3 1415 * @param register one of UBR0 through UBR9 for MDOT, one of UBR0 through UBR21 for XDOT
jreiss 9:ec2fffe31793 1416 * @param data gets set to content of register
jreiss 9:ec2fffe31793 1417 * @returns true if success
jreiss 9:ec2fffe31793 1418 */
jreiss 9:ec2fffe31793 1419 bool readUserBackupRegister(uint32_t reg, uint32_t& data);
jreiss 9:ec2fffe31793 1420
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1421 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1422 * Set LBT time in us
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1423 * @param ms time in us
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1424 * @returns true if success
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1425 */
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1426 bool setLbtTimeUs(uint16_t us);
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1427
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1428 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1429 * Get LBT time in us
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1430 * @returns LBT time in us
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1431 */
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1432 uint16_t getLbtTimeUs();
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1433
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1434 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1435 * Set LBT threshold in dBm
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1436 * @param rssi threshold in dBm
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1437 * @returns true if success
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1438 */
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1439 bool setLbtThreshold(int8_t rssi);
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1440
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1441 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1442 * Get LBT threshold in dBm
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1443 * @returns LBT threshold in dBm
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1444 */
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1445 int8_t getLbtThreshold();
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1446
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 1447 /**
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 1448 * Get Radio Frequency Offset
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 1449 * Used for fine calibration of radio frequencies
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 1450 * @returns frequency offset in MHz
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 1451 */
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 1452 int32_t getFrequencyOffset();
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 1453 /**
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 1454 * Get Radio Frequency Offset
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 1455 * Used for fine calibration of radio frequencies
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 1456 * @param offset frequency offset in MHz
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 1457 */
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 1458 void setFrequencyOffset(int32_t offset);
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 1459
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 1460 /**
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 1461 * Get GPS time from network server
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 1462 * Sends a DeviceTimeReq command to the network server
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 1463 * @returns time since GPS epoch, 0 on failure
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 1464 */
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 1465 uint64_t getGPSTime();
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 1466
Jenkins@KEILDM1.dc.multitech.prv 19:f3a46d2bb9b3 1467 #if defined(TARGET_MTS_MDOT_F411RE)
Jenkins@KEILDM1.dc.multitech.prv 31:7fdee197d415 1468 ///////////////////////////////////////////////////////////////////
Jenkins@KEILDM1.dc.multitech.prv 31:7fdee197d415 1469 // Filesystem (Non Volatile Memory) Operation Functions for mDot //
Jenkins@KEILDM1.dc.multitech.prv 31:7fdee197d415 1470 ///////////////////////////////////////////////////////////////////
Jenkins@KEILDM1.dc.multitech.prv 31:7fdee197d415 1471
Mike Fiore 11:d8464345e1f1 1472 // Save user file data to flash
Mike Fiore 11:d8464345e1f1 1473 // file - name of file max 30 chars
Mike Fiore 11:d8464345e1f1 1474 // data - data of file
Mike Fiore 11:d8464345e1f1 1475 // size - size of file
Jenkins@KEILDM1.dc.multitech.prv 31:7fdee197d415 1476 // returns true if successful
Mike Fiore 11:d8464345e1f1 1477 bool saveUserFile(const char* file, void* data, uint32_t size);
Mike Fiore 11:d8464345e1f1 1478
Mike Fiore 11:d8464345e1f1 1479 // Append user file data to flash
Mike Fiore 11:d8464345e1f1 1480 // file - name of file max 30 chars
Mike Fiore 11:d8464345e1f1 1481 // data - data of file
Mike Fiore 11:d8464345e1f1 1482 // size - size of file
Jenkins@KEILDM1.dc.multitech.prv 31:7fdee197d415 1483 // returns true if successful
Mike Fiore 11:d8464345e1f1 1484 bool appendUserFile(const char* file, void* data, uint32_t size);
Mike Fiore 11:d8464345e1f1 1485
Mike Fiore 11:d8464345e1f1 1486 // Read user file data from flash
Mike Fiore 11:d8464345e1f1 1487 // file - name of file max 30 chars
Mike Fiore 11:d8464345e1f1 1488 // data - data of file
Mike Fiore 11:d8464345e1f1 1489 // size - size of file
Jenkins@KEILDM1.dc.multitech.prv 31:7fdee197d415 1490 // returns true if successful
Mike Fiore 11:d8464345e1f1 1491 bool readUserFile(const char* file, void* data, uint32_t size);
Mike Fiore 11:d8464345e1f1 1492
Mike Fiore 11:d8464345e1f1 1493 // Move a user file in flash
Mike Fiore 11:d8464345e1f1 1494 // file - name of file
Mike Fiore 11:d8464345e1f1 1495 // new_name - new name of file
Jenkins@KEILDM1.dc.multitech.prv 31:7fdee197d415 1496 // returns true if successful
Mike Fiore 11:d8464345e1f1 1497 bool moveUserFile(const char* file, const char* new_name);
Mike Fiore 11:d8464345e1f1 1498
Mike Fiore 11:d8464345e1f1 1499 // Delete user file data from flash
Mike Fiore 11:d8464345e1f1 1500 // file - name of file max 30 chars
Jenkins@KEILDM1.dc.multitech.prv 31:7fdee197d415 1501 // returns true if successful
Mike Fiore 11:d8464345e1f1 1502 bool deleteUserFile(const char* file);
Mike Fiore 11:d8464345e1f1 1503
Mike Fiore 11:d8464345e1f1 1504 // Open user file in flash, max of 4 files open concurrently
Mike Fiore 11:d8464345e1f1 1505 // file - name of file max 30 chars
Mike Fiore 11:d8464345e1f1 1506 // mode - combination of FM_APPEND | FM_TRUNC | FM_CREAT |
Mike Fiore 11:d8464345e1f1 1507 // FM_RDONLY | FM_WRONLY | FM_RDWR | FM_DIRECT
Mike Fiore 11:d8464345e1f1 1508 // returns - mdot_file struct, fd field will be a negative value if file could not be opened
Mike Fiore 11:d8464345e1f1 1509 mDot::mdot_file openUserFile(const char* file, int mode);
Mike Fiore 11:d8464345e1f1 1510
Mike Fiore 11:d8464345e1f1 1511 // Seek an open file
Mike Fiore 11:d8464345e1f1 1512 // file - mdot file struct
Mike Fiore 11:d8464345e1f1 1513 // offset - offset in bytes
Mike Fiore 11:d8464345e1f1 1514 // whence - where offset is based SEEK_SET, SEEK_CUR, SEEK_END
Jenkins@KEILDM1.dc.multitech.prv 31:7fdee197d415 1515 // returns true if successful
Mike Fiore 11:d8464345e1f1 1516 bool seekUserFile(mDot::mdot_file& file, size_t offset, int whence);
Mike Fiore 11:d8464345e1f1 1517
Mike Fiore 11:d8464345e1f1 1518 // Read bytes from open file
Mike Fiore 11:d8464345e1f1 1519 // file - mdot file struct
Mike Fiore 11:d8464345e1f1 1520 // data - mem location to store data
Mike Fiore 11:d8464345e1f1 1521 // length - number of bytes to read
Jenkins@KEILDM1.dc.multitech.prv 31:7fdee197d415 1522 // returns - number of bytes read, negative if error
Mike Fiore 11:d8464345e1f1 1523 int readUserFile(mDot::mdot_file& file, void* data, size_t length);
Mike Fiore 11:d8464345e1f1 1524
Mike Fiore 11:d8464345e1f1 1525 // Write bytes to open file
Mike Fiore 11:d8464345e1f1 1526 // file - mdot file struct
Mike Fiore 11:d8464345e1f1 1527 // data - data to write
Mike Fiore 11:d8464345e1f1 1528 // length - number of bytes to write
Jenkins@KEILDM1.dc.multitech.prv 31:7fdee197d415 1529 // returns - number of bytes written, negative if error
Mike Fiore 11:d8464345e1f1 1530 int writeUserFile(mDot::mdot_file& file, void* data, size_t length);
Mike Fiore 11:d8464345e1f1 1531
Mike Fiore 11:d8464345e1f1 1532 // Close open file
Mike Fiore 11:d8464345e1f1 1533 // file - mdot file struct
Jenkins@KEILDM1.dc.multitech.prv 31:7fdee197d415 1534 // returns true if successful
Mike Fiore 11:d8464345e1f1 1535 bool closeUserFile(mDot::mdot_file& file);
Mike Fiore 11:d8464345e1f1 1536
Mike Fiore 11:d8464345e1f1 1537 // List user files stored in flash
Mike Fiore 11:d8464345e1f1 1538 std::vector<mDot::mdot_file> listUserFiles();
Mike Fiore 11:d8464345e1f1 1539
Mike Fiore 11:d8464345e1f1 1540 // Move file into the firmware upgrade path to be flashed on next boot
Mike Fiore 11:d8464345e1f1 1541 // file - name of file
Jenkins@KEILDM1.dc.multitech.prv 31:7fdee197d415 1542 // returns true if successful
Mike Fiore 11:d8464345e1f1 1543 bool moveUserFileToFirmwareUpgrade(const char* file);
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 1544
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 1545 // Return total size of all files saved in FLASH
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 1546 // Does not include SPIFFS overhead
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 1547 uint32_t getUsedSpace();
Jenkins@KEILDM1.dc.multitech.prv 31:7fdee197d415 1548 #else
Jenkins@KEILDM1.dc.multitech.prv 31:7fdee197d415 1549 ///////////////////////////////////////////////////////////////
Jenkins@KEILDM1.dc.multitech.prv 31:7fdee197d415 1550 // EEPROM (Non Volatile Memory) Operation Functions for xDot //
Jenkins@KEILDM1.dc.multitech.prv 31:7fdee197d415 1551 ///////////////////////////////////////////////////////////////
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 1552
Jenkins@KEILDM1.dc.multitech.prv 31:7fdee197d415 1553 // Write to EEPROM
Jenkins@KEILDM1.dc.multitech.prv 31:7fdee197d415 1554 // addr - address to write to (0 - 0x17FF)
Jenkins@KEILDM1.dc.multitech.prv 31:7fdee197d415 1555 // data - data to write
Jenkins@KEILDM1.dc.multitech.prv 31:7fdee197d415 1556 // size - size of data
Jenkins@KEILDM1.dc.multitech.prv 31:7fdee197d415 1557 // returns true if successful
Jenkins@KEILDM1.dc.multitech.prv 31:7fdee197d415 1558 bool nvmWrite(uint16_t addr, void* data, uint16_t size);
Jenkins@KEILDM1.dc.multitech.prv 31:7fdee197d415 1559
Jenkins@KEILDM1.dc.multitech.prv 31:7fdee197d415 1560 // Read from EEPROM
Jenkins@KEILDM1.dc.multitech.prv 31:7fdee197d415 1561 // addr - address to read from (0 - 0x17FF)
Jenkins@KEILDM1.dc.multitech.prv 31:7fdee197d415 1562 // data - buffer for data
Jenkins@KEILDM1.dc.multitech.prv 31:7fdee197d415 1563 // size - size of buffer
Jenkins@KEILDM1.dc.multitech.prv 31:7fdee197d415 1564 // returns true if successful
Jenkins@KEILDM1.dc.multitech.prv 31:7fdee197d415 1565 bool nvmRead(uint16_t addr, void* data, uint16_t size);
Jenkins@KEILDM1.dc.multitech.prv 19:f3a46d2bb9b3 1566 #endif /* TARGET_MTS_MDOT_F411RE */
Mike Fiore 11:d8464345e1f1 1567
Mike Fiore 11:d8464345e1f1 1568 // get current statistics
Mike Fiore 11:d8464345e1f1 1569 // Join Attempts, Join Fails, Up Packets, Down Packets, Missed Acks
Mike Fiore 11:d8464345e1f1 1570 mdot_stats getStats();
Mike Fiore 11:d8464345e1f1 1571
Mike Fiore 11:d8464345e1f1 1572 // reset statistics
Mike Fiore 11:d8464345e1f1 1573 // Join Attempts, Join Fails, Up Packets, Down Packets, Missed Acks
Mike Fiore 11:d8464345e1f1 1574 void resetStats();
Mike Fiore 11:d8464345e1f1 1575
Mike Fiore 11:d8464345e1f1 1576 // Convert pin number 2-8 to pin name DIO2-DI8
Mike Fiore 11:d8464345e1f1 1577 static PinName pinNum2Name(uint8_t num);
Mike Fiore 11:d8464345e1f1 1578
Mike Fiore 11:d8464345e1f1 1579 // Convert pin name DIO2-DI8 to pin number 2-8
Mike Fiore 11:d8464345e1f1 1580 static uint8_t pinName2Num(PinName name);
Mike Fiore 11:d8464345e1f1 1581
Mike Fiore 11:d8464345e1f1 1582 // Convert pin name DIO2-DI8 to string
Mike Fiore 11:d8464345e1f1 1583 static std::string pinName2Str(PinName name);
Mike Fiore 11:d8464345e1f1 1584
Mike Fiore 11:d8464345e1f1 1585 uint64_t crc64(uint64_t crc, const unsigned char *s, uint64_t l);
mfiore 0:c62615f15125 1586
mfiore 0:c62615f15125 1587 /*************************************************************************
mfiore 0:c62615f15125 1588 * The following functions are only used by the AT command application and
mfiore 0:c62615f15125 1589 * should not be used by standard applications consuming the mDot library
mfiore 0:c62615f15125 1590 ************************************************************************/
Mike Fiore 7:683dba5d576f 1591
mfiore 0:c62615f15125 1592 // set/get configured baud rate for command port
mfiore 0:c62615f15125 1593 // only for use in conjunction with AT interface
mfiore 0:c62615f15125 1594 // set function returns MDOT_OK if success
mfiore 0:c62615f15125 1595 int32_t setBaud(const uint32_t& baud);
mfiore 0:c62615f15125 1596 uint32_t getBaud();
mfiore 0:c62615f15125 1597
mfiore 0:c62615f15125 1598 // set/get baud rate for debug port
mfiore 0:c62615f15125 1599 // set function returns MDOT_OK if success
mfiore 0:c62615f15125 1600 int32_t setDebugBaud(const uint32_t& baud);
mfiore 0:c62615f15125 1601 uint32_t getDebugBaud();
mfiore 0:c62615f15125 1602
mfiore 0:c62615f15125 1603 // set/get command terminal echo
mfiore 0:c62615f15125 1604 // set function returns MDOT_OK if success
mfiore 0:c62615f15125 1605 int32_t setEcho(const bool& on);
mfiore 0:c62615f15125 1606 bool getEcho();
mfiore 0:c62615f15125 1607
mfiore 0:c62615f15125 1608 // set/get command terminal verbose mode
mfiore 0:c62615f15125 1609 // set function returns MDOT_OK if success
mfiore 0:c62615f15125 1610 int32_t setVerbose(const bool& on);
mfiore 0:c62615f15125 1611 bool getVerbose();
mfiore 0:c62615f15125 1612
mfiore 0:c62615f15125 1613 // set/get startup mode
mfiore 0:c62615f15125 1614 // COMMAND_MODE (default), starts up ready to accept AT commands
mfiore 0:c62615f15125 1615 // SERIAL_MODE, read serial data and send it as LoRa packets
mfiore 0:c62615f15125 1616 // set function returns MDOT_OK if success
mfiore 0:c62615f15125 1617 int32_t setStartUpMode(const uint8_t& mode);
mfiore 0:c62615f15125 1618 uint8_t getStartUpMode();
mfiore 0:c62615f15125 1619
mfiore 0:c62615f15125 1620 int32_t setRxDataRate(const uint8_t& dr);
mfiore 0:c62615f15125 1621 uint8_t getRxDataRate();
mfiore 0:c62615f15125 1622
mfiore 0:c62615f15125 1623 // get/set TX/RX frequency
mfiore 0:c62615f15125 1624 // if set to 0, device will hop frequencies
mfiore 0:c62615f15125 1625 // set function returns MDOT_OK if success
mfiore 0:c62615f15125 1626 int32_t setTxFrequency(const uint32_t& freq);
mfiore 0:c62615f15125 1627 uint32_t getTxFrequency();
mfiore 0:c62615f15125 1628 int32_t setRxFrequency(const uint32_t& freq);
mfiore 0:c62615f15125 1629 uint32_t getRxFrequency();
mfiore 0:c62615f15125 1630
mfiore 0:c62615f15125 1631 // get/set RX output mode
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 1632 // valid options are HEXADECIMAL, BINARY, and EXTENDED
mfiore 0:c62615f15125 1633 // set function returns MDOT_OK if success
mfiore 0:c62615f15125 1634 int32_t setRxOutput(const uint8_t& mode);
mfiore 0:c62615f15125 1635 uint8_t getRxOutput();
mfiore 0:c62615f15125 1636
mfiore 0:c62615f15125 1637 // get/set serial wake interval
mfiore 0:c62615f15125 1638 // valid values are 2 s - INT_MAX (2147483647) s
mfiore 0:c62615f15125 1639 // set function returns MDOT_OK if success
Mike Fiore 7:683dba5d576f 1640 int32_t setWakeInterval(const uint32_t& interval);
Mike Fiore 7:683dba5d576f 1641 uint32_t getWakeInterval();
mfiore 0:c62615f15125 1642
mfiore 0:c62615f15125 1643 // get/set serial wake delay
mfiore 0:c62615f15125 1644 // valid values are 2 ms - INT_MAX (2147483647) ms
mfiore 0:c62615f15125 1645 // set function returns MDOT_OK if success
Mike Fiore 7:683dba5d576f 1646 int32_t setWakeDelay(const uint32_t& delay);
Mike Fiore 7:683dba5d576f 1647 uint32_t getWakeDelay();
mfiore 0:c62615f15125 1648
mfiore 0:c62615f15125 1649 // get/set serial receive timeout
mfiore 0:c62615f15125 1650 // valid values are 0 ms - 65000 ms
mfiore 0:c62615f15125 1651 // set function returns MDOT_OK if success
Mike Fiore 7:683dba5d576f 1652 int32_t setWakeTimeout(const uint16_t& timeout);
Mike Fiore 7:683dba5d576f 1653 uint16_t getWakeTimeout();
Mike Fiore 7:683dba5d576f 1654
Mike Fiore 7:683dba5d576f 1655 // get/set serial wake mode
Mike Fiore 7:683dba5d576f 1656 // valid values are INTERRUPT or RTC_ALARM
Mike Fiore 7:683dba5d576f 1657 // set function returns MDOT_OK if success
Mike Fiore 7:683dba5d576f 1658 int32_t setWakeMode(const uint8_t& delay);
Mike Fiore 7:683dba5d576f 1659 uint8_t getWakeMode();
Mike Fiore 7:683dba5d576f 1660
Mike Fiore 12:54f9cac9d690 1661 // get/set serial flow control enabled
Mike Fiore 12:54f9cac9d690 1662 // set function returns MDOT_OK if success
Mike Fiore 12:54f9cac9d690 1663 int32_t setFlowControl(const bool& on);
Mike Fiore 12:54f9cac9d690 1664 bool getFlowControl();
Mike Fiore 12:54f9cac9d690 1665
Mike Fiore 12:54f9cac9d690 1666 // get/set serial clear on error
Mike Fiore 12:54f9cac9d690 1667 // if enabled the data read from the serial port will be discarded if it cannot be sent or if the send fails
Mike Fiore 11:d8464345e1f1 1668 // set function returns MDOT_OK if success
Mike Fiore 12:54f9cac9d690 1669 int32_t setSerialClearOnError(const bool& on);
Mike Fiore 12:54f9cac9d690 1670 bool getSerialClearOnError();
mfiore 0:c62615f15125 1671
mfiore 0:c62615f15125 1672 // MTS_RADIO_DEBUG_COMMANDS
Mike Fiore 7:683dba5d576f 1673
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1674 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1675 * Disable Duty cycle
Mike Fiore 16:b630e18103e5 1676 * enables or disables the duty cycle limitations
Mike Fiore 16:b630e18103e5 1677 * **** ONLY TO BE USED FOR TESTINGS PURPOSES ****
Mike Fiore 16:b630e18103e5 1678 * **** ALL DEPLOYABLE CODE MUST ADHERE TO LOCAL REGULATIONS ****
Mike Fiore 16:b630e18103e5 1679 * **** THIS SETTING WILL NOT BE SAVED TO CONFIGURATION *****
Mike Fiore 16:b630e18103e5 1680 * @param val true to disable duty-cycle (default:false)
Mike Fiore 16:b630e18103e5 1681 */
Mike Fiore 16:b630e18103e5 1682 int32_t setDisableDutyCycle(bool val);
Mike Fiore 16:b630e18103e5 1683
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1684 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1685 * Disable Duty cycle
Mike Fiore 16:b630e18103e5 1686 * **** ONLY TO BE USED FOR TESTINGS PURPOSES ****
Mike Fiore 16:b630e18103e5 1687 * **** ALL DEPLOYABLE CODE MUST ADHERE TO LOCAL REGULATIONS ****
Mike Fiore 16:b630e18103e5 1688 * **** THIS SETTING WILL NOT BE SAVED TO CONFIGURATION *****
Mike Fiore 16:b630e18103e5 1689 * @return true if duty-cycle is disabled (default:false)
Mike Fiore 16:b630e18103e5 1690 */
Mike Fiore 16:b630e18103e5 1691 uint8_t getDisableDutyCycle();
Mike Fiore 16:b630e18103e5 1692
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1693 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1694 * LBT RSSI
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1695 * @return the current RSSI on the configured frequency (SetTxFrequency) using configured LBT Time
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1696 */
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1697 int16_t lbtRssi();
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1698
Mike Fiore 7:683dba5d576f 1699 void openRxWindow(uint32_t timeout, uint8_t bandwidth = 0);
Mike Fiore 16:b630e18103e5 1700 void closeRxWindow();
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 1701 void sendContinuous(bool enable=true, uint32_t timeout=0, uint32_t frequency=0, int8_t txpower=-1);
mfiore 0:c62615f15125 1702 int32_t setDeviceId(const std::vector<uint8_t>& id);
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 1703 int32_t setProtectedAppEUI(const std::vector<uint8_t>& appEUI);
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 1704 int32_t setProtectedAppKey(const std::vector<uint8_t>& appKey);
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1705 int32_t setDefaultFrequencyBand(const uint8_t& band);
mfiore 0:c62615f15125 1706 bool saveProtectedConfig();
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 1707 // resets the radio/mac/link
mfiore 0:c62615f15125 1708 void resetRadio();
mfiore 0:c62615f15125 1709 int32_t setRadioMode(const uint8_t& mode);
mfiore 0:c62615f15125 1710 std::map<uint8_t, uint8_t> dumpRegisters();
mfiore 0:c62615f15125 1711 void eraseFlash();
mfiore 0:c62615f15125 1712
Mike Fiore 11:d8464345e1f1 1713 void setWakeupCallback(void (*function)(void));
Mike Fiore 11:d8464345e1f1 1714
Mike Fiore 11:d8464345e1f1 1715 template<typename T>
Mike Fiore 11:d8464345e1f1 1716 void setWakeupCallback(T *object, void (T::*member)(void)) {
Mike Fiore 11:d8464345e1f1 1717 _wakeup_callback.attach(object, member);
Mike Fiore 11:d8464345e1f1 1718 }
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 1719
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 1720 lora::ChannelPlan* getChannelPlan(void);
Mike Fiore 11:d8464345e1f1 1721
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 1722 uint32_t setRx2DataRate(uint8_t dr);
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 1723 uint8_t getRx2DataRate();
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 1724
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 1725 void mcGroupKeys(uint8_t *mcKeyEncrypt, uint32_t addr, uint8_t groupId, uint32_t frame_count);
mfiore 0:c62615f15125 1726 private:
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 1727
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 1728 void sleep_ms(uint32_t interval,
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 1729 uint8_t wakeup_mode = RTC_ALARM,
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 1730 bool deepsleep = true);
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 1731
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 1732
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 1733 void wakeup();
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 1734
mfiore 0:c62615f15125 1735 mdot_stats _stats;
mfiore 0:c62615f15125 1736
Jenkins@KEILDM1.dc.multitech.prv 69:e22889c7eaa9 1737 FunctionPointer _wakeup_callback;
Mike Fiore 11:d8464345e1f1 1738
Mike Fiore 12:54f9cac9d690 1739 bool _standbyFlag;
Mike Fiore 12:54f9cac9d690 1740 bool _testMode;
Mike Fiore 12:54f9cac9d690 1741 uint8_t _savedPort;
Mike Fiore 12:54f9cac9d690 1742 void handleTestModePacket();
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1743 lora::ChannelPlan* _plan;
mfiore 0:c62615f15125 1744 };
mfiore 0:c62615f15125 1745
mfiore 0:c62615f15125 1746 #endif