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:
datarate()
) for most regions, but uses fixed datarates (according to LoRaWAN regional parameters) for US915/AU915/AS923.Timeout parameter omitted (also omitted in MKRWAN_v2)
Added version that accepts uint64_t appEUI
Differences in timeout and retry datarate handling
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).
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.
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).
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.
These methods allow access to the up and down frame counters.
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.
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.
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.
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).
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 ) inlineRegisters a callback that is called whenever there is some work to do and the maintain() function must be called soon.
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.
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