STM32LoRaWAN
Loading...
Searching...
No Matches
STM32LoRaWAN.h
Go to the documentation of this file.
1#pragma once
2
42#include "Arduino.h"
43#include "STM32CubeWL/LoRaWAN/Mac/LoRaMac.h"
44#include "BSP/mw_log_conf.h"
45#include "BSP/timer_if.h"
46#include "STM32RTC.h"
47
48
53typedef enum {
54 AS923 = LORAMAC_REGION_AS923,
55 AU915 = LORAMAC_REGION_AU915,
56 CN470 = LORAMAC_REGION_CN470,
57 CN779 = LORAMAC_REGION_CN779,
58 EU433 = LORAMAC_REGION_EU433,
59 EU868 = LORAMAC_REGION_EU868,
60 KR920 = LORAMAC_REGION_KR920,
61 IN865 = LORAMAC_REGION_IN865,
62 US915 = LORAMAC_REGION_US915,
63 RU864 = LORAMAC_REGION_RU864,
64 // TODO: AU915_TTN = 0x80 | AU915,
66
67typedef enum {
68 RFO = 0,
70} _rf_mode;
71
72// Reuse enum from STM32CubeWL that uses the same names
73using _lora_class = DeviceClass_t;
74
75class STM32LoRaWAN : public Stream {
76 public:
92 bool begin(_lora_band band);
94
95
134 bool joinOTAA(const char *appEui, const char *appKey, const char *devEui) { return setDevEui(devEui) && joinOTAA(appEui, appKey); }
135 bool joinOTAA(const char *appEui, const char *appKey) { return setAppEui(appEui) && setAppKey(appKey) && joinOTAA(); }
136 bool joinOTAA(String appEui, String appKey) { return joinOTAA(appEui.c_str(), appKey.c_str()); }
137 bool joinOTAA(String appEui, String appKey, String devEui) { return joinOTAA(appEui.c_str(), appKey.c_str(), devEui.c_str()); }
139 bool joinOTAA(uint64_t appEui, const char *appKey, uint64_t devEui) { return setDevEui(devEui) && joinOTAA(appEui, appKey); }
141 bool joinOTAA(uint64_t appEui, const char *appKey) { return setAppEui(appEui) && setAppKey(appKey) && joinOTAA(); }
143 bool joinOTAA(uint64_t appEui, String appKey, uint64_t devEui) { return joinOTAA(appEui, appKey.c_str(), devEui); }
145 bool joinOTAA(uint64_t appEui, String appKey) { return joinOTAA(appEui, appKey.c_str()); }
146
153 bool joinOTAA();
155
179 bool joinABP(const char *devAddr, const char *nwkSKey, const char *appSKey) { return setDevAddr(devAddr) && setNwkSKey(nwkSKey) && setAppSKey(appSKey) && joinABP(); }
180 bool joinABP(String devAddr, String nwkSKey, String appSKey) { return joinABP(devAddr.c_str(), nwkSKey.c_str(), appSKey.c_str()); }
181 bool joinABP(uint32_t devAddr, String nwkSKey, String appSKey) { return setDevAddr(devAddr) && setNwkSKey(nwkSKey) && setAppSKey(appSKey) && joinABP(); }
182
189 bool joinABP();
191
192
212 void beginPacket();
227 int endPacket(bool confirmed = false);
229
230
249 virtual size_t write(uint8_t c);
250 virtual size_t write(const uint8_t *buffer, size_t size);
251
252 template <typename T> inline size_t write(T val) { return write((uint8_t *)&val, sizeof(T)); };
253 using Print::write;
254
265 virtual int availableForWrite();
266
270 virtual void flush() { }
271
273
274
296 int parsePacket();
297
301 uint8_t getDownlinkPort() { return rx_port; }
302
306 int16_t getDownlinkRssi() { return rx_rssi; }
307
311 int8_t getDownlinkSnr() { return rx_snr; }
313
314
339 int read(uint8_t *buf, size_t size);
340 virtual int available();
341 virtual int read();
342 virtual int peek();
343
344
357 bool setDevEui(const char *value) { return mibSetHex("DevEui", MIB_DEV_EUI, value); }
358 bool setDevEui(String value) { return setDevEui(value.c_str()); }
359 bool setDevEui(uint64_t value) { return mibSetUint64("DevEui", MIB_DEV_EUI, value); }
360 bool setAppEui(const char *value) { return mibSetHex("AppEui", MIB_JOIN_EUI, value); }
361 bool setAppEui(String value) { return setAppEui(value.c_str()); }
362 bool setAppEui(uint64_t value) { return mibSetUint64("AppEui", MIB_JOIN_EUI, value); }
363 bool setDevAddr(const char *value) { return mibSetHex("DevAddr", MIB_DEV_ADDR, value); }
364 bool setDevAddr(String value) { return setDevAddr(value.c_str()); }
365 bool setDevAddr(uint32_t value) { return mibSetUint32("DevAddr", MIB_DEV_ADDR, value); }
366 bool setAppKey(const char *value)
367 {
368 // In LoRaWAN 1.0, only the appKey was configured and all keys
369 // were derived from that. In 1.1, this was split into an appKey
370 // and nwkKey. However, when running the LoRaMac-Node in 1.0 mode,
371 // it actually seems to use nwkKey, not appKey. So to support
372 // sketches that only configure appKey for 1.0, this saves the
373 // appKey to nwkKey as well. But to also prepare for future
374 // support of 1.1 and sketches that configure both, only do this
375 // if no nwkKey was explicitly configured.
376 return mibSetHex("AppKey", MIB_APP_KEY, value)
377 && (this->nwk_key_set || mibSetHex("NwkKey", MIB_NWK_KEY, value));
378
379 }
380 bool setAppKey(String value) { return setAppKey(value.c_str()); }
381 bool setNwkKey(const char *value)
382 {
383 this->nwk_key_set = true;
384 return mibSetHex("NwkKey", MIB_NWK_KEY, value);
385 }
386 bool setNwkKey(String value) { return setNwkKey(value.c_str()); }
387 bool setAppSKey(const char *value) { return mibSetHex("AppSKey", MIB_APP_S_KEY, value); }
388 bool setAppSKey(String value) { return setAppSKey(value.c_str()); }
389 bool setNwkSKey(const char *value)
390 {
391#if (defined( LORAMAC_VERSION ) && ( LORAMAC_VERSION == 0x01010100 ))
392 // When compiled for 1.1 crypto, three different keys are used.
393 // When the sketch only supplies a single key, just set all
394 // three keys to the same value.
395 return mibSetHex("NwkSEncKey", MIB_NWK_S_ENC_KEY, value)
396 && mibSetHex("FNwkSIntKey", MIB_F_NWK_S_INT_KEY, value)
397 && mibSetHex("SNwkSIntKey", MIB_S_NWK_S_INT_KEY, value);
398#else /* ( LORAMAC_VERSION == 0x01010100 ) */
399 return mibSetHex("NwkSKey", MIB_NWK_S_KEY, value);
400#endif /* ( LORAMAC_VERSION == 0x01010100 ) */
401 }
402 bool setNwkSKey(String value) { return setNwkSKey(value.c_str()); }
403
404#if (defined( LORAMAC_VERSION ) && ( LORAMAC_VERSION == 0x01010100 ))
405 bool setNwkSEncKey(const char *value) { return mibSetHex("NwkSEncKey", MIB_NWK_S_ENC_KEY, value); }
406 bool setNwkSEncKey(String value) { return setNwkSEncKey(value.c_str()); }
407 bool setFNwkSIntKey(const char *value) { return mibSetHex("FNwkSIntKey", MIB_F_NWK_S_INT_KEY, value); }
408 bool setFNwkSIntKey(String value) { return setFNwkSIntKey(value.c_str()); }
409 bool setSNwkSIntKey(const char *value) { return mibSetHex("SNwkSIntKey", MIB_S_NWK_S_INT_KEY, value); }
410 bool setSNwkSIntKey(String value) { return setSNwkSIntKey(value.c_str()); }
411#endif /* ( LORAMAC_VERSION == 0x01010100 ) */
413
426 bool getDevEui(String *value) { return mibGetHex("DevEui", MIB_DEV_EUI, value); }
427 bool getDevEui(uint64_t *value) { return mibGetUint64("DevEui", MIB_DEV_EUI, value); }
428 bool getAppEui(String *value) { return mibGetHex("AppEui", MIB_JOIN_EUI, value); }
429 bool getAppEui(uint64_t *value) { return mibGetUint64("AppEui", MIB_JOIN_EUI, value); }
430 bool getDevAddr(String *value) { return mibGetHex("DevAddr", MIB_DEV_ADDR, value); }
431 bool getDevAddr(uint32_t *value) { return mibGetUint32("DevAddr", MIB_DEV_ADDR, value); }
433
434
447 String deviceEUI();
448 String getDevAddr();
449
455 bool connected();
456
465 bool busy();
466
470 operator bool() { return connected(); }
472
473
486 bool dataRate(uint8_t dr);
488 int getDataRate();
505 bool power(uint8_t index);
506
516 bool power(_rf_mode mode, uint8_t index) { (void)mode; return power(index); }
517
535 bool powerdB(int8_t db);
536
538 uint8_t getPort();
540 bool setPort(uint8_t port);
541
556 bool setADR(bool adr);
558 int getADR();
560
561
575 bool dutyCycle(bool on);
576
582 bool publicNetwork(bool publicNetwork);
583
585 int getRX2DR();
591 bool setRX2DR(uint8_t dr);
592
594 uint32_t getRX2Freq();
600 bool setRX2Freq(uint32_t freq);
601
603 int getrxfreq();
605
606
625 bool enableChannel(unsigned pos);
626 bool disableChannel(unsigned pos);
628 bool modifyChannelEnabled(unsigned pos, bool value);
629 bool isChannelEnabled(unsigned pos);
631
632
648 int32_t getFCU();
649
654 int32_t getFCD();
655
657 [[gnu::error("Not implemented in STM32LoRaWAN")]]
658 bool setFCD(uint16_t fcd);
659
661 [[gnu::error("Not implemented in STM32LoRaWAN")]]
662 bool setFCU(uint16_t fcu);
663
665
666
678 bool mibGet(const char *name, Mib_t type, MibRequestConfirm_t &mibReq);
679 bool mibGetBool(const char *name, Mib_t type, bool *value);
680 bool mibGetUint8(const char *name, Mib_t type, uint8_t *value);
681 bool mibGetInt8(const char *name, Mib_t type, int8_t *value);
682 bool mibGetUint32(const char *name, Mib_t type, uint32_t *value);
683 bool mibGetUint64(const char *name, Mib_t type, uint64_t *value);
684 bool mibGetHex(const char *name, Mib_t type, String *value);
685 bool mibGetRxChannelParams(const char *name, Mib_t type, RxChannelParams_t *value);
686 bool mibGetPtr(const char *name, Mib_t type, void **value);
687 bool mibSet(const char *name, Mib_t type, MibRequestConfirm_t &mibReq);
688 bool mibSetBool(const char *name, Mib_t type, bool value);
689 bool mibSetUint8(const char *name, Mib_t type, uint8_t value);
690 bool mibSetInt8(const char *name, Mib_t type, int8_t value);
691 bool mibSetUint32(const char *name, Mib_t type, uint32_t value);
692 bool mibSetUint64(const char *name, Mib_t type, uint64_t value);
693 bool mibSetHex(const char *name, Mib_t type, const char *value);
694 bool mibSetRxChannelParams(const char *name, Mib_t type, RxChannelParams_t value);
695 bool mibSetPtr(const char *name, Mib_t type, void *value);
696 size_t mibHexSize(const char *name, Mib_t type);
698
699
726 bool joinOTAAAsync();
727
738 int endPacketAsync(bool confirmed = false);
739
752 bool send(const uint8_t *payload, size_t size, bool confirmed);
753
763 uint8_t lastAck() { return last_tx_acked; }
764
772 void maintain();
773
780 void maintainUntilIdle();
781
801 void setMaintainNeededCallback(std::function<void(void)> callback) { this->maintain_needed_callback = callback; }
802
814 void setBatteryLevelCallback(std::function<uint8_t(void)> callback) { this->battery_level_callback = callback; }
816
829 bool continuousWave(uint32_t frequency, int8_t powerdBm, uint16_t timeout);
830
847 String version() { return "N/A"; }
848
854 [[gnu::deprecated("minPollInterval is a no-op on STM32LoRaWAN")]]
855 void minPollInterval(unsigned long)
856 { }
858
873 [[gnu::error("Not implemented in STM32LoRaWAN: confirmed uplinked better handled through endPacket()")]]
874 bool setCFM(bool cfm);
875
877 [[gnu::error("Not implemented in STM32LoRaWAN: confirmed uplinked better handled through endPacket()")]]
878 int getCFM();
879
881 [[gnu::error("Not implemented in STM32LoRaWAN: confirmed uplinked better handled through endPacket()")]]
882 int getCFS();
883
885 [[gnu::error("Not implemented in STM32LoRaWAN: No serial to configure")]]
886 bool begin(_lora_band band, uint32_t baud, uint16_t config = SERIAL_8N2);
887
889 [[gnu::error("Not implemented in STM32LoRaWAN: No serial to configure")]]
890 bool autoBaud(unsigned long timeout = 10000L);
891
893 [[gnu::error("Not implemented in STM32LoRaWAN: No serial to configure")]]
894 void setBaud(unsigned long baud);
895
897 [[gnu::error("Not implemented in STM32LoRaWAN: Test method")]]
898 String getTConf();
899
901 [[gnu::error("Not implemented in STM32LoRaWAN: Test method")]]
902 String setTConf(String params);
903
905 [[gnu::error("Not implemented in STM32LoRaWAN: Test method")]]
906 bool enTtone();
907
909 [[gnu::error("Not implemented in STM32LoRaWAN: No remote module to restart")]]
910 bool restart();
911
913 [[gnu::error("Not implemented in STM32LoRaWAN: No remote module to poll")]]
914 void poll();
915
917 [[gnu::error("Not implemented in STM32LoRaWAN: No remote module to sleep")]]
918 bool sleep(bool on = true);
919
921 [[gnu::error("Not implemented in STM32LoRaWAN: No remote module to reset")]]
923
925 [[gnu::error("Not implemented in STM32LoRaWAN: No protocol stream to configure")]]
926 bool format(bool hexMode);
927
929 [[gnu::error("Not implemented in STM32LoRaWAN: No protocol stream to configure")]]
930 void dumb();
931
933 [[gnu::error("Not implemented in STM32LoRaWAN: Internal method in MKRWAN")]]
934 bool init();
935
937 [[gnu::error("Not implemented in STM32LoRaWAN: Only class A supported")]]
939
941 [[gnu::error("Not implemented in STM32LoRaWAN: Keys cannot be retrieved")]]
942 String getNwkSKey();
943
945 [[gnu::error("Not implemented in STM32LoRaWAN: Keys cannot be retrieved")]]
946 String getAppSKey();
947
949 [[gnu::error("Not implemented in STM32LoRaWAN: Keys cannot be retrieved")]]
951
953 [[gnu::error("Not implemented in STM32LoRaWAN: Internal method in MKRWAN (use enableChannel/disableChannel instead)")]]
954 bool sendMask(String newMask);
955
957 [[gnu::error("Not implemented in STM32LoRaWAN: Internal method in MKRWAN (use enableChannel/disableChannel instead)")]]
958 bool sendMask();
959
961 [[gnu::error("Not implemented in STM32LoRaWAN: Internal method in MKRWAN (use enableChannel/disableChannel instead)")]]
963
965 [[gnu::error("Not implemented in STM32LoRaWAN: Internal method in MKRWAN (use enableChannel/disableChannel instead)")]]
967
972 [[gnu::error("Not implemented in STM32LoRaWAN: Changing band after initialization not supported")]]
975
976 protected:
977 static void MacMcpsConfirm(McpsConfirm_t *McpsConfirm);
978 static void MacMcpsIndication(McpsIndication_t *McpsIndication, LoRaMacRxStatus_t *RxStatus);
979 static void MacMlmeConfirm(MlmeConfirm_t *MlmeConfirm);
980 static void MacMlmeIndication(MlmeIndication_t *MlmeIndication, LoRaMacRxStatus_t *RxStatus);
981 static void MacProcessNotify();
982 static uint8_t GetBatteryLevel();
983
985
986 LoRaMacPrimitives_t LoRaMacPrimitives = {
988 .MacMcpsIndication = MacMcpsIndication,
989 .MacMlmeConfirm = MacMlmeConfirm,
990 .MacMlmeIndication = MacMlmeIndication,
991 };
992
993 LoRaMacCallback_t LoRaMacCallbacks = {
994 .GetBatteryLevel = GetBatteryLevel,
995 .GetTemperatureLevel = nullptr,
996 .GetUniqueId = nullptr, // Not needed, we just explicitly set the deveui in begin()
997 .GetDevAddress = nullptr, // Not needed, user explicitly configures devaddr
998 .NvmDataChange = nullptr,
999 .MacProcessNotify = MacProcessNotify,
1000 };
1001
1003 uint64_t builtinDevEUI();
1004
1010 static const char *toString(LoRaMacStatus_t);
1012 static const char *toString(LoRaMacEventInfoStatus_t);
1014 static const char *toString(Mlme_t);
1016 static const char *toString(Mcps_t);
1017
1019 static uint8_t parseHex(char c);
1021 static bool parseHex(uint8_t *dest, const char *hex, size_t dest_len);
1023 static char toHex(uint8_t b);
1025 static bool toHex(String *dest, const uint8_t *src, size_t src_len);
1026
1028 static uint32_t makeUint32(uint8_t a, uint8_t b, uint8_t c, uint8_t d) { return (uint32_t)a << 24 | (uint32_t)b << 16 | (uint32_t)c << 8 | (uint32_t)d << 0; }
1029
1034 static bool failure(const char *fmt, ...)
1035 __attribute__((format(printf, 1, 2)));
1036
1038 void clear_rx() { rx_ptr = rx_buf + sizeof(rx_buf); }
1039
1041 void add_rx(const uint8_t *buf, size_t len);
1042
1050 uint8_t tx_dr = DR_4;
1051
1053 uint8_t tx_port = 2;
1054
1056 uint8_t rx_port = 0;
1057
1059 int16_t rx_rssi = 0;
1060
1062 int8_t rx_snr = 0;
1063
1064 bool nwk_key_set = false;
1065
1066 // Buffer sizes match LORAMAC_PHY_MAXPAYLOAD (but that is not
1067 // public).
1068 uint8_t tx_buf[255];
1069 uint8_t *tx_ptr;
1070 uint8_t rx_buf[255];
1071 uint8_t *rx_ptr;
1072
1073 bool last_tx_acked = false;
1074 uint32_t fcnt_up = 0;
1075 uint32_t fcnt_down = 0;
1076
1077 std::function<void(void)> maintain_needed_callback;
1078 std::function<uint8_t(void)> battery_level_callback;
1079
1081
1082 static constexpr uint32_t DEFAULT_JOIN_TIMEOUT = 60000;
1083};
1084// For MKRWAN compatibility
_rf_mode
Definition STM32LoRaWAN.h:67
@ PABOOST
Definition STM32LoRaWAN.h:69
@ RFO
Definition STM32LoRaWAN.h:68
DeviceClass_t _lora_class
Definition STM32LoRaWAN.h:73
_lora_band
Definition STM32LoRaWAN.h:53
@ US915
Definition STM32LoRaWAN.h:62
@ KR920
Definition STM32LoRaWAN.h:60
@ AU915
Definition STM32LoRaWAN.h:55
@ RU864
Definition STM32LoRaWAN.h:63
@ EU868
Definition STM32LoRaWAN.h:59
@ EU433
Definition STM32LoRaWAN.h:58
@ CN779
Definition STM32LoRaWAN.h:57
@ IN865
Definition STM32LoRaWAN.h:61
@ AS923
Definition STM32LoRaWAN.h:54
@ CN470
Definition STM32LoRaWAN.h:56
Definition STM32LoRaWAN.h:75
bool begin(_lora_band band, uint32_t baud, uint16_t config=SERIAL_8N2)
uint8_t getPort()
Definition STM32LoRaWAN.cpp:281
LoRaMacPrimitives_t LoRaMacPrimitives
Definition STM32LoRaWAN.h:986
bool joinABP(const char *devAddr, const char *nwkSKey, const char *appSKey)
Definition STM32LoRaWAN.h:179
int getChannelMaskSize(_lora_band band)
bool setAppSKey(const char *value)
Definition STM32LoRaWAN.h:387
bool configureClass(_lora_class _class)
String getAppSKey()
bool power(_rf_mode mode, uint8_t index)
Definition STM32LoRaWAN.h:516
bool modifyChannelEnabled(unsigned pos, bool value)
Definition STM32LoRaWAN.cpp:394
bool mibSet(const char *name, Mib_t type, MibRequestConfirm_t &mibReq)
Definition STM32LoRaWAN.cpp:526
String getNwkSKey()
uint8_t rx_port
Definition STM32LoRaWAN.h:1056
bool getDevAddr(uint32_t *value)
Definition STM32LoRaWAN.h:431
uint64_t builtinDevEUI()
Definition STM32LoRaWAN.cpp:1390
bool mibGetRxChannelParams(const char *name, Mib_t type, RxChannelParams_t *value)
Definition STM32LoRaWAN.cpp:929
bool getDevEui(String *value)
Definition STM32LoRaWAN.h:426
int32_t getFCU()
Definition STM32LoRaWAN.cpp:374
bool joinABP()
Definition STM32LoRaWAN.cpp:230
bool joinOTAA(uint64_t appEui, String appKey)
Definition STM32LoRaWAN.h:145
bool joinABP(uint32_t devAddr, String nwkSKey, String appSKey)
Definition STM32LoRaWAN.h:181
bool setFCD(uint16_t fcd)
bool nwk_key_set
Definition STM32LoRaWAN.h:1064
static constexpr uint32_t DEFAULT_JOIN_TIMEOUT
Definition STM32LoRaWAN.h:1082
bool mibGetBool(const char *name, Mib_t type, bool *value)
Definition STM32LoRaWAN.cpp:537
bool mibSetInt8(const char *name, Mib_t type, int8_t value)
Definition STM32LoRaWAN.cpp:614
void maintain()
Definition STM32LoRaWAN.cpp:144
uint8_t tx_port
Definition STM32LoRaWAN.h:1053
String setTConf(String params)
bool mibSetHex(const char *name, Mib_t type, const char *value)
Definition STM32LoRaWAN.cpp:866
uint32_t fcnt_down
Definition STM32LoRaWAN.h:1075
bool joinOTAA()
Definition STM32LoRaWAN.cpp:196
static void MacMcpsIndication(McpsIndication_t *McpsIndication, LoRaMacRxStatus_t *RxStatus)
Definition STM32LoRaWAN.cpp:1412
int getADR()
Definition STM32LoRaWAN.cpp:304
bool mibSetPtr(const char *name, Mib_t type, void *value)
Definition STM32LoRaWAN.cpp:976
bool format(bool hexMode)
bool joinOTAAAsync()
Definition STM32LoRaWAN.cpp:175
bool getAppEui(String *value)
Definition STM32LoRaWAN.h:428
uint8_t lastAck()
Definition STM32LoRaWAN.h:763
uint8_t tx_buf[255]
Definition STM32LoRaWAN.h:1068
bool last_tx_acked
Definition STM32LoRaWAN.h:1073
bool setDevAddr(String value)
Definition STM32LoRaWAN.h:364
int8_t getDownlinkSnr()
Definition STM32LoRaWAN.h:311
static const char * toString(LoRaMacStatus_t)
Definition STM32LoRaWAN.cpp:1033
bool mibSetUint64(const char *name, Mib_t type, uint64_t value)
Definition STM32LoRaWAN.cpp:722
bool autoBaud(unsigned long timeout=10000L)
void beginPacket()
Definition STM32LoRaWAN.cpp:1257
bool setDevAddr(uint32_t value)
Definition STM32LoRaWAN.h:365
String getDevAddr()
bool mac_process_pending
Definition STM32LoRaWAN.h:1080
int parsePacket()
Definition STM32LoRaWAN.cpp:1359
std::function< uint8_t(void)> battery_level_callback
Definition STM32LoRaWAN.h:1078
size_t mibHexSize(const char *name, Mib_t type)
Definition STM32LoRaWAN.cpp:745
bool connected()
Definition STM32LoRaWAN.cpp:1012
int endPacketAsync(bool confirmed=false)
Definition STM32LoRaWAN.cpp:1262
String getTConf()
bool dataRate(uint8_t dr)
Definition STM32LoRaWAN.cpp:242
int getDataRate()
Definition STM32LoRaWAN.cpp:247
bool joinOTAA(uint64_t appEui, String appKey, uint64_t devEui)
Definition STM32LoRaWAN.h:143
bool setAppEui(String value)
Definition STM32LoRaWAN.h:361
bool joinOTAA(const char *appEui, const char *appKey, const char *devEui)
Definition STM32LoRaWAN.h:134
bool mibGetPtr(const char *name, Mib_t type, void **value)
Definition STM32LoRaWAN.cpp:960
bool setAppEui(const char *value)
Definition STM32LoRaWAN.h:360
bool setAppEui(uint64_t value)
Definition STM32LoRaWAN.h:362
bool factoryDefault()
bool setRX2Freq(uint32_t freq)
Definition STM32LoRaWAN.cpp:348
static char toHex(uint8_t b)
Definition STM32LoRaWAN.cpp:1227
bool mibGetHex(const char *name, Mib_t type, String *value)
Definition STM32LoRaWAN.cpp:795
static STM32LoRaWAN * instance
Definition STM32LoRaWAN.h:984
bool mibGetUint64(const char *name, Mib_t type, uint64_t *value)
Definition STM32LoRaWAN.cpp:697
virtual size_t write(uint8_t c)
Definition STM32LoRaWAN.cpp:1286
int16_t getDownlinkRssi()
Definition STM32LoRaWAN.h:306
static void MacMlmeIndication(MlmeIndication_t *MlmeIndication, LoRaMacRxStatus_t *RxStatus)
Definition STM32LoRaWAN.cpp:1441
int getrxfreq()
Definition STM32LoRaWAN.cpp:314
virtual void flush()
Definition STM32LoRaWAN.h:270
bool sendMask()
bool enableChannel(unsigned pos)
Definition STM32LoRaWAN.cpp:384
bool disableChannel(unsigned pos)
Definition STM32LoRaWAN.cpp:389
static void MacMcpsConfirm(McpsConfirm_t *McpsConfirm)
Definition STM32LoRaWAN.cpp:1395
bool joinOTAA(String appEui, String appKey, String devEui)
Definition STM32LoRaWAN.h:137
String deviceEUI()
Definition STM32LoRaWAN.cpp:1024
static void MacProcessNotify()
Definition STM32LoRaWAN.cpp:124
int endPacket(bool confirmed=false)
Definition STM32LoRaWAN.cpp:1273
bool mibSetRxChannelParams(const char *name, Mib_t type, RxChannelParams_t value)
Definition STM32LoRaWAN.cpp:946
bool joinABP(String devAddr, String nwkSKey, String appSKey)
Definition STM32LoRaWAN.h:180
int32_t getFCD()
Definition STM32LoRaWAN.cpp:379
bool mibGetInt8(const char *name, Mib_t type, int8_t *value)
Definition STM32LoRaWAN.cpp:593
LoRaMacCallback_t LoRaMacCallbacks
Definition STM32LoRaWAN.h:993
String getChannelMask()
bool restart()
virtual int availableForWrite()
Definition STM32LoRaWAN.cpp:1306
bool configureBand(_lora_band band)
bool setNwkKey(String value)
Definition STM32LoRaWAN.h:386
bool setNwkKey(const char *value)
Definition STM32LoRaWAN.h:381
bool mibGetUint32(const char *name, Mib_t type, uint32_t *value)
Definition STM32LoRaWAN.cpp:632
bool setAppSKey(String value)
Definition STM32LoRaWAN.h:388
bool getAppEui(uint64_t *value)
Definition STM32LoRaWAN.h:429
virtual int peek()
Definition STM32LoRaWAN.cpp:1351
bool setCFM(bool cfm)
void setBaud(unsigned long baud)
bool setNwkSKey(String value)
Definition STM32LoRaWAN.h:402
virtual int available()
Definition STM32LoRaWAN.cpp:1338
bool sleep(bool on=true)
bool joinOTAA(uint64_t appEui, const char *appKey)
Definition STM32LoRaWAN.h:141
virtual int read()
Definition STM32LoRaWAN.cpp:1343
bool getDevEui(uint64_t *value)
Definition STM32LoRaWAN.h:427
bool mibSetUint8(const char *name, Mib_t type, uint8_t value)
Definition STM32LoRaWAN.cpp:581
bool isChannelEnabled(unsigned pos)
Definition STM32LoRaWAN.cpp:430
size_t write(T val)
Definition STM32LoRaWAN.h:252
bool setDevEui(String value)
Definition STM32LoRaWAN.h:358
static uint8_t parseHex(char c)
Definition STM32LoRaWAN.cpp:1195
bool setFCU(uint16_t fcu)
void setBatteryLevelCallback(std::function< uint8_t(void)> callback)
Definition STM32LoRaWAN.h:814
bool busy()
Definition STM32LoRaWAN.cpp:1019
String version()
Definition STM32LoRaWAN.h:847
bool setDevEui(uint64_t value)
Definition STM32LoRaWAN.h:359
static uint32_t makeUint32(uint8_t a, uint8_t b, uint8_t c, uint8_t d)
Definition STM32LoRaWAN.h:1028
bool setAppKey(const char *value)
Definition STM32LoRaWAN.h:366
static uint8_t GetBatteryLevel()
Definition STM32LoRaWAN.cpp:133
bool continuousWave(uint32_t frequency, int8_t powerdBm, uint16_t timeout)
Definition STM32LoRaWAN.cpp:159
bool setDevAddr(const char *value)
Definition STM32LoRaWAN.h:363
uint8_t tx_dr
Definition STM32LoRaWAN.h:1050
uint8_t * tx_ptr
Definition STM32LoRaWAN.h:1069
uint8_t rx_buf[255]
Definition STM32LoRaWAN.h:1070
bool mibGet(const char *name, Mib_t type, MibRequestConfirm_t &mibReq)
Definition STM32LoRaWAN.cpp:515
static bool void clear_rx()
Definition STM32LoRaWAN.h:1038
bool powerdB(int8_t db)
Definition STM32LoRaWAN.cpp:261
uint32_t fcnt_up
Definition STM32LoRaWAN.h:1074
bool begin(_lora_band band)
Definition STM32LoRaWAN.cpp:62
bool send(const uint8_t *payload, size_t size, bool confirmed)
Definition STM32LoRaWAN.cpp:459
bool dutyCycle(bool on)
Definition STM32LoRaWAN.cpp:269
void add_rx(const uint8_t *buf, size_t len)
Definition STM32LoRaWAN.cpp:1365
std::function< void(void)> maintain_needed_callback
Definition STM32LoRaWAN.h:1077
bool mibSetBool(const char *name, Mib_t type, bool value)
Definition STM32LoRaWAN.cpp:553
bool mibSetUint32(const char *name, Mib_t type, uint32_t value)
Definition STM32LoRaWAN.cpp:666
bool power(uint8_t index)
Definition STM32LoRaWAN.cpp:256
uint32_t getRX2Freq()
Definition STM32LoRaWAN.cpp:339
bool mibGetUint8(const char *name, Mib_t type, uint8_t *value)
Definition STM32LoRaWAN.cpp:566
uint8_t * rx_ptr
Definition STM32LoRaWAN.h:1071
void minPollInterval(unsigned long)
Definition STM32LoRaWAN.h:855
bool enTtone()
static void MacMlmeConfirm(MlmeConfirm_t *MlmeConfirm)
Definition STM32LoRaWAN.cpp:1432
static bool failure(const char *fmt,...) __attribute__((format(printf
Definition STM32LoRaWAN.cpp:1248
bool setADR(bool adr)
Definition STM32LoRaWAN.cpp:299
bool setRX2DR(uint8_t dr)
Definition STM32LoRaWAN.cpp:328
bool joinOTAA(uint64_t appEui, const char *appKey, uint64_t devEui)
Definition STM32LoRaWAN.h:139
uint8_t getDownlinkPort()
Definition STM32LoRaWAN.h:301
int8_t rx_snr
Definition STM32LoRaWAN.h:1062
void setMaintainNeededCallback(std::function< void(void)> callback)
Definition STM32LoRaWAN.h:801
int getRX2DR()
Definition STM32LoRaWAN.cpp:319
bool sendMask(String newMask)
int16_t rx_rssi
Definition STM32LoRaWAN.h:1059
bool setAppKey(String value)
Definition STM32LoRaWAN.h:380
bool setPort(uint8_t port)
Definition STM32LoRaWAN.cpp:275
bool joinOTAA(String appEui, String appKey)
Definition STM32LoRaWAN.h:136
String applicationKey()
bool getDevAddr(String *value)
Definition STM32LoRaWAN.h:430
bool setDevEui(const char *value)
Definition STM32LoRaWAN.h:357
bool setNwkSKey(const char *value)
Definition STM32LoRaWAN.h:389
bool joinOTAA(const char *appEui, const char *appKey)
Definition STM32LoRaWAN.h:135
bool publicNetwork(bool publicNetwork)
Definition STM32LoRaWAN.cpp:293
void maintainUntilIdle()
Definition STM32LoRaWAN.cpp:152