STM32LoRaWAN
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 
53 typedef 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,
65 } _lora_band;
66 
67 typedef enum {
68  RFO = 0,
70 } _rf_mode;
71 
72 // Reuse enum from STM32CubeWL that uses the same names
73 using _lora_class = DeviceClass_t;
74 
75 class 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; }
303 
304 
329  int read(uint8_t *buf, size_t size);
330  virtual int available();
331  virtual int read();
332  virtual int peek();
333 
334 
347  bool setDevEui(const char *value) { return mibSetHex("DevEui", MIB_DEV_EUI, value); }
348  bool setDevEui(String value) { return setDevEui(value.c_str()); }
349  bool setDevEui(uint64_t value) { return mibSetUint64("DevEui", MIB_DEV_EUI, value); }
350  bool setAppEui(const char *value) { return mibSetHex("AppEui", MIB_JOIN_EUI, value); }
351  bool setAppEui(String value) { return setAppEui(value.c_str()); }
352  bool setAppEui(uint64_t value) { return mibSetUint64("AppEui", MIB_JOIN_EUI, value); }
353  bool setDevAddr(const char *value) { return mibSetHex("DevAddr", MIB_DEV_ADDR, value); }
354  bool setDevAddr(String value) { return setDevAddr(value.c_str()); }
355  bool setDevAddr(uint32_t value) { return mibSetUint32("DevAddr", MIB_DEV_ADDR, value); }
356  bool setAppKey(const char *value)
357  {
358  // In LoRaWAN 1.0, only the appKey was configured and all keys
359  // were derived from that. In 1.1, this was split into an appKey
360  // and nwkKey. However, when running the LoRaMac-Node in 1.0 mode,
361  // it actually seems to use nwkKey, not appKey. So to support
362  // sketches that only configure appKey for 1.0, this saves the
363  // appKey to nwkKey as well. But to also prepare for future
364  // support of 1.1 and sketches that configure both, only do this
365  // if no nwkKey was explicitly configured.
366  return mibSetHex("AppKey", MIB_APP_KEY, value)
367  && (this->nwk_key_set || mibSetHex("NwkKey", MIB_NWK_KEY, value));
368 
369  }
370  bool setAppKey(String value) { return setAppKey(value.c_str()); }
371  bool setNwkKey(const char *value)
372  {
373  this->nwk_key_set = true;
374  return mibSetHex("NwkKey", MIB_NWK_KEY, value);
375  }
376  bool setNwkKey(String value) { return setNwkKey(value.c_str()); }
377  bool setAppSKey(const char *value) { return mibSetHex("AppSKey", MIB_APP_S_KEY, value); }
378  bool setAppSKey(String value) { return setAppSKey(value.c_str()); }
379  bool setNwkSKey(const char *value)
380  {
381 #if (defined( LORAMAC_VERSION ) && ( LORAMAC_VERSION == 0x01010100 ))
382  // When compiled for 1.1 crypto, three different keys are used.
383  // When the sketch only supplies a single key, just set all
384  // three keys to the same value.
385  return mibSetHex("NwkSEncKey", MIB_NWK_S_ENC_KEY, value)
386  && mibSetHex("FNwkSIntKey", MIB_F_NWK_S_INT_KEY, value)
387  && mibSetHex("SNwkSIntKey", MIB_S_NWK_S_INT_KEY, value);
388 #else /* ( LORAMAC_VERSION == 0x01010100 ) */
389  return mibSetHex("NwkSKey", MIB_NWK_S_KEY, value);
390 #endif /* ( LORAMAC_VERSION == 0x01010100 ) */
391  }
392  bool setNwkSKey(String value) { return setNwkSKey(value.c_str()); }
393 
394 #if (defined( LORAMAC_VERSION ) && ( LORAMAC_VERSION == 0x01010100 ))
395  bool setNwkSEncKey(const char *value) { return mibSetHex("NwkSEncKey", MIB_NWK_S_ENC_KEY, value); }
396  bool setNwkSEncKey(String value) { return setNwkSEncKey(value.c_str()); }
397  bool setFNwkSIntKey(const char *value) { return mibSetHex("FNwkSIntKey", MIB_F_NWK_S_INT_KEY, value); }
398  bool setFNwkSIntKey(String value) { return setFNwkSIntKey(value.c_str()); }
399  bool setSNwkSIntKey(const char *value) { return mibSetHex("SNwkSIntKey", MIB_S_NWK_S_INT_KEY, value); }
400  bool setSNwkSIntKey(String value) { return setSNwkSIntKey(value.c_str()); }
401 #endif /* ( LORAMAC_VERSION == 0x01010100 ) */
403 
416  bool getDevEui(String *value) { return mibGetHex("DevEui", MIB_DEV_EUI, value); }
417  bool getDevEui(uint64_t *value) { return mibGetUint64("DevEui", MIB_DEV_EUI, value); }
418  bool getAppEui(String *value) { return mibGetHex("AppEui", MIB_JOIN_EUI, value); }
419  bool getAppEui(uint64_t *value) { return mibGetUint64("AppEui", MIB_JOIN_EUI, value); }
420  bool getDevAddr(String *value) { return mibGetHex("DevAddr", MIB_DEV_ADDR, value); }
421  bool getDevAddr(uint32_t *value) { return mibGetUint32("DevAddr", MIB_DEV_ADDR, value); }
423 
424 
437  String deviceEUI();
438  String getDevAddr();
439 
445  bool connected();
446 
455  bool busy();
456 
460  operator bool() { return connected(); }
462 
463 
476  bool dataRate(uint8_t dr);
478  int getDataRate();
495  bool power(uint8_t index);
496 
506  bool power(_rf_mode mode, uint8_t index) { (void)mode; return power(index); }
507 
525  bool powerdB(int8_t db);
526 
528  uint8_t getPort();
530  bool setPort(uint8_t port);
531 
546  bool setADR(bool adr);
548  int getADR();
550 
551 
565  bool dutyCycle(bool on);
566 
572  bool publicNetwork(bool publicNetwork);
573 
575  int getRX2DR();
581  bool setRX2DR(uint8_t dr);
582 
584  uint32_t getRX2Freq();
590  bool setRX2Freq(uint32_t freq);
591 
593  int getrxfreq();
595 
596 
615  bool enableChannel(unsigned pos);
616  bool disableChannel(unsigned pos);
618  bool modifyChannelEnabled(unsigned pos, bool value);
619  bool isChannelEnabled(unsigned pos);
621 
622 
638  int32_t getFCU();
639 
644  int32_t getFCD();
645 
647  [[gnu::error("Not implemented in STM32LoRaWAN")]]
648  bool setFCD(uint16_t fcd);
649 
651  [[gnu::error("Not implemented in STM32LoRaWAN")]]
652  bool setFCU(uint16_t fcu);
653 
655 
656 
668  bool mibGet(const char *name, Mib_t type, MibRequestConfirm_t &mibReq);
669  bool mibGetBool(const char *name, Mib_t type, bool *value);
670  bool mibGetUint8(const char *name, Mib_t type, uint8_t *value);
671  bool mibGetInt8(const char *name, Mib_t type, int8_t *value);
672  bool mibGetUint32(const char *name, Mib_t type, uint32_t *value);
673  bool mibGetUint64(const char *name, Mib_t type, uint64_t *value);
674  bool mibGetHex(const char *name, Mib_t type, String *value);
675  bool mibGetRxChannelParams(const char *name, Mib_t type, RxChannelParams_t *value);
676  bool mibGetPtr(const char *name, Mib_t type, void **value);
677  bool mibSet(const char *name, Mib_t type, MibRequestConfirm_t &mibReq);
678  bool mibSetBool(const char *name, Mib_t type, bool value);
679  bool mibSetUint8(const char *name, Mib_t type, uint8_t value);
680  bool mibSetInt8(const char *name, Mib_t type, int8_t value);
681  bool mibSetUint32(const char *name, Mib_t type, uint32_t value);
682  bool mibSetUint64(const char *name, Mib_t type, uint64_t value);
683  bool mibSetHex(const char *name, Mib_t type, const char *value);
684  bool mibSetRxChannelParams(const char *name, Mib_t type, RxChannelParams_t value);
685  bool mibSetPtr(const char *name, Mib_t type, void *value);
686  size_t mibHexSize(const char *name, Mib_t type);
688 
689 
716  bool joinOTAAAsync();
717 
728  int endPacketAsync(bool confirmed = false);
729 
742  bool send(const uint8_t *payload, size_t size, bool confirmed);
743 
753  uint8_t lastAck() { return last_tx_acked; }
754 
762  void maintain();
763 
770  void maintainUntilIdle();
771 
791  void setMaintainNeededCallback(std::function<void(void)> callback) { this->maintain_needed_callback = callback; }
792 
804  void setBatteryLevelCallback(std::function<uint8_t(void)> callback) { this->battery_level_callback = callback; }
806 
819  bool continuousWave(uint32_t frequency, int8_t powerdBm, uint16_t timeout);
820 
837  String version() { return "N/A"; }
838 
844  [[gnu::deprecated("minPollInterval is a no-op on STM32LoRaWAN")]]
845  void minPollInterval(unsigned long)
846  { }
848 
863  [[gnu::error("Not implemented in STM32LoRaWAN: confirmed uplinked better handled through endPacket()")]]
864  bool setCFM(bool cfm);
865 
867  [[gnu::error("Not implemented in STM32LoRaWAN: confirmed uplinked better handled through endPacket()")]]
868  int getCFM();
869 
871  [[gnu::error("Not implemented in STM32LoRaWAN: confirmed uplinked better handled through endPacket()")]]
872  int getCFS();
873 
875  [[gnu::error("Not implemented in STM32LoRaWAN: No serial to configure")]]
876  bool begin(_lora_band band, uint32_t baud, uint16_t config = SERIAL_8N2);
877 
879  [[gnu::error("Not implemented in STM32LoRaWAN: No serial to configure")]]
880  bool autoBaud(unsigned long timeout = 10000L);
881 
883  [[gnu::error("Not implemented in STM32LoRaWAN: No serial to configure")]]
884  void setBaud(unsigned long baud);
885 
887  [[gnu::error("Not implemented in STM32LoRaWAN: Test method")]]
888  String getTConf();
889 
891  [[gnu::error("Not implemented in STM32LoRaWAN: Test method")]]
892  String setTConf(String params);
893 
895  [[gnu::error("Not implemented in STM32LoRaWAN: Test method")]]
896  bool enTtone();
897 
899  [[gnu::error("Not implemented in STM32LoRaWAN: No remote module to restart")]]
900  bool restart();
901 
903  [[gnu::error("Not implemented in STM32LoRaWAN: No remote module to poll")]]
904  void poll();
905 
907  [[gnu::error("Not implemented in STM32LoRaWAN: No remote module to sleep")]]
908  bool sleep(bool on = true);
909 
911  [[gnu::error("Not implemented in STM32LoRaWAN: No remote module to reset")]]
913 
915  [[gnu::error("Not implemented in STM32LoRaWAN: No protocol stream to configure")]]
916  bool format(bool hexMode);
917 
919  [[gnu::error("Not implemented in STM32LoRaWAN: No protocol stream to configure")]]
920  void dumb();
921 
923  [[gnu::error("Not implemented in STM32LoRaWAN: Internal method in MKRWAN")]]
924  bool init();
925 
927  [[gnu::error("Not implemented in STM32LoRaWAN: Only class A supported")]]
929 
931  [[gnu::error("Not implemented in STM32LoRaWAN: Keys cannot be retrieved")]]
932  String getNwkSKey();
933 
935  [[gnu::error("Not implemented in STM32LoRaWAN: Keys cannot be retrieved")]]
936  String getAppSKey();
937 
939  [[gnu::error("Not implemented in STM32LoRaWAN: Keys cannot be retrieved")]]
940  String applicationKey();
941 
943  [[gnu::error("Not implemented in STM32LoRaWAN: Internal method in MKRWAN (use enableChannel/disableChannel instead)")]]
944  bool sendMask(String newMask);
945 
947  [[gnu::error("Not implemented in STM32LoRaWAN: Internal method in MKRWAN (use enableChannel/disableChannel instead)")]]
948  bool sendMask();
949 
951  [[gnu::error("Not implemented in STM32LoRaWAN: Internal method in MKRWAN (use enableChannel/disableChannel instead)")]]
952  String getChannelMask();
953 
955  [[gnu::error("Not implemented in STM32LoRaWAN: Internal method in MKRWAN (use enableChannel/disableChannel instead)")]]
957 
962  [[gnu::error("Not implemented in STM32LoRaWAN: Changing band after initialization not supported")]]
965 
966  protected:
967  static void MacMcpsConfirm(McpsConfirm_t *McpsConfirm);
968  static void MacMcpsIndication(McpsIndication_t *McpsIndication, LoRaMacRxStatus_t *RxStatus);
969  static void MacMlmeConfirm(MlmeConfirm_t *MlmeConfirm);
970  static void MacMlmeIndication(MlmeIndication_t *MlmeIndication, LoRaMacRxStatus_t *RxStatus);
971  static void MacProcessNotify();
972  static uint8_t GetBatteryLevel();
973 
975 
976  LoRaMacPrimitives_t LoRaMacPrimitives = {
977  .MacMcpsConfirm = MacMcpsConfirm,
978  .MacMcpsIndication = MacMcpsIndication,
979  .MacMlmeConfirm = MacMlmeConfirm,
980  .MacMlmeIndication = MacMlmeIndication,
981  };
982 
983  LoRaMacCallback_t LoRaMacCallbacks = {
984  .GetBatteryLevel = GetBatteryLevel,
985  .GetTemperatureLevel = nullptr,
986  .GetUniqueId = nullptr, // Not needed, we just explicitly set the deveui in begin()
987  .GetDevAddress = nullptr, // Not needed, user explicitly configures devaddr
988  .NvmDataChange = nullptr,
989  .MacProcessNotify = MacProcessNotify,
990  };
991 
993  uint64_t builtinDevEUI();
994 
1000  static const char *toString(LoRaMacStatus_t);
1002  static const char *toString(LoRaMacEventInfoStatus_t);
1004  static const char *toString(Mlme_t);
1006  static const char *toString(Mcps_t);
1007 
1009  static uint8_t parseHex(char c);
1011  static bool parseHex(uint8_t *dest, const char *hex, size_t dest_len);
1013  static char toHex(uint8_t b);
1015  static bool toHex(String *dest, const uint8_t *src, size_t src_len);
1016 
1018  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; }
1019 
1024  static bool failure(const char *fmt, ...)
1025  __attribute__((format(printf, 1, 2)));
1026 
1028  void clear_rx() { rx_ptr = rx_buf + sizeof(rx_buf); }
1029 
1031  void add_rx(const uint8_t *buf, size_t len);
1032 
1040  uint8_t tx_dr = DR_4;
1041 
1043  uint8_t tx_port = 2;
1044 
1046  uint8_t rx_port = 0;
1047 
1048  bool nwk_key_set = false;
1049 
1050  // Buffer sizes match LORAMAC_PHY_MAXPAYLOAD (but that is not
1051  // public).
1052  uint8_t tx_buf[255];
1053  uint8_t *tx_ptr;
1054  uint8_t rx_buf[255];
1055  uint8_t *rx_ptr;
1056 
1057  bool last_tx_acked = false;
1058  uint32_t fcnt_up = 0;
1059  uint32_t fcnt_down = 0;
1060 
1061  std::function<void(void)> maintain_needed_callback;
1062  std::function<uint8_t(void)> battery_level_callback;
1063 
1064  bool mac_process_pending = false;
1065 
1066  static constexpr uint32_t DEFAULT_JOIN_TIMEOUT = 60000;
1067 };
1068 // 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:263
LoRaMacPrimitives_t LoRaMacPrimitives
Definition: STM32LoRaWAN.h:976
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:377
bool configureClass(_lora_class _class)
String getAppSKey()
bool power(_rf_mode mode, uint8_t index)
Definition: STM32LoRaWAN.h:506
bool modifyChannelEnabled(unsigned pos, bool value)
Definition: STM32LoRaWAN.cpp:358
bool mibSet(const char *name, Mib_t type, MibRequestConfirm_t &mibReq)
Definition: STM32LoRaWAN.cpp:474
String getNwkSKey()
uint8_t rx_port
Definition: STM32LoRaWAN.h:1046
bool getDevAddr(uint32_t *value)
Definition: STM32LoRaWAN.h:421
uint64_t builtinDevEUI()
Definition: STM32LoRaWAN.cpp:1273
bool mibGetRxChannelParams(const char *name, Mib_t type, RxChannelParams_t *value)
Definition: STM32LoRaWAN.cpp:852
bool getDevEui(String *value)
Definition: STM32LoRaWAN.h:416
int32_t getFCU()
Definition: STM32LoRaWAN.cpp:342
bool joinABP()
Definition: STM32LoRaWAN.cpp:221
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:1048
static constexpr uint32_t DEFAULT_JOIN_TIMEOUT
Definition: STM32LoRaWAN.h:1066
bool mibGetBool(const char *name, Mib_t type, bool *value)
Definition: STM32LoRaWAN.cpp:483
bool mibSetInt8(const char *name, Mib_t type, int8_t value)
Definition: STM32LoRaWAN.cpp:552
void maintain()
Definition: STM32LoRaWAN.cpp:139
uint8_t tx_port
Definition: STM32LoRaWAN.h:1043
String setTConf(String params)
bool mibSetHex(const char *name, Mib_t type, const char *value)
Definition: STM32LoRaWAN.cpp:792
uint32_t fcnt_down
Definition: STM32LoRaWAN.h:1059
bool joinOTAA()
Definition: STM32LoRaWAN.cpp:188
static void MacMcpsIndication(McpsIndication_t *McpsIndication, LoRaMacRxStatus_t *RxStatus)
Definition: STM32LoRaWAN.cpp:1293
int getADR()
Definition: STM32LoRaWAN.cpp:283
bool mibSetPtr(const char *name, Mib_t type, void *value)
Definition: STM32LoRaWAN.cpp:894
bool format(bool hexMode)
bool joinOTAAAsync()
Definition: STM32LoRaWAN.cpp:168
bool getAppEui(String *value)
Definition: STM32LoRaWAN.h:418
uint8_t lastAck()
Definition: STM32LoRaWAN.h:753
uint8_t tx_buf[255]
Definition: STM32LoRaWAN.h:1052
bool last_tx_acked
Definition: STM32LoRaWAN.h:1057
bool setDevAddr(String value)
Definition: STM32LoRaWAN.h:354
static const char * toString(LoRaMacStatus_t)
Definition: STM32LoRaWAN.cpp:947
bool mibSetUint64(const char *name, Mib_t type, uint64_t value)
Definition: STM32LoRaWAN.cpp:656
bool autoBaud(unsigned long timeout=10000L)
void beginPacket()
Definition: STM32LoRaWAN.cpp:1161
bool setDevAddr(uint32_t value)
Definition: STM32LoRaWAN.h:355
String getDevAddr()
bool mac_process_pending
Definition: STM32LoRaWAN.h:1064
int parsePacket()
Definition: STM32LoRaWAN.cpp:1244
std::function< uint8_t(void)> battery_level_callback
Definition: STM32LoRaWAN.h:1062
size_t mibHexSize(const char *name, Mib_t type)
Definition: STM32LoRaWAN.cpp:678
bool connected()
Definition: STM32LoRaWAN.cpp:929
int endPacketAsync(bool confirmed=false)
Definition: STM32LoRaWAN.cpp:1165
String getTConf()
bool dataRate(uint8_t dr)
Definition: STM32LoRaWAN.cpp:231
int getDataRate()
Definition: STM32LoRaWAN.cpp:235
bool joinOTAA(uint64_t appEui, String appKey, uint64_t devEui)
Definition: STM32LoRaWAN.h:143
bool setAppEui(String value)
Definition: STM32LoRaWAN.h:351
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:880
bool setAppEui(const char *value)
Definition: STM32LoRaWAN.h:350
bool setAppEui(uint64_t value)
Definition: STM32LoRaWAN.h:352
bool factoryDefault()
bool setRX2Freq(uint32_t freq)
Definition: STM32LoRaWAN.cpp:318
static char toHex(uint8_t b)
Definition: STM32LoRaWAN.cpp:1135
bool mibGetHex(const char *name, Mib_t type, String *value)
Definition: STM32LoRaWAN.cpp:727
static STM32LoRaWAN * instance
Definition: STM32LoRaWAN.h:974
bool mibGetUint64(const char *name, Mib_t type, uint64_t *value)
Definition: STM32LoRaWAN.cpp:631
virtual size_t write(uint8_t c)
Definition: STM32LoRaWAN.cpp:1185
static void MacMlmeIndication(MlmeIndication_t *MlmeIndication, LoRaMacRxStatus_t *RxStatus)
Definition: STM32LoRaWAN.cpp:1318
int getrxfreq()
Definition: STM32LoRaWAN.cpp:291
virtual void flush()
Definition: STM32LoRaWAN.h:270
bool sendMask()
bool enableChannel(unsigned pos)
Definition: STM32LoRaWAN.cpp:350
bool disableChannel(unsigned pos)
Definition: STM32LoRaWAN.cpp:354
static void MacMcpsConfirm(McpsConfirm_t *McpsConfirm)
Definition: STM32LoRaWAN.cpp:1277
bool joinOTAA(String appEui, String appKey, String devEui)
Definition: STM32LoRaWAN.h:137
String deviceEUI()
Definition: STM32LoRaWAN.cpp:939
static void MacProcessNotify()
Definition: STM32LoRaWAN.cpp:120
int endPacket(bool confirmed=false)
Definition: STM32LoRaWAN.cpp:1174
bool mibSetRxChannelParams(const char *name, Mib_t type, RxChannelParams_t value)
Definition: STM32LoRaWAN.cpp:867
bool joinABP(String devAddr, String nwkSKey, String appSKey)
Definition: STM32LoRaWAN.h:180
int32_t getFCD()
Definition: STM32LoRaWAN.cpp:346
bool mibGetInt8(const char *name, Mib_t type, int8_t *value)
Definition: STM32LoRaWAN.cpp:533
LoRaMacCallback_t LoRaMacCallbacks
Definition: STM32LoRaWAN.h:983
String getChannelMask()
bool restart()
virtual int availableForWrite()
Definition: STM32LoRaWAN.cpp:1201
bool configureBand(_lora_band band)
bool setNwkKey(String value)
Definition: STM32LoRaWAN.h:376
bool setNwkKey(const char *value)
Definition: STM32LoRaWAN.h:371
bool mibGetUint32(const char *name, Mib_t type, uint32_t *value)
Definition: STM32LoRaWAN.cpp:569
bool setAppSKey(String value)
Definition: STM32LoRaWAN.h:378
bool getAppEui(uint64_t *value)
Definition: STM32LoRaWAN.h:419
virtual int peek()
Definition: STM32LoRaWAN.cpp:1238
bool setCFM(bool cfm)
void setBaud(unsigned long baud)
bool setNwkSKey(String value)
Definition: STM32LoRaWAN.h:392
virtual int available()
Definition: STM32LoRaWAN.cpp:1228
bool sleep(bool on=true)
bool joinOTAA(uint64_t appEui, const char *appKey)
Definition: STM32LoRaWAN.h:141
virtual int read()
Definition: STM32LoRaWAN.cpp:1232
bool getDevEui(uint64_t *value)
Definition: STM32LoRaWAN.h:417
bool mibSetUint8(const char *name, Mib_t type, uint8_t value)
Definition: STM32LoRaWAN.cpp:522
bool isChannelEnabled(unsigned pos)
Definition: STM32LoRaWAN.cpp:388
size_t write(T val)
Definition: STM32LoRaWAN.h:252
bool setDevEui(String value)
Definition: STM32LoRaWAN.h:348
static uint8_t parseHex(char c)
Definition: STM32LoRaWAN.cpp:1105
bool setFCU(uint16_t fcu)
void setBatteryLevelCallback(std::function< uint8_t(void)> callback)
Definition: STM32LoRaWAN.h:804
bool busy()
Definition: STM32LoRaWAN.cpp:935
String version()
Definition: STM32LoRaWAN.h:837
bool setDevEui(uint64_t value)
Definition: STM32LoRaWAN.h:349
static uint32_t makeUint32(uint8_t a, uint8_t b, uint8_t c, uint8_t d)
Definition: STM32LoRaWAN.h:1018
bool setAppKey(const char *value)
Definition: STM32LoRaWAN.h:356
static uint8_t GetBatteryLevel()
Definition: STM32LoRaWAN.cpp:128
bool continuousWave(uint32_t frequency, int8_t powerdBm, uint16_t timeout)
Definition: STM32LoRaWAN.cpp:154
bool setDevAddr(const char *value)
Definition: STM32LoRaWAN.h:353
uint8_t tx_dr
Definition: STM32LoRaWAN.h:1040
uint8_t * tx_ptr
Definition: STM32LoRaWAN.h:1053
uint8_t rx_buf[255]
Definition: STM32LoRaWAN.h:1054
bool mibGet(const char *name, Mib_t type, MibRequestConfirm_t &mibReq)
Definition: STM32LoRaWAN.cpp:465
static bool void clear_rx()
Definition: STM32LoRaWAN.h:1028
bool powerdB(int8_t db)
Definition: STM32LoRaWAN.cpp:246
uint32_t fcnt_up
Definition: STM32LoRaWAN.h:1058
bool begin(_lora_band band)
Definition: STM32LoRaWAN.cpp:62
bool send(const uint8_t *payload, size_t size, bool confirmed)
Definition: STM32LoRaWAN.cpp:412
bool dutyCycle(bool on)
Definition: STM32LoRaWAN.cpp:253
void add_rx(const uint8_t *buf, size_t len)
Definition: STM32LoRaWAN.cpp:1249
std::function< void(void)> maintain_needed_callback
Definition: STM32LoRaWAN.h:1061
bool mibSetBool(const char *name, Mib_t type, bool value)
Definition: STM32LoRaWAN.cpp:497
bool mibSetUint32(const char *name, Mib_t type, uint32_t value)
Definition: STM32LoRaWAN.cpp:601
bool power(uint8_t index)
Definition: STM32LoRaWAN.cpp:242
uint32_t getRX2Freq()
Definition: STM32LoRaWAN.cpp:311
bool mibGetUint8(const char *name, Mib_t type, uint8_t *value)
Definition: STM32LoRaWAN.cpp:509
uint8_t * rx_ptr
Definition: STM32LoRaWAN.h:1055
void minPollInterval(unsigned long)
Definition: STM32LoRaWAN.h:845
bool enTtone()
static void MacMlmeConfirm(MlmeConfirm_t *MlmeConfirm)
Definition: STM32LoRaWAN.cpp:1310
static bool failure(const char *fmt,...) __attribute__((format(printf
Definition: STM32LoRaWAN.cpp:1153
bool setADR(bool adr)
Definition: STM32LoRaWAN.cpp:279
bool setRX2DR(uint8_t dr)
Definition: STM32LoRaWAN.cpp:302
bool joinOTAA(uint64_t appEui, const char *appKey, uint64_t devEui)
Definition: STM32LoRaWAN.h:139
uint8_t getDownlinkPort()
Definition: STM32LoRaWAN.h:301
void setMaintainNeededCallback(std::function< void(void)> callback)
Definition: STM32LoRaWAN.h:791
int getRX2DR()
Definition: STM32LoRaWAN.cpp:295
bool sendMask(String newMask)
bool setAppKey(String value)
Definition: STM32LoRaWAN.h:370
bool setPort(uint8_t port)
Definition: STM32LoRaWAN.cpp:258
bool joinOTAA(String appEui, String appKey)
Definition: STM32LoRaWAN.h:136
String applicationKey()
bool getDevAddr(String *value)
Definition: STM32LoRaWAN.h:420
bool setDevEui(const char *value)
Definition: STM32LoRaWAN.h:347
bool setNwkSKey(const char *value)
Definition: STM32LoRaWAN.h:379
bool joinOTAA(const char *appEui, const char *appKey)
Definition: STM32LoRaWAN.h:135
bool publicNetwork(bool publicNetwork)
Definition: STM32LoRaWAN.cpp:274
void maintainUntilIdle()
Definition: STM32LoRaWAN.cpp:147