LoRa API Documentation
Contents
Initialization
LoRa Modes
LoRa Test Stub
Examples
Example - LoRa-WAN End-Device Commissioning:
Initialization
To initialize the LoRa stack, you need to do import lora to be able to call
any lora utility and to automatically initialize the saved operating lora mode:
import lora # mandatory before any lora function call
# automatically initialize lora for current operating mode
lora.deinit() # deinit the stack
# all lora calls will be ignored after it
lora.initialize()
# initialize the stack again and back to normal operation
LoRa Modes
There are two available modes for lora; LoRa-RAW and LoRa-WAN.
lora.mode() # returns the current operating LoRa mode
lora.mode(lora._mode.RAW) # switch mode to LoRa-RAW
lora.mode(lora._mode.WAN) # switch mode to LoRa-WAN (ADR enabled by default)
lora.mode(lora._mode.WAN, adr=False) # switch to LoRa-WAN with ADR disabled
lora.mode(lora._mode.WAN, adr=True) # switch to LoRa-WAN with ADR explicitly enabled
The optional adr keyword argument controls Adaptive Data Rate (ADR) when
switching to WAN mode. ADR allows the network server to optimise the device’s
data rate and transmission power. Disable it when the device is mobile or the
RF environment is expected to change frequently.
NOTE: The
adrargument is only meaningful when switching tolora._mode.WAN. It has no effect when querying the current mode or switching tolora._mode.RAW.
LoRa Test stub
In case of testing and no need to connect a user level callback, lora-stack provides an internal stub for callbacks to be used while testing.
lora.callback_stub_connect() # connect the internal lora-stack callback stub
lora.callback_stub_disconnect() # to disconnect it and connect user provided one