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.
- Launch Arduino IDE then go to: File -> Examples -> RAK WisBlock RUI Examples -> Example -> BLE_Beacon_Custom_Payload.
- Once the example code is open, you can now select the correct serial port, as shown in Figure 2.
- The last step is to upload the code by clicking the highlighted Upload icon.
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.