# This file was automatically generated by SWIG (http://www.swig.org).
# Version 3.0.8
#
# Do not make changes to this file unless you know what you are doing--modify
# the SWIG interface file instead.
from sys import version_info
if version_info >= (2, 6, 0):
def swig_import_helper():
from os.path import dirname
import imp
fp = None
try:
fp, pathname, description = imp.find_module('_pyupm_rn2903', [dirname(__file__)])
except ImportError:
import _pyupm_rn2903
return _pyupm_rn2903
if fp is not None:
try:
_mod = imp.load_module('_pyupm_rn2903', fp, pathname, description)
finally:
fp.close()
return _mod
_pyupm_rn2903 = swig_import_helper()
del swig_import_helper
else:
import _pyupm_rn2903
del version_info
try:
_swig_property = property
except NameError:
pass # Python < 2.2 doesn't have 'property'.
def _swig_setattr_nondynamic(self, class_type, name, value, static=1):
if (name == "thisown"):
return self.this.own(value)
if (name == "this"):
if type(value).__name__ == 'SwigPyObject':
self.__dict__[name] = value
return
method = class_type.__swig_setmethods__.get(name, None)
if method:
return method(self, value)
if (not static):
if _newclass:
object.__setattr__(self, name, value)
else:
self.__dict__[name] = value
else:
raise AttributeError("You cannot add attributes to %s" % self)
def _swig_setattr(self, class_type, name, value):
return _swig_setattr_nondynamic(self, class_type, name, value, 0)
def _swig_getattr_nondynamic(self, class_type, name, static=1):
if (name == "thisown"):
return self.this.own()
method = class_type.__swig_getmethods__.get(name, None)
if method:
return method(self)
if (not static):
return object.__getattr__(self, name)
else:
raise AttributeError(name)
def _swig_getattr(self, class_type, name):
return _swig_getattr_nondynamic(self, class_type, name, 0)
def _swig_repr(self):
try:
strthis = "proxy of " + self.this.__repr__()
except Exception:
strthis = ""
return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,)
try:
_object = object
_newclass = 1
except AttributeError:
class _object:
pass
_newclass = 0
def getVersion():
return _pyupm_rn2903.getVersion()
getVersion = _pyupm_rn2903.getVersion
_pyupm_rn2903.RN2903_MAX_BUFFER_swigconstant(_pyupm_rn2903)
RN2903_MAX_BUFFER = _pyupm_rn2903.RN2903_MAX_BUFFER
_pyupm_rn2903.RN2903_MAX_HEX_EUI64_swigconstant(_pyupm_rn2903)
RN2903_MAX_HEX_EUI64 = _pyupm_rn2903.RN2903_MAX_HEX_EUI64
_pyupm_rn2903.RN2903_DEFAULT_BAUDRATE_swigconstant(_pyupm_rn2903)
RN2903_DEFAULT_BAUDRATE = _pyupm_rn2903.RN2903_DEFAULT_BAUDRATE
_pyupm_rn2903.RN2903_DEFAULT_RESP_DELAY_swigconstant(_pyupm_rn2903)
RN2903_DEFAULT_RESP_DELAY = _pyupm_rn2903.RN2903_DEFAULT_RESP_DELAY
_pyupm_rn2903.RN2903_DEFAULT_RESP2_DELAY_swigconstant(_pyupm_rn2903)
RN2903_DEFAULT_RESP2_DELAY = _pyupm_rn2903.RN2903_DEFAULT_RESP2_DELAY
_pyupm_rn2903.RN2903_PHRASE_TERM_swigconstant(_pyupm_rn2903)
RN2903_PHRASE_TERM = _pyupm_rn2903.RN2903_PHRASE_TERM
_pyupm_rn2903.RN2903_PHRASE_TERM_LEN_swigconstant(_pyupm_rn2903)
RN2903_PHRASE_TERM_LEN = _pyupm_rn2903.RN2903_PHRASE_TERM_LEN
_pyupm_rn2903.RN2903_PHRASE_INV_PARAM_swigconstant(_pyupm_rn2903)
RN2903_PHRASE_INV_PARAM = _pyupm_rn2903.RN2903_PHRASE_INV_PARAM
_pyupm_rn2903.RN2903_PHRASE_OK_swigconstant(_pyupm_rn2903)
RN2903_PHRASE_OK = _pyupm_rn2903.RN2903_PHRASE_OK
_pyupm_rn2903.RN2903_MAC_STATUS_JOINED_swigconstant(_pyupm_rn2903)
RN2903_MAC_STATUS_JOINED = _pyupm_rn2903.RN2903_MAC_STATUS_JOINED
_pyupm_rn2903.RN2903_MAC_STATUS_MAC_STATUS0_swigconstant(_pyupm_rn2903)
RN2903_MAC_STATUS_MAC_STATUS0 = _pyupm_rn2903.RN2903_MAC_STATUS_MAC_STATUS0
_pyupm_rn2903.RN2903_MAC_STATUS_MAC_STATUS1_swigconstant(_pyupm_rn2903)
RN2903_MAC_STATUS_MAC_STATUS1 = _pyupm_rn2903.RN2903_MAC_STATUS_MAC_STATUS1
_pyupm_rn2903.RN2903_MAC_STATUS_MAC_STATUS2_swigconstant(_pyupm_rn2903)
RN2903_MAC_STATUS_MAC_STATUS2 = _pyupm_rn2903.RN2903_MAC_STATUS_MAC_STATUS2
_pyupm_rn2903._RN2903_MAC_STATUS_MAC_STATUS_MASK_swigconstant(_pyupm_rn2903)
_RN2903_MAC_STATUS_MAC_STATUS_MASK = _pyupm_rn2903._RN2903_MAC_STATUS_MAC_STATUS_MASK
_pyupm_rn2903._RN2903_MAC_STATUS_MAC_STATUS_SHIFT_swigconstant(_pyupm_rn2903)
_RN2903_MAC_STATUS_MAC_STATUS_SHIFT = _pyupm_rn2903._RN2903_MAC_STATUS_MAC_STATUS_SHIFT
_pyupm_rn2903.RN2903_MAC_STATUS_AUTO_REPLY_swigconstant(_pyupm_rn2903)
RN2903_MAC_STATUS_AUTO_REPLY = _pyupm_rn2903.RN2903_MAC_STATUS_AUTO_REPLY
_pyupm_rn2903.RN2903_MAC_STATUS_ADR_swigconstant(_pyupm_rn2903)
RN2903_MAC_STATUS_ADR = _pyupm_rn2903.RN2903_MAC_STATUS_ADR
_pyupm_rn2903.RN2903_MAC_STATUS_SILENT_swigconstant(_pyupm_rn2903)
RN2903_MAC_STATUS_SILENT = _pyupm_rn2903.RN2903_MAC_STATUS_SILENT
_pyupm_rn2903.RN2903_MAC_STATUS_PAUSED_swigconstant(_pyupm_rn2903)
RN2903_MAC_STATUS_PAUSED = _pyupm_rn2903.RN2903_MAC_STATUS_PAUSED
_pyupm_rn2903.RN2903_MAC_STATUS_RFU_swigconstant(_pyupm_rn2903)
RN2903_MAC_STATUS_RFU = _pyupm_rn2903.RN2903_MAC_STATUS_RFU
_pyupm_rn2903.RN2903_MAC_STATUS_LINK_CHK_swigconstant(_pyupm_rn2903)
RN2903_MAC_STATUS_LINK_CHK = _pyupm_rn2903.RN2903_MAC_STATUS_LINK_CHK
_pyupm_rn2903.RN2903_MAC_STATUS_CHAN_UPD_swigconstant(_pyupm_rn2903)
RN2903_MAC_STATUS_CHAN_UPD = _pyupm_rn2903.RN2903_MAC_STATUS_CHAN_UPD
_pyupm_rn2903.RN2903_MAC_STATUS_OUT_PWR_UPD_swigconstant(_pyupm_rn2903)
RN2903_MAC_STATUS_OUT_PWR_UPD = _pyupm_rn2903.RN2903_MAC_STATUS_OUT_PWR_UPD
_pyupm_rn2903.RN2903_MAC_STATUS_NBREP_UPD_swigconstant(_pyupm_rn2903)
RN2903_MAC_STATUS_NBREP_UPD = _pyupm_rn2903.RN2903_MAC_STATUS_NBREP_UPD
_pyupm_rn2903.RN2903_MAC_STATUS_PRESCALER_UPD_swigconstant(_pyupm_rn2903)
RN2903_MAC_STATUS_PRESCALER_UPD = _pyupm_rn2903.RN2903_MAC_STATUS_PRESCALER_UPD
_pyupm_rn2903.RN2903_MAC_STATUS_SECOND_RX_UPD_swigconstant(_pyupm_rn2903)
RN2903_MAC_STATUS_SECOND_RX_UPD = _pyupm_rn2903.RN2903_MAC_STATUS_SECOND_RX_UPD
_pyupm_rn2903.RN2903_MAC_STATUS_TX_TIMING_UPD_swigconstant(_pyupm_rn2903)
RN2903_MAC_STATUS_TX_TIMING_UPD = _pyupm_rn2903.RN2903_MAC_STATUS_TX_TIMING_UPD
_pyupm_rn2903.RN2903_MAC_STAT_IDLE_swigconstant(_pyupm_rn2903)
RN2903_MAC_STAT_IDLE = _pyupm_rn2903.RN2903_MAC_STAT_IDLE
_pyupm_rn2903.RN2903_MAC_STAT_TX_IN_PROGESS_swigconstant(_pyupm_rn2903)
RN2903_MAC_STAT_TX_IN_PROGESS = _pyupm_rn2903.RN2903_MAC_STAT_TX_IN_PROGESS
_pyupm_rn2903.RN2903_MAC_STAT_BEFORE_RX_WIN1_swigconstant(_pyupm_rn2903)
RN2903_MAC_STAT_BEFORE_RX_WIN1 = _pyupm_rn2903.RN2903_MAC_STAT_BEFORE_RX_WIN1
_pyupm_rn2903.RN2903_MAC_STAT_RX_WIN1_OPEN_swigconstant(_pyupm_rn2903)
RN2903_MAC_STAT_RX_WIN1_OPEN = _pyupm_rn2903.RN2903_MAC_STAT_RX_WIN1_OPEN
_pyupm_rn2903.RN2903_MAC_STAT_BETWEEN_RX_WIN1_WIN2_swigconstant(_pyupm_rn2903)
RN2903_MAC_STAT_BETWEEN_RX_WIN1_WIN2 = _pyupm_rn2903.RN2903_MAC_STAT_BETWEEN_RX_WIN1_WIN2
_pyupm_rn2903.RN2903_MAC_STAT_RX_WIN2_OPEN_swigconstant(_pyupm_rn2903)
RN2903_MAC_STAT_RX_WIN2_OPEN = _pyupm_rn2903.RN2903_MAC_STAT_RX_WIN2_OPEN
_pyupm_rn2903.RN2903_MAC_STAT_ACK_TIMEOUT_swigconstant(_pyupm_rn2903)
RN2903_MAC_STAT_ACK_TIMEOUT = _pyupm_rn2903.RN2903_MAC_STAT_ACK_TIMEOUT
_pyupm_rn2903.RN2903_JOIN_TYPE_OTAA_swigconstant(_pyupm_rn2903)
RN2903_JOIN_TYPE_OTAA = _pyupm_rn2903.RN2903_JOIN_TYPE_OTAA
_pyupm_rn2903.RN2903_JOIN_TYPE_ABP_swigconstant(_pyupm_rn2903)
RN2903_JOIN_TYPE_ABP = _pyupm_rn2903.RN2903_JOIN_TYPE_ABP
_pyupm_rn2903.RN2903_JOIN_STATUS_ACCEPTED_swigconstant(_pyupm_rn2903)
RN2903_JOIN_STATUS_ACCEPTED = _pyupm_rn2903.RN2903_JOIN_STATUS_ACCEPTED
_pyupm_rn2903.RN2903_JOIN_STATUS_BAD_KEYS_swigconstant(_pyupm_rn2903)
RN2903_JOIN_STATUS_BAD_KEYS = _pyupm_rn2903.RN2903_JOIN_STATUS_BAD_KEYS
_pyupm_rn2903.RN2903_JOIN_STATUS_NO_CHAN_swigconstant(_pyupm_rn2903)
RN2903_JOIN_STATUS_NO_CHAN = _pyupm_rn2903.RN2903_JOIN_STATUS_NO_CHAN
_pyupm_rn2903.RN2903_JOIN_STATUS_SILENT_swigconstant(_pyupm_rn2903)
RN2903_JOIN_STATUS_SILENT = _pyupm_rn2903.RN2903_JOIN_STATUS_SILENT
_pyupm_rn2903.RN2903_JOIN_STATUS_BUSY_swigconstant(_pyupm_rn2903)
RN2903_JOIN_STATUS_BUSY = _pyupm_rn2903.RN2903_JOIN_STATUS_BUSY
_pyupm_rn2903.RN2903_JOIN_STATUS_MAC_PAUSED_swigconstant(_pyupm_rn2903)
RN2903_JOIN_STATUS_MAC_PAUSED = _pyupm_rn2903.RN2903_JOIN_STATUS_MAC_PAUSED
_pyupm_rn2903.RN2903_JOIN_STATUS_DENIED_swigconstant(_pyupm_rn2903)
RN2903_JOIN_STATUS_DENIED = _pyupm_rn2903.RN2903_JOIN_STATUS_DENIED
_pyupm_rn2903.RN2903_JOIN_STATUS_ALREADY_JOINED_swigconstant(_pyupm_rn2903)
RN2903_JOIN_STATUS_ALREADY_JOINED = _pyupm_rn2903.RN2903_JOIN_STATUS_ALREADY_JOINED
_pyupm_rn2903.RN2903_JOIN_STATUS_UPM_ERROR_swigconstant(_pyupm_rn2903)
RN2903_JOIN_STATUS_UPM_ERROR = _pyupm_rn2903.RN2903_JOIN_STATUS_UPM_ERROR
_pyupm_rn2903.RN2903_FLOW_CONTROL_NONE_swigconstant(_pyupm_rn2903)
RN2903_FLOW_CONTROL_NONE = _pyupm_rn2903.RN2903_FLOW_CONTROL_NONE
_pyupm_rn2903.RN2903_FLOW_CONTROL_HARD_swigconstant(_pyupm_rn2903)
RN2903_FLOW_CONTROL_HARD = _pyupm_rn2903.RN2903_FLOW_CONTROL_HARD
_pyupm_rn2903.RN2903_MAC_MSG_TYPE_UNCONFIRMED_swigconstant(_pyupm_rn2903)
RN2903_MAC_MSG_TYPE_UNCONFIRMED = _pyupm_rn2903.RN2903_MAC_MSG_TYPE_UNCONFIRMED
_pyupm_rn2903.RN2903_MAC_MSG_TYPE_CONFIRMED_swigconstant(_pyupm_rn2903)
RN2903_MAC_MSG_TYPE_CONFIRMED = _pyupm_rn2903.RN2903_MAC_MSG_TYPE_CONFIRMED
_pyupm_rn2903.RN2903_MAC_TX_STATUS_TX_OK_swigconstant(_pyupm_rn2903)
RN2903_MAC_TX_STATUS_TX_OK = _pyupm_rn2903.RN2903_MAC_TX_STATUS_TX_OK
_pyupm_rn2903.RN2903_MAC_TX_STATUS_NOT_JOINED_swigconstant(_pyupm_rn2903)
RN2903_MAC_TX_STATUS_NOT_JOINED = _pyupm_rn2903.RN2903_MAC_TX_STATUS_NOT_JOINED
_pyupm_rn2903.RN2903_MAC_TX_STATUS_NO_CHAN_swigconstant(_pyupm_rn2903)
RN2903_MAC_TX_STATUS_NO_CHAN = _pyupm_rn2903.RN2903_MAC_TX_STATUS_NO_CHAN
_pyupm_rn2903.RN2903_MAC_TX_STATUS_SILENT_swigconstant(_pyupm_rn2903)
RN2903_MAC_TX_STATUS_SILENT = _pyupm_rn2903.RN2903_MAC_TX_STATUS_SILENT
_pyupm_rn2903.RN2903_MAC_TX_STATUS_FC_NEED_REJOIN_swigconstant(_pyupm_rn2903)
RN2903_MAC_TX_STATUS_FC_NEED_REJOIN = _pyupm_rn2903.RN2903_MAC_TX_STATUS_FC_NEED_REJOIN
_pyupm_rn2903.RN2903_MAC_TX_STATUS_BUSY_swigconstant(_pyupm_rn2903)
RN2903_MAC_TX_STATUS_BUSY = _pyupm_rn2903.RN2903_MAC_TX_STATUS_BUSY
_pyupm_rn2903.RN2903_MAC_TX_STATUS_MAC_PAUSED_swigconstant(_pyupm_rn2903)
RN2903_MAC_TX_STATUS_MAC_PAUSED = _pyupm_rn2903.RN2903_MAC_TX_STATUS_MAC_PAUSED
_pyupm_rn2903.RN2903_MAC_TX_STATUS_BAD_DATA_LEN_swigconstant(_pyupm_rn2903)
RN2903_MAC_TX_STATUS_BAD_DATA_LEN = _pyupm_rn2903.RN2903_MAC_TX_STATUS_BAD_DATA_LEN
_pyupm_rn2903.RN2903_MAC_TX_STATUS_RX_RECEIVED_swigconstant(_pyupm_rn2903)
RN2903_MAC_TX_STATUS_RX_RECEIVED = _pyupm_rn2903.RN2903_MAC_TX_STATUS_RX_RECEIVED
_pyupm_rn2903.RN2903_MAC_TX_STATUS_MAC_ERR_swigconstant(_pyupm_rn2903)
RN2903_MAC_TX_STATUS_MAC_ERR = _pyupm_rn2903.RN2903_MAC_TX_STATUS_MAC_ERR
_pyupm_rn2903.RN2903_MAC_TX_STATUS_UPM_ERROR_swigconstant(_pyupm_rn2903)
RN2903_MAC_TX_STATUS_UPM_ERROR = _pyupm_rn2903.RN2903_MAC_TX_STATUS_UPM_ERROR
_pyupm_rn2903.RN2903_RESPONSE_OK_swigconstant(_pyupm_rn2903)
RN2903_RESPONSE_OK = _pyupm_rn2903.RN2903_RESPONSE_OK
_pyupm_rn2903.RN2903_RESPONSE_INVALID_PARAM_swigconstant(_pyupm_rn2903)
RN2903_RESPONSE_INVALID_PARAM = _pyupm_rn2903.RN2903_RESPONSE_INVALID_PARAM
_pyupm_rn2903.RN2903_RESPONSE_TIMEOUT_swigconstant(_pyupm_rn2903)
RN2903_RESPONSE_TIMEOUT = _pyupm_rn2903.RN2903_RESPONSE_TIMEOUT
_pyupm_rn2903.RN2903_RESPONSE_UPM_ERROR_swigconstant(_pyupm_rn2903)
RN2903_RESPONSE_UPM_ERROR = _pyupm_rn2903.RN2903_RESPONSE_UPM_ERROR
[docs]class RN2903(_object):
"""
API for the Microchip RN2903 LoRa radio.
ID: rn2903
Name: Microchip RN2903 LoRa radio
Category: wifi
Connection: uart The Microchip RN2903 Low-Power Long Range LoRa
Technology Transceiver module provides an easy to use, low-power
solution for long range wireless data transmission. The advanced
command interface offers rapid time to market.
The RN2903 module complies with the LoRaWAN Class A protocol
specifications. It integrates RF, a baseband controller, and a command
Application Programming Interface (API) processor, making it a
complete long range solution.
Most of the effort in this driver has been geared to supporting
operation within a LoRaWAN network, however methods are provided to
allow you to control the device directly so that you can implement
whatever solution you require.
C++ includes: rn2903.hpp
"""
__swig_setmethods__ = {}
__setattr__ = lambda self, name, value: _swig_setattr(self, RN2903, name, value)
__swig_getmethods__ = {}
__getattr__ = lambda self, name: _swig_getattr(self, RN2903, name)
__repr__ = _swig_repr
def __init__(self, *args):
"""
RN2903(std::string
uart_path, unsigned int baudrate=RN2903_DEFAULT_BAUDRATE)
RN2903 object constructor for a UART specified by PATH (ex:
/dev/ttyUSB0)
Parameters:
-----------
uart_path: Specify path of UART device.
baudrate: Specify the baudrate to use. The default is 57600.
"""
this = _pyupm_rn2903.new_RN2903(*args)
try:
self.this.append(this)
except Exception:
self.this = this
__swig_destroy__ = _pyupm_rn2903.delete_RN2903
__del__ = lambda self: None
[docs] def setResponseWaitTime(self, *args):
"""
void
setResponseWaitTime(unsigned int wait_ms=RN2903_DEFAULT_RESP_DELAY)
Set the default time, in milliseconds, to wait for a response after
sending a command. All commands return at least one response
immediately after issuing the command. This delay sets the maximum
amount of time to wait for it.
Parameters:
-----------
wait_ms: The response delay to set, in milliseconds. The default is 1
second (1000ms).
"""
return _pyupm_rn2903.RN2903_setResponseWaitTime(self, *args)
[docs] def setResponse2WaitTime(self, *args):
"""
void
setResponse2WaitTime(unsigned int wait_ms=RN2903_DEFAULT_RESP2_DELAY)
Set the default time, in milliseconds, to wait for the second response
data to arrive. Some commands will have a second response emitted
after the first response. This delay sets the maximum amount of time
to wait for it.
Parameters:
-----------
wait_ms: The response delay to set, in milliseconds. The default is
60 seconds (60000ms).
"""
return _pyupm_rn2903.RN2903_setResponse2WaitTime(self, *args)
[docs] def dataAvailable(self, millis):
"""
bool
dataAvailable(unsigned int millis)
Determine whether there is data available to be read. This function
will wait up to "millis" milliseconds for data to become available.
Parameters:
-----------
millis: The number of milliseconds to wait for data to become
available.
true if data is available to be read, false otherwise.
"""
return _pyupm_rn2903.RN2903_dataAvailable(self, millis)
[docs] def drain(self):
"""
void drain()
Read and throw away any data currently available to be read. This is
useful to avoid reading data that might have been the result of a
previous command interfering with data you currently want to read.
"""
return _pyupm_rn2903.RN2903_drain(self)
[docs] def command(self, cmd):
"""
RN2903_RESPONSE_T
command(const std::string cmd)
Send a command, wait for a response using waitForResponse(), and
return the status. The response itself will be stored internally, and
can be retrieved using getResponse() and getResponseLen(). Every
command will return at least one response, and this function will
always wait for it and store it into the internal response buffer
after sending the command.
Parameters:
-----------
cmd: A character string containing the command to send
One of the RN2903_RESPONSE_T values
"""
return _pyupm_rn2903.RN2903_command(self, cmd)
[docs] def commandWithArg(self, cmd, arg):
"""
RN2903_RESPONSE_T
commandWithArg(const std::string cmd, const std::string arg)
Build a command string with the supplied command and string argument.
Then call command() with the result, and return the result. This is
just a convenience function.
Parameters:
-----------
cmd: A character string containing the command to send
arg: A string argument for the command
One of the RN2903_RESPONSE_T values
"""
return _pyupm_rn2903.RN2903_commandWithArg(self, cmd, arg)
[docs] def waitForResponse(self, wait_ms):
"""
RN2903_RESPONSE_T waitForResponse(int wait_ms)
Wait up to wait_ms milliseconds for a response.
In the case of errors ("invalid_param" received, timeout occurred,
or other UPM specific error), this will be indicated by the return
value.
Otherwise, an "ok" or other data value will not be considered an
error and will return RN2903_RESPONSE_OK. The response itself will be
stored internally, and can be retrieved using getResponse() and
getResponseLen().
NOTE: the response buffer is overwritten whenever this function is
called, so if there is data in there that you need to save, copy it
somewhere else before calling any other methods in this driver to be
safe.
Parameters:
-----------
wait_ms: The maximum number of milliseconds to wait for a response.
One of the RN2903_RESPONSE_T values
"""
return _pyupm_rn2903.RN2903_waitForResponse(self, wait_ms)
[docs] def getResponse(self):
"""
std::string
getResponse()
Return a string containing a copy of the last response saved in the
response buffer
A string containing a copy of the response buffer
"""
return _pyupm_rn2903.RN2903_getResponse(self)
[docs] def getResponseLen(self):
"""
int
getResponseLen()
Return the length in bytes of the string containing the last response.
The length of the last response in bytes
"""
return _pyupm_rn2903.RN2903_getResponseLen(self)
[docs] def setDeviceEUI(self, str):
"""
void
setDeviceEUI(const std::string str)
Set the MAC device EUI for LoRaWAN communications. The device EUI must
be a hex encoded string of 16 bytes. This value must be set for
LoRaWAN OTAA joining.
Parameters:
-----------
str: The 16-byte hex encoded device EUI
Exceptions:
-----------
std::runtime_error: if the EUI is invalid or the mac set command
failed
"""
return _pyupm_rn2903.RN2903_setDeviceEUI(self, str)
[docs] def getDeviceEUI(self):
"""
void getDeviceEUI()
Retrieve the device EUI from the device. If this function succeeds,
you can then use getResponse() to get the value.
UPM result
Exceptions:
-----------
std::runtime_error: if the mac get command failed
"""
return _pyupm_rn2903.RN2903_getDeviceEUI(self)
[docs] def setDeviceAddr(self, str):
"""
void
setDeviceAddr(std::string str)
Set the MAC device address for LoRaWAN communications. The device
address must be a hex encoded string of 8 bytes. This value must be
set for LoRaWAN ABP joining.
For OTAA joining, this value will be overwritten once the join has
completed, and therefore must not be set if performing an OTAA join.
Parameters:
-----------
str: The 8-byte hex encoded device address
Exceptions:
-----------
std::runtime_error: if the mac set command failed or the hex string
is invalid
"""
return _pyupm_rn2903.RN2903_setDeviceAddr(self, str)
[docs] def getDeviceAddr(self):
"""
void
getDeviceAddr()
Retrieve the device address from the device. If this function
succeeds, you can then use getResponse() to get the value.
Exceptions:
-----------
std::runtime_error: if the mac get failed
"""
return _pyupm_rn2903.RN2903_getDeviceAddr(self)
[docs] def setNetworkSessionKey(self, str):
"""
void
setNetworkSessionKey(std::string str)
Set the MAC network session key for LoRaWAN communications. The
network session key must be a hex encoded string of 32 bytes. This
value must be set for LoRaWAN ABP joining. It it not possible to
retrieve this key.
For OTAA joining, this value will be overwritten once the join has
completed, and therefore must not be set if performing an OTAA join.
Parameters:
-----------
str: The 32-byte hex encoded network session key
Exceptions:
-----------
std::runtime_error: if the mac set command failed or the hex string
is invalid
"""
return _pyupm_rn2903.RN2903_setNetworkSessionKey(self, str)
[docs] def setApplicationSessionKey(self, str):
"""
void
setApplicationSessionKey(std::string str)
Set the MAC application session key for LoRaWAN communications. The
application session key must be a hex encoded string of 32 bytes. This
value must be set for LoRaWAN ABP joining. It it not possible to
retrieve this key.
For OTAA joining, this value will be overwritten once the join has
completed, and therefore must not be set if performing an OTAA join.
Parameters:
-----------
str: The 32-byte hex encoded application session key
Exceptions:
-----------
std::runtime_error: if the mac set command failed or the hex string
is invalid
"""
return _pyupm_rn2903.RN2903_setApplicationSessionKey(self, str)
[docs] def setApplicationEUI(self, str):
"""
void
setApplicationEUI(const std::string str)
Set the MAC application EUI for LoRaWAN communications. The
application EUI must be a hex encoded string of 16 bytes. This value
must be set for LoRaWAN OTAA joining.
Parameters:
-----------
str: The 16-byte hex encoded application EUI
Exceptions:
-----------
std::runtime_error: if the EUI is invalid, or if the mac set command
failed
"""
return _pyupm_rn2903.RN2903_setApplicationEUI(self, str)
[docs] def getApplicationEUI(self):
"""
void
getApplicationEUI()
Retrieve the application EUI from the device. If this function
succeeds, you can then use getResponse() to get the value.
Exceptions:
-----------
std::runtime_error: if the mac get command failed
"""
return _pyupm_rn2903.RN2903_getApplicationEUI(self)
[docs] def setApplicationKey(self, str):
"""
void
setApplicationKey(const std::string str)
Set the MAC application key for LoRaWAN communications. The
application key must be a hex encoded string of 32 bytes. This value
must be set for LoRaWAN OTAA joining.
Parameters:
-----------
str: The 32-byte hex encoded application key
Exceptions:
-----------
std::runtime_error: if the key is invalid, or if the mac set command
failed
"""
return _pyupm_rn2903.RN2903_setApplicationKey(self, str)
[docs] def getApplicationKey(self):
"""
void
getApplicationKey()
Retrieve the application key from the device. If this function
succeeds, you can then use rn2903_get_response() to get the value.
Exceptions:
-----------
std::runtime_error: if the mac get command failed
"""
return _pyupm_rn2903.RN2903_getApplicationKey(self)
[docs] def toHex(self, src):
"""
std::string toHex(const
std::string src)
Convert src into a hex byte string. All non-command related data such
as keys, and payload sent to the device must be hex encoded.
Parameters:
-----------
src: A string to encode
A string containing the hex encoded version of str. In the event of an
error, the return string will be empty.
"""
return _pyupm_rn2903.RN2903_toHex(self, src)
[docs] def fromHex(self, src):
"""
std::string
fromHex(const std::string src)
Decode a hex byte string into the original string. The hex string must
have a length that is a multiple of two, and all characters in the
string must be valid hex characters.
A string containing the decoded contents of the hex string passed, or
an empty string if there was an error.
"""
return _pyupm_rn2903.RN2903_fromHex(self, src)
[docs] def join(self, type):
"""
RN2903_JOIN_STATUS_T
join(RN2903_JOIN_TYPE_T type)
Join a LoRaWAN network. There are two types of joins possible - Over
The Air Activation (OTAA) and Activation by Personalization ( ABP).
Each join method requires that certain items have been configured
first.
For OTAA activation, the Device Extended Unique Identifier (EUI), the
Application EUI, and Application Key must be set.
For ABP activation, The Device Address, Network Session Key, and the
Application Session Key must be set.
Parameters:
-----------
type: The LoRaWAN join activation type, one of the RN2903_JOIN_TYPE_T
values
The status of the join, one of the RN2903_JOIN_STATUS_T values
"""
return _pyupm_rn2903.RN2903_join(self, type)
[docs] def macTx(self, type, port, payload):
"""
RN2903_MAC_TX_STATUS_T
macTx(RN2903_MAC_MSG_TYPE_T type, int port, std::string payload)
Transmit a packet in a LoRaWAN network. You must already be joined to
a LoRaWAN network for this command to succeed, and the MAC stack must
be in the idle (RN2903_MAC_STAT_IDLE) state.
The packet payload must be a valid hex encoded string.
There is the possibility of receiving a downlink message after
transmitting a packet. If this occurs, this function will return
RN2903_MAC_TX_STATUS_RX_RECEIVED, and the returned data will be stored
in the response buffer.
Parameters:
-----------
type: The type of message to send - confirmed or unconfirmed. One of
the RN2903_MAC_MSG_TYPE_T values.
port: An integer in the range 1-223
payload: A valid hex encoded string that makes up the payload of the
message
The status of the transmit request, one of the RN2903_MAC_TX_STATUS_T
values
"""
return _pyupm_rn2903.RN2903_macTx(self, type, port, payload)
[docs] def radioTx(self, payload):
"""
RN2903_RESPONSE_T
radioTx(const std::string payload)
Transmit a packet. This method uses the radio directly without the
LoRaWAN stack running. For this reason, you must call macPause()
before trying to transmit using this function. You should also
configure any radio parameters (frequency, etc), before calling this
function.
Parameters:
-----------
payload: A valid hex encoded string that makes up the payload of the
message
The status of the transmit request, one of the RN2903_RESPONSE_T
values
"""
return _pyupm_rn2903.RN2903_radioTx(self, payload)
[docs] def radioRx(self, window_size):
"""
RN2903_RESPONSE_T
radioRx(int window_size)
Receive a packet. This method uses the radio directly without the
LoRaWAN stack running. For this reason, you must call macPause()
before trying to receive using this function. You should also
configure any parameters (frequency, etc) to match the transmitter
before calling this function.
Parameters:
-----------
window_size: An integer that represents the number of symbols to wait
for (lora) or the maximum number of milliseconds to wait (fsk). This
parameter is passed to the "radio rx" command. Passing 0 causes the
radio to enter continuous receive mode which will return when either a
packet is received, or the radio watchdog timer expires. See the
RN2903 Command Reference for details.
The status of the transmit request, one of the RN2903_RESPONSE_T
values
"""
return _pyupm_rn2903.RN2903_radioRx(self, window_size)
[docs] def getHardwareEUI(self):
"""
std::string
getHardwareEUI()
Return the Hardware Extended Unique Identifier (EUI). The is a 16 byte
hex encoded string representing the 64b hardware EUI. This value
cannot be changed, and is globally unique to each device. It is
obtained from the device at initialization time.
A const string pointer to the hex encoded Hardware EUI
"""
return _pyupm_rn2903.RN2903_getHardwareEUI(self)
[docs] def updateMacStatus(self):
"""
void
updateMacStatus()
Retrieve the device MAC status, decode it, and store it internally.
This function must be called prior to calling getMacStatusWord() or
getMacStatus().
Exceptions:
-----------
std::runtime_error: if the mac get command failed
"""
return _pyupm_rn2903.RN2903_updateMacStatus(self)
[docs] def getMacStatusWord(self):
"""
int
getMacStatusWord()
Retrieve the MAC status word. updateMacStatus() must have been called
prior to calling this function.
The MAC status word. This is a bitmask of RN2903_MAC_STATUS_BITS_T
bits.
"""
return _pyupm_rn2903.RN2903_getMacStatusWord(self)
[docs] def getMacStatus(self):
"""
RN2903_MAC_STATUS_T
getMacStatus()
Retrieve the MAC status. updateMacStatus() must have been called prior
to calling this function. The MAC status is a bitfield embedded in the
mac status word. It provides information on the status of the internal
MAC state machine.
The MAC status, one of the RN2903_MAC_STATUS_T values.
"""
return _pyupm_rn2903.RN2903_getMacStatus(self)
[docs] def macSave(self):
"""
void macSave()
Save the configurable device values to EEPROM. These values will be
reloaded automatically on a reset or power up.
The data that can be saved are: deveui, appeui, appkey, nwkskey
(Network Session Key), appskey, devaddr, channels, upctr (Uplink
Counter), dnctr (Downlink Counter), adr (automatic data-rate) state,
and rx2 (the RX2 receive window parameters).
Exceptions:
-----------
std::runtime_error: if the mac save command failed
"""
return _pyupm_rn2903.RN2903_macSave(self)
[docs] def macPause(self):
"""
void macPause()
Pause the MAC LoRaWAN stack. This device can operate in one of two
modes.
The most common mode is used to join and participate in a LoRaWAN
network as a Class A End Device. This is handled by the MAC LoRaWAN
stack on the device dealing with the details of LoRaWAN participation
automatically.
The other mode disables MAC LoRaWAN stack functionality and allows you
to issue commands directly to the radio to set frequencies, data
rates, modulation and many other parameters.
Calling this function disables the MAC LoRaWAN stack and allows you to
issue radio commands that are otherwise handled automatically.
When pausing, the maximum allowable pause time in milliseconds will be
returned in the response buffer. You can grab this value by calling
getResponse() after this function completes successfully.
When the MAC is idle ( getMacStatus()), you can pause the stack
indefinitely.
Exceptions:
-----------
std::runtime_error: if the mac pause command failed
"""
return _pyupm_rn2903.RN2903_macPause(self)
[docs] def macResume(self):
"""
void macResume()
Resume the MAC LoRaWAN stack. Call this to resume MAC LoRaWAN
operation after having called macPause(), to resume participation in a
LoRaWAN network.
Parameters:
-----------
dev: Device context
UPM result
Exceptions:
-----------
std::runtime_error: if the mac resume command failed
"""
return _pyupm_rn2903.RN2903_macResume(self)
[docs] def reset(self):
"""
void reset()
Reset the device. Any configuration is lost, as well as the current
join status. This method also calls setBaudrate() after the reset to
re-establish communications with the device in the event you are not
using the default baudrate (which the device will revert to after a
reset).
Exceptions:
-----------
std::runtime_error: if the mac reset, or setBaudrate() command fails
"""
return _pyupm_rn2903.RN2903_reset(self)
[docs] def macSetBattery(self, level):
"""
void
macSetBattery(int level)
LoRaWAN communications allows for the reporting of current battery
charge remaining to the LoRaWAN gateway/network server. This function
allows you to specify the value that should be reported.
The valid values are from 0 to 255. 0 = using external power 1(low) to
254(high) = battery power 255 = unable to measure battery level
Parameters:
-----------
level: The battery level value from 0-255
Exceptions:
-----------
std::runtime_error: if the mac set bat command failed, or if the
battery level is invalid
"""
return _pyupm_rn2903.RN2903_macSetBattery(self, level)
[docs] def setDebug(self, enable):
"""
void setDebug(bool
enable)
Enable debugging. If enabled, commands will be printed out before
being sent to the device. Any responses will be printed out after
retrieval. Other miscellaneous debug output will also be printed.
Parameters:
-----------
enable: true to enable debugging, false otherwise
"""
return _pyupm_rn2903.RN2903_setDebug(self, enable)
[docs] def setBaudrate(self, baudrate):
"""
void
setBaudrate(unsigned int baudrate)
Set the baudrate of the device. Auto-bauding is currently only
supported on Linux (due to the need to send a break signal) and only
on a recent MRAA which supports it (> 1.6.1). If on a non-linux OS,
you should not try to change the baudrate to anything other than the
default 57600 or you will lose control of the device.
Parameters:
-----------
baudrate: The baud rate to set for the device
Exceptions:
-----------
std::runtime_error: if the autobaud test command failed
"""
return _pyupm_rn2903.RN2903_setBaudrate(self, baudrate)
[docs] def setFlowControl(self, fc):
"""
void
setFlowControl(RN2903_FLOW_CONTROL_T fc)
Set a flow control method for the UART. By default, during
initialization, flow control is disabled. The device MAY support
hardware flow control, but MRAA does not (at least for UART numbers),
so we can't either. We leave the option here though so that if you are
using a TTY (as opposed to a UART instance) it might work if the
device is also configured to use hardware flow control.
Parameters:
-----------
fc: One of the RN2903_FLOW_CONTROL_T values
Exceptions:
-----------
std::runtime_error: on failure
"""
return _pyupm_rn2903.RN2903_setFlowControl(self, fc)
[docs] def find(self, str):
"""
bool find(const std::string
str)
This is a utility function that can be used to indicate if a given
string is present at the beginning of the response buffer. The search
is case sensitive.
Parameters:
-----------
str: The string to search for
true if the string was found at the beginning of the response buffer,
false otherwise
"""
return _pyupm_rn2903.RN2903_find(self, str)
[docs] def getRadioRxPayload(self):
"""
std::string
getRadioRxPayload()
This is a utility function that can be used to return the hex encoded
payload string for radio_rx messages received.
A string representing the hex encoded payload, or an empty string if
there was an error
"""
return _pyupm_rn2903.RN2903_getRadioRxPayload(self)
[docs] def autobaud(self, retries):
"""
bool autobaud(int
retries)
This function attempts to sync the device to the current baudrate. It
tries retries times, to send an autobaud sequence to the device and
run a test command.
Parameters:
-----------
retries: The number of times to retry autobaud detection
true if the test command succeeded, false otherwise
"""
return _pyupm_rn2903.RN2903_autobaud(self, retries)
RN2903_swigregister = _pyupm_rn2903.RN2903_swigregister
RN2903_swigregister(RN2903)
# This file is compatible with both classic and new-style classes.