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
view or change the LoRAWAN APPKEY and use it to setup the LoRAWAN connection

Member Function Documentation

◆ get()

bool get ( uint8_t *  buf,
uint32_t  len 
)
Description
This api allows the user to get the application key
Syntax
api.lorawan.appkey.get(buf, len)
Parameters
bufthe buffer to get AppKey
lenthe length of AppKey(must be 16 bytes)
Returns
bool
Return values
TRUEfor getting AppKey successfully
FALSEfor getting Appkey failure
Example
  // OTAA Application Key MSB
  uint8_t node_app_key[16] = {0x2B, 0x7E, 0x15, 0x16, 0x28, 0xAE, 0xD2, 0xA6, 0xAB, 0xF7, 0x15, 0x88, 0x09, 0xCF, 0x4F, 0x3E};

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

      api.lorawan.njm.set(RAK_LORA_OTAA); // Set LoRaWan join mode to OTAA

      if(api.lorawan.appkey.set(node_app_key, 16) == true)
          Serial.println("LoRaWan AppKey set success");
      else
          Serial.println("LoRaWan AppKey set fail");
  }

  void loop()
  {
      uint8_t buff[16];

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

      delay(1000);
  }

◆ set()

bool set ( uint8_t *  buf,
uint32_t  len 
)
Description
This api allows the user to set the application key
Syntax
api.lorawan.appkey.set(buf, len);
Parameters
bufthe buffer to set AppKey
lenthe length of AppKey(must be 16 bytes)
Returns
bool
Return values
TRUEfor setting AppKey successfully
FALSEfor setting Appkey failure
Example
  // OTAA Application Key MSB
  uint8_t node_app_key[16] = {0x2B, 0x7E, 0x15, 0x16, 0x28, 0xAE, 0xD2, 0xA6, 0xAB, 0xF7, 0x15, 0x88, 0x09, 0xCF, 0x4F, 0x3E};

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

      api.lorawan.njm.set(RAK_LORA_OTAA); // Set LoRaWan join mode to OTAA

      if(api.lorawan.appkey.set(node_app_key, 16) == true)
          Serial.println("LoRaWan AppKey set success");
      else
          Serial.println("LoRaWan AppKey set fail");
  }

  void loop()
  {
      uint8_t buff[16];

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

      delay(1000);
  }