BLE Configuration
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_Configuration.
- 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.
- You should now be able to see the project logs on the serial monitor of Arduino IDE.
Example details
This sketch shows RUI3 BLE API configuration parameters that can be used in your RUI3 project.
Configurable Parameters
Start BLE UART Service
Start the BLE UART Service using BLE API.
api.ble.uart.start();
Advertise Status
Get the current Advertise Status using BLE API.
get_dav_status = api.ble.advertise.status();
Set Tx Power Level
Set the Tx Power Level. The code below sets the Tx Power to 8 dBm.
get_dav_status = api.ble.settings.txPower.set(8);
Set BLE Broadcast Name
Set the Broadcast Name. The code below sets the Broadcast Name to RAKBLE-4631.
char dev_name[12] = { 'R', 'A', 'K', 'B', 'L', 'E', '-', '4', '6', '3', '1', '\0' };
if (!(ret = api.ble.settings.broadcastName.set(dev_name, 12))) {
Serial.printf("BLE Configuration - set broadcast name is incorrect! \r\n");
return;
}
Start the BLE Advertising
Configure the BLE Advertising timeout.
if (!(ret = api.ble.advertise.start(60))) {
Serial.printf("BLE Configuration - set start advertise parameter is incorrect! \r\n");
return;
}
Get the BLE Advertising Interval
Get the current advertising interval in milliseconds.
int32_t get_adv_interval = api.ble.settings.advertiseInterval.get();
Get Device MAC Address
Get the current MAC Address position 2.
char *get_position_2_mac_addr = api.ble.mac.get(2);
Scanning BLE Advertising Packets
You can check the BLE packets sent by the BLE_Configuration
project using the nRF Connect for Mobile tool.