![]() |
RUI3-Arduino-Library V1.0.1
RAKWireless library for communication over UART with RUI3 based WisDuo modules.
|
#include <rui3_at.h>
Public Member Functions | |
RUI3 (Stream &serial1, Stream &serial=Serial) | |
Construct a new RUI3 object A simplified constructor taking only a Stream ({Software/Hardware}Serial) object. The serial port should already be initialised when initialising this library. Serial is used for debug output: host MCU <==> debug console. | |
bool | setLPM (int mode) |
Enable/Disable Low power mode See AT+LPM | |
uint8_t | getLPM (void) |
Get Low power mode status See AT+LPM | |
bool | setLPMLevel (int mode) |
Set the LPM level See AT+LPMLVL | |
uint8_t | getLPMLevel (void) |
Get the current LPM level See AT+LPMLVL | |
bool | setWorkingMode (int mode) |
Set the device to LoRaWAN mode or LoRa P2P mode See AT+NWM When switching the device mode, the device will perform a reset. | |
uint8_t | getWorkingMode (void) |
Get the Working Mode status See AT+NWM | |
bool | setDataRate (int rate) |
Set the Data Rate See AT+DR | |
uint8_t | getDataRate (void) |
Get the data rate See AT+DR | |
bool | setClass (int classMode) |
Set the LoRaWAN device Class See AT+CLASS | |
uint8_t | getClass (void) |
Get the class See AT+CLASS | |
bool | setRegion (int region) |
Set the LoRaWAN Region See AT+BAND | |
uint8_t | getRegion (void) |
Get the Region See AT+BAND | |
bool | setJoinMode (int mode) |
Set network join mode OTAA or ABP See AT+NJM | |
uint8_t | getJoinMode (void) |
Get the network join mode See AT+NJM | |
bool | setConfirmed (int type) |
Set package transmission mode In confirmed mode, the LNS will acknowledge the packet, in unconfirmed mode is no acknowledgement See AT+CFM | |
uint8_t | getConfirmed (void) |
Get the Confirmed/Unconfirmed packet status In confirmed mode, the LNS will acknowledge the packet, in unconfirmed mode is no acknowledgement See AT+CFM | |
bool | initOTAA (String devEUI, String appEUI, String appKEY) |
Set LoRaWAN credentials for OTAA join mode Before using this command, you must call setJoinMode(0) | |
bool | getDevEUI (char *eui, uint16_t array_len) |
Get the DevEUI See AT+DEVEUI | |
bool | getAppEUI (char *eui, uint16_t array_len) |
Get the App EUI See AT+APPEUI | |
bool | getAppKey (char *key, uint16_t array_len) |
Get the AppKey See AT+APPKEY | |
bool | initABP (String devADDR, String nwksKEY, String appsKEY) |
Set credentials for ABP join mode Before using this command, you must call setJoinMode(1) | |
uint32_t | getDevAddress (void) |
Get the DevAddr See AT+DEVADDR | |
bool | getAppsKey (char *key, uint16_t array_len) |
Get the AppsKey See AT+APPSKEY | |
bool | getNwsKey (char *key, uint16_t array_len) |
Get the NwsKey See AT+NWKSKEY | |
bool | joinLoRaNetwork (int timeout=15) |
Join the network See AT+JOIN | |
bool | getVersion (void) |
Get the firmware version number of the module. See AT+VER | |
bool | getJoinStatus (void) |
Get the Join Status See AT+NJS | |
String | getChannelList (void) |
Get the current channel list settings This feature works only in Regions US915, AU915 or CN470 See AT+MASK | |
bool | sendData (int port, char *datahex) |
Send data in LoRaWAN mode See AT+SEND | |
bool | initP2P (p2p_settings *p2p_settings) |
Initialize LoRa P2P mode See AT+P2P | |
bool | getP2P (p2p_settings *p2p_settings) |
Get current P2P settings See AT+P2P | |
bool | sendP2PData (char *datahex) |
Send a data packet over LoRa P2P See AT+PSEND | |
bool | setP2PCAD (bool enable) |
Enable or disable P2P Channel Activitity Detection See AT+CAD | |
bool | getP2PCAD (void) |
Get CAD status (enabled/disabled) | |
bool | recvResponse (uint32_t timeout=10000) |
Get response to an AT command from the device The last response to an AT command is stored in ** RUI3::ret ** for further parsing. See the example codes for detailed usage. | |
void | recvRX (uint32_t timeout) |
Get RX packet after LoRaWAN TX or LoRa P2P receive command The last received RX packet is stored in ** RUI3::ret ** for further parsing. See the example codes for detailed usage. In case of LoRa P2P, recvRX() can be used to catch any received packet during the specified timeout. In case of LoRaWAN Class A, the received data is in ** RUI3::ret ** after the recvResponse() call. LoRaWAN Class B and C RX is not implemented, but would work similar to LoRa P2P | |
void | flushRX (uint32_t timeout=5000) |
Flush the RX buffer in case there is something left. | |
bool | sleep (int mode) |
Set the module in sleep mode. not required if low power mode is enabled) When the module is in sleep mode, the host can send any character to wake it up. When the module is awakened, the event response will automatically return through the serial information. See AT+SLEEP | |
void | reset (void) |
Reset the RUI3 module Communication with the module will be lost See ATZ | |
bool | setUARTConfig (int Baud) |
Change RUI3 communication baud rate See AT+BAUD | |
bool | sendRawCommand (char *command) |
Send a raw command to the RUI3 module. See RUI3 AT command manual | |
bool | byteArrayToAscii (char *b_array, char *a_array, uint16_t b_array_len, uint16_t a_array_len) |
Convert a byte array into a ASCII HEX string array. | |
bool | asciiArrayToByte (char *b_array, char *a_array, uint16_t b_array_len, uint16_t a_array_len) |
Convert a ASCII HEX string array into a byte array. | |
Public Attributes | |
char | ret [1024] = {0} |
Char array with the last response from the WisDuo module. | |
stParam | param |
RUI3::RUI3 | ( | Stream & | serial1, |
Stream & | serial = Serial |
||
) |
Construct a new RUI3 object A simplified constructor taking only a Stream ({Software/Hardware}Serial) object. The serial port should already be initialised when initialising this library. Serial is used for debug output: host MCU <==> debug console.
serial1 | Serial for communication with RUI3 module: WisDuo <==> host MCU |
serial | Serial for debug: host MCU <==> debug console – Defaults to Serial |
bool RUI3::asciiArrayToByte | ( | char * | b_array, |
char * | a_array, | ||
uint16_t | b_array_len, | ||
uint16_t | a_array_len | ||
) |
Convert a ASCII HEX string array into a byte array.
b_array | byte array to be filled with values |
a_array | char array to be converted |
b_array_len | length of the byte array |
a_array_len | length of char array |
bool RUI3::byteArrayToAscii | ( | char * | b_array, |
char * | a_array, | ||
uint16_t | b_array_len, | ||
uint16_t | a_array_len | ||
) |
Convert a byte array into a ASCII HEX string array.
b_array | byte array to be converted |
a_array | char array to be filled with the ASCII HEX values, MUST BE DOUBLE SIZE OF THE BYTE ARRAY |
b_array_len | length of the byte array |
a_array_len | length of the char array |
void RUI3::flushRX | ( | uint32_t | timeout = 5000 | ) |
Flush the RX buffer in case there is something left.
timeout | time to wait for a response |
bool RUI3::getAppEUI | ( | char * | eui, |
uint16_t | array_len | ||
) |
Get the App EUI
See AT+APPEUI
eui | byte array for AppEUI |
array_len | length of byte array (8 at least) |
bool RUI3::getAppKey | ( | char * | key, |
uint16_t | array_len | ||
) |
Get the AppKey
See AT+APPKEY
key | byte array for AppKey |
array_len | length of byte array (16 at least) |
bool RUI3::getAppsKey | ( | char * | key, |
uint16_t | array_len | ||
) |
Get the AppsKey
See AT+APPSKEY
key | byte array for AppsKey |
array_len | length of byte array (16 at least) |
String RUI3::getChannelList | ( | void | ) |
Get the current channel list settings
This feature works only in Regions US915, AU915 or CN470
See AT+MASK
uint8_t RUI3::getClass | ( | void | ) |
Get the class
See AT+CLASS
uint8_t RUI3::getConfirmed | ( | void | ) |
Get the Confirmed/Unconfirmed packet status
In confirmed mode, the LNS will acknowledge the packet, in unconfirmed mode is no acknowledgement
See AT+CFM
uint8_t RUI3::getDataRate | ( | void | ) |
Get the data rate
See AT+DR
uint32_t RUI3::getDevAddress | ( | void | ) |
Get the DevAddr
See AT+DEVADDR
bool RUI3::getDevEUI | ( | char * | eui, |
uint16_t | array_len | ||
) |
Get the DevEUI
See AT+DEVEUI
eui | byte array for DevEUI |
array_len | length of byte array (8 at least) |
uint8_t RUI3::getJoinMode | ( | void | ) |
Get the network join mode
See AT+NJM
bool RUI3::getJoinStatus | ( | void | ) |
Get the Join Status
See AT+NJS
uint8_t RUI3::getLPM | ( | void | ) |
Get Low power mode status
See AT+LPM
uint8_t RUI3::getLPMLevel | ( | void | ) |
Get the current LPM level
See AT+LPMLVL
bool RUI3::getNwsKey | ( | char * | key, |
uint16_t | array_len | ||
) |
Get the NwsKey
See AT+NWKSKEY
key | byte array for AppsKey |
array_len | length of byte array (16 at least) |
bool RUI3::getP2P | ( | p2p_settings * | p2p_settings | ) |
Get current P2P settings
See AT+P2P
P2P configuration is returned in structure:
p2p_settings | pointer to settings for P2P configuration |
bool RUI3::getP2PCAD | ( | void | ) |
Get CAD status (enabled/disabled)
uint8_t RUI3::getRegion | ( | void | ) |
Get the Region
See AT+BAND
bool RUI3::getVersion | ( | void | ) |
Get the firmware version number of the module.
See AT+VER
uint8_t RUI3::getWorkingMode | ( | void | ) |
Get the Working Mode status
See AT+NWM
bool RUI3::initABP | ( | String | devADDR, |
String | nwksKEY, | ||
String | appsKEY | ||
) |
Set credentials for ABP join mode
Before using this command, you must call setJoinMode(1)
devADDR | device address as HEX string see AT+DEVADDR |
nwksKEY | network Session Key as a HEX string see AT+NWKSKEY |
appsKEY | application Session Key as a HEX string see AT+APPSKEY |
bool RUI3::initOTAA | ( | String | devEUI, |
String | appEUI, | ||
String | appKEY | ||
) |
Set LoRaWAN credentials for OTAA join mode
Before using this command, you must call setJoinMode(0)
devEUI | device EUI as string see AT+DEVEUI |
appEUI | application EUI as string see AT+APPEUI |
appKEY | application key as string see AT+APPKEY |
bool RUI3::initP2P | ( | p2p_settings * | p2p_settings | ) |
Initialize LoRa P2P mode
See AT+P2P
P2P configuration is set in a structure:
p2p_settings | Pointer to the structure with the P2P settings |
bool RUI3::joinLoRaNetwork | ( | int | timeout = 15 | ) |
Join the network
See AT+JOIN
timeout | in seconds |
bool RUI3::recvResponse | ( | uint32_t | timeout = 10000 | ) |
Get response to an AT command from the device
The last response to an AT command is stored in **RUI3::ret
** for further parsing. See the example codes for detailed usage.
timeout | time to wait for a response |
void RUI3::recvRX | ( | uint32_t | timeout | ) |
Get RX packet after LoRaWAN TX or LoRa P2P receive command
The last received RX packet is stored in **RUI3::ret
** for further parsing. See the example codes for detailed usage.
In case of LoRa P2P, recvRX()
can be used to catch any received packet during the specified timeout.
In case of LoRaWAN Class A, the received data is in **RUI3::ret
** after the recvResponse()
call.
LoRaWAN Class B and C RX is not implemented, but would work similar to LoRa P2P
timeout | max wait time for the RX packet |
Received data is included in the response of the send command
void RUI3::reset | ( | void | ) |
Reset the RUI3 module
Communication with the module will be lost
See ATZ
bool RUI3::sendData | ( | int | port, |
char * | datahex | ||
) |
Send data in LoRaWAN mode
See AT+SEND
port | fPort number.(1-223) |
datahex | payload in byte array |
bool RUI3::sendP2PData | ( | char * | datahex | ) |
Send a data packet over LoRa P2P
See AT+PSEND
datahex | payload in byte array |
bool RUI3::sendRawCommand | ( | char * | command | ) |
Send a raw command to the RUI3 module.
See RUI3 AT command manual
command | char array with any of the RUI3 AT commands |
bool RUI3::setClass | ( | int | classMode | ) |
Set the LoRaWAN device Class
See AT+CLASS
classMode | 0 -> Class A, 1 -> Class B, 2 -> Class C |
bool RUI3::setConfirmed | ( | int | type | ) |
Set package transmission mode
In confirmed mode, the LNS will acknowledge the packet, in unconfirmed mode is no acknowledgement
See AT+CFM
type | 0->unconfirm, 1->confirm |
bool RUI3::setDataRate | ( | int | rate | ) |
Set the Data Rate
See AT+DR
rate | datarate between 0 and 15 see Data Rate by Region for available data rates per LoRaWAN region |
bool RUI3::setJoinMode | ( | int | mode | ) |
Set network join mode OTAA or ABP
See AT+NJM
mode | 0: join a network using over the air activation, 1: join a network using personalization |
bool RUI3::setLPM | ( | int | mode | ) |
Enable/Disable Low power mode See AT+LPM
mode | 0 = LPM off, 1 = LPM on |
bool RUI3::setLPMLevel | ( | int | mode | ) |
Set the LPM level
See AT+LPMLVL
mode | 1 = STOP1 mode, 2 = STOP2 mode (lowest power consumption) |
bool RUI3::setP2PCAD | ( | bool | enable | ) |
Enable or disable P2P Channel Activitity Detection
See AT+CAD
enable | true = CAD enabled, false = CAD disabled |
bool RUI3::setRegion | ( | int | region | ) |
Set the LoRaWAN Region
See AT+BAND
region |
|
bool RUI3::setUARTConfig | ( | int | Baud | ) |
Change RUI3 communication baud rate
See AT+BAUD
Baud | Serial baud rate.Supports baud rate: 9600 19200 38400 57600 115200 230400 460800 921600. |
bool RUI3::setWorkingMode | ( | int | mode | ) |
Set the device to LoRaWAN mode or LoRa P2P mode
See AT+NWM
When switching the device mode, the device will perform a reset.
mode | 0 = LoRa P2P, 1 = LoRaWAN mode |
bool RUI3::sleep | ( | int | mode | ) |
Set the module in sleep mode. not required if low power mode is enabled) When the module is in sleep mode, the host can send any character to wake it up. When the module is awakened, the event response will automatically return through the serial information. See AT+SLEEP
mode | 0 == sleep until new commands is received, > 1 sleep time in milliseconds |
stParam RUI3::param |
char RUI3::ret[1024] = {0} |
Char array with the last response from the WisDuo module.