RUI3-Arduino-Library V1.0.1
RAKWireless library for communication over UART with RUI3 based WisDuo modules.
Loading...
Searching...
No Matches
RUI3 Class Reference

#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
 

Constructor & Destructor Documentation

◆ RUI3()

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.

RUI3(Stream &serial1, Stream &serial);
Definition rui3_at.h:121
Parameters
serial1Serial for communication with RUI3 module: WisDuo <==> host MCU
serialSerial for debug: host MCU <==> debug console – Defaults to Serial
Usage
RUI3 wisduo(Serial1, Serial);
Todo:
test if no need to set the timeouts

Member Function Documentation

◆ asciiArrayToByte()

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.

bool asciiArrayToByte(char *b_array, char *a_array, uint16_t b_array_len, uint16_t a_array_len);
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.
Definition rui3_at.cpp:1043
Parameters
b_arraybyte array to be filled with values
a_arraychar array to be converted
b_array_lenlength of the byte array
a_array_lenlength of char array
Returns
true if length of char array is even
false if length of char array is odd or the buffer sizes do not match
Usage
uint8_t c_array[16];
char d_array[34] = "000102030405060708090A0B0C0D0E0F";
if (wisduo.asciiArrayToByte((char *)c_array, d_array, ARRAY_SIZE(d_array), ARRAY_SIZE(c_array)))
{
Serial.printf("Result: %s\r\n", a_array);
for (int idx = 0; idx < 16; idx++)
{
Serial.printf("%02X,", c_array[idx]);
}
Serial.println("}");
}
else
{
Serial.println("asciiArrayToByte throw error");
}
#define ARRAY_SIZE(array)
Definition rui3_at.h:21

◆ byteArrayToAscii()

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.

bool byteArrayToAscii(char *b_array, char *a_array, uint16_t b_array_len, uint16_t a_array_len);
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.
Definition rui3_at.cpp:1029
Parameters
b_arraybyte array to be converted
a_arraychar array to be filled with the ASCII HEX values, MUST BE DOUBLE SIZE OF THE BYTE ARRAY
b_array_lenlength of the byte array
a_array_lenlength of the char array
Returns
true if buffer sizes do match
false if buffer sizes do not match
Usage
uint8_t b_array[16] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
char a_array[34];
if (wisduo.byteArrayToAscii((char *)b_array, a_array, ARRAY_SIZE(b_array), ARRAY_SIZE(a_array)))
{
Serial.printf("Result: %s\r\n", a_array);
}
Serial.printf("Result: %s\r\n", a_array);
{
Serial.println("byteArrayToAscii throw error");
}

◆ flushRX()

void RUI3::flushRX ( uint32_t  timeout = 5000)

Flush the RX buffer in case there is something left.

void flushRX(uint32_t timeout = 5000);
void flushRX(uint32_t timeout=5000)
Flush the RX buffer in case there is something left.
Definition rui3_at.cpp:847
Parameters
timeouttime to wait for a response

◆ getAppEUI()

bool RUI3::getAppEUI ( char *  eui,
uint16_t  array_len 
)

Get the App EUI
See AT+APPEUI

bool getAppEUI(char *eui, uint16_t array_len);
bool getAppEUI(char *eui, uint16_t array_len)
Get the App EUI See AT+APPEUI
Definition rui3_at.cpp:515
Parameters
euibyte array for AppEUI
array_lenlength of byte array (8 at least)
Returns
true if AppEUI could be obtained
false No response or error response
Usage
char eui_key[34];
if (wisduo.getAppEUI(eui_key, ARRAY_SIZE(eui_key)))
{
Serial.print("AppEUI: ");
for (int idx = 0; idx < 8; idx++)
{
Serial.printf("%02X", eui_key[idx]);
}
Serial.println("\r\n");
}
else
{
Serial.printf("Response: %d\r\n", wisduo.ret);
}

◆ getAppKey()

bool RUI3::getAppKey ( char *  key,
uint16_t  array_len 
)

Get the AppKey
See AT+APPKEY

bool getAppKey(char *key, uint16_t array_len);
bool getAppKey(char *key, uint16_t array_len)
Get the AppKey See AT+APPKEY
Definition rui3_at.cpp:534
Parameters
keybyte array for AppKey
array_lenlength of byte array (16 at least)
Returns
true if AppKey could be obtained
false No response or error response
Usage
char eui_key[34];
if (wisduo.getAppKey(eui_key, ARRAY_SIZE(eui_key)))
{
Serial.print("AppKey: ");
for (int idx = 0; idx < 16; idx++)
{
Serial.printf("%02X", eui_key[idx]);
}
Serial.println("\r\n");
}
else
{
Serial.printf("Response: %d\r\n", wisduo.ret);
}

◆ getAppsKey()

bool RUI3::getAppsKey ( char *  key,
uint16_t  array_len 
)

Get the AppsKey
See AT+APPSKEY

bool getAppsKey(char *key, uint16_t array_len);
bool getAppsKey(char *key, uint16_t array_len)
Get the AppsKey See AT+APPSKEY
Definition rui3_at.cpp:621
Parameters
keybyte array for AppsKey
array_lenlength of byte array (16 at least)
Returns
true if AppsKey could be obtained
false No response or error response
Usage
char eui_key[34];
if (wisduo.getAppsKey(eui_key, ARRAY_SIZE(eui_key)))
{
Serial.print("AppsKey: ");
for (int idx = 0; idx < 16; idx++)
{
Serial.printf("%02X", eui_key[idx]);
}
Serial.println("\r\n");
}
else
{
Serial.printf("Response: %d\r\n", wisduo.ret);
}

◆ getChannelList()

String RUI3::getChannelList ( void  )

Get the current channel list settings
This feature works only in Regions US915, AU915 or CN470
See AT+MASK

String getChannelList(void);
String getChannelList(void)
Get the current channel list settings This feature works only in Regions US915, AU915 or CN470 Se...
Definition rui3_at.cpp:51
Returns
String List of enabled channels

◆ getClass()

uint8_t RUI3::getClass ( void  )

Get the class
See AT+CLASS

uint8_t getClass(void);
uint8_t getClass(void)
Get the class See AT+CLASS
Definition rui3_at.cpp:131
Returns
uint8_t class 0 -> Class A, 1 -> Class B, 2 -> Class C, 255 = no response from WisDuo
Usage
uint8_t q_result = wisduo.getClass();
if (q_result != NO_RESPONSE)
{
Serial.printf("Class %d (0=A, 1=B, 2=C)\r\n", q_result);
}
else
{
Serial.printf("Response: %d\r\n", wisduo.ret);
}
#define NO_RESPONSE
Definition rui3_at.h:18

◆ getConfirmed()

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 getConfirmed(void);
uint8_t getConfirmed(void)
Get the Confirmed/Unconfirmed packet status In confirmed mode, the LNS will acknowledge the packet,...
Definition rui3_at.cpp:684
Returns
uint8_t type 0->unconfirm, 1->confirm
Usage
uint8_t q_result = wisduo.getConfirmed();
if (q_result != NO_RESPONSE)
{
Serial.printf("Confirm mode %d = %s\r\n", q_result, q_result == CONF ? "confirmed" : "unconfirmed");
}
else
{
Serial.printf("Response: %d\r\n", wisduo.ret);
}
#define CONF
Definition rui3_at.h:57

◆ getDataRate()

uint8_t RUI3::getDataRate ( void  )

Get the data rate
See AT+DR

int8_t getDataRate(void);
uint8_t getDataRate(void)
Get the data rate See AT+DR
Definition rui3_at.cpp:82
Returns
uint8_t datarate 0 - 15, 255 = no response from WisDuo
Usage
uint8_t q_result = wisduo.getDataRate();
if (q_result != NO_RESPONSE)
{
Serial.printf("Datarate %d\r\n", q_result);
}
else
{
Serial.printf("Response: %d\r\n", wisduo.ret);
}

◆ getDevAddress()

uint32_t RUI3::getDevAddress ( void  )

Get the DevAddr
See AT+DEVADDR

uint32_t getDevAddress(void);
uint32_t getDevAddress(void)
Get the DevAddr See AT+DEVADDR
Definition rui3_at.cpp:606
Returns
uint32_t device address, NO_RESPONSE if device address could not be obtained
Usage
uint32_t dev_addr = wisduo.getDevAddress();
{
Serial.printf("Device Address: %08X\r\n", dev_addr);
}
else
{
Serial.printf("Response: %d\r\n", wisduo.ret);
}

◆ getDevEUI()

bool RUI3::getDevEUI ( char *  eui,
uint16_t  array_len 
)

Get the DevEUI
See AT+DEVEUI

bool getDevEUI(char *eui, uint16_t array_len);
bool getDevEUI(char *eui, uint16_t array_len)
Get the DevEUI See AT+DEVEUI
Definition rui3_at.cpp:496
Parameters
euibyte array for DevEUI
array_lenlength of byte array (8 at least)
Returns
true if DevEUI could be obtained
false No response or error response
Usage
char eui_key[34];
if (wisduo.getDevEUI(eui_key, ARRAY_SIZE(eui_key)))
{
Serial.print("DevEUI: ");
for (int idx = 0; idx < 8; idx++)
{
Serial.printf("%02X", eui_key[idx]);
}
Serial.println("\r\n");
}
else
{
Serial.printf("Response: %d\r\n", wisduo.ret);
}

◆ getJoinMode()

uint8_t RUI3::getJoinMode ( void  )

Get the network join mode
See AT+NJM

uint8_t getJoinMode(void);
uint8_t getJoinMode(void)
Get the network join mode See AT+NJM
Definition rui3_at.cpp:410
Returns
uint8_t mode 0: join a network using over the air activation, 1: join a network using personalization, 255 = no response from WisDuo
Usage
uint8_t q_result = wisduo.getJoinMode();
if (q_result != NO_RESPONSE)
{
Serial.printf("Join mode %d = %s\r\n", q_result, q_result == OTAA ? "OTAA" : "ABP");
}
else
{
Serial.printf("Response: %d\r\n", wisduo.ret);
}
#define OTAA
Definition rui3_at.h:36

◆ getJoinStatus()

bool RUI3::getJoinStatus ( void  )

Get the Join Status
See AT+NJS

bool getJoinStatus(void);
bool getJoinStatus(void)
Get the Join Status See AT+NJS
Definition rui3_at.cpp:38
Returns
true if device has joined LoRaWAN network
false if device has not joined LoRaWAN network
Usage
if (!wisduo.getJoinStatus())
{
str_ptr = strstr(wisduo.ret, "=");
if (str_ptr != NULL)
{
Serial.println("Network not yet joined");
}
else
{
Serial.println("Network joined");
}

◆ getLPM()

uint8_t RUI3::getLPM ( void  )

Get Low power mode status
See AT+LPM

uint8_t getLPM(void);
uint8_t getLPM(void)
Get Low power mode status See AT+LPM
Definition rui3_at.cpp:282
Returns
0 - LPM off, 1 = LPM on, 255 no response from WisDuo
Usage
uint8_t q_result = wisduo.getLPM();
if (q_result != NO_RESPONSE)
{
Serial.printf("LPM %d = %s\r\n", q_result, q_result == 0 ? "off" : "on");
}
else
{
Serial.printf("Response: %d\r\n", wisduo.ret);
}

◆ getLPMLevel()

uint8_t RUI3::getLPMLevel ( void  )

Get the current LPM level
See AT+LPMLVL

uint8_t getLPMLevel(void);
uint8_t getLPMLevel(void)
Get the current LPM level See AT+LPMLVL
Definition rui3_at.cpp:319
Returns
uint8_t 1 = LPM level 1, 2 = LPM level 2, 255 no response from WisDuo
Usage
uint8_t q_result = wisduo.getLPMLevel();
if (q_result != NO_RESPONSE)
{
Serial.printf("LPM level %d\r\n", q_result);
}
else
{
Serial.printf("Response: %d\r\n", wisduo.ret);
}

◆ getNwsKey()

bool RUI3::getNwsKey ( char *  key,
uint16_t  array_len 
)

Get the NwsKey
See AT+NWKSKEY

bool getNwsKey(char *key, uint16_t array_len);
bool getNwsKey(char *key, uint16_t array_len)
Get the NwsKey See AT+NWKSKEY
Definition rui3_at.cpp:639
Parameters
keybyte array for AppsKey
array_lenlength of byte array (16 at least)
Returns
true if NwsKey could be obtained
false No response or error response
Usage
char eui_key[34];
if (wisduo.getNwsKey(eui_key, ARRAY_SIZE(eui_key)))
{
Serial.print("NwsKey: ");
for (int idx = 0; idx < 16; idx++)
{
Serial.printf("%02X", eui_key[idx]);
}
Serial.println("\r\n");
}
else
{
Serial.printf("Response: %d\r\n", wisduo.ret);
}

◆ getP2P()

bool RUI3::getP2P ( p2p_settings p2p_settings)

Get current P2P settings
See AT+P2P

P2P configuration is returned in structure:

typedef struct _p2p_settings
{
uint32_t freq; // Frequency in Hz, 150000000-960000000 Hz
uint16_t sf; // Spreading factor 6 - 12
uint16_t bw; // Bandwidth 0=125kHz, 1=250kHz, 2=500kHz, 3=7.8kHz, 4=10.4kHz, 5=15.63kHz, 6=20.83kHz, 7=31.25kHz, 8=41.67kHz, 9=62.5kHz
uint16_t cr; // Coding Rate 0 = 4/5, 1 = 4/6, 2 = 4/7, 3 = 4/8
uint16_t ppl; // Preamble length 2-65535
uint16_t txp; // TX power 5 - 22
struct _p2p_settings p2p_settings
Definition rui3_at.h:102
Parameters
p2p_settingspointer to settings for P2P configuration
Returns
true Success
false No response or error response
Usage
p2p_settings p2p_sett;
if (wisduo.getP2P(&p2p_sett))
{
Serial.printf("Freq: %d\r\n", p2p_sett.freq);
Serial.printf("SF: %d\r\n", p2p_sett.sf);
Serial.printf("BW: %d\r\n", p2p_sett.bw);
Serial.printf("CR: %d\r\n", p2p_sett.cr);
Serial.printf("PPL: %d\r\n", p2p_sett.ppl);
Serial.printf("TXP: %d\r\n", p2p_sett.txp);
}
else
{
Serial.printf("Response: %d\r\n", wisduo.ret);
}
}
else
{
Serial.println("Error while trying to send a packet");
}
uint16_t bw
Definition rui3_at.h:105
uint16_t cr
Definition rui3_at.h:106
uint16_t txp
Definition rui3_at.h:108
uint16_t ppl
Definition rui3_at.h:107
uint16_t sf
Definition rui3_at.h:104
uint32_t freq
Definition rui3_at.h:103

◆ getP2PCAD()

bool RUI3::getP2PCAD ( void  )

Get CAD status (enabled/disabled)

Returns
true CAD enabled
false CAD disabled
Usage
if (wisduo.getP2PCAD())
{
Serial.printf("CAD enabled\r\n");
}
else
{
Serial.printf("CAD disabled\r\n");
}

◆ getRegion()

uint8_t RUI3::getRegion ( void  )

Get the Region
See AT+BAND

uint8_t getRegion(void);
uint8_t getRegion(void)
Get the Region See AT+BAND
Definition rui3_at.cpp:226
Returns
uint8_t Region 0 to 12, 255 = no response from WisDuo
Usage
uint8_t q_result = wisduo.getRegion();
if (q_result != NO_RESPONSE)
{
Serial.printf("Region %d\r\n", q_result);
}
else
{
Serial.printf("Response: %d\r\n", wisduo.ret);
}

◆ getVersion()

bool RUI3::getVersion ( void  )

Get the firmware version number of the module.
See AT+VER

bool getVersion(void);
bool getVersion(void)
Get the firmware version number of the module. See AT+VER
Definition rui3_at.cpp:32
Returns
true Success
false No response or error response
Usage
wisduo.getVersion(); // get RUI3 firmware version
wisduo.recvResponse(5000);
str_ptr = strstr(wisduo.ret, "=");
if (str_ptr != NULL)
{
Serial.printf("Ver: %s\r\n", str_ptr + 1);
}
else
{
Serial.printf("Response: %s\r\n", wisduo.ret);
}

◆ getWorkingMode()

uint8_t RUI3::getWorkingMode ( void  )

Get the Working Mode status
See AT+NWM

uint8_t getWorkingMode(void);
uint8_t getWorkingMode(void)
Get the Working Mode status See AT+NWM
Definition rui3_at.cpp:368
Returns
uint8_t 0 = LoRa P2P, 1 = LoRaWAN mode 255 = no response from WisDuo
Usage
uint8_t q_result = wisduo.getWorkingMode();
if (q_result != NO_RESPONSE)
{
Serial.printf("Mode %d = %s\r\n", q_result, q_result == 0 ? "P2P" : "LoRaWAN");
}
else
{
Serial.printf("Response: %d\r\n", wisduo.ret);
}

◆ initABP()

bool RUI3::initABP ( String  devADDR,
String  nwksKEY,
String  appsKEY 
)

Set credentials for ABP join mode
Before using this command, you must call setJoinMode(1)

bool initABP(String devADDR, String nwksKEY, String appsKEY);
bool initABP(String devADDR, String nwksKEY, String appsKEY)
Set credentials for ABP join mode Before using this command, you must call setJoinMode(1)
Definition rui3_at.cpp:552
Parameters
devADDRdevice address as HEX string see AT+DEVADDR
nwksKEYnetwork Session Key as a HEX string see AT+NWKSKEY
appsKEYapplication Session Key as a HEX string see AT+APPSKEY
Returns
true Success
false No response or error response
Usage
String DevAddr = "01360085";
String AppSKey = "f55a71bcc94ec6498511007c64a06c02";
String NwSKey = "616a6b21d7fcb25012d62b38a5829725";
if (!wisduo.initABP(DevAddr, NwSKey, AppSKey))
{
Serial.println("Set ABP credentials failed.");
}

◆ initOTAA()

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)

bool initOTAA(String devEUI, String appEUI, String appKEY);
bool initOTAA(String devEUI, String appEUI, String appKEY)
Set LoRaWAN credentials for OTAA join mode Before using this command, you must call setJoinMode(0)
Definition rui3_at.cpp:438
Parameters
devEUIdevice EUI as string see AT+DEVEUI
appEUIapplication EUI as string see AT+APPEUI
appKEYapplication key as string see AT+APPKEY
Returns
true Success
false No response or error response
Usage
String DevEUI = "AC1F09FFFE000000";
String AppEUI = "AC1F09FFFE000000";
String AppKey = "EFADFF0000004829ACF71E1A6E000000";
if (!wisduo.initOTAA(DevEUI, AppEUI, AppKey))
{
Serial.println("Set OTAA credentials failed.");
}

◆ initP2P()

bool RUI3::initP2P ( p2p_settings p2p_settings)

Initialize LoRa P2P mode
See AT+P2P

P2P configuration is set in a structure:

typedef struct _p2p_settings
{
uint32_t freq; // Frequency in Hz, 150000000-960000000 Hz
uint16_t sf; // Spreading factor 6 - 12
uint16_t bw; // Bandwidth 0=125kHz, 1=250kHz, 2=500kHz, 3=7.8kHz, 4=10.4kHz, 5=15.63kHz, 6=20.83kHz, 7=31.25kHz, 8=41.67kHz, 9=62.5kHz
uint16_t cr; // Coding Rate 0 = 4/5, 1 = 4/6, 2 = 4/7, 3 = 4/8
uint16_t ppl; // Preamble length 2-65535
uint16_t txp; // TX power 5 - 22
bool initP2P(p2p_settings *p2p_settings)
Initialize LoRa P2P mode See AT+P2P
Definition rui3_at.cpp:882
Parameters
p2p_settingsPointer to the structure with the P2P settings
Returns
true Success
false No response or error response
Usage
p2p_settings p2p_sett;
p2p_sett.freq = 916100000; // Frequency 916100000 MHz
p2p_sett.sf = 7; // Spreading factor 7
p2p_sett.bw = 0; // Bandwidth 125kHz
p2p_sett.cr = 1; // Coding rate 4/5
p2p_sett.ppl = 8; // Preamble length 8
p2p_sett.txp = 22; // TX power 22 dBi
if (!wisduo.initP2P(&p2p_sett))
{
Serial.printf("Response: %d\r\n", wisduo.ret);
}
else
{
Serial.printf("P2P setup done\r\n");
}

◆ joinLoRaNetwork()

bool RUI3::joinLoRaNetwork ( int  timeout = 15)

Join the network
See AT+JOIN

bool joinLoRaNetwork(int timeout = 15);
bool joinLoRaNetwork(int timeout=15)
Join the network See AT+JOIN
Definition rui3_at.cpp:423
Parameters
timeoutin seconds
Returns
true Success
false No response or error response
Usage
if (!wisduo.joinLoRaNetwork(60))
{
Serial.println("Join request error, please make sure settings are correct.");
}
else
{
Serial.println("Network join requested");
}

◆ recvResponse()

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.

bool recvResponse(uint32_t timeout = 10000);
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 **RUI...
Definition rui3_at.cpp:714
Parameters
timeouttime to wait for a response
Returns
true Success
false No response or error response
Usage
wisduo.getVersion(); // get RUI3 firmware version
wisduo.recvResponse(5000);
str_ptr = strstr(wisduo.ret, "=");
if (str_ptr != NULL)
{
Serial.printf("Ver: %s\r\n", str_ptr + 1);
}
else
{
Serial.printf("Response: %s\r\n", wisduo.ret);
}

◆ recvRX()

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

void recvRX(uint32_t timeout);
void recvRX(uint32_t timeout)
Get RX packet after LoRaWAN TX or LoRa P2P receive command The last received RX packet is stored in...
Definition rui3_at.cpp:764
Parameters
timeoutmax wait time for the RX packet
Usage

LoRa P2P

Serial.printf("Listen for 30 seconds\r\n");
wisduo.recvRX(30000);
if (strstr(wisduo.ret, "+EVT:RX") != NULL)
{
Serial.printf("RX!\r\n");
Serial.printf("%s\r\n", wisduo.ret);
}
else
{
Serial.println("No data received");
}

LoRaWAN Class A

Received data is included in the response of the send command

if (wisduo.sendData(1, buffer))
{
// Wait for TX finished or error
Serial.println("Wait for TX/RX result");
if (wisduo.recvResponse(60000))
{
Serial.printf("TX success - RX: %s\r\n", wisduo.ret); // Shows received packet if any
}
else
{
Serial.printf("TX failed: %s\r\n", wisduo.ret);
}
}

◆ reset()

void RUI3::reset ( void  )

Reset the RUI3 module
Communication with the module will be lost
See ATZ

void reset(void);
void reset(void)
Reset the RUI3 module Communication with the module will be lost See ATZ
Definition rui3_at.cpp:336
Usage
bool wait_for_response(uint32_t timeout)
{
uint32_t start_time = millis();
bool got_response = false;
while (1)
{
if (Serial1.available())
{
got_response = true;
break;
}
if ((millis() - start_time) > timeout)
{
break;
}
}
return got_response;
}
wisduo.reset(); // force sleep mode
if (wait_for_response(30000))
{
wisduo.recvResponse(5000);
Serial.printf("Response:\r\n>>>\r\n%s\r\n<<<\r\n", wisduo.ret);
}
else
{
Serial.println("WisDuo module didn't send any response in 30 seconds");
}

◆ sendData()

bool RUI3::sendData ( int  port,
char *  datahex 
)

Send data in LoRaWAN mode
See AT+SEND

bool sendData(int port, char *datahex);
bool sendData(int port, char *datahex)
Send data in LoRaWAN mode See AT+SEND
Definition rui3_at.cpp:697
Parameters
portfPort number.(1-223)
datahexpayload in byte array
Returns
true Success
false No response or error response
Usage
char buffer[] = "0174016e06688c0767011a087327560902fd98";
if (wisduo.sendData(1, buffer))
{
// Wait for TX finished or error
if (wisduo.recvResponse(60000))
{
Serial.printf("TX success - RX: %s\r\n", wisduo.ret);
}
else
{
Serial.printf("TX failed: %s\r\n", wisduo.ret);
}
}
else
{
Serial.println("Error while trying to send a packet");
}

◆ sendP2PData()

bool RUI3::sendP2PData ( char *  datahex)

Send a data packet over LoRa P2P
See AT+PSEND

bool sendP2PData(char *datahex);
bool sendP2PData(char *datahex)
Send a data packet over LoRa P2P See AT+PSEND
Definition rui3_at.cpp:955
Parameters
datahexpayload in byte array
Returns
true Success
false No response or error response
Usage
char buffer[] = "0174016e06688c0767011a087327560902fd98";
if (wisduo.sendData(1, buffer))
{
// Wait for TX finished or error
if (wisduo.recvResponse(60000))
{
Serial.printf("TX success - RX: %s\r\n", wisduo.ret);
}
else
{
Serial.printf("TX failed: %s\r\n", wisduo.ret);
}
}
else
{
Serial.println("Error while trying to send a packet");
}

◆ sendRawCommand()

bool RUI3::sendRawCommand ( char *  command)

Send a raw command to the RUI3 module.
See RUI3 AT command manual

bool sendRawCommand(char *command);
bool sendRawCommand(char *command)
Send a raw command to the RUI3 module. See RUI3 AT command manual
Definition rui3_at.cpp:1015
char command[1024]
Definition rui3_at.cpp:20
Parameters
commandchar array with any of the RUI3 AT commands
Returns
true Success
false No response or error response
Usage
char buffer[128] = ;
sprintf(buffer, "AT\r\n"); // Want to send AT command
wisduo.sendRawCommand(buffer);
if (wait_for_response(30000))
{
wisduo.recvResponse(5000);
Serial.printf("Response:\r\n>>>\r\n%s\r\n<<<\r\n", wisduo.ret);
}
else
{
Serial.println("RAK3172 didn't send any response in 30 seconds");
}

◆ setClass()

bool RUI3::setClass ( int  classMode)

Set the LoRaWAN device Class
See AT+CLASS

bool setClass(int classMode);
bool setClass(int classMode)
Set the LoRaWAN device Class See AT+CLASS
Definition rui3_at.cpp:100
Parameters
classMode0 -> Class A, 1 -> Class B, 2 -> Class C
Returns
true Success
false No response or error response
Usage
if (!wisduo.setClass(CLASS_A)) // set Class A
{
Serial.println("Set class failed.");
}
#define CLASS_A
Definition rui3_at.h:24

◆ setConfirmed()

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

bool setConfirmed(int type);
bool setConfirmed(int type)
Set package transmission mode In confirmed mode, the LNS will acknowledge the packet,...
Definition rui3_at.cpp:657
Parameters
type0->unconfirm, 1->confirm
Returns
true Success
false No response or error response
Usage
if (!wisduo.setConfirmed(CONF)) // set Confirmed transmission mode
{
Serial.println("Set confirmed mode failed.");
}

◆ setDataRate()

bool RUI3::setDataRate ( int  rate)

Set the Data Rate
See AT+DR

bool setDataRate(int rate);
bool setDataRate(int rate)
Set the Data Rate See AT+DR
Definition rui3_at.cpp:62
Parameters
ratedatarate between 0 and 15 see Data Rate by Region for available data rates per LoRaWAN region
Returns
true Success
false No response or error response
Usage
if (!wisduo.setDataRate(3)) // set datarate 3
{
Serial.println("Set data rate failed.");
}

◆ setJoinMode()

bool RUI3::setJoinMode ( int  mode)

Set network join mode OTAA or ABP
See AT+NJM

bool setJoinMode(int mode);
bool setJoinMode(int mode)
Set network join mode OTAA or ABP See AT+NJM
Definition rui3_at.cpp:381
Parameters
mode0: join a network using over the air activation, 1: join a network using personalization
Returns
true Success
false No response or error response
Usage
if (!wisduo.setJoinMode(OTAA)) // set OTAA network join mode
{
Serial.println("Set join mode failed.");
}

◆ setLPM()

bool RUI3::setLPM ( int  mode)

Enable/Disable Low power mode See AT+LPM

bool setLPM(int mode);
bool setLPM(int mode)
Enable/Disable Low power mode See AT+LPM
Definition rui3_at.cpp:263
Parameters
mode0 = LPM off, 1 = LPM on
Returns
true Success
false No response or error response
Usage
if (!wisduo.setLPM(LPM_ON)) // set device LPM on
{
Serial.println("Error setting LPM mode.");
}
#define LPM_ON
Definition rui3_at.h:69

◆ setLPMLevel()

bool RUI3::setLPMLevel ( int  mode)

Set the LPM level
See AT+LPMLVL

bool setLPMLevel(int mode);
bool setLPMLevel(int mode)
Set the LPM level See AT+LPMLVL
Definition rui3_at.cpp:299
Parameters
mode1 = STOP1 mode, 2 = STOP2 mode (lowest power consumption)
Returns
true Success
false No response or error response
Usage
if (!wisduo.setLPMLevel(LPM_LVL_2)) // set device LPM level 2
{
Serial.println("Error setting LPM level.");
}
#define LPM_LVL_2
Definition rui3_at.h:64

◆ setP2PCAD()

bool RUI3::setP2PCAD ( bool  enable)

Enable or disable P2P Channel Activitity Detection
See AT+CAD

Parameters
enabletrue = CAD enabled, false = CAD disabled
Returns
true Success
false No response or error response
Usage
if (wisduo.setP2PCAD(true))
{
Serial.printf("CAD enabled\r\n");
}
else
{
Serial.printf("Response: %d\r\n", wisduo.ret);
}

◆ setRegion()

bool RUI3::setRegion ( int  region)

Set the LoRaWAN Region
See AT+BAND

bool setRegion(int region);
bool setRegion(int region)
Set the LoRaWAN Region See AT+BAND
Definition rui3_at.cpp:159
Parameters
region
  • EU433 0
  • CN470 1
  • RU864 2
  • IN865 3
  • EU868 4
  • US915 5
  • AU915 6
  • KR920 7
  • AS923 8
  • AS923_1 8
  • AS923_2 9
  • AS923_3 10
  • AS923_4 11
  • LA915 12
Returns
true Success
false No response or error response
Usage
if (!wisduo.setRegion(AS923_3)) // set region AS923 variant 3
{
Serial.println("Set Region failed.");
}
#define AS923_3
Definition rui3_at.h:52

◆ setUARTConfig()

bool RUI3::setUARTConfig ( int  Baud)

Change RUI3 communication baud rate
See AT+BAUD

bool setUARTConfig(int Baud);
bool setUARTConfig(int Baud)
Change RUI3 communication baud rate See AT+BAUD
Definition rui3_at.cpp:1007
Parameters
BaudSerial baud rate.Supports baud rate: 9600 19200 38400 57600 115200 230400 460800 921600.
Returns
true Success
false No response or error response

◆ setWorkingMode()

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.

bool setWorkingMode(int mode);
bool setWorkingMode(int mode)
Set the device to LoRaWAN mode or LoRa P2P mode See AT+NWM When switching the device mode,...
Definition rui3_at.cpp:342
Parameters
mode0 = LoRa P2P, 1 = LoRaWAN mode
Returns
true Success
false No response or error response
Usage
if (!wisduo.setWorkingMode(LoRaWAN)) // set WisNode work_mode to LoRaWAN.
{
Serial.println("set work_mode failed, please reset module.");
}
#define LoRaWAN
Definition rui3_at.h:31

◆ sleep()

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

void sleep(int mode);
bool sleep(int mode)
Set the module in sleep mode. not required if low power mode is enabled) When the module is in sleep ...
Definition rui3_at.cpp:244
Parameters
mode0 == sleep until new commands is received, > 1 sleep time in milliseconds
Returns
true Success
false No response or error response
Usage
wisduo.sleep(60000); // force sleep mode for 1 minute

Member Data Documentation

◆ param

stParam RUI3::param

◆ ret

char RUI3::ret[1024] = {0}

Char array with the last response from the WisDuo module.


The documentation for this class was generated from the following files: