libmDot0mbed5
Fork of libmDot-mbed5 by
mDot.h@60:d58af0eae613, 2017-07-13 (annotated)
- Committer:
- efersko
- Date:
- Thu Jul 13 19:03:33 2017 +0000
- Revision:
- 60:d58af0eae613
- Parent:
- 43:ba29a595814e
No change
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jreiss | 9:ec2fffe31793 | 1 | // TODO: add license header |
mfiore | 0:c62615f15125 | 2 | |
mfiore | 0:c62615f15125 | 3 | #ifndef MDOT_H |
mfiore | 0:c62615f15125 | 4 | #define MDOT_H |
mfiore | 0:c62615f15125 | 5 | |
mfiore | 0:c62615f15125 | 6 | #include "mbed.h" |
mfiore | 0:c62615f15125 | 7 | #include "rtos.h" |
Mike Fiore |
16:b630e18103e5 | 8 | #include "Mote.h" |
mfiore | 0:c62615f15125 | 9 | #include <vector> |
mfiore | 0:c62615f15125 | 10 | #include <map> |
mfiore | 0:c62615f15125 | 11 | #include <string> |
mfiore | 0:c62615f15125 | 12 | |
Mike Fiore |
12:54f9cac9d690 | 13 | class mDotEvent; |
mfiore | 0:c62615f15125 | 14 | class LoRaConfig; |
mfiore | 0:c62615f15125 | 15 | |
mfiore | 0:c62615f15125 | 16 | class mDot { |
Mike Fiore |
16:b630e18103e5 | 17 | friend class mDotEvent; |
mfiore | 0:c62615f15125 | 18 | |
mfiore | 0:c62615f15125 | 19 | private: |
mfiore | 0:c62615f15125 | 20 | |
mfiore | 0:c62615f15125 | 21 | mDot(); |
mfiore | 0:c62615f15125 | 22 | ~mDot(); |
mfiore | 0:c62615f15125 | 23 | |
Mike Fiore |
16:b630e18103e5 | 24 | void initLora(); |
Mike Fiore |
16:b630e18103e5 | 25 | |
mfiore | 0:c62615f15125 | 26 | void setLastError(const std::string& str); |
mfiore | 0:c62615f15125 | 27 | |
mfiore | 0:c62615f15125 | 28 | static bool validateBaudRate(const uint32_t& baud); |
mfiore | 0:c62615f15125 | 29 | static bool validateFrequencySubBand(const uint8_t& band); |
mfiore | 0:c62615f15125 | 30 | bool validateDataRate(const uint8_t& dr); |
mfiore | 0:c62615f15125 | 31 | |
mfiore | 0:c62615f15125 | 32 | int32_t joinBase(const uint32_t& retries); |
mfiore | 0:c62615f15125 | 33 | int32_t sendBase(const std::vector<uint8_t>& data, const bool& confirmed = false, const bool& blocking = true, const bool& highBw = false); |
mfiore | 0:c62615f15125 | 34 | void waitForPacket(); |
mfiore | 0:c62615f15125 | 35 | void waitForLinkCheck(); |
mfiore | 0:c62615f15125 | 36 | |
mfiore | 0:c62615f15125 | 37 | void setActivityLedState(const uint8_t& state); |
mfiore | 0:c62615f15125 | 38 | uint8_t getActivityLedState(); |
mfiore | 0:c62615f15125 | 39 | |
mfiore | 0:c62615f15125 | 40 | void blinkActivityLed(void) { |
Mike Fiore |
6:390fc83d588d | 41 | if (_activity_led) { |
Mike Fiore |
6:390fc83d588d | 42 | int val = _activity_led->read(); |
Mike Fiore |
6:390fc83d588d | 43 | _activity_led->write(!val); |
Mike Fiore |
6:390fc83d588d | 44 | } |
mfiore | 0:c62615f15125 | 45 | } |
mfiore | 0:c62615f15125 | 46 | |
mfiore | 0:c62615f15125 | 47 | mDot(const mDot&); |
mfiore | 0:c62615f15125 | 48 | mDot& operator=(const mDot&); |
mfiore | 0:c62615f15125 | 49 | |
Mike Fiore |
7:683dba5d576f | 50 | uint32_t RTC_ReadBackupRegister(uint32_t RTC_BKP_DR); |
Mike Fiore |
7:683dba5d576f | 51 | void RTC_WriteBackupRegister(uint32_t RTC_BKP_DR, uint32_t Data); |
Mike Fiore |
7:683dba5d576f | 52 | |
Mike Fiore |
7:683dba5d576f | 53 | void wakeup(); |
Mike Fiore |
7:683dba5d576f | 54 | |
Mike Fiore |
12:54f9cac9d690 | 55 | void enterStopMode(const uint32_t& interval, const uint8_t& wakeup_mode = RTC_ALARM); |
Mike Fiore |
12:54f9cac9d690 | 56 | void enterStandbyMode(const uint32_t& interval, const uint8_t& wakeup_mode = RTC_ALARM); |
Mike Fiore |
12:54f9cac9d690 | 57 | |
mfiore | 0:c62615f15125 | 58 | static mDot* _instance; |
mfiore | 0:c62615f15125 | 59 | |
Mike Fiore |
16:b630e18103e5 | 60 | lora::Mote _mote; |
mfiore | 0:c62615f15125 | 61 | LoRaConfig* _config; |
Mike Fiore |
16:b630e18103e5 | 62 | lora::Settings _settings; |
Mike Fiore |
16:b630e18103e5 | 63 | mDotEvent* _events; |
Mike Fiore |
16:b630e18103e5 | 64 | |
mfiore | 0:c62615f15125 | 65 | std::string _last_error; |
mfiore | 0:c62615f15125 | 66 | static const uint32_t _baud_rates[]; |
mfiore | 0:c62615f15125 | 67 | uint8_t _activity_led_state; |
mfiore | 0:c62615f15125 | 68 | Ticker _tick; |
Mike Fiore |
6:390fc83d588d | 69 | DigitalOut* _activity_led; |
Mike Fiore |
6:390fc83d588d | 70 | bool _activity_led_enable; |
Mike Fiore |
6:390fc83d588d | 71 | PinName _activity_led_pin; |
Mike Fiore |
5:0bfe6a650513 | 72 | bool _activity_led_external; |
jreiss | 9:ec2fffe31793 | 73 | uint8_t _linkFailCount; |
Mike Fiore |
7:683dba5d576f | 74 | uint8_t _class; |
Mike Fiore |
7:683dba5d576f | 75 | InterruptIn* _wakeup; |
Mike Fiore |
7:683dba5d576f | 76 | PinName _wakeup_pin; |
mfiore | 0:c62615f15125 | 77 | |
mfiore | 0:c62615f15125 | 78 | typedef enum { |
Jason Reiss |
10:27dafba9fe19 | 79 | OFF, |
Jason Reiss |
10:27dafba9fe19 | 80 | ON, |
Jason Reiss |
10:27dafba9fe19 | 81 | BLINK, |
mfiore | 0:c62615f15125 | 82 | } state; |
mfiore | 0:c62615f15125 | 83 | |
mfiore | 0:c62615f15125 | 84 | public: |
mfiore | 0:c62615f15125 | 85 | |
Jenkins@KEILDM1.dc.multitech.prv | 19:f3a46d2bb9b3 | 86 | #if defined(TARGET_MTS_MDOT_F411RE) |
mfiore | 0:c62615f15125 | 87 | typedef enum { |
Mike Fiore |
7:683dba5d576f | 88 | FM_APPEND = (1 << 0), |
Mike Fiore |
7:683dba5d576f | 89 | FM_TRUNC = (1 << 1), |
Mike Fiore |
7:683dba5d576f | 90 | FM_CREAT = (1 << 2), |
Mike Fiore |
7:683dba5d576f | 91 | FM_RDONLY = (1 << 3), |
Mike Fiore |
7:683dba5d576f | 92 | FM_WRONLY = (1 << 4), |
Mike Fiore |
7:683dba5d576f | 93 | FM_RDWR = (FM_RDONLY | FM_WRONLY), |
Mike Fiore |
7:683dba5d576f | 94 | FM_DIRECT = (1 << 5) |
Mike Fiore |
7:683dba5d576f | 95 | } FileMode; |
Jenkins@KEILDM1.dc.multitech.prv | 19:f3a46d2bb9b3 | 96 | #endif /* TARGET_MTS_MDOT_F411RE */ |
Mike Fiore |
7:683dba5d576f | 97 | |
Mike Fiore |
7:683dba5d576f | 98 | typedef enum { |
mfiore | 0:c62615f15125 | 99 | MDOT_OK = 0, |
mfiore | 0:c62615f15125 | 100 | MDOT_INVALID_PARAM = -1, |
mfiore | 0:c62615f15125 | 101 | MDOT_TX_ERROR = -2, |
mfiore | 0:c62615f15125 | 102 | MDOT_RX_ERROR = -3, |
mfiore | 0:c62615f15125 | 103 | MDOT_JOIN_ERROR = -4, |
mfiore | 0:c62615f15125 | 104 | MDOT_TIMEOUT = -5, |
mfiore | 0:c62615f15125 | 105 | MDOT_NOT_JOINED = -6, |
mfiore | 0:c62615f15125 | 106 | MDOT_ENCRYPTION_DISABLED = -7, |
mfiore | 0:c62615f15125 | 107 | MDOT_NO_FREE_CHAN = -8, |
Mike Fiore |
12:54f9cac9d690 | 108 | MDOT_TEST_MODE = -9, |
Mike Fiore |
12:54f9cac9d690 | 109 | MDOT_NO_ENABLED_CHAN = -10, |
Mike Fiore |
12:54f9cac9d690 | 110 | MDOT_AGGREGATED_DUTY_CYCLE = -11, |
Jenkins@KEILDM1.dc.multitech.prv | 43:ba29a595814e | 111 | MDOT_MAX_PAYLOAD_EXCEEDED = -12, |
mfiore | 0:c62615f15125 | 112 | MDOT_ERROR = -1024, |
mfiore | 0:c62615f15125 | 113 | } mdot_ret_code; |
mfiore | 0:c62615f15125 | 114 | |
mfiore | 0:c62615f15125 | 115 | enum JoinMode { |
Mike Fiore |
16:b630e18103e5 | 116 | MANUAL = 0, |
Jason Reiss |
10:27dafba9fe19 | 117 | OTA, |
Mike Fiore |
12:54f9cac9d690 | 118 | AUTO_OTA, |
Mike Fiore |
12:54f9cac9d690 | 119 | PEER_TO_PEER |
mfiore | 0:c62615f15125 | 120 | }; |
mfiore | 0:c62615f15125 | 121 | |
mfiore | 0:c62615f15125 | 122 | enum Mode { |
Jason Reiss |
10:27dafba9fe19 | 123 | COMMAND_MODE, |
Jason Reiss |
10:27dafba9fe19 | 124 | SERIAL_MODE |
mfiore | 0:c62615f15125 | 125 | }; |
mfiore | 0:c62615f15125 | 126 | |
mfiore | 0:c62615f15125 | 127 | enum RX_Output { |
Jason Reiss |
10:27dafba9fe19 | 128 | HEXADECIMAL, |
Jason Reiss |
10:27dafba9fe19 | 129 | BINARY |
mfiore | 0:c62615f15125 | 130 | }; |
mfiore | 0:c62615f15125 | 131 | |
mfiore | 0:c62615f15125 | 132 | enum DataRates { |
Mike Fiore |
12:54f9cac9d690 | 133 | DR0, |
Mike Fiore |
12:54f9cac9d690 | 134 | DR1, |
Mike Fiore |
12:54f9cac9d690 | 135 | DR2, |
Mike Fiore |
12:54f9cac9d690 | 136 | DR3, |
Mike Fiore |
12:54f9cac9d690 | 137 | DR4, |
Mike Fiore |
12:54f9cac9d690 | 138 | DR5, |
Mike Fiore |
12:54f9cac9d690 | 139 | DR6, |
Mike Fiore |
12:54f9cac9d690 | 140 | DR7, |
Mike Fiore |
12:54f9cac9d690 | 141 | DR8, |
Mike Fiore |
12:54f9cac9d690 | 142 | DR9, |
Mike Fiore |
12:54f9cac9d690 | 143 | DR10, |
Mike Fiore |
12:54f9cac9d690 | 144 | DR11, |
Mike Fiore |
12:54f9cac9d690 | 145 | DR12, |
Mike Fiore |
12:54f9cac9d690 | 146 | DR13, |
Mike Fiore |
12:54f9cac9d690 | 147 | DR14, |
Mike Fiore |
12:54f9cac9d690 | 148 | DR15, |
Mike Fiore |
12:54f9cac9d690 | 149 | SF_12 = 16, |
Jason Reiss |
10:27dafba9fe19 | 150 | SF_11, |
Jason Reiss |
10:27dafba9fe19 | 151 | SF_10, |
Jason Reiss |
10:27dafba9fe19 | 152 | SF_9, |
Jason Reiss |
10:27dafba9fe19 | 153 | SF_8, |
Jason Reiss |
10:27dafba9fe19 | 154 | SF_7, |
Jason Reiss |
10:27dafba9fe19 | 155 | SF_7H, |
Mike Fiore |
12:54f9cac9d690 | 156 | SF_FSK |
mfiore | 0:c62615f15125 | 157 | }; |
mfiore | 0:c62615f15125 | 158 | |
mfiore | 0:c62615f15125 | 159 | enum FrequencyBands { |
Mike Fiore |
16:b630e18103e5 | 160 | FB_868 = 0, |
Mike Fiore |
16:b630e18103e5 | 161 | FB_915 = 1, |
Mike Fiore |
16:b630e18103e5 | 162 | FB_EU868 = 0, // EU868 |
Mike Fiore |
16:b630e18103e5 | 163 | FB_US915 = 1, // US915 |
Mike Fiore |
16:b630e18103e5 | 164 | FB_AU915 = 2 |
mfiore | 0:c62615f15125 | 165 | }; |
mfiore | 0:c62615f15125 | 166 | |
mfiore | 0:c62615f15125 | 167 | enum FrequencySubBands { |
Jason Reiss |
10:27dafba9fe19 | 168 | FSB_ALL, |
Jason Reiss |
10:27dafba9fe19 | 169 | FSB_1, |
Jason Reiss |
10:27dafba9fe19 | 170 | FSB_2, |
Jason Reiss |
10:27dafba9fe19 | 171 | FSB_3, |
Jason Reiss |
10:27dafba9fe19 | 172 | FSB_4, |
Jason Reiss |
10:27dafba9fe19 | 173 | FSB_5, |
Jason Reiss |
10:27dafba9fe19 | 174 | FSB_6, |
Jason Reiss |
10:27dafba9fe19 | 175 | FSB_7, |
Jason Reiss |
10:27dafba9fe19 | 176 | FSB_8 |
mfiore | 0:c62615f15125 | 177 | }; |
mfiore | 0:c62615f15125 | 178 | |
Mike Fiore |
6:390fc83d588d | 179 | enum JoinByteOrder { |
Jason Reiss |
10:27dafba9fe19 | 180 | LSB, |
Jason Reiss |
10:27dafba9fe19 | 181 | MSB |
Mike Fiore |
6:390fc83d588d | 182 | }; |
Mike Fiore |
6:390fc83d588d | 183 | |
Mike Fiore |
7:683dba5d576f | 184 | enum wakeup_mode { |
Jason Reiss |
10:27dafba9fe19 | 185 | RTC_ALARM, |
Jason Reiss |
10:27dafba9fe19 | 186 | INTERRUPT, |
Jason Reiss |
10:27dafba9fe19 | 187 | RTC_ALARM_OR_INTERRUPT |
Mike Fiore |
7:683dba5d576f | 188 | }; |
Mike Fiore |
7:683dba5d576f | 189 | |
jreiss | 9:ec2fffe31793 | 190 | enum UserBackupRegs { |
Jason Reiss |
10:27dafba9fe19 | 191 | UBR0, |
Jason Reiss |
10:27dafba9fe19 | 192 | UBR1, |
Jason Reiss |
10:27dafba9fe19 | 193 | UBR2, |
Jason Reiss |
10:27dafba9fe19 | 194 | UBR3, |
Jason Reiss |
10:27dafba9fe19 | 195 | UBR4, |
Jason Reiss |
10:27dafba9fe19 | 196 | UBR5, |
Jason Reiss |
10:27dafba9fe19 | 197 | UBR6, |
Jason Reiss |
10:27dafba9fe19 | 198 | UBR7, |
Jason Reiss |
10:27dafba9fe19 | 199 | UBR8, |
Jason Reiss |
10:27dafba9fe19 | 200 | UBR9 |
Jenkins@KEILDM1.dc.multitech.prv | 19:f3a46d2bb9b3 | 201 | #if defined (TARGET_XDOT_L151CC) |
Jenkins@KEILDM1.dc.multitech.prv | 19:f3a46d2bb9b3 | 202 | ,UBR10, |
Jenkins@KEILDM1.dc.multitech.prv | 19:f3a46d2bb9b3 | 203 | UBR11, |
Jenkins@KEILDM1.dc.multitech.prv | 19:f3a46d2bb9b3 | 204 | UBR12, |
Jenkins@KEILDM1.dc.multitech.prv | 19:f3a46d2bb9b3 | 205 | UBR13, |
Jenkins@KEILDM1.dc.multitech.prv | 19:f3a46d2bb9b3 | 206 | UBR14, |
Jenkins@KEILDM1.dc.multitech.prv | 19:f3a46d2bb9b3 | 207 | UBR15, |
Jenkins@KEILDM1.dc.multitech.prv | 19:f3a46d2bb9b3 | 208 | UBR16, |
Jenkins@KEILDM1.dc.multitech.prv | 19:f3a46d2bb9b3 | 209 | UBR17, |
Jenkins@KEILDM1.dc.multitech.prv | 19:f3a46d2bb9b3 | 210 | UBR18, |
Jenkins@KEILDM1.dc.multitech.prv | 19:f3a46d2bb9b3 | 211 | UBR19, |
Jenkins@KEILDM1.dc.multitech.prv | 19:f3a46d2bb9b3 | 212 | UBR20, |
Jenkins@KEILDM1.dc.multitech.prv | 19:f3a46d2bb9b3 | 213 | UBR21 |
Jenkins@KEILDM1.dc.multitech.prv | 19:f3a46d2bb9b3 | 214 | #endif /* TARGET_XDOT_L151CC */ |
jreiss | 9:ec2fffe31793 | 215 | }; |
jreiss | 9:ec2fffe31793 | 216 | |
Jenkins@KEILDM1.dc.multitech.prv | 19:f3a46d2bb9b3 | 217 | #if defined(TARGET_MTS_MDOT_F411RE) |
Mike Fiore |
7:683dba5d576f | 218 | typedef struct { |
Mike Fiore |
7:683dba5d576f | 219 | int16_t fd; |
Mike Fiore |
16:b630e18103e5 | 220 | char name[33]; |
Mike Fiore |
7:683dba5d576f | 221 | uint32_t size; |
Mike Fiore |
7:683dba5d576f | 222 | } mdot_file; |
Jenkins@KEILDM1.dc.multitech.prv | 19:f3a46d2bb9b3 | 223 | #endif /* TARGET_MTS_MDOT_F411RE */ |
Mike Fiore |
7:683dba5d576f | 224 | |
mfiore | 0:c62615f15125 | 225 | typedef struct { |
mfiore | 0:c62615f15125 | 226 | uint32_t Up; |
mfiore | 0:c62615f15125 | 227 | uint32_t Down; |
mfiore | 0:c62615f15125 | 228 | uint32_t Joins; |
mfiore | 0:c62615f15125 | 229 | uint32_t JoinFails; |
mfiore | 0:c62615f15125 | 230 | uint32_t MissedAcks; |
Mike Fiore |
16:b630e18103e5 | 231 | uint32_t CRCErrors; |
mfiore | 0:c62615f15125 | 232 | } mdot_stats; |
mfiore | 0:c62615f15125 | 233 | |
mfiore | 0:c62615f15125 | 234 | typedef struct { |
mfiore | 0:c62615f15125 | 235 | int16_t last; |
mfiore | 0:c62615f15125 | 236 | int16_t min; |
mfiore | 0:c62615f15125 | 237 | int16_t max; |
mfiore | 0:c62615f15125 | 238 | int16_t avg; |
mfiore | 0:c62615f15125 | 239 | } rssi_stats; |
mfiore | 0:c62615f15125 | 240 | |
mfiore | 0:c62615f15125 | 241 | typedef struct { |
Mike Fiore |
11:d8464345e1f1 | 242 | int16_t last; |
Mike Fiore |
11:d8464345e1f1 | 243 | int16_t min; |
Mike Fiore |
11:d8464345e1f1 | 244 | int16_t max; |
Mike Fiore |
11:d8464345e1f1 | 245 | int16_t avg; |
mfiore | 0:c62615f15125 | 246 | } snr_stats; |
mfiore | 0:c62615f15125 | 247 | |
mfiore | 0:c62615f15125 | 248 | typedef struct { |
mfiore | 0:c62615f15125 | 249 | bool status; |
mfiore | 0:c62615f15125 | 250 | int32_t dBm; |
mfiore | 0:c62615f15125 | 251 | uint32_t gateways; |
mfiore | 0:c62615f15125 | 252 | std::vector<uint8_t> payload; |
mfiore | 0:c62615f15125 | 253 | } link_check; |
mfiore | 0:c62615f15125 | 254 | |
mfiore | 0:c62615f15125 | 255 | typedef struct { |
mfiore | 0:c62615f15125 | 256 | int32_t status; |
mfiore | 0:c62615f15125 | 257 | int16_t rssi; |
mfiore | 0:c62615f15125 | 258 | int16_t snr; |
mfiore | 0:c62615f15125 | 259 | } ping_response; |
mfiore | 0:c62615f15125 | 260 | |
mfiore | 0:c62615f15125 | 261 | static const uint8_t MaxLengths_915[]; |
mfiore | 0:c62615f15125 | 262 | static const uint8_t MaxLengths_868[]; |
mfiore | 0:c62615f15125 | 263 | |
mfiore | 0:c62615f15125 | 264 | static std::string JoinModeStr(uint8_t mode); |
mfiore | 0:c62615f15125 | 265 | static std::string ModeStr(uint8_t mode); |
mfiore | 0:c62615f15125 | 266 | static std::string RxOutputStr(uint8_t format); |
mfiore | 0:c62615f15125 | 267 | static std::string DataRateStr(uint8_t rate); |
mfiore | 0:c62615f15125 | 268 | static std::string FrequencyBandStr(uint8_t band); |
mfiore | 0:c62615f15125 | 269 | static std::string FrequencySubBandStr(uint8_t band); |
mfiore | 0:c62615f15125 | 270 | |
Jenkins@KEILDM1.dc.multitech.prv | 19:f3a46d2bb9b3 | 271 | #if defined(TARGET_MTS_MDOT_F411RE) |
jreiss | 9:ec2fffe31793 | 272 | uint32_t UserRegisters[10]; |
Jenkins@KEILDM1.dc.multitech.prv | 19:f3a46d2bb9b3 | 273 | #else |
Jenkins@KEILDM1.dc.multitech.prv | 19:f3a46d2bb9b3 | 274 | uint32_t UserRegisters[22]; |
Jenkins@KEILDM1.dc.multitech.prv | 19:f3a46d2bb9b3 | 275 | #endif /* TARGET_MTS_MDOT_F411RE */ |
jreiss | 9:ec2fffe31793 | 276 | |
mfiore | 0:c62615f15125 | 277 | /** Get a handle to the singleton object |
mfiore | 0:c62615f15125 | 278 | * @returns pointer to mDot object |
mfiore | 0:c62615f15125 | 279 | */ |
mfiore | 0:c62615f15125 | 280 | static mDot* getInstance(); |
mfiore | 0:c62615f15125 | 281 | |
Mike Fiore |
12:54f9cac9d690 | 282 | void setEvents(mDotEvent* events); |
Mike Fiore |
12:54f9cac9d690 | 283 | |
mfiore | 0:c62615f15125 | 284 | /** Get library version information |
mfiore | 0:c62615f15125 | 285 | * @returns string containing library version information |
mfiore | 0:c62615f15125 | 286 | */ |
mfiore | 0:c62615f15125 | 287 | std::string getId(); |
mfiore | 0:c62615f15125 | 288 | |
mfiore | 0:c62615f15125 | 289 | /** Perform a soft reset of the system |
mfiore | 0:c62615f15125 | 290 | */ |
mfiore | 0:c62615f15125 | 291 | void resetCpu(); |
mfiore | 0:c62615f15125 | 292 | |
mfiore | 0:c62615f15125 | 293 | /** Reset config to factory default |
mfiore | 0:c62615f15125 | 294 | */ |
mfiore | 0:c62615f15125 | 295 | void resetConfig(); |
mfiore | 0:c62615f15125 | 296 | |
mfiore | 0:c62615f15125 | 297 | /** Save config data to non volatile memory |
mfiore | 0:c62615f15125 | 298 | * @returns true if success, false if failure |
mfiore | 0:c62615f15125 | 299 | */ |
mfiore | 0:c62615f15125 | 300 | bool saveConfig(); |
mfiore | 0:c62615f15125 | 301 | |
mfiore | 0:c62615f15125 | 302 | /** Set the log level for the library |
mfiore | 0:c62615f15125 | 303 | * options are: |
mfiore | 0:c62615f15125 | 304 | * NONE_LEVEL - logging is off at this level |
mfiore | 0:c62615f15125 | 305 | * FATAL_LEVEL - only critical errors will be reported |
mfiore | 0:c62615f15125 | 306 | * ERROR_LEVEL |
mfiore | 0:c62615f15125 | 307 | * WARNING_LEVEL |
mfiore | 0:c62615f15125 | 308 | * INFO_LEVEL |
mfiore | 0:c62615f15125 | 309 | * DEBUG_LEVEL |
mfiore | 0:c62615f15125 | 310 | * TRACE_LEVEL - every detail will be reported |
mfiore | 0:c62615f15125 | 311 | * @param level the level to log at |
mfiore | 0:c62615f15125 | 312 | * @returns MDOT_OK if success |
mfiore | 0:c62615f15125 | 313 | */ |
mfiore | 0:c62615f15125 | 314 | int32_t setLogLevel(const uint8_t& level); |
mfiore | 0:c62615f15125 | 315 | |
mfiore | 0:c62615f15125 | 316 | /** Get the current log level for the library |
mfiore | 0:c62615f15125 | 317 | * @returns current log level |
mfiore | 0:c62615f15125 | 318 | */ |
Mike Fiore |
6:390fc83d588d | 319 | uint8_t getLogLevel(); |
Mike Fiore |
6:390fc83d588d | 320 | |
Mike Fiore |
12:54f9cac9d690 | 321 | /** Seed pseudo RNG in LoRaMac layer, uses random value from radio RSSI reading by default |
Mike Fiore |
12:54f9cac9d690 | 322 | * @param seed for RNG |
Mike Fiore |
12:54f9cac9d690 | 323 | */ |
Mike Fiore |
12:54f9cac9d690 | 324 | void seedRandom(uint32_t seed); |
Mike Fiore |
12:54f9cac9d690 | 325 | |
Mike Fiore |
6:390fc83d588d | 326 | /** Enable or disable the activity LED. |
Mike Fiore |
6:390fc83d588d | 327 | * @param enable true to enable the LED, false to disable |
Mike Fiore |
6:390fc83d588d | 328 | */ |
Mike Fiore |
6:390fc83d588d | 329 | void setActivityLedEnable(const bool& enable); |
Mike Fiore |
4:94969e981dcc | 330 | |
Mike Fiore |
6:390fc83d588d | 331 | /** Find out if the activity LED is enabled |
Mike Fiore |
6:390fc83d588d | 332 | * @returns true if activity LED is enabled, false if disabled |
Mike Fiore |
6:390fc83d588d | 333 | */ |
Mike Fiore |
6:390fc83d588d | 334 | bool getActivityLedEnable(); |
Mike Fiore |
6:390fc83d588d | 335 | |
Mike Fiore |
6:390fc83d588d | 336 | /** Use a different pin for the activity LED. |
Mike Fiore |
6:390fc83d588d | 337 | * The default is XBEE_RSSI. |
Mike Fiore |
6:390fc83d588d | 338 | * @param pin the new pin to use |
Mike Fiore |
6:390fc83d588d | 339 | */ |
Mike Fiore |
6:390fc83d588d | 340 | void setActivityLedPin(const PinName& pin); |
Mike Fiore |
6:390fc83d588d | 341 | |
Mike Fiore |
5:0bfe6a650513 | 342 | /** Use an external DigitalOut object for the activity LED. |
Mike Fiore |
5:0bfe6a650513 | 343 | * The pointer must stay valid! |
Mike Fiore |
5:0bfe6a650513 | 344 | * @param pin the DigitalOut object to use |
Mike Fiore |
5:0bfe6a650513 | 345 | */ |
Mike Fiore |
5:0bfe6a650513 | 346 | void setActivityLedPin(DigitalOut* pin); |
Mike Fiore |
6:390fc83d588d | 347 | |
Mike Fiore |
6:390fc83d588d | 348 | /** Find out what pin the activity LED is on |
Mike Fiore |
6:390fc83d588d | 349 | * @returns the pin the activity LED is using |
Mike Fiore |
6:390fc83d588d | 350 | */ |
Mike Fiore |
6:390fc83d588d | 351 | PinName getActivityLedPin(); |
mfiore | 0:c62615f15125 | 352 | |
Mike Fiore |
12:54f9cac9d690 | 353 | /** Returns boolean indicative of start-up from standby mode |
Mike Fiore |
12:54f9cac9d690 | 354 | * @returns true if dot woke from standby |
Mike Fiore |
12:54f9cac9d690 | 355 | */ |
Mike Fiore |
12:54f9cac9d690 | 356 | bool getStandbyFlag(); |
Mike Fiore |
12:54f9cac9d690 | 357 | |
Mike Fiore |
16:b630e18103e5 | 358 | std::vector<uint16_t> getChannelMask(); |
Mike Fiore |
16:b630e18103e5 | 359 | |
Mike Fiore |
16:b630e18103e5 | 360 | int32_t setChannelMask(uint8_t offset, uint16_t mask); |
Mike Fiore |
16:b630e18103e5 | 361 | |
Mike Fiore |
12:54f9cac9d690 | 362 | /** Add a channel frequencies currently in use |
Mike Fiore |
12:54f9cac9d690 | 363 | * @returns MDOT_OK |
Mike Fiore |
12:54f9cac9d690 | 364 | */ |
Mike Fiore |
12:54f9cac9d690 | 365 | int32_t addChannel(uint8_t index, uint32_t frequency, uint8_t datarateRange); |
Mike Fiore |
12:54f9cac9d690 | 366 | |
mfiore | 0:c62615f15125 | 367 | /** Get list of channel frequencies currently in use |
mfiore | 0:c62615f15125 | 368 | * @returns vector of channels currently in use |
mfiore | 0:c62615f15125 | 369 | */ |
mfiore | 0:c62615f15125 | 370 | std::vector<uint32_t> getChannels(); |
mfiore | 0:c62615f15125 | 371 | |
Mike Fiore |
12:54f9cac9d690 | 372 | /** Get list of channel datarate ranges currently in use |
Mike Fiore |
12:54f9cac9d690 | 373 | * @returns vector of datarate ranges currently in use |
Mike Fiore |
12:54f9cac9d690 | 374 | */ |
Mike Fiore |
12:54f9cac9d690 | 375 | std::vector<uint8_t> getChannelRanges(); |
Mike Fiore |
12:54f9cac9d690 | 376 | |
Mike Fiore |
12:54f9cac9d690 | 377 | /** Get list of channel frequencies in config file to be used as session defaults |
Mike Fiore |
12:54f9cac9d690 | 378 | * @returns vector of channels in config file |
Mike Fiore |
12:54f9cac9d690 | 379 | */ |
Mike Fiore |
12:54f9cac9d690 | 380 | std::vector<uint32_t> getConfigChannels(); |
Mike Fiore |
12:54f9cac9d690 | 381 | |
Mike Fiore |
12:54f9cac9d690 | 382 | /** Get list of channel datarate ranges in config file to be used as session defaults |
Mike Fiore |
12:54f9cac9d690 | 383 | * @returns vector of datarate ranges in config file |
Mike Fiore |
12:54f9cac9d690 | 384 | */ |
Mike Fiore |
12:54f9cac9d690 | 385 | std::vector<uint8_t> getConfigChannelRanges(); |
Mike Fiore |
12:54f9cac9d690 | 386 | |
mfiore | 0:c62615f15125 | 387 | /** Get frequency band |
mfiore | 0:c62615f15125 | 388 | * @returns FB_915 if configured for United States, FB_868 if configured for Europe |
mfiore | 0:c62615f15125 | 389 | */ |
mfiore | 0:c62615f15125 | 390 | uint8_t getFrequencyBand(); |
mfiore | 0:c62615f15125 | 391 | |
mfiore | 0:c62615f15125 | 392 | /** Set frequency sub band |
mfiore | 0:c62615f15125 | 393 | * only applicable if frequency band is set for United States (FB_915) |
Jason Reiss |
10:27dafba9fe19 | 394 | * sub band 0 will allow the radio to use all 64 channels |
mfiore | 0:c62615f15125 | 395 | * sub band 1 - 8 will allow the radio to use the 8 channels in that sub band |
mfiore | 0:c62615f15125 | 396 | * for use with Conduit gateway and MTAC_LORA, use sub bands 1 - 8, not sub band 0 |
mfiore | 0:c62615f15125 | 397 | * @param band the sub band to use (0 - 8) |
mfiore | 0:c62615f15125 | 398 | * @returns MDOT_OK if success |
mfiore | 0:c62615f15125 | 399 | */ |
mfiore | 0:c62615f15125 | 400 | int32_t setFrequencySubBand(const uint8_t& band); |
mfiore | 0:c62615f15125 | 401 | |
mfiore | 0:c62615f15125 | 402 | /** Get frequency sub band |
mfiore | 0:c62615f15125 | 403 | * @returns frequency sub band currently in use |
mfiore | 0:c62615f15125 | 404 | */ |
mfiore | 0:c62615f15125 | 405 | uint8_t getFrequencySubBand(); |
mfiore | 0:c62615f15125 | 406 | |
Mike Fiore |
12:54f9cac9d690 | 407 | /** Get the datarate currently in use within the MAC layer |
Mike Fiore |
12:54f9cac9d690 | 408 | * returns 0-15 |
Mike Fiore |
12:54f9cac9d690 | 409 | */ |
Mike Fiore |
12:54f9cac9d690 | 410 | uint8_t getSessionDataRate(); |
Mike Fiore |
12:54f9cac9d690 | 411 | |
mfiore | 0:c62615f15125 | 412 | /** Enable/disable public network mode |
Jason Reiss |
10:27dafba9fe19 | 413 | * JoinDelay will be set to (public: 5s, private: 1s) and |
Jason Reiss |
10:27dafba9fe19 | 414 | * RxDelay will be set to 1s both can be adjusted afterwards |
mfiore | 0:c62615f15125 | 415 | * @param on should be true to enable public network mode |
mfiore | 0:c62615f15125 | 416 | * @returns MDOT_OK if success |
mfiore | 0:c62615f15125 | 417 | */ |
mfiore | 0:c62615f15125 | 418 | int32_t setPublicNetwork(const bool& on); |
mfiore | 0:c62615f15125 | 419 | |
mfiore | 0:c62615f15125 | 420 | /** Get public network mode |
mfiore | 0:c62615f15125 | 421 | * @returns true if public network mode is enabled |
mfiore | 0:c62615f15125 | 422 | */ |
mfiore | 0:c62615f15125 | 423 | bool getPublicNetwork(); |
mfiore | 0:c62615f15125 | 424 | |
mfiore | 0:c62615f15125 | 425 | /** Get the device ID |
mfiore | 0:c62615f15125 | 426 | * @returns vector containing the device ID (size 8) |
mfiore | 0:c62615f15125 | 427 | */ |
mfiore | 0:c62615f15125 | 428 | std::vector<uint8_t> getDeviceId(); |
mfiore | 0:c62615f15125 | 429 | |
Jason Reiss |
10:27dafba9fe19 | 430 | /** Get the device port to be used for lora application data (1-223) |
Jason Reiss |
10:27dafba9fe19 | 431 | * @returns port |
Jason Reiss |
10:27dafba9fe19 | 432 | */ |
Jason Reiss |
10:27dafba9fe19 | 433 | uint8_t getAppPort(); |
Jason Reiss |
10:27dafba9fe19 | 434 | |
Jason Reiss |
10:27dafba9fe19 | 435 | /** Set the device port to be used for lora application data (1-223) |
Jason Reiss |
10:27dafba9fe19 | 436 | * @returns MDOT_OK if success |
Jason Reiss |
10:27dafba9fe19 | 437 | */ |
Jason Reiss |
10:27dafba9fe19 | 438 | int32_t setAppPort(uint8_t port); |
Jason Reiss |
10:27dafba9fe19 | 439 | |
Jason Reiss |
10:27dafba9fe19 | 440 | /** Set the device class A, B or C |
Jason Reiss |
10:27dafba9fe19 | 441 | * @returns MDOT_OK if success |
Jason Reiss |
10:27dafba9fe19 | 442 | */ |
Jason Reiss |
10:27dafba9fe19 | 443 | int32_t setClass(std::string newClass); |
Jason Reiss |
10:27dafba9fe19 | 444 | |
Jason Reiss |
10:27dafba9fe19 | 445 | /** Get the device class A, B or C |
Jason Reiss |
10:27dafba9fe19 | 446 | * @returns MDOT_OK if success |
Jason Reiss |
10:27dafba9fe19 | 447 | */ |
Jason Reiss |
10:27dafba9fe19 | 448 | std::string getClass(); |
Jason Reiss |
10:27dafba9fe19 | 449 | |
Jason Reiss |
10:27dafba9fe19 | 450 | /** Get the max packet length with current settings |
Jason Reiss |
10:27dafba9fe19 | 451 | * @returns max packet length |
Jason Reiss |
10:27dafba9fe19 | 452 | */ |
Jason Reiss |
10:27dafba9fe19 | 453 | uint8_t getMaxPacketLength(); |
Jason Reiss |
10:27dafba9fe19 | 454 | |
mfiore | 0:c62615f15125 | 455 | /** Set network address |
mfiore | 0:c62615f15125 | 456 | * for use with MANUAL network join mode, will be assigned in OTA & AUTO_OTA modes |
mfiore | 0:c62615f15125 | 457 | * @param addr a vector of 4 bytes |
mfiore | 0:c62615f15125 | 458 | * @returns MDOT_OK if success |
mfiore | 0:c62615f15125 | 459 | */ |
mfiore | 0:c62615f15125 | 460 | int32_t setNetworkAddress(const std::vector<uint8_t>& addr); |
mfiore | 0:c62615f15125 | 461 | |
mfiore | 0:c62615f15125 | 462 | /** Get network address |
mfiore | 0:c62615f15125 | 463 | * @returns vector containing network address (size 4) |
mfiore | 0:c62615f15125 | 464 | */ |
mfiore | 0:c62615f15125 | 465 | std::vector<uint8_t> getNetworkAddress(); |
mfiore | 0:c62615f15125 | 466 | |
mfiore | 0:c62615f15125 | 467 | /** Set network session key |
mfiore | 0:c62615f15125 | 468 | * for use with MANUAL network join mode, will be assigned in OTA & AUTO_OTA modes |
mfiore | 0:c62615f15125 | 469 | * @param key a vector of 16 bytes |
mfiore | 0:c62615f15125 | 470 | * @returns MDOT_OK if success |
mfiore | 0:c62615f15125 | 471 | */ |
mfiore | 0:c62615f15125 | 472 | int32_t setNetworkSessionKey(const std::vector<uint8_t>& key); |
mfiore | 0:c62615f15125 | 473 | |
mfiore | 0:c62615f15125 | 474 | /** Get network session key |
mfiore | 0:c62615f15125 | 475 | * @returns vector containing network session key (size 16) |
mfiore | 0:c62615f15125 | 476 | */ |
mfiore | 0:c62615f15125 | 477 | std::vector<uint8_t> getNetworkSessionKey(); |
mfiore | 0:c62615f15125 | 478 | |
mfiore | 0:c62615f15125 | 479 | /** Set data session key |
mfiore | 0:c62615f15125 | 480 | * for use with MANUAL network join mode, will be assigned in OTA & AUTO_OTA modes |
mfiore | 0:c62615f15125 | 481 | * @param key a vector of 16 bytes |
mfiore | 0:c62615f15125 | 482 | * @returns MDOT_OK if success |
mfiore | 0:c62615f15125 | 483 | */ |
mfiore | 0:c62615f15125 | 484 | int32_t setDataSessionKey(const std::vector<uint8_t>& key); |
mfiore | 0:c62615f15125 | 485 | |
mfiore | 0:c62615f15125 | 486 | /** Get data session key |
mfiore | 0:c62615f15125 | 487 | * @returns vector containing data session key (size 16) |
mfiore | 0:c62615f15125 | 488 | */ |
mfiore | 0:c62615f15125 | 489 | std::vector<uint8_t> getDataSessionKey(); |
mfiore | 0:c62615f15125 | 490 | |
mfiore | 0:c62615f15125 | 491 | /** Set network name |
mfiore | 0:c62615f15125 | 492 | * for use with OTA & AUTO_OTA network join modes |
mfiore | 0:c62615f15125 | 493 | * generates network ID (crc64 of name) automatically |
mfiore | 0:c62615f15125 | 494 | * @param name a string of of at least 8 bytes and no more than 128 bytes |
mfiore | 0:c62615f15125 | 495 | * @return MDOT_OK if success |
mfiore | 0:c62615f15125 | 496 | */ |
mfiore | 0:c62615f15125 | 497 | int32_t setNetworkName(const std::string& name); |
mfiore | 0:c62615f15125 | 498 | |
mfiore | 0:c62615f15125 | 499 | /** Get network name |
mfiore | 0:c62615f15125 | 500 | * @return string containing network name (size 8 to 128) |
mfiore | 0:c62615f15125 | 501 | */ |
mfiore | 0:c62615f15125 | 502 | std::string getNetworkName(); |
mfiore | 0:c62615f15125 | 503 | |
mfiore | 0:c62615f15125 | 504 | /** Set network ID |
mfiore | 0:c62615f15125 | 505 | * for use with OTA & AUTO_OTA network join modes |
mfiore | 0:c62615f15125 | 506 | * setting network ID via this function sets network name to empty |
mfiore | 0:c62615f15125 | 507 | * @param id a vector of 8 bytes |
mfiore | 0:c62615f15125 | 508 | * @returns MDOT_OK if success |
mfiore | 0:c62615f15125 | 509 | */ |
mfiore | 0:c62615f15125 | 510 | int32_t setNetworkId(const std::vector<uint8_t>& id); |
mfiore | 0:c62615f15125 | 511 | |
mfiore | 0:c62615f15125 | 512 | /** Get network ID |
mfiore | 0:c62615f15125 | 513 | * @returns vector containing network ID (size 8) |
mfiore | 0:c62615f15125 | 514 | */ |
mfiore | 0:c62615f15125 | 515 | std::vector<uint8_t> getNetworkId(); |
mfiore | 0:c62615f15125 | 516 | |
mfiore | 0:c62615f15125 | 517 | /** Set network passphrase |
mfiore | 0:c62615f15125 | 518 | * for use with OTA & AUTO_OTA network join modes |
mfiore | 0:c62615f15125 | 519 | * generates network key (cmac of passphrase) automatically |
mfiore | 0:c62615f15125 | 520 | * @param name a string of of at least 8 bytes and no more than 128 bytes |
mfiore | 0:c62615f15125 | 521 | * @return MDOT_OK if success |
mfiore | 0:c62615f15125 | 522 | */ |
mfiore | 0:c62615f15125 | 523 | int32_t setNetworkPassphrase(const std::string& passphrase); |
mfiore | 0:c62615f15125 | 524 | |
mfiore | 0:c62615f15125 | 525 | /** Get network passphrase |
mfiore | 0:c62615f15125 | 526 | * @return string containing network passphrase (size 8 to 128) |
mfiore | 0:c62615f15125 | 527 | */ |
mfiore | 0:c62615f15125 | 528 | std::string getNetworkPassphrase(); |
mfiore | 0:c62615f15125 | 529 | |
mfiore | 0:c62615f15125 | 530 | /** Set network key |
mfiore | 0:c62615f15125 | 531 | * for use with OTA & AUTO_OTA network join modes |
mfiore | 0:c62615f15125 | 532 | * setting network key via this function sets network passphrase to empty |
mfiore | 0:c62615f15125 | 533 | * @param id a vector of 16 bytes |
mfiore | 0:c62615f15125 | 534 | * @returns MDOT_OK if success |
mfiore | 0:c62615f15125 | 535 | */ |
mfiore | 0:c62615f15125 | 536 | int32_t setNetworkKey(const std::vector<uint8_t>& id); |
mfiore | 0:c62615f15125 | 537 | |
mfiore | 0:c62615f15125 | 538 | /** Get network key |
mfiore | 0:c62615f15125 | 539 | * @returns a vector containing network key (size 16) |
mfiore | 0:c62615f15125 | 540 | */ |
mfiore | 0:c62615f15125 | 541 | std::vector<uint8_t> getNetworkKey(); |
mfiore | 0:c62615f15125 | 542 | |
Mike Fiore |
6:390fc83d588d | 543 | /** Set join byte order |
Mike Fiore |
6:390fc83d588d | 544 | * @param order 0:LSB 1:MSB |
Mike Fiore |
6:390fc83d588d | 545 | */ |
Mike Fiore |
6:390fc83d588d | 546 | uint32_t setJoinByteOrder(uint8_t order); |
Mike Fiore |
6:390fc83d588d | 547 | |
Mike Fiore |
6:390fc83d588d | 548 | /** Get join byte order |
Mike Fiore |
6:390fc83d588d | 549 | * @returns byte order to use in joins 0:LSB 1:MSB |
Mike Fiore |
6:390fc83d588d | 550 | */ |
Mike Fiore |
6:390fc83d588d | 551 | uint8_t getJoinByteOrder(); |
Mike Fiore |
6:390fc83d588d | 552 | |
mfiore | 0:c62615f15125 | 553 | /** Attempt to join network |
Mike Fiore |
12:54f9cac9d690 | 554 | * each attempt will be made with a random datarate up to the configured datarate |
Mike Fiore |
12:54f9cac9d690 | 555 | * 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 | 556 | * Check getNextTxMs() for time until next join attempt can be made |
mfiore | 0:c62615f15125 | 557 | * @returns MDOT_OK if success |
mfiore | 0:c62615f15125 | 558 | */ |
mfiore | 0:c62615f15125 | 559 | int32_t joinNetwork(); |
mfiore | 0:c62615f15125 | 560 | |
mfiore | 0:c62615f15125 | 561 | /** Attempts to join network once |
mfiore | 0:c62615f15125 | 562 | * @returns MDOT_OK if success |
mfiore | 0:c62615f15125 | 563 | */ |
mfiore | 0:c62615f15125 | 564 | int32_t joinNetworkOnce(); |
mfiore | 0:c62615f15125 | 565 | |
mfiore | 0:c62615f15125 | 566 | /** Resets current network session, essentially disconnecting from the network |
mfiore | 0:c62615f15125 | 567 | * has no effect for MANUAL network join mode |
mfiore | 0:c62615f15125 | 568 | */ |
mfiore | 0:c62615f15125 | 569 | void resetNetworkSession(); |
mfiore | 0:c62615f15125 | 570 | |
Mike Fiore |
12:54f9cac9d690 | 571 | /** Restore saved network session from flash |
Mike Fiore |
12:54f9cac9d690 | 572 | * has no effect for MANUAL network join mode |
Mike Fiore |
12:54f9cac9d690 | 573 | */ |
Mike Fiore |
12:54f9cac9d690 | 574 | void restoreNetworkSession(); |
Mike Fiore |
12:54f9cac9d690 | 575 | |
Mike Fiore |
12:54f9cac9d690 | 576 | /** Save current network session to flash |
Mike Fiore |
12:54f9cac9d690 | 577 | * has no effect for MANUAL network join mode |
Mike Fiore |
12:54f9cac9d690 | 578 | */ |
Mike Fiore |
12:54f9cac9d690 | 579 | void saveNetworkSession(); |
Mike Fiore |
12:54f9cac9d690 | 580 | |
jreiss | 17:306ffaa5d79b | 581 | /** Set number of times joining will retry each sub-band before changing |
jreiss | 17:306ffaa5d79b | 582 | * to the next subband in US915 and AU915 |
mfiore | 0:c62615f15125 | 583 | * @param retries must be between 0 - 255 |
mfiore | 0:c62615f15125 | 584 | * @returns MDOT_OK if success |
mfiore | 0:c62615f15125 | 585 | */ |
mfiore | 0:c62615f15125 | 586 | int32_t setJoinRetries(const uint8_t& retries); |
mfiore | 0:c62615f15125 | 587 | |
jreiss | 17:306ffaa5d79b | 588 | /** Get number of times joining will retry each sub-band |
mfiore | 0:c62615f15125 | 589 | * @returns join retries (0 - 255) |
mfiore | 0:c62615f15125 | 590 | */ |
mfiore | 0:c62615f15125 | 591 | uint8_t getJoinRetries(); |
mfiore | 0:c62615f15125 | 592 | |
mfiore | 0:c62615f15125 | 593 | /** Set network join mode |
mfiore | 0:c62615f15125 | 594 | * MANUAL: set network address and session keys manually |
mfiore | 0:c62615f15125 | 595 | * OTA: User sets network name and passphrase, then attempts to join |
mfiore | 0:c62615f15125 | 596 | * AUTO_OTA: same as OTA, but network sessions can be saved and restored |
mfiore | 0:c62615f15125 | 597 | * @param mode MANUAL, OTA, or AUTO_OTA |
mfiore | 0:c62615f15125 | 598 | * @returns MDOT_OK if success |
mfiore | 0:c62615f15125 | 599 | */ |
mfiore | 0:c62615f15125 | 600 | int32_t setJoinMode(const uint8_t& mode); |
mfiore | 0:c62615f15125 | 601 | |
mfiore | 0:c62615f15125 | 602 | /** Get network join mode |
mfiore | 0:c62615f15125 | 603 | * @returns MANUAL, OTA, or AUTO_OTA |
mfiore | 0:c62615f15125 | 604 | */ |
mfiore | 0:c62615f15125 | 605 | uint8_t getJoinMode(); |
mfiore | 0:c62615f15125 | 606 | |
mfiore | 0:c62615f15125 | 607 | /** Get network join status |
mfiore | 0:c62615f15125 | 608 | * @returns true if currently joined to network |
mfiore | 0:c62615f15125 | 609 | */ |
mfiore | 0:c62615f15125 | 610 | bool getNetworkJoinStatus(); |
mfiore | 0:c62615f15125 | 611 | |
mfiore | 0:c62615f15125 | 612 | /** Do a network link check |
mfiore | 0:c62615f15125 | 613 | * application data may be returned in response to a network link check command |
mfiore | 0:c62615f15125 | 614 | * @returns link_check structure containing success, dBm above noise floor, gateways in range, and packet payload |
mfiore | 0:c62615f15125 | 615 | */ |
mfiore | 0:c62615f15125 | 616 | link_check networkLinkCheck(); |
mfiore | 0:c62615f15125 | 617 | |
mfiore | 0:c62615f15125 | 618 | /** Set network link check count to perform automatic link checks every count packets |
mfiore | 0:c62615f15125 | 619 | * only applicable if ACKs are disabled |
mfiore | 0:c62615f15125 | 620 | * @param count must be between 0 - 255 |
mfiore | 0:c62615f15125 | 621 | * @returns MDOT_OK if success |
mfiore | 0:c62615f15125 | 622 | */ |
mfiore | 0:c62615f15125 | 623 | int32_t setLinkCheckCount(const uint8_t& count); |
mfiore | 0:c62615f15125 | 624 | |
mfiore | 0:c62615f15125 | 625 | /** Get network link check count |
mfiore | 0:c62615f15125 | 626 | * @returns count (0 - 255) |
mfiore | 0:c62615f15125 | 627 | */ |
mfiore | 0:c62615f15125 | 628 | uint8_t getLinkCheckCount(); |
mfiore | 0:c62615f15125 | 629 | |
mfiore | 0:c62615f15125 | 630 | /** Set network link check threshold, number of link check failures or missed acks to tolerate |
mfiore | 0:c62615f15125 | 631 | * before considering network connection lost |
mfiore | 0:c62615f15125 | 632 | * @pararm count must be between 0 - 255 |
mfiore | 0:c62615f15125 | 633 | * @returns MDOT_OK if success |
mfiore | 0:c62615f15125 | 634 | */ |
mfiore | 0:c62615f15125 | 635 | int32_t setLinkCheckThreshold(const uint8_t& count); |
mfiore | 0:c62615f15125 | 636 | |
mfiore | 0:c62615f15125 | 637 | /** Get network link check threshold |
mfiore | 0:c62615f15125 | 638 | * @returns threshold (0 - 255) |
mfiore | 0:c62615f15125 | 639 | */ |
mfiore | 0:c62615f15125 | 640 | uint8_t getLinkCheckThreshold(); |
mfiore | 0:c62615f15125 | 641 | |
Mike Fiore |
12:54f9cac9d690 | 642 | /** Get/set number of failed link checks in the current session |
Mike Fiore |
12:54f9cac9d690 | 643 | * @returns count (0 - 255) |
Mike Fiore |
12:54f9cac9d690 | 644 | */ |
Mike Fiore |
12:54f9cac9d690 | 645 | uint8_t getLinkFailCount(); |
Mike Fiore |
12:54f9cac9d690 | 646 | int32_t setLinkFailCount(uint8_t count); |
Mike Fiore |
12:54f9cac9d690 | 647 | |
Mike Fiore |
12:54f9cac9d690 | 648 | /** Set UpLinkCounter number of packets sent to the gateway during this network session (sequence number) |
Mike Fiore |
12:54f9cac9d690 | 649 | * @returns MDOT_OK |
Mike Fiore |
12:54f9cac9d690 | 650 | */ |
Mike Fiore |
12:54f9cac9d690 | 651 | int32_t setUpLinkCounter(uint32_t count); |
Mike Fiore |
12:54f9cac9d690 | 652 | |
mfiore | 0:c62615f15125 | 653 | /** Get UpLinkCounter |
mfiore | 0:c62615f15125 | 654 | * @returns number of packets sent to the gateway during this network session (sequence number) |
mfiore | 0:c62615f15125 | 655 | */ |
mfiore | 0:c62615f15125 | 656 | uint32_t getUpLinkCounter(); |
mfiore | 0:c62615f15125 | 657 | |
Mike Fiore |
12:54f9cac9d690 | 658 | /** Set UpLinkCounter number of packets sent by the gateway during this network session (sequence number) |
Mike Fiore |
12:54f9cac9d690 | 659 | * @returns MDOT_OK |
Mike Fiore |
12:54f9cac9d690 | 660 | */ |
Mike Fiore |
12:54f9cac9d690 | 661 | int32_t setDownLinkCounter(uint32_t count); |
Mike Fiore |
12:54f9cac9d690 | 662 | |
Mike Fiore |
12:54f9cac9d690 | 663 | /** Get DownLinkCounter |
Mike Fiore |
12:54f9cac9d690 | 664 | * @returns number of packets sent by the gateway during this network session (sequence number) |
Mike Fiore |
12:54f9cac9d690 | 665 | */ |
Mike Fiore |
12:54f9cac9d690 | 666 | uint32_t getDownLinkCounter(); |
Mike Fiore |
12:54f9cac9d690 | 667 | |
mfiore | 0:c62615f15125 | 668 | /** Enable/disable AES encryption |
mfiore | 0:c62615f15125 | 669 | * AES encryption must be enabled for use with Conduit gateway and MTAC_LORA card |
mfiore | 0:c62615f15125 | 670 | * @param on true for AES encryption to be enabled |
mfiore | 0:c62615f15125 | 671 | * @returns MDOT_OK if success |
mfiore | 0:c62615f15125 | 672 | */ |
mfiore | 0:c62615f15125 | 673 | int32_t setAesEncryption(const bool& on); |
mfiore | 0:c62615f15125 | 674 | |
mfiore | 0:c62615f15125 | 675 | /** Get AES encryption |
mfiore | 0:c62615f15125 | 676 | * @returns true if AES encryption is enabled |
mfiore | 0:c62615f15125 | 677 | */ |
mfiore | 0:c62615f15125 | 678 | bool getAesEncryption(); |
mfiore | 0:c62615f15125 | 679 | |
mfiore | 0:c62615f15125 | 680 | /** Get RSSI stats |
Mike Fiore |
11:d8464345e1f1 | 681 | * @returns rssi_stats struct containing last, min, max, and avg RSSI in dB |
mfiore | 0:c62615f15125 | 682 | */ |
mfiore | 0:c62615f15125 | 683 | rssi_stats getRssiStats(); |
mfiore | 0:c62615f15125 | 684 | |
mfiore | 0:c62615f15125 | 685 | /** Get SNR stats |
Mike Fiore |
11:d8464345e1f1 | 686 | * @returns snr_stats struct containing last, min, max, and avg SNR in cB |
mfiore | 0:c62615f15125 | 687 | */ |
mfiore | 0:c62615f15125 | 688 | snr_stats getSnrStats(); |
mfiore | 0:c62615f15125 | 689 | |
mfiore | 0:c62615f15125 | 690 | /** Get ms until next free channel |
mfiore | 0:c62615f15125 | 691 | * only applicable for European models, US models return 0 |
mfiore | 0:c62615f15125 | 692 | * @returns time (ms) until a channel is free to use for transmitting |
mfiore | 0:c62615f15125 | 693 | */ |
mfiore | 0:c62615f15125 | 694 | uint32_t getNextTxMs(); |
mfiore | 0:c62615f15125 | 695 | |
Jason Reiss |
10:27dafba9fe19 | 696 | /** Get join delay in seconds |
Jason Reiss |
10:27dafba9fe19 | 697 | * Public network defaults to 5 seconds |
Jason Reiss |
10:27dafba9fe19 | 698 | * Private network defaults to 1 second |
Jason Reiss |
10:27dafba9fe19 | 699 | * @returns number of seconds before join accept message is expected |
Jason Reiss |
10:27dafba9fe19 | 700 | */ |
Jason Reiss |
10:27dafba9fe19 | 701 | uint8_t getJoinDelay(); |
Jason Reiss |
10:27dafba9fe19 | 702 | |
Jason Reiss |
10:27dafba9fe19 | 703 | /** Set join delay in seconds |
Jason Reiss |
10:27dafba9fe19 | 704 | * Public network defaults to 5 seconds |
Jason Reiss |
10:27dafba9fe19 | 705 | * Private network defaults to 1 second |
Jason Reiss |
10:27dafba9fe19 | 706 | * @param delay number of seconds before join accept message is expected |
Jason Reiss |
10:27dafba9fe19 | 707 | * @return MDOT_OK if success |
Jason Reiss |
10:27dafba9fe19 | 708 | */ |
Jason Reiss |
10:27dafba9fe19 | 709 | uint32_t setJoinDelay(uint8_t delay); |
Jason Reiss |
10:27dafba9fe19 | 710 | |
Mike Fiore |
16:b630e18103e5 | 711 | /** Get join Rx1 datarate offset |
Mike Fiore |
16:b630e18103e5 | 712 | * defaults to 0 |
Mike Fiore |
16:b630e18103e5 | 713 | * @returns offset |
Mike Fiore |
16:b630e18103e5 | 714 | */ |
Mike Fiore |
16:b630e18103e5 | 715 | uint8_t getJoinRx1DataRateOffset(); |
Mike Fiore |
16:b630e18103e5 | 716 | |
Mike Fiore |
16:b630e18103e5 | 717 | /** Set join Rx1 datarate offset |
Mike Fiore |
16:b630e18103e5 | 718 | * @param offset for datarate |
Mike Fiore |
16:b630e18103e5 | 719 | * @return MDOT_OK if success |
Mike Fiore |
16:b630e18103e5 | 720 | */ |
Mike Fiore |
16:b630e18103e5 | 721 | uint32_t setJoinRx1DataRateOffset(uint8_t offset); |
Mike Fiore |
16:b630e18103e5 | 722 | |
Mike Fiore |
16:b630e18103e5 | 723 | /** Get join Rx2 datarate |
Mike Fiore |
16:b630e18103e5 | 724 | * defaults to US:DR8, AU:DR8, EU:DR0 |
Mike Fiore |
16:b630e18103e5 | 725 | * @returns datarate |
Mike Fiore |
16:b630e18103e5 | 726 | */ |
Mike Fiore |
16:b630e18103e5 | 727 | uint8_t getJoinRx2DataRate(); |
Mike Fiore |
16:b630e18103e5 | 728 | |
Mike Fiore |
16:b630e18103e5 | 729 | /** Set join Rx2 datarate |
Mike Fiore |
16:b630e18103e5 | 730 | * @param datarate |
Mike Fiore |
16:b630e18103e5 | 731 | * @return MDOT_OK if success |
Mike Fiore |
16:b630e18103e5 | 732 | */ |
Mike Fiore |
16:b630e18103e5 | 733 | uint32_t setJoinRx2DataRate(uint8_t datarate); |
Mike Fiore |
16:b630e18103e5 | 734 | |
Mike Fiore |
16:b630e18103e5 | 735 | /** Get join Rx2 frequency |
Mike Fiore |
16:b630e18103e5 | 736 | * defaults US:923.3, AU:923.3, EU:869.525 |
Mike Fiore |
16:b630e18103e5 | 737 | * @returns frequency |
Mike Fiore |
16:b630e18103e5 | 738 | */ |
Mike Fiore |
16:b630e18103e5 | 739 | uint32_t getJoinRx2Frequency(); |
Mike Fiore |
16:b630e18103e5 | 740 | |
Mike Fiore |
16:b630e18103e5 | 741 | /** Set join Rx2 frequency |
Mike Fiore |
16:b630e18103e5 | 742 | * @param frequency |
Mike Fiore |
16:b630e18103e5 | 743 | * @return MDOT_OK if success |
Mike Fiore |
16:b630e18103e5 | 744 | */ |
Mike Fiore |
16:b630e18103e5 | 745 | uint32_t setJoinRx2Frequency(uint32_t frequency); |
Mike Fiore |
16:b630e18103e5 | 746 | |
Jason Reiss |
10:27dafba9fe19 | 747 | /** Get rx delay in seconds |
Jason Reiss |
10:27dafba9fe19 | 748 | * Defaults to 1 second |
Jason Reiss |
10:27dafba9fe19 | 749 | * @returns number of seconds before response message is expected |
Jason Reiss |
10:27dafba9fe19 | 750 | */ |
Jason Reiss |
10:27dafba9fe19 | 751 | uint8_t getRxDelay(); |
Jason Reiss |
10:27dafba9fe19 | 752 | |
Jason Reiss |
10:27dafba9fe19 | 753 | /** Set rx delay in seconds |
Jason Reiss |
10:27dafba9fe19 | 754 | * Defaults to 1 second |
Jason Reiss |
10:27dafba9fe19 | 755 | * @param delay number of seconds before response message is expected |
Jason Reiss |
10:27dafba9fe19 | 756 | * @return MDOT_OK if success |
Jason Reiss |
10:27dafba9fe19 | 757 | */ |
Jason Reiss |
10:27dafba9fe19 | 758 | uint32_t setRxDelay(uint8_t delay); |
Jason Reiss |
10:27dafba9fe19 | 759 | |
Jason Reiss |
10:27dafba9fe19 | 760 | /** Get preserve session to save network session info through reset or power down in AUTO_OTA mode |
Jason Reiss |
10:27dafba9fe19 | 761 | * Defaults to off |
Jason Reiss |
10:27dafba9fe19 | 762 | * @returns true if enabled |
Jason Reiss |
10:27dafba9fe19 | 763 | */ |
Jason Reiss |
10:27dafba9fe19 | 764 | bool getPreserveSession(); |
Jason Reiss |
10:27dafba9fe19 | 765 | |
Jason Reiss |
10:27dafba9fe19 | 766 | /** Set preserve session to save network session info through reset or power down in AUTO_OTA mode |
Jason Reiss |
10:27dafba9fe19 | 767 | * Defaults to off |
Jason Reiss |
10:27dafba9fe19 | 768 | * @param enable |
Jason Reiss |
10:27dafba9fe19 | 769 | * @return MDOT_OK if success |
Jason Reiss |
10:27dafba9fe19 | 770 | */ |
Jason Reiss |
10:27dafba9fe19 | 771 | uint32_t setPreserveSession(bool enable); |
Jason Reiss |
10:27dafba9fe19 | 772 | |
mfiore | 0:c62615f15125 | 773 | /** Get data pending |
mfiore | 0:c62615f15125 | 774 | * only valid after sending data to the gateway |
mfiore | 0:c62615f15125 | 775 | * @returns true if server has available packet(s) |
mfiore | 0:c62615f15125 | 776 | */ |
mfiore | 0:c62615f15125 | 777 | bool getDataPending(); |
mfiore | 0:c62615f15125 | 778 | |
Mike Fiore |
16:b630e18103e5 | 779 | /** Get ack requested |
Mike Fiore |
16:b630e18103e5 | 780 | * only valid after sending data to the gateway |
Mike Fiore |
16:b630e18103e5 | 781 | * @returns true if server has requested ack |
Mike Fiore |
16:b630e18103e5 | 782 | */ |
Mike Fiore |
16:b630e18103e5 | 783 | bool getAckRequested(); |
Mike Fiore |
16:b630e18103e5 | 784 | |
Mike Fiore |
16:b630e18103e5 | 785 | /** Get is transmitting indicator |
mfiore | 0:c62615f15125 | 786 | * @returns true if currently transmitting |
mfiore | 0:c62615f15125 | 787 | */ |
mfiore | 0:c62615f15125 | 788 | bool getIsTransmitting(); |
mfiore | 0:c62615f15125 | 789 | |
Mike Fiore |
16:b630e18103e5 | 790 | /** Get is idle indicator |
Mike Fiore |
16:b630e18103e5 | 791 | * @returns true if not currently transmitting, waiting or receiving |
Mike Fiore |
16:b630e18103e5 | 792 | */ |
Mike Fiore |
16:b630e18103e5 | 793 | bool getIsIdle(); |
Mike Fiore |
16:b630e18103e5 | 794 | |
mfiore | 0:c62615f15125 | 795 | /** Set TX data rate |
mfiore | 0:c62615f15125 | 796 | * data rates affect maximum payload size |
Mike Fiore |
11:d8464345e1f1 | 797 | * @param dr SF_7 - SF_12|DR0-DR7 for Europe, SF_7 - SF_10 | DR0-DR4 for United States |
mfiore | 0:c62615f15125 | 798 | * @returns MDOT_OK if success |
mfiore | 0:c62615f15125 | 799 | */ |
mfiore | 0:c62615f15125 | 800 | int32_t setTxDataRate(const uint8_t& dr); |
mfiore | 0:c62615f15125 | 801 | |
mfiore | 0:c62615f15125 | 802 | /** Get TX data rate |
Mike Fiore |
11:d8464345e1f1 | 803 | * @returns current TX data rate (DR0-DR15) |
mfiore | 0:c62615f15125 | 804 | */ |
mfiore | 0:c62615f15125 | 805 | uint8_t getTxDataRate(); |
mfiore | 0:c62615f15125 | 806 | |
Mike Fiore |
12:54f9cac9d690 | 807 | /** Get a random value from the radio based on RSSI |
Mike Fiore |
12:54f9cac9d690 | 808 | * @returns randome value |
Mike Fiore |
12:54f9cac9d690 | 809 | */ |
Mike Fiore |
12:54f9cac9d690 | 810 | uint32_t getRadioRandom(); |
Mike Fiore |
12:54f9cac9d690 | 811 | |
Mike Fiore |
11:d8464345e1f1 | 812 | /** Get data rate spreading factor and bandwidth |
Mike Fiore |
11:d8464345e1f1 | 813 | * EU868 Datarates |
Mike Fiore |
11:d8464345e1f1 | 814 | * --------------- |
Mike Fiore |
11:d8464345e1f1 | 815 | * DR0 - SF12BW125 |
Mike Fiore |
11:d8464345e1f1 | 816 | * DR1 - SF11BW125 |
Mike Fiore |
11:d8464345e1f1 | 817 | * DR2 - SF10BW125 |
Mike Fiore |
11:d8464345e1f1 | 818 | * DR3 - SF9BW125 |
Mike Fiore |
11:d8464345e1f1 | 819 | * DR4 - SF8BW125 |
Mike Fiore |
11:d8464345e1f1 | 820 | * DR5 - SF7BW125 |
Mike Fiore |
11:d8464345e1f1 | 821 | * DR6 - SF7BW250 |
Mike Fiore |
11:d8464345e1f1 | 822 | * DR7 - FSK |
Mike Fiore |
11:d8464345e1f1 | 823 | * |
Mike Fiore |
11:d8464345e1f1 | 824 | * US915 Datarates |
Mike Fiore |
11:d8464345e1f1 | 825 | * --------------- |
Mike Fiore |
11:d8464345e1f1 | 826 | * DR0 - SF10BW125 |
Mike Fiore |
11:d8464345e1f1 | 827 | * DR1 - SF9BW125 |
Mike Fiore |
11:d8464345e1f1 | 828 | * DR2 - SF8BW125 |
Mike Fiore |
11:d8464345e1f1 | 829 | * DR3 - SF7BW125 |
Mike Fiore |
11:d8464345e1f1 | 830 | * DR4 - SF8BW500 |
Mike Fiore |
11:d8464345e1f1 | 831 | * |
jreiss | 17:306ffaa5d79b | 832 | * AU915 Datarates |
jreiss | 17:306ffaa5d79b | 833 | * --------------- |
jreiss | 17:306ffaa5d79b | 834 | * DR0 - SF10BW125 |
jreiss | 17:306ffaa5d79b | 835 | * DR1 - SF9BW125 |
jreiss | 17:306ffaa5d79b | 836 | * DR2 - SF8BW125 |
jreiss | 17:306ffaa5d79b | 837 | * DR3 - SF7BW125 |
jreiss | 17:306ffaa5d79b | 838 | * DR4 - SF8BW500 |
jreiss | 17:306ffaa5d79b | 839 | * |
Mike Fiore |
11:d8464345e1f1 | 840 | * @returns spreading factor and bandwidth |
Mike Fiore |
11:d8464345e1f1 | 841 | */ |
Mike Fiore |
11:d8464345e1f1 | 842 | std::string getDateRateDetails(uint8_t rate); |
Mike Fiore |
11:d8464345e1f1 | 843 | |
Mike Fiore |
12:54f9cac9d690 | 844 | /** Set TX power output of radio before antenna gain, default: 14 dBm |
Mike Fiore |
12:54f9cac9d690 | 845 | * actual output power may be limited by local regulations for the chosen frequency |
mfiore | 0:c62615f15125 | 846 | * power affects maximum range |
mfiore | 0:c62615f15125 | 847 | * @param power 2 dBm - 20 dBm |
mfiore | 0:c62615f15125 | 848 | * @returns MDOT_OK if success |
mfiore | 0:c62615f15125 | 849 | */ |
mfiore | 0:c62615f15125 | 850 | int32_t setTxPower(const uint32_t& power); |
mfiore | 0:c62615f15125 | 851 | |
mfiore | 0:c62615f15125 | 852 | /** Get TX power |
mfiore | 0:c62615f15125 | 853 | * @returns TX power (2 dBm - 20 dBm) |
mfiore | 0:c62615f15125 | 854 | */ |
mfiore | 0:c62615f15125 | 855 | uint32_t getTxPower(); |
mfiore | 0:c62615f15125 | 856 | |
Mike Fiore |
12:54f9cac9d690 | 857 | /** Get configured gain of installed antenna, default: +3 dBi |
Mike Fiore |
11:d8464345e1f1 | 858 | * @returns gain of antenna in dBi |
Mike Fiore |
11:d8464345e1f1 | 859 | */ |
Mike Fiore |
11:d8464345e1f1 | 860 | int8_t getAntennaGain(); |
Mike Fiore |
11:d8464345e1f1 | 861 | |
Mike Fiore |
12:54f9cac9d690 | 862 | /** Set configured gain of installed antenna, default: +3 dBi |
Mike Fiore |
11:d8464345e1f1 | 863 | * @param gain -127 dBi - 128 dBi |
Mike Fiore |
11:d8464345e1f1 | 864 | * @returns MDOT_OK if success |
Mike Fiore |
11:d8464345e1f1 | 865 | */ |
Mike Fiore |
11:d8464345e1f1 | 866 | int32_t setAntennaGain(int8_t gain); |
Mike Fiore |
11:d8464345e1f1 | 867 | |
mfiore | 0:c62615f15125 | 868 | /** Enable/disable TX waiting for rx windows |
mfiore | 0:c62615f15125 | 869 | * when enabled, send calls will block until a packet is received or RX timeout |
mfiore | 0:c62615f15125 | 870 | * @param enable set to true if expecting responses to transmitted packets |
mfiore | 0:c62615f15125 | 871 | * @returns MDOT_OK if success |
mfiore | 0:c62615f15125 | 872 | */ |
mfiore | 0:c62615f15125 | 873 | int32_t setTxWait(const bool& enable); |
mfiore | 0:c62615f15125 | 874 | |
mfiore | 0:c62615f15125 | 875 | /** Get TX wait |
mfiore | 0:c62615f15125 | 876 | * @returns true if TX wait is enabled |
mfiore | 0:c62615f15125 | 877 | */ |
mfiore | 0:c62615f15125 | 878 | bool getTxWait(); |
mfiore | 0:c62615f15125 | 879 | |
Mike Fiore |
16:b630e18103e5 | 880 | /** Cancel pending rx windows |
Mike Fiore |
16:b630e18103e5 | 881 | */ |
Mike Fiore |
16:b630e18103e5 | 882 | void cancelRxWindow(); |
Mike Fiore |
16:b630e18103e5 | 883 | |
mfiore | 0:c62615f15125 | 884 | /** Get time on air |
mfiore | 0:c62615f15125 | 885 | * @returns the amount of time (in ms) it would take to send bytes bytes based on current configuration |
mfiore | 0:c62615f15125 | 886 | */ |
mfiore | 0:c62615f15125 | 887 | uint32_t getTimeOnAir(uint8_t bytes); |
mfiore | 0:c62615f15125 | 888 | |
mfiore | 0:c62615f15125 | 889 | /** Get min frequency |
mfiore | 0:c62615f15125 | 890 | * @returns minimum frequency based on current configuration |
mfiore | 0:c62615f15125 | 891 | */ |
mfiore | 0:c62615f15125 | 892 | uint32_t getMinFrequency(); |
mfiore | 0:c62615f15125 | 893 | |
mfiore | 0:c62615f15125 | 894 | /** Get max frequency |
mfiore | 0:c62615f15125 | 895 | * @returns maximum frequency based on current configuration |
mfiore | 0:c62615f15125 | 896 | */ |
mfiore | 0:c62615f15125 | 897 | uint32_t getMaxFrequency(); |
mfiore | 0:c62615f15125 | 898 | |
Mike Fiore |
12:54f9cac9d690 | 899 | // get/set adaptive data rate |
Mike Fiore |
12:54f9cac9d690 | 900 | // configure data rates and power levels based on signal to noise of packets received at gateway |
Mike Fiore |
12:54f9cac9d690 | 901 | // true == adaptive data rate is on |
Mike Fiore |
12:54f9cac9d690 | 902 | // set function returns MDOT_OK if success |
Mike Fiore |
12:54f9cac9d690 | 903 | int32_t setAdr(const bool& on); |
Mike Fiore |
12:54f9cac9d690 | 904 | bool getAdr(); |
Mike Fiore |
12:54f9cac9d690 | 905 | |
mfiore | 0:c62615f15125 | 906 | /** Set forward error correction bytes |
mfiore | 0:c62615f15125 | 907 | * @param bytes 1 - 4 bytes |
mfiore | 0:c62615f15125 | 908 | * @returns MDOT_OK if success |
mfiore | 0:c62615f15125 | 909 | */ |
mfiore | 0:c62615f15125 | 910 | int32_t setFec(const uint8_t& bytes); |
mfiore | 0:c62615f15125 | 911 | |
mfiore | 0:c62615f15125 | 912 | /** Get forward error correction bytes |
mfiore | 0:c62615f15125 | 913 | * @returns bytes (1 - 4) |
mfiore | 0:c62615f15125 | 914 | */ |
mfiore | 0:c62615f15125 | 915 | uint8_t getFec(); |
mfiore | 0:c62615f15125 | 916 | |
mfiore | 0:c62615f15125 | 917 | /** Enable/disable CRC checking of packets |
mfiore | 0:c62615f15125 | 918 | * CRC checking must be enabled for use with Conduit gateway and MTAC_LORA card |
mfiore | 0:c62615f15125 | 919 | * @param on set to true to enable CRC checking |
mfiore | 0:c62615f15125 | 920 | * @returns MDOT_OK if success |
mfiore | 0:c62615f15125 | 921 | */ |
mfiore | 0:c62615f15125 | 922 | int32_t setCrc(const bool& on); |
mfiore | 0:c62615f15125 | 923 | |
mfiore | 0:c62615f15125 | 924 | /** Get CRC checking |
mfiore | 0:c62615f15125 | 925 | * @returns true if CRC checking is enabled |
mfiore | 0:c62615f15125 | 926 | */ |
mfiore | 0:c62615f15125 | 927 | bool getCrc(); |
mfiore | 0:c62615f15125 | 928 | |
mfiore | 0:c62615f15125 | 929 | /** Set ack |
mfiore | 0:c62615f15125 | 930 | * @param retries 0 to disable acks, otherwise 1 - 8 |
mfiore | 0:c62615f15125 | 931 | * @returns MDOT_OK if success |
mfiore | 0:c62615f15125 | 932 | */ |
mfiore | 0:c62615f15125 | 933 | int32_t setAck(const uint8_t& retries); |
mfiore | 0:c62615f15125 | 934 | |
mfiore | 0:c62615f15125 | 935 | /** Get ack |
mfiore | 0:c62615f15125 | 936 | * @returns 0 if acks are disabled, otherwise retries (1 - 8) |
mfiore | 0:c62615f15125 | 937 | */ |
mfiore | 0:c62615f15125 | 938 | uint8_t getAck(); |
mfiore | 0:c62615f15125 | 939 | |
Mike Fiore |
12:54f9cac9d690 | 940 | /** Set number of packet repeats for unconfirmed frames |
Mike Fiore |
12:54f9cac9d690 | 941 | * @param repeat 0 or 1 for no repeats, otherwise 2-15 |
Mike Fiore |
12:54f9cac9d690 | 942 | * @returns MDOT_OK if success |
Mike Fiore |
12:54f9cac9d690 | 943 | */ |
Mike Fiore |
12:54f9cac9d690 | 944 | int32_t setRepeat(const uint8_t& repeat); |
Mike Fiore |
12:54f9cac9d690 | 945 | |
Mike Fiore |
12:54f9cac9d690 | 946 | /** Get number of packet repeats for unconfirmed frames |
Mike Fiore |
12:54f9cac9d690 | 947 | * @returns 0 or 1 if no repeats, otherwise 2-15 |
Mike Fiore |
12:54f9cac9d690 | 948 | */ |
Mike Fiore |
12:54f9cac9d690 | 949 | uint8_t getRepeat(); |
Mike Fiore |
12:54f9cac9d690 | 950 | |
mfiore | 0:c62615f15125 | 951 | /** Send data to the gateway |
mfiore | 0:c62615f15125 | 952 | * validates data size (based on spreading factor) |
mfiore | 0:c62615f15125 | 953 | * @param data a vector of up to 242 bytes (may be less based on spreading factor) |
mfiore | 0:c62615f15125 | 954 | * @returns MDOT_OK if packet was sent successfully (ACKs disabled), or if an ACK was received (ACKs enabled) |
mfiore | 0:c62615f15125 | 955 | */ |
mfiore | 0:c62615f15125 | 956 | int32_t send(const std::vector<uint8_t>& data, const bool& blocking = true, const bool& highBw = false); |
mfiore | 0:c62615f15125 | 957 | |
Mike Fiore |
16:b630e18103e5 | 958 | /** Inject mac command |
Mike Fiore |
16:b630e18103e5 | 959 | * @param data a vector containing mac commands |
Mike Fiore |
16:b630e18103e5 | 960 | * @returns MDOT_OK |
Mike Fiore |
16:b630e18103e5 | 961 | */ |
Mike Fiore |
16:b630e18103e5 | 962 | int32_t injectMacCommand(const std::vector<uint8_t>& data); |
Mike Fiore |
16:b630e18103e5 | 963 | |
Mike Fiore |
16:b630e18103e5 | 964 | /** |
Mike Fiore |
16:b630e18103e5 | 965 | * Clear MAC command buffer to be sent in next uplink |
Mike Fiore |
16:b630e18103e5 | 966 | * @returns MDOT_OK |
Mike Fiore |
16:b630e18103e5 | 967 | */ |
Mike Fiore |
16:b630e18103e5 | 968 | int32_t clearMacCommands(); |
Mike Fiore |
16:b630e18103e5 | 969 | |
Mike Fiore |
16:b630e18103e5 | 970 | /** |
Mike Fiore |
16:b630e18103e5 | 971 | * Get MAC command buffer to be sent in next uplink |
Mike Fiore |
16:b630e18103e5 | 972 | * @returns command bytes |
Mike Fiore |
16:b630e18103e5 | 973 | */ |
Mike Fiore |
16:b630e18103e5 | 974 | std::vector<uint8_t> getMacCommands(); |
Mike Fiore |
16:b630e18103e5 | 975 | |
mfiore | 0:c62615f15125 | 976 | /** Fetch data received from the gateway |
mfiore | 0:c62615f15125 | 977 | * this function only checks to see if a packet has been received - it does not open a receive window |
mfiore | 0:c62615f15125 | 978 | * send() must be called before recv() |
mfiore | 0:c62615f15125 | 979 | * @param data a vector to put the received data into |
mfiore | 0:c62615f15125 | 980 | * @returns MDOT_OK if packet was successfully received |
mfiore | 0:c62615f15125 | 981 | */ |
mfiore | 0:c62615f15125 | 982 | int32_t recv(std::vector<uint8_t>& data); |
mfiore | 0:c62615f15125 | 983 | |
mfiore | 0:c62615f15125 | 984 | /** Ping |
mfiore | 0:c62615f15125 | 985 | * status will be MDOT_OK if ping succeeded |
mfiore | 0:c62615f15125 | 986 | * @returns ping_response struct containing status, RSSI, and SNR |
mfiore | 0:c62615f15125 | 987 | */ |
mfiore | 0:c62615f15125 | 988 | ping_response ping(); |
mfiore | 0:c62615f15125 | 989 | |
mfiore | 0:c62615f15125 | 990 | /** Get return code string |
mfiore | 0:c62615f15125 | 991 | * @returns string containing a description of the given error code |
mfiore | 0:c62615f15125 | 992 | */ |
mfiore | 0:c62615f15125 | 993 | static std::string getReturnCodeString(const int32_t& code); |
mfiore | 0:c62615f15125 | 994 | |
mfiore | 0:c62615f15125 | 995 | /** Get last error |
mfiore | 0:c62615f15125 | 996 | * @returns string explaining the last error that occured |
mfiore | 0:c62615f15125 | 997 | */ |
mfiore | 0:c62615f15125 | 998 | std::string getLastError(); |
mfiore | 0:c62615f15125 | 999 | |
Mike Fiore |
7:683dba5d576f | 1000 | /** Go to sleep |
Jason Reiss |
10:27dafba9fe19 | 1001 | * @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 | 1002 | * @param wakeup_mode RTC_ALARM, INTERRUPT, RTC_ALARM_OR_INTERRUPT |
Mike Fiore |
7:683dba5d576f | 1003 | * if RTC_ALARM the real time clock is configured to wake the device up after the specified interval |
Mike Fiore |
7:683dba5d576f | 1004 | * if INTERRUPT the device will wake up on the rising edge of the interrupt pin |
Jason Reiss |
10:27dafba9fe19 | 1005 | * if RTC_ALARM_OR_INTERRUPT the device will wake on the first event to occur |
Mike Fiore |
7:683dba5d576f | 1006 | * @param deepsleep if true go into deep sleep mode (lowest power, all memory and registers are lost, peripherals turned off) |
Mike Fiore |
7:683dba5d576f | 1007 | * else go into sleep mode (low power, memory and registers are maintained, peripherals stay on) |
Mike Fiore |
7:683dba5d576f | 1008 | * |
Jenkins@KEILDM1.dc.multitech.prv | 19:f3a46d2bb9b3 | 1009 | * For the MDOT |
Jenkins@KEILDM1.dc.multitech.prv | 19:f3a46d2bb9b3 | 1010 | * 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 | 1011 | * 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 | 1012 | * For the XDOT |
Jenkins@KEILDM1.dc.multitech.prv | 19:f3a46d2bb9b3 | 1013 | * 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 | 1014 | * in deepsleep mode, the device can only be woken up using the WKUP pin (PA0, WAKE) or by the RTC alarm |
Mike Fiore |
7:683dba5d576f | 1015 | */ |
Mike Fiore |
7:683dba5d576f | 1016 | void sleep(const uint32_t& interval, const uint8_t& wakeup_mode = RTC_ALARM, const bool& deepsleep = true); |
Mike Fiore |
7:683dba5d576f | 1017 | |
Mike Fiore |
7:683dba5d576f | 1018 | /** Set wake pin |
Jenkins@KEILDM1.dc.multitech.prv | 19:f3a46d2bb9b3 | 1019 | * @param pin the pin to use to wake the device from sleep mode |
Jenkins@KEILDM1.dc.multitech.prv | 19:f3a46d2bb9b3 | 1020 | * For MDOT, XBEE_DI (2-8) |
Jenkins@KEILDM1.dc.multitech.prv | 19:f3a46d2bb9b3 | 1021 | * For XDOT, GPIO (0-3), UART1_RX, or WAKE |
Mike Fiore |
7:683dba5d576f | 1022 | */ |
Mike Fiore |
7:683dba5d576f | 1023 | void setWakePin(const PinName& pin); |
Mike Fiore |
7:683dba5d576f | 1024 | |
Mike Fiore |
7:683dba5d576f | 1025 | /** Get wake pin |
Jenkins@KEILDM1.dc.multitech.prv | 19:f3a46d2bb9b3 | 1026 | * @returns the pin to use to wake the device from sleep mode |
Jenkins@KEILDM1.dc.multitech.prv | 19:f3a46d2bb9b3 | 1027 | * For MDOT, XBEE_DI (2-8) |
Jenkins@KEILDM1.dc.multitech.prv | 19:f3a46d2bb9b3 | 1028 | * For XDOT, GPIO (0-3), UART1_RX, or WAKE |
Mike Fiore |
7:683dba5d576f | 1029 | */ |
Mike Fiore |
7:683dba5d576f | 1030 | PinName getWakePin(); |
Mike Fiore |
7:683dba5d576f | 1031 | |
jreiss | 9:ec2fffe31793 | 1032 | /** Write data in a user backup register |
Jenkins@KEILDM1.dc.multitech.prv | 19:f3a46d2bb9b3 | 1033 | * @param register one of UBR0 through UBR9 for MDOT, one of UBR0 through UBR21 for XDOT |
jreiss | 9:ec2fffe31793 | 1034 | * @param data user data to back up |
jreiss | 9:ec2fffe31793 | 1035 | * @returns true if success |
jreiss | 9:ec2fffe31793 | 1036 | */ |
jreiss | 9:ec2fffe31793 | 1037 | bool writeUserBackupRegister(uint32_t reg, uint32_t data); |
jreiss | 9:ec2fffe31793 | 1038 | |
jreiss | 9:ec2fffe31793 | 1039 | /** Read data in a user backup register |
Jenkins@KEILDM1.dc.multitech.prv | 19:f3a46d2bb9b3 | 1040 | * @param register one of UBR0 through UBR9 for MDOT, one of UBR0 through UBR21 for XDOT |
jreiss | 9:ec2fffe31793 | 1041 | * @param data gets set to content of register |
jreiss | 9:ec2fffe31793 | 1042 | * @returns true if success |
jreiss | 9:ec2fffe31793 | 1043 | */ |
jreiss | 9:ec2fffe31793 | 1044 | bool readUserBackupRegister(uint32_t reg, uint32_t& data); |
jreiss | 9:ec2fffe31793 | 1045 | |
Jenkins@KEILDM1.dc.multitech.prv | 19:f3a46d2bb9b3 | 1046 | #if defined(TARGET_MTS_MDOT_F411RE) |
Jenkins@KEILDM1.dc.multitech.prv | 31:7fdee197d415 | 1047 | /////////////////////////////////////////////////////////////////// |
Jenkins@KEILDM1.dc.multitech.prv | 31:7fdee197d415 | 1048 | // Filesystem (Non Volatile Memory) Operation Functions for mDot // |
Jenkins@KEILDM1.dc.multitech.prv | 31:7fdee197d415 | 1049 | /////////////////////////////////////////////////////////////////// |
Jenkins@KEILDM1.dc.multitech.prv | 31:7fdee197d415 | 1050 | |
Mike Fiore |
11:d8464345e1f1 | 1051 | // Save user file data to flash |
Mike Fiore |
11:d8464345e1f1 | 1052 | // file - name of file max 30 chars |
Mike Fiore |
11:d8464345e1f1 | 1053 | // data - data of file |
Mike Fiore |
11:d8464345e1f1 | 1054 | // size - size of file |
Jenkins@KEILDM1.dc.multitech.prv | 31:7fdee197d415 | 1055 | // returns true if successful |
Mike Fiore |
11:d8464345e1f1 | 1056 | bool saveUserFile(const char* file, void* data, uint32_t size); |
Mike Fiore |
11:d8464345e1f1 | 1057 | |
Mike Fiore |
11:d8464345e1f1 | 1058 | // Append user file data to flash |
Mike Fiore |
11:d8464345e1f1 | 1059 | // file - name of file max 30 chars |
Mike Fiore |
11:d8464345e1f1 | 1060 | // data - data of file |
Mike Fiore |
11:d8464345e1f1 | 1061 | // size - size of file |
Jenkins@KEILDM1.dc.multitech.prv | 31:7fdee197d415 | 1062 | // returns true if successful |
Mike Fiore |
11:d8464345e1f1 | 1063 | bool appendUserFile(const char* file, void* data, uint32_t size); |
Mike Fiore |
11:d8464345e1f1 | 1064 | |
Mike Fiore |
11:d8464345e1f1 | 1065 | // Read user file data from flash |
Mike Fiore |
11:d8464345e1f1 | 1066 | // file - name of file max 30 chars |
Mike Fiore |
11:d8464345e1f1 | 1067 | // data - data of file |
Mike Fiore |
11:d8464345e1f1 | 1068 | // size - size of file |
Jenkins@KEILDM1.dc.multitech.prv | 31:7fdee197d415 | 1069 | // returns true if successful |
Mike Fiore |
11:d8464345e1f1 | 1070 | bool readUserFile(const char* file, void* data, uint32_t size); |
Mike Fiore |
11:d8464345e1f1 | 1071 | |
Mike Fiore |
11:d8464345e1f1 | 1072 | // Move a user file in flash |
Mike Fiore |
11:d8464345e1f1 | 1073 | // file - name of file |
Mike Fiore |
11:d8464345e1f1 | 1074 | // new_name - new name of file |
Jenkins@KEILDM1.dc.multitech.prv | 31:7fdee197d415 | 1075 | // returns true if successful |
Mike Fiore |
11:d8464345e1f1 | 1076 | bool moveUserFile(const char* file, const char* new_name); |
Mike Fiore |
11:d8464345e1f1 | 1077 | |
Mike Fiore |
11:d8464345e1f1 | 1078 | // Delete user file data from flash |
Mike Fiore |
11:d8464345e1f1 | 1079 | // file - name of file max 30 chars |
Jenkins@KEILDM1.dc.multitech.prv | 31:7fdee197d415 | 1080 | // returns true if successful |
Mike Fiore |
11:d8464345e1f1 | 1081 | bool deleteUserFile(const char* file); |
Mike Fiore |
11:d8464345e1f1 | 1082 | |
Mike Fiore |
11:d8464345e1f1 | 1083 | // Open user file in flash, max of 4 files open concurrently |
Mike Fiore |
11:d8464345e1f1 | 1084 | // file - name of file max 30 chars |
Mike Fiore |
11:d8464345e1f1 | 1085 | // mode - combination of FM_APPEND | FM_TRUNC | FM_CREAT | |
Mike Fiore |
11:d8464345e1f1 | 1086 | // FM_RDONLY | FM_WRONLY | FM_RDWR | FM_DIRECT |
Mike Fiore |
11:d8464345e1f1 | 1087 | // returns - mdot_file struct, fd field will be a negative value if file could not be opened |
Mike Fiore |
11:d8464345e1f1 | 1088 | mDot::mdot_file openUserFile(const char* file, int mode); |
Mike Fiore |
11:d8464345e1f1 | 1089 | |
Mike Fiore |
11:d8464345e1f1 | 1090 | // Seek an open file |
Mike Fiore |
11:d8464345e1f1 | 1091 | // file - mdot file struct |
Mike Fiore |
11:d8464345e1f1 | 1092 | // offset - offset in bytes |
Mike Fiore |
11:d8464345e1f1 | 1093 | // whence - where offset is based SEEK_SET, SEEK_CUR, SEEK_END |
Jenkins@KEILDM1.dc.multitech.prv | 31:7fdee197d415 | 1094 | // returns true if successful |
Mike Fiore |
11:d8464345e1f1 | 1095 | bool seekUserFile(mDot::mdot_file& file, size_t offset, int whence); |
Mike Fiore |
11:d8464345e1f1 | 1096 | |
Mike Fiore |
11:d8464345e1f1 | 1097 | // Read bytes from open file |
Mike Fiore |
11:d8464345e1f1 | 1098 | // file - mdot file struct |
Mike Fiore |
11:d8464345e1f1 | 1099 | // data - mem location to store data |
Mike Fiore |
11:d8464345e1f1 | 1100 | // length - number of bytes to read |
Jenkins@KEILDM1.dc.multitech.prv | 31:7fdee197d415 | 1101 | // returns - number of bytes read, negative if error |
Mike Fiore |
11:d8464345e1f1 | 1102 | int readUserFile(mDot::mdot_file& file, void* data, size_t length); |
Mike Fiore |
11:d8464345e1f1 | 1103 | |
Mike Fiore |
11:d8464345e1f1 | 1104 | // Write bytes to open file |
Mike Fiore |
11:d8464345e1f1 | 1105 | // file - mdot file struct |
Mike Fiore |
11:d8464345e1f1 | 1106 | // data - data to write |
Mike Fiore |
11:d8464345e1f1 | 1107 | // length - number of bytes to write |
Jenkins@KEILDM1.dc.multitech.prv | 31:7fdee197d415 | 1108 | // returns - number of bytes written, negative if error |
Mike Fiore |
11:d8464345e1f1 | 1109 | int writeUserFile(mDot::mdot_file& file, void* data, size_t length); |
Mike Fiore |
11:d8464345e1f1 | 1110 | |
Mike Fiore |
11:d8464345e1f1 | 1111 | // Close open file |
Mike Fiore |
11:d8464345e1f1 | 1112 | // file - mdot file struct |
Jenkins@KEILDM1.dc.multitech.prv | 31:7fdee197d415 | 1113 | // returns true if successful |
Mike Fiore |
11:d8464345e1f1 | 1114 | bool closeUserFile(mDot::mdot_file& file); |
Mike Fiore |
11:d8464345e1f1 | 1115 | |
Mike Fiore |
11:d8464345e1f1 | 1116 | // List user files stored in flash |
Mike Fiore |
11:d8464345e1f1 | 1117 | std::vector<mDot::mdot_file> listUserFiles(); |
Mike Fiore |
11:d8464345e1f1 | 1118 | |
Mike Fiore |
11:d8464345e1f1 | 1119 | // Move file into the firmware upgrade path to be flashed on next boot |
Mike Fiore |
11:d8464345e1f1 | 1120 | // file - name of file |
Jenkins@KEILDM1.dc.multitech.prv | 31:7fdee197d415 | 1121 | // returns true if successful |
Mike Fiore |
11:d8464345e1f1 | 1122 | bool moveUserFileToFirmwareUpgrade(const char* file); |
Jenkins@KEILDM1.dc.multitech.prv | 31:7fdee197d415 | 1123 | #else |
Jenkins@KEILDM1.dc.multitech.prv | 31:7fdee197d415 | 1124 | /////////////////////////////////////////////////////////////// |
Jenkins@KEILDM1.dc.multitech.prv | 31:7fdee197d415 | 1125 | // EEPROM (Non Volatile Memory) Operation Functions for xDot // |
Jenkins@KEILDM1.dc.multitech.prv | 31:7fdee197d415 | 1126 | /////////////////////////////////////////////////////////////// |
Jenkins@KEILDM1.dc.multitech.prv | 31:7fdee197d415 | 1127 | |
Jenkins@KEILDM1.dc.multitech.prv | 31:7fdee197d415 | 1128 | // Write to EEPROM |
Jenkins@KEILDM1.dc.multitech.prv | 31:7fdee197d415 | 1129 | // addr - address to write to (0 - 0x17FF) |
Jenkins@KEILDM1.dc.multitech.prv | 31:7fdee197d415 | 1130 | // data - data to write |
Jenkins@KEILDM1.dc.multitech.prv | 31:7fdee197d415 | 1131 | // size - size of data |
Jenkins@KEILDM1.dc.multitech.prv | 31:7fdee197d415 | 1132 | // returns true if successful |
Jenkins@KEILDM1.dc.multitech.prv | 31:7fdee197d415 | 1133 | bool nvmWrite(uint16_t addr, void* data, uint16_t size); |
Jenkins@KEILDM1.dc.multitech.prv | 31:7fdee197d415 | 1134 | |
Jenkins@KEILDM1.dc.multitech.prv | 31:7fdee197d415 | 1135 | // Read from EEPROM |
Jenkins@KEILDM1.dc.multitech.prv | 31:7fdee197d415 | 1136 | // addr - address to read from (0 - 0x17FF) |
Jenkins@KEILDM1.dc.multitech.prv | 31:7fdee197d415 | 1137 | // data - buffer for data |
Jenkins@KEILDM1.dc.multitech.prv | 31:7fdee197d415 | 1138 | // size - size of buffer |
Jenkins@KEILDM1.dc.multitech.prv | 31:7fdee197d415 | 1139 | // returns true if successful |
Jenkins@KEILDM1.dc.multitech.prv | 31:7fdee197d415 | 1140 | bool nvmRead(uint16_t addr, void* data, uint16_t size); |
Jenkins@KEILDM1.dc.multitech.prv | 19:f3a46d2bb9b3 | 1141 | #endif /* TARGET_MTS_MDOT_F411RE */ |
Mike Fiore |
11:d8464345e1f1 | 1142 | |
Mike Fiore |
11:d8464345e1f1 | 1143 | // get current statistics |
Mike Fiore |
11:d8464345e1f1 | 1144 | // Join Attempts, Join Fails, Up Packets, Down Packets, Missed Acks |
Mike Fiore |
11:d8464345e1f1 | 1145 | mdot_stats getStats(); |
Mike Fiore |
11:d8464345e1f1 | 1146 | |
Mike Fiore |
11:d8464345e1f1 | 1147 | // reset statistics |
Mike Fiore |
11:d8464345e1f1 | 1148 | // Join Attempts, Join Fails, Up Packets, Down Packets, Missed Acks |
Mike Fiore |
11:d8464345e1f1 | 1149 | void resetStats(); |
Mike Fiore |
11:d8464345e1f1 | 1150 | |
Mike Fiore |
11:d8464345e1f1 | 1151 | // Convert pin number 2-8 to pin name DIO2-DI8 |
Mike Fiore |
11:d8464345e1f1 | 1152 | static PinName pinNum2Name(uint8_t num); |
Mike Fiore |
11:d8464345e1f1 | 1153 | |
Mike Fiore |
11:d8464345e1f1 | 1154 | // Convert pin name DIO2-DI8 to pin number 2-8 |
Mike Fiore |
11:d8464345e1f1 | 1155 | static uint8_t pinName2Num(PinName name); |
Mike Fiore |
11:d8464345e1f1 | 1156 | |
Mike Fiore |
11:d8464345e1f1 | 1157 | // Convert pin name DIO2-DI8 to string |
Mike Fiore |
11:d8464345e1f1 | 1158 | static std::string pinName2Str(PinName name); |
Mike Fiore |
11:d8464345e1f1 | 1159 | |
Mike Fiore |
11:d8464345e1f1 | 1160 | uint64_t crc64(uint64_t crc, const unsigned char *s, uint64_t l); |
mfiore | 0:c62615f15125 | 1161 | |
mfiore | 0:c62615f15125 | 1162 | /************************************************************************* |
mfiore | 0:c62615f15125 | 1163 | * The following functions are only used by the AT command application and |
mfiore | 0:c62615f15125 | 1164 | * should not be used by standard applications consuming the mDot library |
mfiore | 0:c62615f15125 | 1165 | ************************************************************************/ |
Mike Fiore |
7:683dba5d576f | 1166 | |
mfiore | 0:c62615f15125 | 1167 | // set/get configured baud rate for command port |
mfiore | 0:c62615f15125 | 1168 | // only for use in conjunction with AT interface |
mfiore | 0:c62615f15125 | 1169 | // set function returns MDOT_OK if success |
mfiore | 0:c62615f15125 | 1170 | int32_t setBaud(const uint32_t& baud); |
mfiore | 0:c62615f15125 | 1171 | uint32_t getBaud(); |
mfiore | 0:c62615f15125 | 1172 | |
mfiore | 0:c62615f15125 | 1173 | // set/get baud rate for debug port |
mfiore | 0:c62615f15125 | 1174 | // set function returns MDOT_OK if success |
mfiore | 0:c62615f15125 | 1175 | int32_t setDebugBaud(const uint32_t& baud); |
mfiore | 0:c62615f15125 | 1176 | uint32_t getDebugBaud(); |
mfiore | 0:c62615f15125 | 1177 | |
mfiore | 0:c62615f15125 | 1178 | // set/get command terminal echo |
mfiore | 0:c62615f15125 | 1179 | // set function returns MDOT_OK if success |
mfiore | 0:c62615f15125 | 1180 | int32_t setEcho(const bool& on); |
mfiore | 0:c62615f15125 | 1181 | bool getEcho(); |
mfiore | 0:c62615f15125 | 1182 | |
mfiore | 0:c62615f15125 | 1183 | // set/get command terminal verbose mode |
mfiore | 0:c62615f15125 | 1184 | // set function returns MDOT_OK if success |
mfiore | 0:c62615f15125 | 1185 | int32_t setVerbose(const bool& on); |
mfiore | 0:c62615f15125 | 1186 | bool getVerbose(); |
mfiore | 0:c62615f15125 | 1187 | |
mfiore | 0:c62615f15125 | 1188 | // set/get startup mode |
mfiore | 0:c62615f15125 | 1189 | // COMMAND_MODE (default), starts up ready to accept AT commands |
mfiore | 0:c62615f15125 | 1190 | // SERIAL_MODE, read serial data and send it as LoRa packets |
mfiore | 0:c62615f15125 | 1191 | // set function returns MDOT_OK if success |
mfiore | 0:c62615f15125 | 1192 | int32_t setStartUpMode(const uint8_t& mode); |
mfiore | 0:c62615f15125 | 1193 | uint8_t getStartUpMode(); |
mfiore | 0:c62615f15125 | 1194 | |
mfiore | 0:c62615f15125 | 1195 | int32_t setRxDataRate(const uint8_t& dr); |
mfiore | 0:c62615f15125 | 1196 | uint8_t getRxDataRate(); |
mfiore | 0:c62615f15125 | 1197 | |
mfiore | 0:c62615f15125 | 1198 | // get/set TX/RX frequency |
mfiore | 0:c62615f15125 | 1199 | // if frequency band == FB_868 (Europe), must be between 863000000 - 870000000 |
mfiore | 0:c62615f15125 | 1200 | // if frequency band == FB_915 (United States), must be between 902000000-928000000 |
mfiore | 0:c62615f15125 | 1201 | // if set to 0, device will hop frequencies |
mfiore | 0:c62615f15125 | 1202 | // set function returns MDOT_OK if success |
mfiore | 0:c62615f15125 | 1203 | int32_t setTxFrequency(const uint32_t& freq); |
mfiore | 0:c62615f15125 | 1204 | uint32_t getTxFrequency(); |
mfiore | 0:c62615f15125 | 1205 | int32_t setRxFrequency(const uint32_t& freq); |
mfiore | 0:c62615f15125 | 1206 | uint32_t getRxFrequency(); |
mfiore | 0:c62615f15125 | 1207 | |
mfiore | 0:c62615f15125 | 1208 | // get/set TX/RX inverted |
mfiore | 0:c62615f15125 | 1209 | // true == signal is inverted |
mfiore | 0:c62615f15125 | 1210 | // set function returns MDOT_OK if success |
mfiore | 0:c62615f15125 | 1211 | int32_t setTxInverted(const bool& on); |
mfiore | 0:c62615f15125 | 1212 | bool getTxInverted(); |
mfiore | 0:c62615f15125 | 1213 | int32_t setRxInverted(const bool& on); |
mfiore | 0:c62615f15125 | 1214 | bool getRxInverted(); |
mfiore | 0:c62615f15125 | 1215 | |
mfiore | 0:c62615f15125 | 1216 | // get/set RX output mode |
mfiore | 0:c62615f15125 | 1217 | // valid options are HEXADECIMAL and BINARY |
mfiore | 0:c62615f15125 | 1218 | // set function returns MDOT_OK if success |
mfiore | 0:c62615f15125 | 1219 | int32_t setRxOutput(const uint8_t& mode); |
mfiore | 0:c62615f15125 | 1220 | uint8_t getRxOutput(); |
mfiore | 0:c62615f15125 | 1221 | |
mfiore | 0:c62615f15125 | 1222 | // get/set serial wake interval |
mfiore | 0:c62615f15125 | 1223 | // valid values are 2 s - INT_MAX (2147483647) s |
mfiore | 0:c62615f15125 | 1224 | // set function returns MDOT_OK if success |
Mike Fiore |
7:683dba5d576f | 1225 | int32_t setWakeInterval(const uint32_t& interval); |
Mike Fiore |
7:683dba5d576f | 1226 | uint32_t getWakeInterval(); |
mfiore | 0:c62615f15125 | 1227 | |
mfiore | 0:c62615f15125 | 1228 | // get/set serial wake delay |
mfiore | 0:c62615f15125 | 1229 | // valid values are 2 ms - INT_MAX (2147483647) ms |
mfiore | 0:c62615f15125 | 1230 | // set function returns MDOT_OK if success |
Mike Fiore |
7:683dba5d576f | 1231 | int32_t setWakeDelay(const uint32_t& delay); |
Mike Fiore |
7:683dba5d576f | 1232 | uint32_t getWakeDelay(); |
mfiore | 0:c62615f15125 | 1233 | |
mfiore | 0:c62615f15125 | 1234 | // get/set serial receive timeout |
mfiore | 0:c62615f15125 | 1235 | // valid values are 0 ms - 65000 ms |
mfiore | 0:c62615f15125 | 1236 | // set function returns MDOT_OK if success |
Mike Fiore |
7:683dba5d576f | 1237 | int32_t setWakeTimeout(const uint16_t& timeout); |
Mike Fiore |
7:683dba5d576f | 1238 | uint16_t getWakeTimeout(); |
Mike Fiore |
7:683dba5d576f | 1239 | |
Mike Fiore |
7:683dba5d576f | 1240 | // get/set serial wake mode |
Mike Fiore |
7:683dba5d576f | 1241 | // valid values are INTERRUPT or RTC_ALARM |
Mike Fiore |
7:683dba5d576f | 1242 | // set function returns MDOT_OK if success |
Mike Fiore |
7:683dba5d576f | 1243 | int32_t setWakeMode(const uint8_t& delay); |
Mike Fiore |
7:683dba5d576f | 1244 | uint8_t getWakeMode(); |
Mike Fiore |
7:683dba5d576f | 1245 | |
Mike Fiore |
12:54f9cac9d690 | 1246 | // get/set serial flow control enabled |
Mike Fiore |
12:54f9cac9d690 | 1247 | // set function returns MDOT_OK if success |
Mike Fiore |
12:54f9cac9d690 | 1248 | int32_t setFlowControl(const bool& on); |
Mike Fiore |
12:54f9cac9d690 | 1249 | bool getFlowControl(); |
Mike Fiore |
12:54f9cac9d690 | 1250 | |
Mike Fiore |
12:54f9cac9d690 | 1251 | // get/set serial clear on error |
Mike Fiore |
12:54f9cac9d690 | 1252 | // 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 | 1253 | // set function returns MDOT_OK if success |
Mike Fiore |
12:54f9cac9d690 | 1254 | int32_t setSerialClearOnError(const bool& on); |
Mike Fiore |
12:54f9cac9d690 | 1255 | bool getSerialClearOnError(); |
mfiore | 0:c62615f15125 | 1256 | |
mfiore | 0:c62615f15125 | 1257 | // MTS_RADIO_DEBUG_COMMANDS |
Mike Fiore |
7:683dba5d576f | 1258 | |
Mike Fiore |
16:b630e18103e5 | 1259 | /** Disable Duty cycle |
Mike Fiore |
16:b630e18103e5 | 1260 | * enables or disables the duty cycle limitations |
Mike Fiore |
16:b630e18103e5 | 1261 | * **** ONLY TO BE USED FOR TESTINGS PURPOSES **** |
Mike Fiore |
16:b630e18103e5 | 1262 | * **** ALL DEPLOYABLE CODE MUST ADHERE TO LOCAL REGULATIONS **** |
Mike Fiore |
16:b630e18103e5 | 1263 | * **** THIS SETTING WILL NOT BE SAVED TO CONFIGURATION ***** |
Mike Fiore |
16:b630e18103e5 | 1264 | * @param val true to disable duty-cycle (default:false) |
Mike Fiore |
16:b630e18103e5 | 1265 | */ |
Mike Fiore |
16:b630e18103e5 | 1266 | int32_t setDisableDutyCycle(bool val); |
Mike Fiore |
16:b630e18103e5 | 1267 | |
Mike Fiore |
16:b630e18103e5 | 1268 | /** Disable Duty cycle |
Mike Fiore |
16:b630e18103e5 | 1269 | * **** ONLY TO BE USED FOR TESTINGS PURPOSES **** |
Mike Fiore |
16:b630e18103e5 | 1270 | * **** ALL DEPLOYABLE CODE MUST ADHERE TO LOCAL REGULATIONS **** |
Mike Fiore |
16:b630e18103e5 | 1271 | * **** THIS SETTING WILL NOT BE SAVED TO CONFIGURATION ***** |
Mike Fiore |
16:b630e18103e5 | 1272 | * @return true if duty-cycle is disabled (default:false) |
Mike Fiore |
16:b630e18103e5 | 1273 | */ |
Mike Fiore |
16:b630e18103e5 | 1274 | uint8_t getDisableDutyCycle(); |
Mike Fiore |
16:b630e18103e5 | 1275 | |
Mike Fiore |
7:683dba5d576f | 1276 | void openRxWindow(uint32_t timeout, uint8_t bandwidth = 0); |
Mike Fiore |
16:b630e18103e5 | 1277 | void closeRxWindow(); |
Mike Fiore |
16:b630e18103e5 | 1278 | void sendContinuous(bool enable=true); |
mfiore | 0:c62615f15125 | 1279 | int32_t setDeviceId(const std::vector<uint8_t>& id); |
mfiore | 0:c62615f15125 | 1280 | int32_t setFrequencyBand(const uint8_t& band); |
mfiore | 0:c62615f15125 | 1281 | bool saveProtectedConfig(); |
mfiore | 0:c62615f15125 | 1282 | void resetRadio(); |
mfiore | 0:c62615f15125 | 1283 | int32_t setRadioMode(const uint8_t& mode); |
mfiore | 0:c62615f15125 | 1284 | std::map<uint8_t, uint8_t> dumpRegisters(); |
mfiore | 0:c62615f15125 | 1285 | void eraseFlash(); |
mfiore | 0:c62615f15125 | 1286 | |
Mike Fiore |
7:683dba5d576f | 1287 | // deprecated - use setWakeInterval |
Mike Fiore |
7:683dba5d576f | 1288 | int32_t setSerialWakeInterval(const uint32_t& interval); |
Mike Fiore |
7:683dba5d576f | 1289 | // deprecated - use getWakeInterval |
Mike Fiore |
7:683dba5d576f | 1290 | uint32_t getSerialWakeInterval(); |
Mike Fiore |
6:390fc83d588d | 1291 | |
Mike Fiore |
7:683dba5d576f | 1292 | // deprecated - use setWakeDelay |
Mike Fiore |
7:683dba5d576f | 1293 | int32_t setSerialWakeDelay(const uint32_t& delay); |
Mike Fiore |
7:683dba5d576f | 1294 | // deprecated - use setWakeDelay |
Mike Fiore |
7:683dba5d576f | 1295 | uint32_t getSerialWakeDelay(); |
Mike Fiore |
7:683dba5d576f | 1296 | |
Mike Fiore |
7:683dba5d576f | 1297 | // deprecated - use setWakeTimeout |
Mike Fiore |
7:683dba5d576f | 1298 | int32_t setSerialReceiveTimeout(const uint16_t& timeout); |
Mike Fiore |
7:683dba5d576f | 1299 | // deprecated - use getWakeTimeout |
Mike Fiore |
7:683dba5d576f | 1300 | uint16_t getSerialReceiveTimeout(); |
mfiore | 0:c62615f15125 | 1301 | |
Mike Fiore |
11:d8464345e1f1 | 1302 | void setWakeupCallback(void (*function)(void)); |
Mike Fiore |
11:d8464345e1f1 | 1303 | |
Mike Fiore |
11:d8464345e1f1 | 1304 | template<typename T> |
Mike Fiore |
11:d8464345e1f1 | 1305 | void setWakeupCallback(T *object, void (T::*member)(void)) { |
Mike Fiore |
11:d8464345e1f1 | 1306 | _wakeup_callback.attach(object, member); |
Mike Fiore |
11:d8464345e1f1 | 1307 | } |
Mike Fiore |
11:d8464345e1f1 | 1308 | |
mfiore | 0:c62615f15125 | 1309 | private: |
mfiore | 0:c62615f15125 | 1310 | mdot_stats _stats; |
mfiore | 0:c62615f15125 | 1311 | |
Mike Fiore |
11:d8464345e1f1 | 1312 | FunctionPointer _wakeup_callback; |
Mike Fiore |
11:d8464345e1f1 | 1313 | |
Mike Fiore |
12:54f9cac9d690 | 1314 | bool _standbyFlag; |
Mike Fiore |
12:54f9cac9d690 | 1315 | bool _testMode; |
Mike Fiore |
12:54f9cac9d690 | 1316 | uint8_t _savedPort; |
Mike Fiore |
12:54f9cac9d690 | 1317 | void handleTestModePacket(); |
Mike Fiore |
12:54f9cac9d690 | 1318 | |
mfiore | 0:c62615f15125 | 1319 | }; |
mfiore | 0:c62615f15125 | 1320 | |
mfiore | 0:c62615f15125 | 1321 | #endif |