STM32LoRaWAN
|
#include <STM32LoRaWAN.h>
Public Member Functions | |||
bool | continuousWave (uint32_t frequency, int8_t powerdBm, uint16_t timeout) | ||
Initialization | |||
bool | begin (_lora_band band) | ||
OTAA Join | |||
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 ( 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:
| |||
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 () | ||
ABP Join | |||
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 (
| |||
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 () | ||
Packet sending | |||
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) | ||
Stream/Print writing | |||
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 () | ||
Packet reception | |||
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 () | ||
Stream reading | |||
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.
| |||
int | read (uint8_t *buf, size_t size) | ||
virtual int | available () | ||
virtual int | read () | ||
virtual int | peek () | ||
Setters for identifiers and keys | |||
These methods allow setting various identifiers and keys. You can pass a hex-encoded (MSB-first) string (
| |||
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) | ||
Getters for identifiers | |||
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) | ||
Querying current state | |||
String | deviceEUI () | ||
String | getDevAddr () | ||
bool | connected () | ||
bool | busy () | ||
operator bool () | |||
Radio / transmission configuration | |||
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 () | ||
Advanced configuration | |||
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 () | ||
Channel manipulation | |||
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.
| |||
bool | enableChannel (unsigned pos) | ||
bool | disableChannel (unsigned pos) | ||
bool | modifyChannelEnabled (unsigned pos, bool value) | ||
bool | isChannelEnabled (unsigned pos) | ||
Frame counters | |||
These methods allow access to the up and down frame counters.
| |||
int32_t | getFCU () | ||
int32_t | getFCD () | ||
bool | setFCD (uint16_t fcd) | ||
bool | setFCU (uint16_t fcu) | ||
Advanced MIB access | |||
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.
| |||
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) | ||
Non-blocking (async) methods | |||
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 | |||
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) | ||
Dummy implementations | |||
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) | ||
Missing methods | |||
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) | ||
Protected Member Functions | |
uint64_t | builtinDevEUI () |
static bool void | clear_rx () |
void | add_rx (const uint8_t *buf, size_t len) |
Static Protected Member Functions | |
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 |
Protected Attributes | |
LoRaMacPrimitives_t | LoRaMacPrimitives |
LoRaMacCallback_t | LoRaMacCallbacks |
uint8_t | tx_dr = DR_4 |
uint8_t | tx_port = 2 |
uint8_t | rx_port = 0 |
bool | nwk_key_set = false |
uint8_t | tx_buf [255] |
uint8_t * | tx_ptr |
uint8_t | rx_buf [255] |
uint8_t * | rx_ptr |
bool | last_tx_acked = false |
uint32_t | fcnt_up = 0 |
uint32_t | fcnt_down = 0 |
std::function< void(void)> | maintain_needed_callback |
std::function< uint8_t(void)> | battery_level_callback |
bool | mac_process_pending = false |
Static Protected Attributes | |
static STM32LoRaWAN * | instance |
static constexpr uint32_t | DEFAULT_JOIN_TIMEOUT = 60000 |
|
protected |
Add data to the rx buffer
String STM32LoRaWAN::applicationKey | ( | ) |
bool STM32LoRaWAN::autoBaud | ( | unsigned long | timeout = 10000L | ) |
|
virtual |
|
virtual |
Returns how many bytes can still be written into the current packet.
This takes the maximum payload size at the current datarate into account. When this is called directly after beginPacket(), it returns the maximum payload size.
You can usually write more than this amount, but then sending the packet with endPacket() will likely fail.
bool STM32LoRaWAN::begin | ( | _lora_band | band | ) |
Initialize the library. Must be called before any other methods.
band | The region/band to use. See _lora_band for allowed values. |
bool STM32LoRaWAN::begin | ( | _lora_band | band, |
uint32_t | baud, | ||
uint16_t | config = SERIAL_8N2 |
||
) |
void STM32LoRaWAN::beginPacket | ( | ) |
|
protected |
Generate the builtin DevEUI for this board
bool STM32LoRaWAN::busy | ( | ) |
Returns whether the modem is currently busy processing a request. After a non-blocking request (e.g. unconfirmed uplink), this returns true until the request is completed and then returns false until some new request is made.
|
inlineprotected |
Empty the rx buffer
bool STM32LoRaWAN::configureBand | ( | _lora_band | band | ) |
This could be supported, but needs careful consideration and complete re-initialization.
bool STM32LoRaWAN::configureClass | ( | _lora_class | _class | ) |
bool STM32LoRaWAN::connected | ( | ) |
Returns whether connected to the network (i.e. for OTAA a successful join exchange has happened, or for ABP session information has been supplied by calling joinABP).
bool STM32LoRaWAN::continuousWave | ( | uint32_t | frequency, |
int8_t | powerdBm, | ||
uint16_t | timeout | ||
) |
Set the radio into continuous wave (CW) mode. In this mode radio outputs a signal at the specified frequency and power for the specified duration.
Used only for compliance testing and antenna testing.
frequency | Frequency in Hz. |
powerdBm | transmit power in dBm. |
timeout | Duration in seconds. |
bool STM32LoRaWAN::dataRate | ( | uint8_t | dr | ) |
Set the datarate to use for future packets. If ADR is enabled, that might change the datarate again (but the rate passed should be used for at least one uplink packet).
String STM32LoRaWAN::deviceEUI | ( | ) |
Return the currently configured deviceEUI. On startup, this is the EUI for the chip (stored in ROM). If changed (i.e. with joinOTAA() or setDevEUI()), the changed value is returned instead.
bool STM32LoRaWAN::disableChannel | ( | unsigned | pos | ) |
void STM32LoRaWAN::dumb | ( | ) |
bool STM32LoRaWAN::dutyCycle | ( | bool | on | ) |
When false is passed, duty cycle limits are no longer checked.
bool STM32LoRaWAN::enableChannel | ( | unsigned | pos | ) |
int STM32LoRaWAN::endPacket | ( | bool | confirmed = false | ) |
Finalize and send a packet previously prepared using beginPacket() and write().
This blocks until the packet is completely sent an both RX windows have been completed.
int STM32LoRaWAN::endPacketAsync | ( | bool | confirmed = false | ) |
Finalize and asynchronously send a packet. This can be used in place of endPacket()
when you do not want blocking behavior.
The return value only reflects whether the packet could successfully queued, to see if a confirmed packet was actually confirmed by the network, call lastAck().
bool STM32LoRaWAN::enTtone | ( | ) |
bool STM32LoRaWAN::factoryDefault | ( | ) |
|
staticprotected |
Helper that prints an error and then always returns false, to allow for combining reporting and returning in a single line.
|
inlinevirtual |
This is a no-op, to send written data, use endPacket().
bool STM32LoRaWAN::format | ( | bool | hexMode | ) |
int STM32LoRaWAN::getADR | ( | ) |
Return whether ADR (automatic datarate) is enabled.
|
inline |
|
inline |
String STM32LoRaWAN::getAppSKey | ( | ) |
|
staticprotected |
int STM32LoRaWAN::getCFM | ( | ) |
int STM32LoRaWAN::getCFS | ( | ) |
String STM32LoRaWAN::getChannelMask | ( | ) |
int STM32LoRaWAN::getChannelMaskSize | ( | _lora_band | band | ) |
int STM32LoRaWAN::getDataRate | ( | ) |
Retrieve the current datarate (possibly modified by ADR)
String STM32LoRaWAN::getDevAddr | ( | ) |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Returns the port number of the most recently received packet.
int32_t STM32LoRaWAN::getFCD | ( | ) |
Return the frame counter of the most recent downlink message that was received.
int32_t STM32LoRaWAN::getFCU | ( | ) |
Return the frame counter of the most recent uplink message that was completely transmitted (i.e. after the RX windows have passed).
String STM32LoRaWAN::getNwkSKey | ( | ) |
uint8_t STM32LoRaWAN::getPort | ( | ) |
Return the port used for data transmission.
int STM32LoRaWAN::getRX2DR | ( | ) |
Return the datarate used for the RX2 window.
uint32_t STM32LoRaWAN::getRX2Freq | ( | ) |
Return the frequency used for the RX2 window.
int STM32LoRaWAN::getrxfreq | ( | ) |
Alias of getRX2Freq() for MKRWAN_v2 compatibility
String STM32LoRaWAN::getTConf | ( | ) |
bool STM32LoRaWAN::init | ( | ) |
bool STM32LoRaWAN::isChannelEnabled | ( | unsigned | pos | ) |
bool STM32LoRaWAN::joinABP | ( | ) |
Perform a join with parameters previously set using after using setDevAddr(), setNwkSKey() and setAppSKey().
|
inline |
|
inline |
|
inline |
bool STM32LoRaWAN::joinOTAA | ( | ) |
Perform a join with parameters previously set using after using setAppEui(), setAppKey() and optionally setDevEui().
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
bool STM32LoRaWAN::joinOTAAAsync | ( | ) |
Do an asynchronous OTAA join using previously configured AppEui, AppKey and optionally DevEui. This can be used in place of joinOTAA() when you do not want blocking behavior.
This initiates a single join attempt (one JoinReq message). After both receive windows are complete, busy()
will become false and the sketch can call connected()
to see if the join attempt was successful. If not, it is up to the sketch to decide on retries.
|
inline |
Returns true when the most recently transmitted packet has received a confirmation from the network (if requested). Directly after transmitting any packet, this will return false and it will become true when the ack is received (which is, at the latest, when busy() becomes false again).
|
staticprotected |
|
staticprotected |
|
staticprotected |
|
staticprotected |
|
staticprotected |
void STM32LoRaWAN::maintain | ( | ) |
Perform any pending work, or quickly return if there is none.
While the stack is busy, this method should be called very frequently to ensure accurate timing. It is automatically called by all blocking methods in this library.
void STM32LoRaWAN::maintainUntilIdle | ( | ) |
Call maintain() to process any background work for as long as the stack is busy (i.e. until busy() returns false).
|
inlinestaticprotected |
Build a uint32_t from four bytes (big-endian, a is MSB)
bool STM32LoRaWAN::mibGet | ( | const char * | name, |
Mib_t | type, | ||
MibRequestConfirm_t & | mibReq | ||
) |
bool STM32LoRaWAN::mibGetBool | ( | const char * | name, |
Mib_t | type, | ||
bool * | value | ||
) |
bool STM32LoRaWAN::mibGetHex | ( | const char * | name, |
Mib_t | type, | ||
String * | value | ||
) |
bool STM32LoRaWAN::mibGetInt8 | ( | const char * | name, |
Mib_t | type, | ||
int8_t * | value | ||
) |
bool STM32LoRaWAN::mibGetPtr | ( | const char * | name, |
Mib_t | type, | ||
void ** | value | ||
) |
bool STM32LoRaWAN::mibGetRxChannelParams | ( | const char * | name, |
Mib_t | type, | ||
RxChannelParams_t * | value | ||
) |
bool STM32LoRaWAN::mibGetUint32 | ( | const char * | name, |
Mib_t | type, | ||
uint32_t * | value | ||
) |
bool STM32LoRaWAN::mibGetUint64 | ( | const char * | name, |
Mib_t | type, | ||
uint64_t * | value | ||
) |
bool STM32LoRaWAN::mibGetUint8 | ( | const char * | name, |
Mib_t | type, | ||
uint8_t * | value | ||
) |
size_t STM32LoRaWAN::mibHexSize | ( | const char * | name, |
Mib_t | type | ||
) |
bool STM32LoRaWAN::mibSet | ( | const char * | name, |
Mib_t | type, | ||
MibRequestConfirm_t & | mibReq | ||
) |
bool STM32LoRaWAN::mibSetBool | ( | const char * | name, |
Mib_t | type, | ||
bool | value | ||
) |
bool STM32LoRaWAN::mibSetHex | ( | const char * | name, |
Mib_t | type, | ||
const char * | value | ||
) |
bool STM32LoRaWAN::mibSetInt8 | ( | const char * | name, |
Mib_t | type, | ||
int8_t | value | ||
) |
bool STM32LoRaWAN::mibSetPtr | ( | const char * | name, |
Mib_t | type, | ||
void * | value | ||
) |
bool STM32LoRaWAN::mibSetRxChannelParams | ( | const char * | name, |
Mib_t | type, | ||
RxChannelParams_t | value | ||
) |
bool STM32LoRaWAN::mibSetUint32 | ( | const char * | name, |
Mib_t | type, | ||
uint32_t | value | ||
) |
bool STM32LoRaWAN::mibSetUint64 | ( | const char * | name, |
Mib_t | type, | ||
uint64_t | value | ||
) |
bool STM32LoRaWAN::mibSetUint8 | ( | const char * | name, |
Mib_t | type, | ||
uint8_t | value | ||
) |
|
inline |
Dummy for MKRWAN compatibility. Exact purpose on MKRWAN is unclear, see https://github.com/arduino-libraries/MKRWAN/issues/25
bool STM32LoRaWAN::modifyChannelEnabled | ( | unsigned | pos, |
bool | value | ||
) |
|
inline |
Converts this object into a bool (e.g. for using in an if directly), returning the same value as connected().
|
staticprotected |
Convert a single hex char into its numerical value
|
staticprotected |
Convert a hex string into a binary buffer
int STM32LoRaWAN::parsePacket | ( | ) |
Alias of available(), returns the number of bytes available to read.
|
virtual |
void STM32LoRaWAN::poll | ( | ) |
|
inline |
Set the transmit power (MKRWAN version)
mode | This parameter is ignored, the mode is automatically determined based on the selected power. |
index | See power(uint8_t) for details. |
bool STM32LoRaWAN::power | ( | uint8_t | index | ) |
Set the transmit power (MKRWAN_v2 version)
index | This sets the power index which is passed to the underlying stack directly. Unexpectedly, a value of 0 indicates the maximum power, and higher values decrease the value in steps of 2dB (so 0 = max, 1 = -2dB, 2 = -4dB, etc.). |
The available options depend on the region (see the TX_POWER constants in LoRaMacInterfaces.h), but indices 0-5 should be supported by all regions (but most regions support additional values).
If an unavailable option is passed, this method will fail and return false.
bool STM32LoRaWAN::powerdB | ( | int8_t | db | ) |
Set transmit power in dB.
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).
bool STM32LoRaWAN::publicNetwork | ( | bool | publicNetwork | ) |
Configure the syncword to use. The default is the "public" (LoRaWAN standard) syncword, when set to false this uses another syncword that is often recommended for "private" networks.
|
virtual |
int STM32LoRaWAN::read | ( | uint8_t * | buf, |
size_t | size | ||
) |
bool STM32LoRaWAN::restart | ( | ) |
bool STM32LoRaWAN::send | ( | const uint8_t * | payload, |
size_t | size, | ||
bool | confirmed | ||
) |
Send a packet asynchronously by passing a buffer. This can be used instead of beginPacket() / write() / endPacket(), when you prefer building the data to send in an external buffer and do not want to skip one buffer copy.
The return value only reflects whether the packet could successfully queued, to see if a confirmed packet was actually confirmed by the network, call lastAck().
bool STM32LoRaWAN::sendMask | ( | ) |
bool STM32LoRaWAN::sendMask | ( | String | newMask | ) |
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).
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Registers a callback that is called whenever there is a DevStatusReq.
BAT_LEVEL_EXT_SRC - The end-device is connected to an external power source BAT_LEVEL_EMPTY - The battery is empty 1..254 - The battery level, 1 being at minimum and 254 being at maximum BAT_LEVEL_FULL - The battery is full BAT_LEVEL_NO_MEASURE - The end-device was not able to measure the battery level
void STM32LoRaWAN::setBaud | ( | unsigned long | baud | ) |
bool STM32LoRaWAN::setCFM | ( | bool | cfm | ) |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
bool STM32LoRaWAN::setFCD | ( | uint16_t | fcd | ) |
bool STM32LoRaWAN::setFCU | ( | uint16_t | fcu | ) |
|
inline |
Registers 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.
|
inline |
|
inline |
|
inline |
|
inline |
bool STM32LoRaWAN::setPort | ( | uint8_t | port | ) |
Set the port to be used for data transmission.
bool STM32LoRaWAN::setRX2DR | ( | uint8_t | dr | ) |
Set the datarate used for the RX2 window. The network might override this value using downlink commands (typically only in OTAA mode).
bool STM32LoRaWAN::setRX2Freq | ( | uint32_t | freq | ) |
Set the frequency used for the RX2 window. The network might override this value using downlink commands (typically only in OTAA mode).
String STM32LoRaWAN::setTConf | ( | String | params | ) |
bool STM32LoRaWAN::sleep | ( | bool | on = true | ) |
|
staticprotected |
Convert a binary buffer to a hex string
|
staticprotected |
Convert a nibble (0-15) to a hex char
|
staticprotected |
Convert an enum value into string containing its name. The string returned is a static constant, so no memory management needed.
|
staticprotected |
Convert an enum value into string containing its name. The string returned is a static constant, so no memory management needed.
|
staticprotected |
Convert an enum value into string containing its name. The string returned is a static constant, so no memory management needed.
|
staticprotected |
Convert an enum value into string containing its name. The string returned is a static constant, so no memory management needed.
|
inline |
Dummy for MKRWAN compatibility. On MKRWAN this returned the module firmware version, but this does not apply here.
|
virtual |
|
inline |
|
virtual |
|
protected |
|
staticconstexprprotected |
|
protected |
|
protected |
|
staticprotected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
Port for most recently received packet
|
protected |
|
protected |
|
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.
|
protected |
Port for data transmissions. Default taken from MKRWAN_v2 / mkrwan1300-fw
|
protected |