RUI3 (RAK Unified Interface 3) - RAK4631

Public Member Functions

bool get (uint8_t *buf, uint32_t len)
 
bool set (uint8_t *buf, uint32_t len)
 

Detailed Description

Description
This api allows the user to get or set the application session key

Member Function Documentation

◆ get()

bool get ( uint8_t *  buf,
uint32_t  len 
)
Description
This api allows the user to get the application session key
Syntax
api.lorawan.appskey.get(buf, len);
Note
This function can only work in ABP mode
Parameters
bufthe buffer to get AppSKey
lenthe length of AppSKey(must be 16 bytes)
Returns
bool
Return values
TRUEfor getting AppSKey successfully
FALSEfor getting AppSKey failure
Example
  // ABP Application Session Key
  uint8_t node_app_skey[16] = {0x25, 0xC4, 0xF1, 0xD1, 0x78, 0xC8, 0x8D, 0x01, 0xA8, 0x80, 0xC2, 0x79, 0xA7, 0x9F, 0x34, 0x3B};

  void setup()
  {
      Serial.begin(115200);

      api.lorawan.njm.set(RAK_LORA_ABP); // Set LoRaWan join mode to ABP

      if(api.lorawan.appskey.set(node_app_skey, 16) == true)
          Serial.println("LoRaWan AppSKey set success");
      else
          Serial.println("LoRaWan AppSKey set fail");
  }

  void loop()
  {
      uint8_t buff[16];

      if(api.lorawan.appskey.get(buff, 16) == true) {
          Serial.print("LoRaWan AppSKey = 0x");
          for(int i = 0; i < 16; i++) {
              Serial.printf("%02X", buff[i]);
          }
          Serial.println("");
      } else {
          Serial.println("LoRaWan AppSKey get fail");
      }

      delay(1000);
  }

◆ set()

bool set ( uint8_t *  buf,
uint32_t  len 
)
Description
This api allows the user to set the application session key
Syntax
api.lorawan.appskey.set(buf, len)
Parameters
bufThe buffer to get AppSKey
lenthe length of AppSkey(must be 16 bytes)
Returns
bool
Return values
TRUEfor getting AppSKey successfully
FALSEfor getting AppSKey failure
Example
  // ABP Application Session Key
  uint8_t node_app_skey[16] = {0x25, 0xC4, 0xF1, 0xD1, 0x78, 0xC8, 0x8D, 0x01, 0xA8, 0x80, 0xC2, 0x79, 0xA7, 0x9F, 0x34, 0x3B};

  void setup()
  {
      Serial.begin(115200);

      api.lorawan.njm.set(RAK_LORA_ABP); // Set LoRaWan join mode to ABP

      if(api.lorawan.appskey.set(node_app_skey, 16) == true)
          Serial.println("LoRaWan AppSKey set success");
      else
          Serial.println("LoRaWan AppSKey set fail");
  }

  void loop()
  {
      uint8_t buff[16];

      if(api.lorawan.appskey.get(buff, 16) == true) {
          Serial.print("LoRaWan AppSKey = 0x");
          for(int i = 0; i < 16; i++) {
              Serial.printf("%02X", buff[i]);
          }
          Serial.println("");
      } else {
          Serial.println("LoRaWan AppSKey get fail");
      }

      delay(1000);
  }