A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://stm32duino.github.io/STM32LoRaWAN/classSTM32LoRaWAN.html below:

STM32LoRaWAN: STM32LoRaWAN Class Reference

bool  continuousWave (uint32_t frequency, int8_t powerdBm, uint16_t timeout)   bool  begin (_lora_band band)  

This method can be used to join the network using the OTAA (over-the-air-activation) method, where the device uses the credentials specified here to negotiate a session (including session address and encryption keys) with the network by exchanging messages.

The appEUI and appKey are mandatory, the devEUI can be omitted, in which case the devEUI baked into the chip is used.

For both EUIs and the key, you can pass a hex-encoded (MSB-first) string (String object or const char*), for the EUIs also a raw integer (64-bits).

These methods will perform multiple join attempts and block until the join completes successfully, or a timeout (60 seconds) occurs.

There are some subtle differences with MKRWAN in how the join process works:

MKRWAN API difference:

Timeout parameter omitted (also omitted in MKRWAN_v2)

Added version that accepts uint64_t appEUI

Differences in timeout and retry datarate handling

bool  joinOTAA (const char *appEui, const char *appKey, const char *devEui)   bool  joinOTAA (const char *appEui, const char *appKey)   bool  joinOTAA (String appEui, String appKey)   bool  joinOTAA (String appEui, String appKey, String devEui)   bool  joinOTAA (uint64_t appEui, const char *appKey, uint64_t devEui)   bool  joinOTAA (uint64_t appEui, const char *appKey)   bool  joinOTAA (uint64_t appEui, String appKey, uint64_t devEui)   bool  joinOTAA (uint64_t appEui, String appKey)   bool  joinOTAA ()  

This method can be used to join the network using the ABP method, where the session address and keys are preconfigured and no exchange with the network is needed before data can be sent.

For the address and both keys, you can pass a hex-encoded (MSB-first) string (String object or const char*), for the address also a raw integer (32-bits).

Warning
This library does not preserve frame counters in non-volatile storage, so it starts at zero after every reset. This only works when the server disables framecounter-based replay attacks, otherwise only the first session will work and data will be dropped after the first reset.
Note
An ABP join returns immediately, it does not need to wait for the network, so there is no separate non-blocking/async version of this method.
bool  joinABP (const char *devAddr, const char *nwkSKey, const char *appSKey)   bool  joinABP (String devAddr, String nwkSKey, String appSKey)   bool  joinABP (uint32_t devAddr, String nwkSKey, String appSKey)   bool  joinABP ()  

These methods allow sending a data packet.

After a join was completed, sending a packet consists of calling beginPacket(), writing data to using the Stream write methods, and calling endPacket() to finish up and send the packet.

The port number to use for the packet can be set using setPort() (to be called before endPacket()). A confirmed packet can be sent using the parameter to endPacket(), which will request the network to confirm the packet was received (but if not, no automatic retries are done).

The send() method offers an alternative (and always non-blocking) API, where you pass a payload already built into your own buffer.

void  beginPacket ()   int  endPacket (bool confirmed=false)  

These are standard methods defined by the Arduino Stream (or actually its Print superclass) class to allow writing data into a packet being built.

In addition to the methods listed here, all methods offered by the Arduino Print class are also available (but at the time of writing, unfortunately not documented by Arduino).

There is one addition, there is a templated write method that accepts any type of object (e.g. a struct, integer, etc.) and writes its memory representation into the packet. When using this, note that data will be written exactly as the processor stores it in memory, so typically little-endian.

virtual size_t  write (uint8_t c)   virtual size_t  write (const uint8_t *buffer, size_t size)   template<typename T > size_t  write (T val)   virtual int  availableForWrite ()   virtual void  flush ()  

These methods are about reception of downlink packets.

After an uplink packet was fully sent, a received downlink packet can be checked by calling parsePacket() (or simply available() to see if any bytes are ready to read). If so, the contents of the packet can be read using the Stream read methods.

int  parsePacket ()   uint8_t  getDownlinkPort ()   int16_t  getDownlinkRssi ()   int8_t  getDownlinkSnr ()  

These are standard methods defined by the Arduino Stream class to allow reading received data.

In addition to the methods listed here, all methods offered by the Arduino Stream class are also available, see https://www.arduino.cc/reference/en/language/functions/communication/stream/

After a packet is received, the available() method can be used to query how much bytes are in the packet (or after some bytes were read, how many are left to be read), and various read() versions can be used to read the data.

Note
If data is left unread when a new packet is received, the new data will be appended to the unread data and it becomes impossible to query where the first packet ends and the second begins. It is recommended to always fully read any received data before transmitting a new packet (which is, in class A LoRaWAN, the only time a new packet can be received).
int  read (uint8_t *buf, size_t size)   virtual int  available ()   virtual int  read ()   virtual int  peek ()  

These methods allow setting various identifiers and keys.

You can pass a hex-encoded (MSB-first) string (String object or const char*), or a raw integer (32-bits for DevAddr and 64-bits for EUIs, keys are too long to be passed as an integer).

MKRWAN API difference:
Not supported by MKRWAN
bool  setDevEui (const char *value)   bool  setDevEui (String value)   bool  setDevEui (uint64_t value)   bool  setAppEui (const char *value)   bool  setAppEui (String value)   bool  setAppEui (uint64_t value)   bool  setDevAddr (const char *value)   bool  setDevAddr (String value)   bool  setDevAddr (uint32_t value)   bool  setAppKey (const char *value)   bool  setAppKey (String value)   bool  setNwkKey (const char *value)   bool  setNwkKey (String value)   bool  setAppSKey (const char *value)   bool  setAppSKey (String value)   bool  setNwkSKey (const char *value)   bool  setNwkSKey (String value)  

These methods allow getting various identifiers.

The value is written into the pointer passed, which can be a String object to get a hex-encoded (MSB-first) string, or a raw integer (32-bits for DevAddr and 64-bits for EUIs).

Note that encryption keys cannot be retrieved.

bool  getDevEui (String *value)   bool  getDevEui (uint64_t *value)   bool  getAppEui (String *value)   bool  getAppEui (uint64_t *value)   bool  getDevAddr (String *value)   bool  getDevAddr (uint32_t *value)   String  deviceEUI ()   String  getDevAddr ()   bool  connected ()   bool  busy ()     operator bool ()  

These methods allow configuring various radio and transmission parameters.

bool  dataRate (uint8_t dr)   int  getDataRate ()   bool  power (uint8_t index)   bool  power (_rf_mode mode, uint8_t index)   bool  powerdB (int8_t db)   uint8_t  getPort ()   bool  setPort (uint8_t port)   bool  setADR (bool adr)   int  getADR ()  

These methods allow configuring advanced settings, which are usually not required for normal operation.

bool  dutyCycle (bool on)   bool  publicNetwork (bool publicNetwork)   int  getRX2DR ()   bool  setRX2DR (uint8_t dr)   uint32_t  getRX2Freq ()   bool  setRX2Freq (uint32_t freq)   int  getrxfreq ()  

These methods allow manipulating the list of enabled channels.

The number of channels that are actually available and defined and their frequency and other settings are region-dependent. The fixed frequency regions (US915 and AU915) have 96 fixed channels, while the other regions have just a couple (up to 16) of channels defined.

Note
The list of channels will be reset when starting an OTAA join an when the join completes. Also, the network can send commands to modify the channel plan (define new channels or replace them, and enable/disable them), also as part of ADR messages.
bool  enableChannel (unsigned pos)   bool  disableChannel (unsigned pos)   bool  modifyChannelEnabled (unsigned pos, bool value)   bool  isChannelEnabled (unsigned pos)  

These methods allow access to the up and down frame counters.

Note
Currently setting the framecounters is not supported, since the underlying LoRaWAN library has no obvious way to set these. This might be implemented in the future with some extra work.
int32_t  getFCU ()   int32_t  getFCD ()   bool  setFCD (uint16_t fcd)   bool  setFCU (uint16_t fcu)  

These methods allow direct access to the MIB (Mac Information Base) layer of the underlying stack to set and query values. These are only intended for advanced usage, when the regular API does not provide sufficient access.

Parameters
name Parameter name, only used in error messages
bool  mibGet (const char *name, Mib_t type, MibRequestConfirm_t &mibReq)   bool  mibGetBool (const char *name, Mib_t type, bool *value)   bool  mibGetUint8 (const char *name, Mib_t type, uint8_t *value)   bool  mibGetInt8 (const char *name, Mib_t type, int8_t *value)   bool  mibGetUint32 (const char *name, Mib_t type, uint32_t *value)   bool  mibGetUint64 (const char *name, Mib_t type, uint64_t *value)   bool  mibGetHex (const char *name, Mib_t type, String *value)   bool  mibGetRxChannelParams (const char *name, Mib_t type, RxChannelParams_t *value)   bool  mibGetPtr (const char *name, Mib_t type, void **value)   bool  mibSet (const char *name, Mib_t type, MibRequestConfirm_t &mibReq)   bool  mibSetBool (const char *name, Mib_t type, bool value)   bool  mibSetUint8 (const char *name, Mib_t type, uint8_t value)   bool  mibSetInt8 (const char *name, Mib_t type, int8_t value)   bool  mibSetUint32 (const char *name, Mib_t type, uint32_t value)   bool  mibSetUint64 (const char *name, Mib_t type, uint64_t value)   bool  mibSetHex (const char *name, Mib_t type, const char *value)   bool  mibSetRxChannelParams (const char *name, Mib_t type, RxChannelParams_t value)   bool  mibSetPtr (const char *name, Mib_t type, void *value)   size_t  mibHexSize (const char *name, Mib_t type)  

These are variants of other methods that are asynchronous, i.e. these start an operation and then return immediately without waiting (blocking) for the operation to complete.

After calling these methods, the sketch must periodically call the maintain() method to allow any background work to be performed. This must be done at least until busy() returns false. You can use maintainUntilIdle() for this if you no longer have other things to do while waiting.

bool  joinOTAAAsync ()   int  endPacketAsync (bool confirmed=false)   bool  send (const uint8_t *payload, size_t size, bool confirmed)   uint8_t  lastAck ()   void  maintain ()   void  maintainUntilIdle ()   void  setMaintainNeededCallback (std::function< void(void)> callback)   void  setBatteryLevelCallback (std::function< uint8_t(void)> callback)  

These methods have only dummy implementations, because no meaningful implementations exist and having a dummy implementation is harmless (and also helps to make some examples work without modification).

String  version ()   void  minPollInterval (unsigned long)  

These methods are present in MKRWAN, but are not implemented in this library (because they are specific to the module-based serial approach used by MKRWAN, are for testing purposes only or have better API not tied to the MKRWAN AT commands available.

These methods are declared in this library, but marked so the compiler can generate a friendly error message when they are used.

bool  setCFM (bool cfm)   int  getCFM ()   int  getCFS ()   bool  begin (_lora_band band, uint32_t baud, uint16_t config=SERIAL_8N2)   bool  autoBaud (unsigned long timeout=10000L)   void  setBaud (unsigned long baud)   String  getTConf ()   String  setTConf (String params)   bool  enTtone ()   bool  restart ()   void  poll ()   bool  sleep (bool on=true)   bool  factoryDefault ()   bool  format (bool hexMode)   void  dumb ()   bool  init ()   bool  configureClass (_lora_class _class)   String  getNwkSKey ()   String  getAppSKey ()   String  applicationKey ()   bool  sendMask (String newMask)   bool  sendMask ()   String  getChannelMask ()   int  getChannelMaskSize (_lora_band band)   bool  configureBand (_lora_band band)   static void  MacMcpsConfirm (McpsConfirm_t *McpsConfirm)   static void  MacMcpsIndication (McpsIndication_t *McpsIndication, LoRaMacRxStatus_t *RxStatus)   static void  MacMlmeConfirm (MlmeConfirm_t *MlmeConfirm)   static void  MacMlmeIndication (MlmeIndication_t *MlmeIndication, LoRaMacRxStatus_t *RxStatus)   static void  MacProcessNotify ()   static uint8_t  GetBatteryLevel ()   static const char *  toString (LoRaMacStatus_t)   static const char *  toString (LoRaMacEventInfoStatus_t)   static const char *  toString (Mlme_t)   static const char *  toString (Mcps_t)   static uint8_t  parseHex (char c)   static bool  parseHex (uint8_t *dest, const char *hex, size_t dest_len)   static char  toHex (uint8_t b)   static bool  toHex (String *dest, const uint8_t *src, size_t src_len)   static uint32_t  makeUint32 (uint8_t a, uint8_t b, uint8_t c, uint8_t d)   static bool  failure (const char *fmt,...) __attribute__((format(printf   bool STM32LoRaWAN::powerdB ( int8_t  db )

Set transmit power in dB.

Parameters
db The transmit power in dB. It must be 0 or negative, where 0 is the maximum power and negative values indicate how much dB below the maximum to operate.

Note that only even values are supported, but an uneven value will be rounded down automatically.

The available options depend on the region (see the TX_POWER constants in LoRaMacInterfaces.h), but down to -10 dB should be supported by all regions (but most regions support additional values, down to -28 dB for some regions).

MKRWAN API difference:
Not supported by MKRWAN
bool STM32LoRaWAN::setADR ( bool  adr )

Enable or disable ADR (automatic datarate).

This is enabled by default and allows the network to increase the datarate used (when sending downlink commands) when transmissions from this device are received with sufficient quality that a higher datarate is expected to still be received. In addition, it causes the device to request periodic confirmations and lets it reduce the datarate when transmissions are left unconfirmed.

Together, these two mechanisms should ensure the highest possible datarate is used, maximizing bandwidth and/or reducing spectrum usage (time on air).

void STM32LoRaWAN::setMaintainNeededCallback ( std::function< void(void)>  callback ) inline

Registers a callback that is called whenever there is some work to do and the maintain() function must be called soon.

Warning
This callback is called from an interrupt handler, so it should not do any work and definitely not call maintain(), but just set a flag, enable a task, or something similarly short, and make sure to do that in a interrupt-safe manner.

When using this callback, it is not needed to call the maintain() method unless this callback is called, allowing applications to be more efficient, or use sleeping (but care should be taken to prevent race conditions).

Only one callback can be active at the same time, so any previously configured callback is replaced by the new one passed.

MKRWAN API difference:
Not supported by MKRWAN
uint8_t STM32LoRaWAN::tx_dr = DR_4 protected

Datarate for joining and data transmission (until ADR changes it, if enabled). This defaults to DR 4 since that is the fastest/highest (least spectrum usage) DR that is supported by all regions. If this DR has insufficient range, the join process (and ADR) will fall back to lower datarates automatically.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4