Skip to main content

BLE Beacon Custom Payload

Prerequisite

Before compiling the RUI3 BLE Examples, you must check the procedures described in the Prerequisite section of RAK4631-R QuickStart Guide. You will also need to install and configure the Arduino IDE, as described in the RAK4631-R Software section.

Loading the Example

The project is available on Arduino IDE RAK WisBlock RUI Examples.

  1. Launch Arduino IDE then go to: File -> Examples -> RAK WisBlock RUI Examples -> Example -> BLE_Beacon_Custom_Payload.
Figure 770: RAK WisBlock RUI BLE Beacon custom payload example
  1. Once the example code is open, you can now select the correct serial port, as shown in Figure 2.
Figure 771: Selecting the correct serial port
  1. The last step is to upload the code by clicking the highlighted Upload icon.
Figure 772: Uploading the BLE Beacon Custom Payload example code

Example Details

This sketch sends an Eddystone URL beacon. The BLE beacons can contain up to 31 bytes of data in their payload.

Configurable Parameters

Custom Payload

Set custom payload API. The URLs must be in Eddystone format.

uint8_t cus_adv_url[] =
{ 0x02, 0x01, 0x06, 0x03, 0x03, 0xAA, 0xFE, 0x12, 0x16, 0xAA, 0xFE,
0x10, 0xF8, 0x01, 0x72, 0x61, 0x6B, 0x77, 0x69, 0x72, 0x65, 0x6C,
0x65, 0x73, 0x73, 0x07 };

if (!(ret = api.ble.beacon.custom.payload.set(cus_adv_url, 26))) {
Serial.printf("Set BLE Beacon Customize Payload parameter is incorrect! \r\n");
return;
}

Beacon Mode

To send a beacon using RUI3 BLE API, you need to switch to Beacon mode.

api.ble.settings.blemode(RAK_BLE_BEACON_MODE);

Scanning Beacons

You can scan the custom beacons sent by the BLE_Beacon_Custom_Payload project using the nRF Connect for Mobile tool.

Figure 773: nRF Connect for Mobile tool scan