RUI API Documentation
The permission setting of AT command
enum RAK_AT_PERMISSION
Enumerator | |
---|---|
RAK_ATCMD_PERM_READ | Read permission allows for reading a variable data only and disables any write functionality. |
RAK_ATCMD_PERM_WRITE | Write permission allows for writing a variable data only and disables any read functionality. |
RAK_ATCMD_PERM_WRITEONCEREAD | Special functionality that allows for setting variable once and only allows for reading after. |
RAK_ATCMD_PERM_DISABLE | Disables the AT command from being used. |
This api allow user to get the firmware version
const string get()
Syntax | api.system.firmwareVersion.get() |
---|---|
Returns | firmware version(Type: string) |
void setup()
{
Serial.begin(115200);
}
void loop()
{
Serial.printf("Firmware Version: %s\r\n", api.system.firmwareVersion.get().c_str());
delay(1000);
}
This api allow user to get the cli version
const string get()
Syntax | api.system.cliVersion.get() |
---|---|
Returns | cli version(Type: string) |
void setup()
{
Serial.begin(115200);
}
void loop()
{
Serial.printf("AT Command Version: %s\r\n", api.system.cliVersion.get().c_str());
delay(1000);
}
Read a range of data from user flash partition.
bool get(uint32_t offset, uint8_t * buf, uint32_t len)
Syntax | api.system.flash.get(offset, buf, len) |
---|---|
Parameters | offset the offset to the start of user flash partition buf the buffer for reading the data lenthe length of data |
Returns | TRUE for reading data successfully FALSE for reading data failure |
Write a range of data from user flash partition.
bool set(uint32_t offset, uint8_t * buf, uint32_t len)
Syntax | api.system.flash.set(offset, buf, len) |
---|---|
Parameters | offset the offset to the start of user flash partition buf the buffer for writing the data lenthe length of data |
Returns | TRUE for writing data successfully FALSE for writing data failure |
Sleep lora with default no timeout.
void lora(int ms_time = POWERSAVE_NO_TIMEOUT)
Syntax | api.system.sleep.lora(); |
---|---|
Parameters | ms_time(optional) - Duration for cpu to sleep(default = no timeout) |
Returns | void |
void setup()
{
}
void loop()
{
api.system.sleep.lora(1000);
}
Sleep all with default no timeout.
void all(int ms_time = POWERSAVE_NO_TIMEOUT)
Syntax | api.system.sleep.all(); |
---|---|
Parameters | ms_time(optional) - Duration for all component to sleep(default = no timeout) |
Returns | void |
void setup()
{
}
void loop()
{
api.system.sleep.all(1000);
}
Sleep all with default no timeout.
void setup(RUI_WAKEUP_TRIGGER_MODE mode, uint32_t pin)
Syntax | api.system.sleep.setup(mode); |
---|---|
Parameters | mode -This decide to use Rising or Falling trigger mode pin This is the pin to be chosen as the wake up source |
Returns | void |
void setup()
{
api.system.sleep.setup(RUI_WAKEUP_FALLING_EDGE);
}
void loop()
{
api.system.sleep.all(1000);
}
This api allow user to set a 1~8 digits password to lock the default serial
bool set(char * passwd, uint32_t len)
Syntax | api.system.pword.set(passwd_Str) api.system.pword.set(passwd_Char, len) |
---|---|
Parameters | passwd_Str - the password to lock the Default Serial(Type: string) passwd_Char - the password to lock the Default Serial(Type: char *) len- the length of password |
Returns | TRUE successfully set a password FALSE failed to set a password |
int loopCount = 0;
void setup()
{
string password = "12345678";
api.system.pword.set(password); // set the password to 12345678
api.system.pword.lock(); // lock the default port
}
void loop()
{
loopCount++;
if (loopCount == 60)
api.system.pword.unlock(); // unlock the default port after 60 seconds
delay(1000);
}
This api allow user to lock the default serial with the pass set in api.system.pword.set()
📝 NOTE
If you never set a password successfully, the default password will be 00000000
void lock(void)
Syntax | api.system.pword.lock() |
---|---|
Returns | void |
int loopCount = 0;
void setup()
{
string password = "12345678";
api.system.pword.set(password); // set the password to 12345678
api.system.pword.lock(); // lock the default port
}
void loop()
{
loopCount++;
if (loopCount == 60)
api.system.pword.unlock(); // unlock the default port after 60 seconds
delay(1000);
}
This api allow user to unlock the default serial without password when its locked
void unlock(void)
Syntax | api.system.pword.unlock() |
---|---|
Returns | void |
int loopCount = 0;
void setup()
{
string password = "12345678";
api.system.pword.set(password); // set the password to 12345678
api.system.pword.lock(); // lock the default port
}
void loop()
{
loopCount++;
if (loopCount == 60)
api.system.pword.unlock(); // unlock the default port after 60 seconds
delay(1000);
}
Set the alias name for device.
bool set(char* buf , uint32_t len)
Syntax | api.system.alias.set(buf, len) |
---|---|
Parameters | buf - the buffer to set alias name len - the length of alias name(<= 16 bytes) |
Returns | TRUE for setting alias name successfully FALSE for setting alias name failure |
void setup()
{
Serial.begin(115200);
api.system.alias.set("my device",16);
char buf[16];
Serial.println(api.system.alias.get(buf,16));
Serial.println(buf);
}
void loop()
{
}
Get the alias name for device.
bool get(char* buf , uint32_t len)
Syntax | api.system.alias.get(buf, len) |
---|---|
Parameters | buf - the buffer to get alias name len - the length of alias name(<= 16 bytes) |
Returns | TRUE for getting alias name successfully FALSE for getting alias name failure |
void setup()
{
Serial.begin(115200);
api.system.alias.set("my device",16);
char buf[16];
Serial.println(api.system.alias.get(buf,16));
Serial.println(buf);
}
void loop()
{
}
Provide developers to create AT CMD.
bool add(char *cmd, char *usage, char *title, PF_handle handle,unsigned int perm = RAK_ATCMD_PERM_WRITE | RAK_ATCMD_PERM_READ);
Syntax | api.system.atMode.add(cmd, usage, title, handle, perm) |
---|---|
Parameters | cmd the cmd to define cmd name usage the cmd usage title the cmd title handle the handler that this command will execute perm the cmd execution permission |
uint32_t led_status;
int led_handle(SERIAL_PORT port, char *cmd, stParam *param) {
if (param->argc == 1 && !strcmp(param->argv[0], "?")) {
Serial.print(cmd);
Serial.print("=");
Serial.println(led_status?"HIGH":"LOW");
} else if (param->argc == 1) {
for (int i = 0 ; i < strlen(param->argv[0]) ; i++) {
if (!isdigit(*(param->argv[0]+i))) {
return AT_PARAM_ERROR;
}
}
led_status = strtoul(param->argv[0], NULL, 10);
if (led_status != 0 && led_status != 1) {
return AT_PARAM_ERROR;
}
pinMode(GREEN_LED, OUTPUT);
pinMode(BLUE_LED, OUTPUT);
digitalWrite(GREEN_LED, (led_status == 1)?HIGH:LOW);
digitalWrite(BLUE_LED, (led_status == 1)?HIGH:LOW);
} else {
return AT_PARAM_ERROR;
}
return AT_OK;
}
void setup()
{
api.system.atMode.add("LED", "This controls both green and blue LEDs.", "LED", led_handle, RAK_ATCMD_PERM_WRITE | RAK_ATCMD_PERM_READ);
}
void loop()
{
}
Change AT command permission
PERMISSION LEVEL:
RAK_ATCMD_PERM_READ
, RAK_ATCMD_PERM_WRITE
, RAK_ATCMD_PERM_WRITEONCEREAD
, RAK_ATCMD_PERM_DISABLE
AT commands' default permission are RAK_ATCMD_PERM_READ | RAK_ATCMD_PERM_WRITE
#define CHANGE_ATCMD_PERM(_atcmd_name, _atcmd_perm)
Value:
ATCMD_ITEM(atcmd_queue, atcmd_permission_item UNIQUE_NAME(permissions)) = \
{ \
.atcmd_id = _atcmd_name, \
.permission = _atcmd_perm, \
}
CHANGE_ATCMD_PERM("AT+APPKEY", RAK_ATCMD_PERM_READ);
CHANGE_ATCMD_PERM("AT+APPSKEY", RAK_ATCMD_PERM_WRITE);
CHANGE_ATCMD_PERM("AT+DEVADDR", RAK_ATCMD_PERM_WRITEONCEREAD);
CHANGE_ATCMD_PERM("AT+APPEUI", RAK_ATCMD_PERM_DISABLE);
CHANGE_ATCMD_PERM("AT+NETID", RAK_ATCMD_PERM_READ | RAK_ATCMD_PERM_WRITE);
CHANGE_ATCMD_PERM("AT+ALIAS", RAK_ATCMD_PERM_READ | RAK_ATCMD_PERM_WRITE);
CHANGE_ATCMD_PERM("AT+HWID", RAK_ATCMD_PERM_READ | RAK_ATCMD_PERM_WRITE);
void setup()
{
}
void loop()
{
}
void reboot()
Syntax | api.system.reboot() |
---|---|
Returns | void |
int loopCount = 0;
void setup()
{
}
void loop()
{
loopCount++;
if(loopCount == 60)
api.system.reboot(); // Reboot after 60 seconds
delay(1000);
}
void restoreDefault()
Syntax | api.system.restoreDefault() |
---|---|
Returns | void |
void setup()
{
api.system.restoreDefault();
}
void loop()
{
}