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 
794 
807  bool continuousWave(uint32_t frequency, int8_t powerdBm, uint16_t timeout);
808 
825  String version() { return "N/A"; }
826 
832  [[gnu::deprecated("minPollInterval is a no-op on STM32LoRaWAN")]]
833  void minPollInterval(unsigned long)
834  { }
836 
851  [[gnu::error("Not implemented in STM32LoRaWAN: confirmed uplinked better handled through endPacket()")]]
852  bool setCFM(bool cfm);
853 
855  [[gnu::error("Not implemented in STM32LoRaWAN: confirmed uplinked better handled through endPacket()")]]
856  int getCFM();
857 
859  [[gnu::error("Not implemented in STM32LoRaWAN: confirmed uplinked better handled through endPacket()")]]
860  int getCFS();
861 
863  [[gnu::error("Not implemented in STM32LoRaWAN: No serial to configure")]]
864  bool begin(_lora_band band, uint32_t baud, uint16_t config = SERIAL_8N2);
865 
867  [[gnu::error("Not implemented in STM32LoRaWAN: No serial to configure")]]
868  bool autoBaud(unsigned long timeout = 10000L);
869 
871  [[gnu::error("Not implemented in STM32LoRaWAN: No serial to configure")]]
872  void setBaud(unsigned long baud);
873 
875  [[gnu::error("Not implemented in STM32LoRaWAN: Test method")]]
876  String getTConf();
877 
879  [[gnu::error("Not implemented in STM32LoRaWAN: Test method")]]
880  String setTConf(String params);
881 
883  [[gnu::error("Not implemented in STM32LoRaWAN: Test method")]]
884  bool enTtone();
885 
887  [[gnu::error("Not implemented in STM32LoRaWAN: No remote module to restart")]]
888  bool restart();
889 
891  [[gnu::error("Not implemented in STM32LoRaWAN: No remote module to poll")]]
892  void poll();
893 
895  [[gnu::error("Not implemented in STM32LoRaWAN: No remote module to sleep")]]
896  bool sleep(bool on = true);
897 
899  [[gnu::error("Not implemented in STM32LoRaWAN: No remote module to reset")]]
901 
903  [[gnu::error("Not implemented in STM32LoRaWAN: No protocol stream to configure")]]
904  bool format(bool hexMode);
905 
907  [[gnu::error("Not implemented in STM32LoRaWAN: No protocol stream to configure")]]
908  void dumb();
909 
911  [[gnu::error("Not implemented in STM32LoRaWAN: Internal method in MKRWAN")]]
912  bool init();
913 
915  [[gnu::error("Not implemented in STM32LoRaWAN: Only class A supported")]]
917 
919  [[gnu::error("Not implemented in STM32LoRaWAN: Keys cannot be retrieved")]]
920  String getNwkSKey();
921 
923  [[gnu::error("Not implemented in STM32LoRaWAN: Keys cannot be retrieved")]]
924  String getAppSKey();
925 
927  [[gnu::error("Not implemented in STM32LoRaWAN: Keys cannot be retrieved")]]
928  String applicationKey();
929 
931  [[gnu::error("Not implemented in STM32LoRaWAN: Internal method in MKRWAN (use enableChannel/disableChannel instead)")]]
932  bool sendMask(String newMask);
933 
935  [[gnu::error("Not implemented in STM32LoRaWAN: Internal method in MKRWAN (use enableChannel/disableChannel instead)")]]
936  bool sendMask();
937 
939  [[gnu::error("Not implemented in STM32LoRaWAN: Internal method in MKRWAN (use enableChannel/disableChannel instead)")]]
940  String getChannelMask();
941 
943  [[gnu::error("Not implemented in STM32LoRaWAN: Internal method in MKRWAN (use enableChannel/disableChannel instead)")]]
945 
950  [[gnu::error("Not implemented in STM32LoRaWAN: Changing band after initialization not supported")]]
953 
954  protected:
955  static void MacMcpsConfirm(McpsConfirm_t *McpsConfirm);
956  static void MacMcpsIndication(McpsIndication_t *McpsIndication, LoRaMacRxStatus_t *RxStatus);
957  static void MacMlmeConfirm(MlmeConfirm_t *MlmeConfirm);
958  static void MacMlmeIndication(MlmeIndication_t *MlmeIndication, LoRaMacRxStatus_t *RxStatus);
959  static void MacProcessNotify();
960 
962 
963  LoRaMacPrimitives_t LoRaMacPrimitives = {
964  .MacMcpsConfirm = MacMcpsConfirm,
965  .MacMcpsIndication = MacMcpsIndication,
966  .MacMlmeConfirm = MacMlmeConfirm,
967  .MacMlmeIndication = MacMlmeIndication,
968  };
969 
970  LoRaMacCallback_t LoRaMacCallbacks = {
971  .GetBatteryLevel = nullptr,
972  .GetTemperatureLevel = nullptr,
973  .GetUniqueId = nullptr, // Not needed, we just explicitly set the deveui in begin()
974  .GetDevAddress = nullptr, // Not needed, user explicitly configures devaddr
975  .NvmDataChange = nullptr,
976  .MacProcessNotify = MacProcessNotify,
977  };
978 
980  uint64_t builtinDevEUI();
981 
987  static const char *toString(LoRaMacStatus_t);
989  static const char *toString(LoRaMacEventInfoStatus_t);
991  static const char *toString(Mlme_t);
993  static const char *toString(Mcps_t);
994 
996  static uint8_t parseHex(char c);
998  static bool parseHex(uint8_t *dest, const char *hex, size_t dest_len);
1000  static char toHex(uint8_t b);
1002  static bool toHex(String *dest, const uint8_t *src, size_t src_len);
1003 
1005  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; }
1006 
1011  static bool failure(const char *fmt, ...)
1012  __attribute__((format(printf, 1, 2)));
1013 
1015  void clear_rx() { rx_ptr = rx_buf + sizeof(rx_buf); }
1016 
1018  void add_rx(const uint8_t *buf, size_t len);
1019 
1027  uint8_t tx_dr = DR_4;
1028 
1030  uint8_t tx_port = 2;
1031 
1033  uint8_t rx_port = 0;
1034 
1035  bool nwk_key_set = false;
1036 
1037  // Buffer sizes match LORAMAC_PHY_MAXPAYLOAD (but that is not
1038  // public).
1039  uint8_t tx_buf[255];
1040  uint8_t *tx_ptr;
1041  uint8_t rx_buf[255];
1042  uint8_t *rx_ptr;
1043 
1044  bool last_tx_acked = false;
1045  uint32_t fcnt_up = 0;
1046  uint32_t fcnt_down = 0;
1047 
1048  std::function<void(void)> maintain_needed_callback;
1049 
1050  bool mac_process_pending = false;
1051 
1052  static constexpr uint32_t DEFAULT_JOIN_TIMEOUT = 60000;
1053 };
1054 // 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:252
LoRaMacPrimitives_t LoRaMacPrimitives
Definition: STM32LoRaWAN.h:963
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:347
bool mibSet(const char *name, Mib_t type, MibRequestConfirm_t &mibReq)
Definition: STM32LoRaWAN.cpp:463
String getNwkSKey()
uint8_t rx_port
Definition: STM32LoRaWAN.h:1033
bool getDevAddr(uint32_t *value)
Definition: STM32LoRaWAN.h:421
uint64_t builtinDevEUI()
Definition: STM32LoRaWAN.cpp:1262
bool mibGetRxChannelParams(const char *name, Mib_t type, RxChannelParams_t *value)
Definition: STM32LoRaWAN.cpp:841
bool getDevEui(String *value)
Definition: STM32LoRaWAN.h:416
int32_t getFCU()
Definition: STM32LoRaWAN.cpp:331
bool joinABP()
Definition: STM32LoRaWAN.cpp:210
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:1035
static constexpr uint32_t DEFAULT_JOIN_TIMEOUT
Definition: STM32LoRaWAN.h:1052
bool mibGetBool(const char *name, Mib_t type, bool *value)
Definition: STM32LoRaWAN.cpp:472
bool mibSetInt8(const char *name, Mib_t type, int8_t value)
Definition: STM32LoRaWAN.cpp:541
void maintain()
Definition: STM32LoRaWAN.cpp:128
uint8_t tx_port
Definition: STM32LoRaWAN.h:1030
String setTConf(String params)
bool mibSetHex(const char *name, Mib_t type, const char *value)
Definition: STM32LoRaWAN.cpp:781
uint32_t fcnt_down
Definition: STM32LoRaWAN.h:1046
bool joinOTAA()
Definition: STM32LoRaWAN.cpp:177
static void MacMcpsIndication(McpsIndication_t *McpsIndication, LoRaMacRxStatus_t *RxStatus)
Definition: STM32LoRaWAN.cpp:1282
int getADR()
Definition: STM32LoRaWAN.cpp:272
bool mibSetPtr(const char *name, Mib_t type, void *value)
Definition: STM32LoRaWAN.cpp:883
bool format(bool hexMode)
bool joinOTAAAsync()
Definition: STM32LoRaWAN.cpp:157
bool getAppEui(String *value)
Definition: STM32LoRaWAN.h:418
uint8_t lastAck()
Definition: STM32LoRaWAN.h:753
uint8_t tx_buf[255]
Definition: STM32LoRaWAN.h:1039
bool last_tx_acked
Definition: STM32LoRaWAN.h:1044
bool setDevAddr(String value)
Definition: STM32LoRaWAN.h:354
static const char * toString(LoRaMacStatus_t)
Definition: STM32LoRaWAN.cpp:936
bool mibSetUint64(const char *name, Mib_t type, uint64_t value)
Definition: STM32LoRaWAN.cpp:645
bool autoBaud(unsigned long timeout=10000L)
void beginPacket()
Definition: STM32LoRaWAN.cpp:1150
bool setDevAddr(uint32_t value)
Definition: STM32LoRaWAN.h:355
String getDevAddr()
bool mac_process_pending
Definition: STM32LoRaWAN.h:1050
int parsePacket()
Definition: STM32LoRaWAN.cpp:1233
size_t mibHexSize(const char *name, Mib_t type)
Definition: STM32LoRaWAN.cpp:667
bool connected()
Definition: STM32LoRaWAN.cpp:918
int endPacketAsync(bool confirmed=false)
Definition: STM32LoRaWAN.cpp:1154
String getTConf()
bool dataRate(uint8_t dr)
Definition: STM32LoRaWAN.cpp:220
int getDataRate()
Definition: STM32LoRaWAN.cpp:224
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:869
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:307
static char toHex(uint8_t b)
Definition: STM32LoRaWAN.cpp:1124
bool mibGetHex(const char *name, Mib_t type, String *value)
Definition: STM32LoRaWAN.cpp:716
static STM32LoRaWAN * instance
Definition: STM32LoRaWAN.h:961
bool mibGetUint64(const char *name, Mib_t type, uint64_t *value)
Definition: STM32LoRaWAN.cpp:620
virtual size_t write(uint8_t c)
Definition: STM32LoRaWAN.cpp:1174
static void MacMlmeIndication(MlmeIndication_t *MlmeIndication, LoRaMacRxStatus_t *RxStatus)
Definition: STM32LoRaWAN.cpp:1307
int getrxfreq()
Definition: STM32LoRaWAN.cpp:280
virtual void flush()
Definition: STM32LoRaWAN.h:270
bool sendMask()
bool enableChannel(unsigned pos)
Definition: STM32LoRaWAN.cpp:339
bool disableChannel(unsigned pos)
Definition: STM32LoRaWAN.cpp:343
static void MacMcpsConfirm(McpsConfirm_t *McpsConfirm)
Definition: STM32LoRaWAN.cpp:1266
bool joinOTAA(String appEui, String appKey, String devEui)
Definition: STM32LoRaWAN.h:137
String deviceEUI()
Definition: STM32LoRaWAN.cpp:928
static void MacProcessNotify()
Definition: STM32LoRaWAN.cpp:120
int endPacket(bool confirmed=false)
Definition: STM32LoRaWAN.cpp:1163
bool mibSetRxChannelParams(const char *name, Mib_t type, RxChannelParams_t value)
Definition: STM32LoRaWAN.cpp:856
bool joinABP(String devAddr, String nwkSKey, String appSKey)
Definition: STM32LoRaWAN.h:180
int32_t getFCD()
Definition: STM32LoRaWAN.cpp:335
bool mibGetInt8(const char *name, Mib_t type, int8_t *value)
Definition: STM32LoRaWAN.cpp:522
LoRaMacCallback_t LoRaMacCallbacks
Definition: STM32LoRaWAN.h:970
String getChannelMask()
bool restart()
virtual int availableForWrite()
Definition: STM32LoRaWAN.cpp:1190
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:558
bool setAppSKey(String value)
Definition: STM32LoRaWAN.h:378
bool getAppEui(uint64_t *value)
Definition: STM32LoRaWAN.h:419
virtual int peek()
Definition: STM32LoRaWAN.cpp:1227
bool setCFM(bool cfm)
void setBaud(unsigned long baud)
bool setNwkSKey(String value)
Definition: STM32LoRaWAN.h:392
virtual int available()
Definition: STM32LoRaWAN.cpp:1217
bool sleep(bool on=true)
bool joinOTAA(uint64_t appEui, const char *appKey)
Definition: STM32LoRaWAN.h:141
virtual int read()
Definition: STM32LoRaWAN.cpp:1221
bool getDevEui(uint64_t *value)
Definition: STM32LoRaWAN.h:417
bool mibSetUint8(const char *name, Mib_t type, uint8_t value)
Definition: STM32LoRaWAN.cpp:511
bool isChannelEnabled(unsigned pos)
Definition: STM32LoRaWAN.cpp:377
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:1094
bool setFCU(uint16_t fcu)
bool busy()
Definition: STM32LoRaWAN.cpp:924
String version()
Definition: STM32LoRaWAN.h:825
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:1005
bool setAppKey(const char *value)
Definition: STM32LoRaWAN.h:356
bool continuousWave(uint32_t frequency, int8_t powerdBm, uint16_t timeout)
Definition: STM32LoRaWAN.cpp:143
bool setDevAddr(const char *value)
Definition: STM32LoRaWAN.h:353
uint8_t tx_dr
Definition: STM32LoRaWAN.h:1027
uint8_t * tx_ptr
Definition: STM32LoRaWAN.h:1040
uint8_t rx_buf[255]
Definition: STM32LoRaWAN.h:1041
bool mibGet(const char *name, Mib_t type, MibRequestConfirm_t &mibReq)
Definition: STM32LoRaWAN.cpp:454
static bool void clear_rx()
Definition: STM32LoRaWAN.h:1015
bool powerdB(int8_t db)
Definition: STM32LoRaWAN.cpp:235
uint32_t fcnt_up
Definition: STM32LoRaWAN.h:1045
bool begin(_lora_band band)
Definition: STM32LoRaWAN.cpp:62
bool send(const uint8_t *payload, size_t size, bool confirmed)
Definition: STM32LoRaWAN.cpp:401
bool dutyCycle(bool on)
Definition: STM32LoRaWAN.cpp:242
void add_rx(const uint8_t *buf, size_t len)
Definition: STM32LoRaWAN.cpp:1238
std::function< void(void)> maintain_needed_callback
Definition: STM32LoRaWAN.h:1048
bool mibSetBool(const char *name, Mib_t type, bool value)
Definition: STM32LoRaWAN.cpp:486
bool mibSetUint32(const char *name, Mib_t type, uint32_t value)
Definition: STM32LoRaWAN.cpp:590
bool power(uint8_t index)
Definition: STM32LoRaWAN.cpp:231
uint32_t getRX2Freq()
Definition: STM32LoRaWAN.cpp:300
bool mibGetUint8(const char *name, Mib_t type, uint8_t *value)
Definition: STM32LoRaWAN.cpp:498
uint8_t * rx_ptr
Definition: STM32LoRaWAN.h:1042
void minPollInterval(unsigned long)
Definition: STM32LoRaWAN.h:833
bool enTtone()
static void MacMlmeConfirm(MlmeConfirm_t *MlmeConfirm)
Definition: STM32LoRaWAN.cpp:1299
static bool failure(const char *fmt,...) __attribute__((format(printf
Definition: STM32LoRaWAN.cpp:1142
bool setADR(bool adr)
Definition: STM32LoRaWAN.cpp:268
bool setRX2DR(uint8_t dr)
Definition: STM32LoRaWAN.cpp:291
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:284
bool sendMask(String newMask)
bool setAppKey(String value)
Definition: STM32LoRaWAN.h:370
bool setPort(uint8_t port)
Definition: STM32LoRaWAN.cpp:247
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:263
void maintainUntilIdle()
Definition: STM32LoRaWAN.cpp:136