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 access the device address

Member Function Documentation

◆ get()

bool get ( uint8_t *  buf,
uint32_t  len 
)
Description
This api allows the user to get the device address
Syntax
api.lorawan.daddr.get(buf, len);
Note
This function can only work in ABP mode
Parameters
bufthe buffer to get device address
lenthe length of device address(must be 4 bytes)
Returns
bool
Return values
TRUEfor getting device address successfully
FALSEfor getting device address failure
Example
  // ABP Device Address
  uint8_t node_dev_addr[4] = {0x05, 0x05, 0x06, 0x06};

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

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

      if(api.lorawan.daddr.set(node_dev_addr, 4) == true)
          Serial.println("LoRaWan device address set success");
      else
          Serial.println("LoRaWan device address set fail");
  }

  void loop()
  {
      uint8_t buff[4];

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

      delay(1000);
  }

◆ set()

bool set ( uint8_t *  buf,
uint32_t  len 
)
Description
This api allows the user to set the device address
Syntax
api.lorawan.daddr.set(buf, len);
Parameters
bufthe buffer to set device address
lenthe length of device address(must be 4 bytes)
Returns
bool
Return values
TRUEfor setting device address successfully
FALSEfor setting device address failure
Example
  // ABP Device Address
  uint8_t node_dev_addr[4] = {0x05, 0x05, 0x06, 0x06};

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

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

      if(api.lorawan.daddr.set(node_dev_addr, 4) == true)
          Serial.println("LoRaWan device address set success");
      else
          Serial.println("LoRaWan device address set fail");
  }

  void loop()
  {
      uint8_t buff[4];

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

      delay(1000);
  }