Year End 2024 Sale
Skip to main content

BLE

Devices that support RUI3 BLE API

RAK Modules
RAK4630
RAK11720

RUI BLE Data Type

Enumerations

RAK_BLE_SERVICE_MODE

enum RAK_BLE_SERVICE_MODE
ModeComment
RAK_BLE_UART_MODESwitch to BLE UART mode
RAK_BLE_SERVICE_MODESwitch to Beacon Mode.

RAK_CHARS_SECURITY_REQ

enum RAK_CHARS_SECURITY_REQ
ModeComment
RAK_SET_OPENSet sec_mode pointed to by ptr to require no protection, open link.
RAK_SET_ENC_NO_MITMSet sec_mode pointed to by ptr to require encryption, but no MITM protection.
RAK_SET_ENC_WITH_MITMSet sec_mode pointed to by ptr to require encryption and MITM protection.

RAK_CHARS_PROPERTIES

PropertyComment
RAK_CHR_PROPS_READSet the characteristic property to be Read.
RAK_CHR_PROPS_NOTIFYSet the characteristic property to be Notify.

BLE_HANDLER

typedef void(* BLE_HANDLER) (void)

Event

enum Event
Enumerator
BLE_CONNECTED Set callback for connection event.
BLE_DISCONNECTED Set callback for disconnect event.

BLE

The following commands are the generic BLE commands:

stop()

Disconnect an existing BLE connection.

api.ble.stop()
Functionvoid stop(void)
Returnsvoid

registerCallback

Set a callback function when a bluetooth connection is established or disconnected.

api.ble.registerCallback()
Functionvoid registerCallback (Event event, BLE_HANDLER callback)
Parametersevent - set connect or disconnect event
callback - callback function
Returnsvoid

BLE UART

NOTE

Serial6 is the UART interface for BLE. To enable AT commands via BLE, you can use Serial6.begin(115200, RAK_AT_MODE);.

start()

This API is used to start the BLE UART Service.

api.ble.uart.start()
Functionvoid start(uint8_t adv_time)
Parametersadv_time - advertising timeout in seconds. If x = 0, advertising never stops
Returnsvoid

stop()

This API is used to stop the BLE UART Service.

api.ble.uart.stop()
Functionvoid stop(void)
Returnsvoid
Click to view the code
void setup()
{
api.ble.uart.stop();
}

void loop()
{
}

available()

This API is used to check if there is any incoming Byte from BLE UART Service.

api.ble.uart.available()
Functionbool available(void)
Returnsbool
Return ValuesTRUE - receive data from the ble device
FALSE - nothing to get

read()

This API is used to read incoming Byte from BLE UART Service.

api.ble.uart.read()
Functionchar read(void)
ReturnsThe first byte of incoming BLE data available (Type: char)

write()

This API is used to write data and send it to the connected device via BLE.

api.ble.uart.write(data, size)
Functionvoid write(uint8_t * data, uint16_t size = 6)
Parametersdata - an array to send as a series of bytes
size - length of the data that will be written to the ble device
Returnsvoid

setPIN()

This API is used to set the passkey with BLE pairing.

api.ble.uart.setPIN(key, size)
Functionvoid setPIN(uint8_t * key, uint16_t size)
Parameterskey - the key to set the passkey (6 digits only)
size - the length of key (can only be 6)
Returnsvoid

setPermission()

This API is used to access BLE UART to require man-in-the-middle protection.

api.ble.uart.setPermission(permission)
Functionvoid setPermission(RAK_CHARS_SECURITY_REQ permission)
Parameterspermission - This will cause apps to perform pairing with static PIN you set
RAK_SET_ENC_WITH_MITM
RAK_SET_ENC_NO_MITM
Returnsvoid

BLE Setting

mac

get()

This API is used to get the current Device MAC Address.

api.ble.mac.get()
api.ble.mac.get(pos)
NOTE

If MAC is 6 bytes and x is passed as 2, the return value will be position [2] in the array. If x is NOT passed, the function will default to returning a string, all uppercase.

Functionchar* get(uint8_t pos)
Parameterspos - single byte, array location
ReturnsThe current BLE MAC Address

txPower

set()

This API is used to set the current transmit power level for the module's radio.

api.ble.settings.txPower.set(txpwr)
Functionbool set(int8_t txpwr)
Parameterstxpwr - The TX power level (dBm), which can be one of the following values (from lowest to higher transmit power): 0~8, -4, -8, -12, -16, -20, -40
Returnsbool
Return ValuesTRUE for success SET
FALSE for SET fail

get()

This API is used to get the current transmit power level (in dBm).

api.ble.settings.txPower.get()
Functionint8_t get()
ReturnsThe current transmit power

advertiseInterval

set()

This API is used to set the time interval between two consecutive advertisements of Bluetooth low energy peripherals.

api.ble.settings.advertiseInterval.set(adv_interval)
Functionbool set (int32_t adv_interval
Parametersadv_interval 1000 ms ~ 10240 ms
Returnsbool
Return ValuesTRUE for success SET
FALSE for SET fail

get()

This API is used to get the current advertisement interval.

api.ble.settings.advertiseInterval.get()
Functionint32_t get()
ReturnsReturn the current advertisement interval (1000 ms ~ 10240 ms)

broadcastName

set()

This API sets the name for this device. It is used in advertisement and as the Device Name available to a connected peer.

api.ble.settings.broadcastName.set(ble_name, device_name_length)
Functionbool set(char *ble_name, uint8_t device_name_length)
Parametersble_name - setting device name an array of data to send as bytes
device_name_length - the number of bytes to transmit
Returnsbool
Return ValuesTRUE for success SET
FALSE for SET fail

get()

This API is used to get the current BLE device name.

api.ble.settings.broadcastName.get()
Functionchar* get()
ReturnsThe current BLE Device Name

RAKBleAdvertise

start()

This API is used to start advertising after configuring the BLE settings.

api.ble.advertise.start(adv_time)
Functionbool start(uint8_t adv_time)
Parametersadv_time - advertising timeout in seconds. If x = 0, advertising never stops.
Returnsbool
Returns ValuesTRUE for start advertising success
FALSE for start advertising failure

stop()

This API is used to stop advertising.

api.ble.advertise.stop()
Functionbool stop()
Returnsbool
Returns ValuesTRUE for stop advertising success
FALSE for stop advertising failure
Click to view the code
void setup()
{
api.ble.advertise.stop();
}

void loop()
{
}

status()

api.ble.advertise.status()
Functionbool status()
Returnsbool
Returns ValuesTRUE - the device is in advertising
FALSE - the device stops in advertising

bleMode()

This API is used to support the current BLE UART Service mode switch to beacon mode.

api.ble.settings.blemode(ble_mode)
Functionvoid blemode(RAK_BLE_SERVICE_MODE ble_mode)
Parametersble_mode RAK_BLE_BEACON_MODE
Returnsvoid

Beacon Mode

iBeacon

uuid

set()

Application developers should define a UUID specific to their app and deployment use case.

api.ble.beacon.ibeacon.uuid.set(beaconUuid)
Functionbool set(uint8_t beaconUuid[])
ParametersbeaconUuid - define 16 bytes
Returnsbool
Return ValuesTRUE for success SET
FALSE for SET fail

major

set()

This API further specifies a specific iBeacon and use case. For example, this could define a sub-region within a larger region defined by the UUID.

api.ble.beacon.ibeacon.major.set(major_value)
Functionbool set(uint16_t major_value)
Parametersmajor_value - set major (define 2 bytes)
Returnsbool
Return ValuesTRUE for success SET
FALSE for SET fail

minor

set()

This API allows further subdivision of region or use case specified by the application developer.

api.ble.beacon.ibeacon.minor.set(minor_value)
Functionbool set(uint16_t minor_value)
Parametersminor_value - set minor (define 2 bytes)
Returnsbool
Return ValuesTRUE for success SET
FALSE for SET fail

power

set()

This API provides information about the measured power value expected at one (1) meter from the beacon.

api.ble.beacon.ibeacon.power.set(ibeacon_power)
Functionbool set(int8_t ibeacon_power)
Parametersibeacon_power - display measured power value (RSSI)
Returnsbool
Return ValuesTRUE for success SET
FALSE for SET fail

set()

This API provides the developer to control all data for BLE Beacon advertising and allows function to support full 31 byte payload.

api.ble.beacon.custom.payload.set(cus_adv_data[], cus_adv_len)
Functionbool set(uint8_t cus_adv_data[], uint8_t cus_adv_len)
Parameterscus_adv_data[] - set the advertising payload (Max 31 bytes)
cus_adv_len - the number of bytes to advertising data
Returnsbool
Return ValuesTRUE for success SET
FALSE for SET fail

BLE Scanner

start()

This API starts scanning for BLE peripherals in range and parsing the advertising data that is being sent out by the peripherals.

api.ble.scanner.start(timeout_sec)
Functionvoid start(uint16_t timeout_sec)
Parameterstimeout_sec - field is scanning stop after x seconds. If timeout_sec=0, always scanning on.
Returnsvoid

setInterval()

This API is used to specify a scan window (how long to scan) and interval (how long to wait between scans).

api.ble.scanner.setInterval(scan_interval, scan_window);
Functionbool setInterval(uint16_t scan_interval, uint16_t scan_window)
Parametersscan_interval - Defines at what intervals scanner is started. (3 ms ~ 40960 ms)
scan_window - Defines how long to scan at each interval (3 ms ~ 40960 ms)
Returnsbool
Return ValuesTRUE for success SET
FALSE for SET fail

setScannerCallback()

This API is used to register a callback function, so that application can be notified on receiving scan data.

void setScannerCallback	(void(*)(int8_t, uint8_t *, uint8_t *, uint16_t) userFunc)
Functionapi.ble.scanner.setScannerCallback(userFunc)
ParametersuserFunc callback
Returnsvoid

Customize Service

RAKBleService

RAKBleService()

This API provides developers to create a new BLE service and construct an instance of BLEService.

RAKBleService hrms = RAKBleService(service_uuid[])
FunctionRAKBleService(uint8_t service_uuid[])
Parametersservice_uuid[] - create a 128-bit base UUID, and the 3rd and 4th byte means Service 16-bit UUID
Returnsvoid

begin()

Before constructing an instance BLECharacteristic, you need to construct an instance BLEServices and execute .begin().

hrms.begin()
NOTE

You should create your own instance to use this API:

RAKBleService hrms = RAKBleService(service_uuid[])
Functionvoid begin()
Returnsvoid
Click to view the code
#include "Arduino.h"
#define UUID16_SVC_HEART_RATE 0x180D
#define UUID16_CHR_HEART_RATE_MEASUREMENT 0x2A37
#define UUID16_CHR_BODY_SENSOR_LOCATION 0x2A38
RAKBleCharacteristic hrmc = RAKBleCharacteristic(UUID16_CHR_HEART_RATE_MEASUREMENT);
void cccd_callback(uint16_t chars_uuid, uint8_t *cccd_value)
{
if (chars_uuid == UUID16_CHR_HEART_RATE_MEASUREMENT)
{
if (hrmc.notifyEnabled())
{
Serial.println("[Heart Rate Measurement 'Notify' enabled]");
}
else
{
Serial.println("[Heart Rate Measurement 'Notify' disabled]");
return;
}
}
//Serial.println((char *)cccd_value);
Serial.println("");
Serial.print("chars_uuid: ");
Serial.print("0x");
String uuid_str = String(chars_uuid, HEX);
Serial.println(uuid_str);
Serial.println("notify value:");
String cccd_value1 = String(cccd_value[0], HEX);
String cccd_value2 = String(cccd_value[1], HEX);
Serial.print("0x");
Serial.println(cccd_value1);
Serial.print("0x");
Serial.println(cccd_value2);
}
void send_callback(uint16_t chars_uuid, uint8_t *send_value)
{
if (chars_uuid == UUID16_CHR_BODY_SENSOR_LOCATION)
{
Serial.println("[Heart Rate - Body Sensor Location Read!]");
Serial.print("chars_uuid: ");
Serial.print("0x");
String uuid_str = String(chars_uuid, HEX);
Serial.println(uuid_str);
Serial.println("");
Serial.print("send value: ");
char send_str = send_value[0];
Serial.println(send_str);
}
}
void setup()
{
//Base 128-bit UUID : B320F8FA-5AFC-4C1B-B96F-16247D912D0A
//--The 3rd and 4th byte 'F8FA' means Service 16bit UUID
uint8_t base_uuid[]={0xB3, 0x20, 0xF8, 0xFA, 0x5A, 0xFC, 0x4C, 0x1B, 0xB9, 0x6F, 0x16, 0x24, 0x7D, 0x91, 0x2D, 0x0A};
Serial.begin(115200);
delay(5000);
Serial.println("RAKwireless BLE Customer Services Example");
Serial.println("------------------------------------------------------");
api.ble.customer.init();
RAKBleService hrms = RAKBleService(base_uuid);
RAKBleCharacteristic bslc = RAKBleCharacteristic(UUID16_CHR_BODY_SENSOR_LOCATION);
hrms.begin();
hrmc.setProperties(RAK_CHR_PROPS_NOTIFY);
hrmc.setPermission(RAK_SET_OPEN);
hrmc.setFixedLen(2);
hrmc.setCccdWriteCallback(cccd_callback);
hrmc.begin();
delay(1000);
uint8_t hrmdata[2] = {0x39, 0x40};
hrmc.notify(hrmdata);
delay(1000);
//Body Sensor Location
// 0 = Other
// 1 = Chest
// 2 = Wrist
// 3 = Finger
// 4 = Hand
// 5 = Ear Lobe
// 6 = Foot
// 7:255 = Reserved
bslc.setProperties(RAK_CHR_PROPS_READ);
bslc.setPermission(RAK_SET_OPEN);
bslc.setFixedLen(1);
bslc.setWriteCallback(send_callback);
bslc.begin();
delay(1000);
uint8_t sensor_location[1] = {'2'};
bslc.write(sensor_location); // Set the characteristic to 'Wrist' (2)
api.ble.customer.start();
}
void loop()
{
}

RAKBleCharacteristic

RAKBleCharacteristic()

This API creates a new BLE characteristic associated with this service.

RAKBleCharacteristic bslc = RAKBleCharacteristic(characteristicUUID)
FunctionRAKBleCharacteristic(uint16_t characteristicUUID)
ParameterscharacteristicUUID - The base is the same as the base UUID used when construct an instance BLEService, only provided the 3rd and 4th byte means characteristic (16 bit UUID)

setProperties()

This API sets the characteristic properties.

bslc.setProperties(prop)
NOTE

You should create your own instance to use this API.

RAKBleCharacteristic bslc = RAKBleCharacteristic(characteristicUUID)
Functionvoid setProperties(RAK_CHARS_PROPERTIES prop)
Parametersprop - currently supports (CHR_PROPS_NOTIFY/CHR_PROPS_READ)
Returnsvoid
Click to view the code
#include "Arduino.h"
#define UUID16_SVC_HEART_RATE 0x180D
#define UUID16_CHR_HEART_RATE_MEASUREMENT 0x2A37
#define UUID16_CHR_BODY_SENSOR_LOCATION 0x2A38
RAKBleCharacteristic hrmc = RAKBleCharacteristic(UUID16_CHR_HEART_RATE_MEASUREMENT);
void cccd_callback(uint16_t chars_uuid, uint8_t *cccd_value)
{
if (chars_uuid == UUID16_CHR_HEART_RATE_MEASUREMENT)
{
if (hrmc.notifyEnabled())
{
Serial.println("[Heart Rate Measurement 'Notify' enabled]");
}
else
{
Serial.println("[Heart Rate Measurement 'Notify' disabled]");
return;
}
}
//Serial.println((char *)cccd_value);
Serial.println("");
Serial.print("chars_uuid: ");
Serial.print("0x");
String uuid_str = String(chars_uuid, HEX);
Serial.println(uuid_str);
Serial.println("notify value:");
String cccd_value1 = String(cccd_value[0], HEX);
String cccd_value2 = String(cccd_value[1], HEX);
Serial.print("0x");
Serial.println(cccd_value1);
Serial.print("0x");
Serial.println(cccd_value2);
}
void send_callback(uint16_t chars_uuid, uint8_t *send_value)
{
if (chars_uuid == UUID16_CHR_BODY_SENSOR_LOCATION)
{
Serial.println("[Heart Rate - Body Sensor Location Read!]");
Serial.print("chars_uuid: ");
Serial.print("0x");
String uuid_str = String(chars_uuid, HEX);
Serial.println(uuid_str);
Serial.println("");
Serial.print("send value: ");
char send_str = send_value[0];
Serial.println(send_str);
}
}
void setup()
{
//Base 128-bit UUID : B320F8FA-5AFC-4C1B-B96F-16247D912D0A
//--The 3rd and 4th byte 'F8FA' means Service 16bit UUID
uint8_t base_uuid[]={0xB3, 0x20, 0xF8, 0xFA, 0x5A, 0xFC, 0x4C, 0x1B, 0xB9, 0x6F, 0x16, 0x24, 0x7D, 0x91, 0x2D, 0x0A};
Serial.begin(115200);
delay(5000);
Serial.println("RAKwireless BLE Customer Services Example");
Serial.println("------------------------------------------------------");
api.ble.customer.init();
RAKBleService hrms = RAKBleService(base_uuid);
RAKBleCharacteristic bslc = RAKBleCharacteristic(UUID16_CHR_BODY_SENSOR_LOCATION);
hrms.begin();
hrmc.setProperties(RAK_CHR_PROPS_NOTIFY);
hrmc.setPermission(RAK_SET_OPEN);
hrmc.setFixedLen(2);
hrmc.setCccdWriteCallback(cccd_callback);
hrmc.begin();
delay(1000);
uint8_t hrmdata[2] = {0x39, 0x40};
hrmc.notify(hrmdata);
delay(1000);
//Body Sensor Location
// 0 = Other
// 1 = Chest
// 2 = Wrist
// 3 = Finger
// 4 = Hand
// 5 = Ear Lobe
// 6 = Foot
// 7:255 = Reserved
bslc.setProperties(RAK_CHR_PROPS_READ);
bslc.setPermission(RAK_SET_OPEN);
bslc.setFixedLen(1);
bslc.setWriteCallback(send_callback);
bslc.begin();
delay(1000);
uint8_t sensor_location[1] = {'2'};
bslc.write(sensor_location); // Set the characteristic to 'Wrist' (2)
api.ble.customer.start();
}
void loop()
{
}

setPermission()

This API sets the security for the characteristic.

bslc.setPermission(read_write_perm)
NOTE

You should create your own instance to use this API.

RAKBleCharacteristic bslc = RAKBleCharacteristic(characteristicUUID)
Functionvoid setPermission(RAK_CHARS_SECURITY_REQ read_write_perm)
Parametersread_write_perm RAK_SET_OPEN
Returnsvoid
Click to view the code
#include "Arduino.h"
#define UUID16_SVC_HEART_RATE 0x180D
#define UUID16_CHR_HEART_RATE_MEASUREMENT 0x2A37
#define UUID16_CHR_BODY_SENSOR_LOCATION 0x2A38
RAKBleCharacteristic hrmc = RAKBleCharacteristic(UUID16_CHR_HEART_RATE_MEASUREMENT);
void cccd_callback(uint16_t chars_uuid, uint8_t *cccd_value)
{
if (chars_uuid == UUID16_CHR_HEART_RATE_MEASUREMENT)
{
if (hrmc.notifyEnabled())
{
Serial.println("[Heart Rate Measurement 'Notify' enabled]");
}
else
{
Serial.println("[Heart Rate Measurement 'Notify' disabled]");
return;
}
}
//Serial.println((char *)cccd_value);
Serial.println("");
Serial.print("chars_uuid: ");
Serial.print("0x");
String uuid_str = String(chars_uuid, HEX);
Serial.println(uuid_str);
Serial.println("notify value:");
String cccd_value1 = String(cccd_value[0], HEX);
String cccd_value2 = String(cccd_value[1], HEX);
Serial.print("0x");
Serial.println(cccd_value1);
Serial.print("0x");
Serial.println(cccd_value2);
}
void send_callback(uint16_t chars_uuid, uint8_t *send_value)
{
if (chars_uuid == UUID16_CHR_BODY_SENSOR_LOCATION)
{
Serial.println("[Heart Rate - Body Sensor Location Read!]");
Serial.print("chars_uuid: ");
Serial.print("0x");
String uuid_str = String(chars_uuid, HEX);
Serial.println(uuid_str);
Serial.println("");
Serial.print("send value: ");
char send_str = send_value[0];
Serial.println(send_str);
}
}
void setup()
{
//Base 128-bit UUID : B320F8FA-5AFC-4C1B-B96F-16247D912D0A
//--The 3rd and 4th byte 'F8FA' means Service 16bit UUID
uint8_t base_uuid[]={0xB3, 0x20, 0xF8, 0xFA, 0x5A, 0xFC, 0x4C, 0x1B, 0xB9, 0x6F, 0x16, 0x24, 0x7D, 0x91, 0x2D, 0x0A};
Serial.begin(115200);
delay(5000);
Serial.println("RAKwireless BLE Customer Services Example");
Serial.println("------------------------------------------------------");
api.ble.customer.init();
RAKBleService hrms = RAKBleService(base_uuid);
RAKBleCharacteristic bslc = RAKBleCharacteristic(UUID16_CHR_BODY_SENSOR_LOCATION);
hrms.begin();
hrmc.setProperties(RAK_CHR_PROPS_NOTIFY);
hrmc.setPermission(RAK_SET_OPEN);
hrmc.setFixedLen(2);
hrmc.setCccdWriteCallback(cccd_callback);
hrmc.begin();
delay(1000);
uint8_t hrmdata[2] = {0x39, 0x40};
hrmc.notify(hrmdata);
delay(1000);
//Body Sensor Location
// 0 = Other
// 1 = Chest
// 2 = Wrist
// 3 = Finger
// 4 = Hand
// 5 = Ear Lobe
// 6 = Foot
// 7:255 = Reserved
bslc.setProperties(RAK_CHR_PROPS_READ);
bslc.setPermission(RAK_SET_OPEN);
bslc.setFixedLen(1);
bslc.setWriteCallback(send_callback);
bslc.begin();
delay(1000);
uint8_t sensor_location[1] = {'2'};
bslc.write(sensor_location); // Set the characteristic to 'Wrist' (2)
api.ble.customer.start();
}
void loop()
{
}

setFixedLen()

This API indicates how many bytes this characteristic has.

bslc.setFixedLen(fixed_len)
NOTE

You should create your own instance to use this API.

RAKBleCharacteristic bslc = RAKBleCharacteristic(characteristicUUID)
Functionvoid setFixedLen(uint16_t fixed_len)
Parametersfixed_len - the length of the incoming data for notify or write
Returnsvoid
Click to view the code
#include "Arduino.h"
#define UUID16_SVC_HEART_RATE 0x180D
#define UUID16_CHR_HEART_RATE_MEASUREMENT 0x2A37
#define UUID16_CHR_BODY_SENSOR_LOCATION 0x2A38
RAKBleCharacteristic hrmc = RAKBleCharacteristic(UUID16_CHR_HEART_RATE_MEASUREMENT);
void cccd_callback(uint16_t chars_uuid, uint8_t *cccd_value)
{
if (chars_uuid == UUID16_CHR_HEART_RATE_MEASUREMENT)
{
if (hrmc.notifyEnabled())
{
Serial.println("[Heart Rate Measurement 'Notify' enabled]");
}
else
{
Serial.println("[Heart Rate Measurement 'Notify' disabled]");
return;
}
}
//Serial.println((char *)cccd_value);
Serial.println("");
Serial.print("chars_uuid: ");
Serial.print("0x");
String uuid_str = String(chars_uuid, HEX);
Serial.println(uuid_str);
Serial.println("notify value:");
String cccd_value1 = String(cccd_value[0], HEX);
String cccd_value2 = String(cccd_value[1], HEX);
Serial.print("0x");
Serial.println(cccd_value1);
Serial.print("0x");
Serial.println(cccd_value2);
}
void send_callback(uint16_t chars_uuid, uint8_t *send_value)
{
if (chars_uuid == UUID16_CHR_BODY_SENSOR_LOCATION)
{
Serial.println("[Heart Rate - Body Sensor Location Read!]");
Serial.print("chars_uuid: ");
Serial.print("0x");
String uuid_str = String(chars_uuid, HEX);
Serial.println(uuid_str);
Serial.println("");
Serial.print("send value: ");
char send_str = send_value[0];
Serial.println(send_str);
}
}
void setup()
{
//Base 128-bit UUID : B320F8FA-5AFC-4C1B-B96F-16247D912D0A
//--The 3rd and 4th byte 'F8FA' means Service 16bit UUID
uint8_t base_uuid[]={0xB3, 0x20, 0xF8, 0xFA, 0x5A, 0xFC, 0x4C, 0x1B, 0xB9, 0x6F, 0x16, 0x24, 0x7D, 0x91, 0x2D, 0x0A};
Serial.begin(115200);
delay(5000);
Serial.println("RAKwireless BLE Customer Services Example");
Serial.println("------------------------------------------------------");
api.ble.customer.init();
RAKBleService hrms = RAKBleService(base_uuid);
RAKBleCharacteristic bslc = RAKBleCharacteristic(UUID16_CHR_BODY_SENSOR_LOCATION);
hrms.begin();
hrmc.setProperties(RAK_CHR_PROPS_NOTIFY);
hrmc.setPermission(RAK_SET_OPEN);
hrmc.setFixedLen(2);
hrmc.setCccdWriteCallback(cccd_callback);
hrmc.begin();
delay(1000);
uint8_t hrmdata[2] = {0x39, 0x40};
hrmc.notify(hrmdata);
delay(1000);
//Body Sensor Location
// 0 = Other
// 1 = Chest
// 2 = Wrist
// 3 = Finger
// 4 = Hand
// 5 = Ear Lobe
// 6 = Foot
// 7:255 = Reserved
bslc.setProperties(RAK_CHR_PROPS_READ);
bslc.setPermission(RAK_SET_OPEN);
bslc.setFixedLen(1);
bslc.setWriteCallback(send_callback);
bslc.begin();
delay(1000);
uint8_t sensor_location[1] = {'2'};
bslc.write(sensor_location); // Set the characteristic to 'Wrist' (2)
api.ble.customer.start();
}
void loop()
{
}

begin()

After adding the characteristic, must call .begin() to complete the configuration action

bslc.begin()
NOTE

You should create your own instance to use this API.

RAKBleCharacteristic bslc = RAKBleCharacteristic(characteristicUUID)
Functionvoid begin()
Returnsvoid
Click to view the code
#include "Arduino.h"
#define UUID16_SVC_HEART_RATE 0x180D
#define UUID16_CHR_HEART_RATE_MEASUREMENT 0x2A37
#define UUID16_CHR_BODY_SENSOR_LOCATION 0x2A38
RAKBleCharacteristic hrmc = RAKBleCharacteristic(UUID16_CHR_HEART_RATE_MEASUREMENT);
void cccd_callback(uint16_t chars_uuid, uint8_t *cccd_value)
{
if (chars_uuid == UUID16_CHR_HEART_RATE_MEASUREMENT)
{
if (hrmc.notifyEnabled())
{
Serial.println("[Heart Rate Measurement 'Notify' enabled]");
}
else
{
Serial.println("[Heart Rate Measurement 'Notify' disabled]");
return;
}
}
//Serial.println((char *)cccd_value);
Serial.println("");
Serial.print("chars_uuid: ");
Serial.print("0x");
String uuid_str = String(chars_uuid, HEX);
Serial.println(uuid_str);
Serial.println("notify value:");
String cccd_value1 = String(cccd_value[0], HEX);
String cccd_value2 = String(cccd_value[1], HEX);
Serial.print("0x");
Serial.println(cccd_value1);
Serial.print("0x");
Serial.println(cccd_value2);
}
void send_callback(uint16_t chars_uuid, uint8_t *send_value)
{
if (chars_uuid == UUID16_CHR_BODY_SENSOR_LOCATION)
{
Serial.println("[Heart Rate - Body Sensor Location Read!]");
Serial.print("chars_uuid: ");
Serial.print("0x");
String uuid_str = String(chars_uuid, HEX);
Serial.println(uuid_str);
Serial.println("");
Serial.print("send value: ");
char send_str = send_value[0];
Serial.println(send_str);
}
}
void setup()
{
//Base 128-bit UUID : B320F8FA-5AFC-4C1B-B96F-16247D912D0A
//--The 3rd and 4th byte 'F8FA' means Service 16bit UUID
uint8_t base_uuid[]={0xB3, 0x20, 0xF8, 0xFA, 0x5A, 0xFC, 0x4C, 0x1B, 0xB9, 0x6F, 0x16, 0x24, 0x7D, 0x91, 0x2D, 0x0A};
Serial.begin(115200);
delay(5000);
Serial.println("RAKwireless BLE Customer Services Example");
Serial.println("------------------------------------------------------");
api.ble.customer.init();
RAKBleService hrms = RAKBleService(base_uuid);
RAKBleCharacteristic bslc = RAKBleCharacteristic(UUID16_CHR_BODY_SENSOR_LOCATION);
hrms.begin();
hrmc.setProperties(RAK_CHR_PROPS_NOTIFY);
hrmc.setPermission(RAK_SET_OPEN);
hrmc.setFixedLen(2);
hrmc.setCccdWriteCallback(cccd_callback);
hrmc.begin();
delay(1000);
uint8_t hrmdata[2] = {0x39, 0x40};
hrmc.notify(hrmdata);
delay(1000);
//Body Sensor Location
// 0 = Other
// 1 = Chest
// 2 = Wrist
// 3 = Finger
// 4 = Hand
// 5 = Ear Lobe
// 6 = Foot
// 7:255 = Reserved
bslc.setProperties(RAK_CHR_PROPS_READ);
bslc.setPermission(RAK_SET_OPEN);
bslc.setFixedLen(1);
bslc.setWriteCallback(send_callback);
bslc.begin();
delay(1000);
uint8_t sensor_location[1] = {'2'};
bslc.write(sensor_location); // Set the characteristic to 'Wrist' (2)
api.ble.customer.start();
}
void loop()
{
}

notify()

This API provides information to send notifications to the connector.

bslc.notify(notify_data)
NOTE

You should create your own instance to use this API.

RAKBleCharacteristic bslc = RAKBleCharacteristic(characteristicUUID)
Functionvoid notify (uint8_t * notify_data)
Parametersnotify_data - an array to send as a series of bytes
Returnsvoid
Click to view the code
#include "Arduino.h"
#define UUID16_SVC_HEART_RATE 0x180D
#define UUID16_CHR_HEART_RATE_MEASUREMENT 0x2A37
#define UUID16_CHR_BODY_SENSOR_LOCATION 0x2A38
RAKBleCharacteristic hrmc = RAKBleCharacteristic(UUID16_CHR_HEART_RATE_MEASUREMENT);
void cccd_callback(uint16_t chars_uuid, uint8_t *cccd_value)
{
if (chars_uuid == UUID16_CHR_HEART_RATE_MEASUREMENT)
{
if (hrmc.notifyEnabled())
{
Serial.println("[Heart Rate Measurement 'Notify' enabled]");
}
else
{
Serial.println("[Heart Rate Measurement 'Notify' disabled]");
return;
}
}
//Serial.println((char *)cccd_value);
Serial.println("");
Serial.print("chars_uuid: ");
Serial.print("0x");
String uuid_str = String(chars_uuid, HEX);
Serial.println(uuid_str);
Serial.println("notify value:");
String cccd_value1 = String(cccd_value[0], HEX);
String cccd_value2 = String(cccd_value[1], HEX);
Serial.print("0x");
Serial.println(cccd_value1);
Serial.print("0x");
Serial.println(cccd_value2);
}
void send_callback(uint16_t chars_uuid, uint8_t *send_value)
{
if (chars_uuid == UUID16_CHR_BODY_SENSOR_LOCATION)
{
Serial.println("[Heart Rate - Body Sensor Location Read!]");
Serial.print("chars_uuid: ");
Serial.print("0x");
String uuid_str = String(chars_uuid, HEX);
Serial.println(uuid_str);
Serial.println("");
Serial.print("send value: ");
char send_str = send_value[0];
Serial.println(send_str);
}
}
void setup()
{
//Base 128-bit UUID : B320F8FA-5AFC-4C1B-B96F-16247D912D0A
//--The 3rd and 4th byte 'F8FA' means Service 16bit UUID
uint8_t base_uuid[]={0xB3, 0x20, 0xF8, 0xFA, 0x5A, 0xFC, 0x4C, 0x1B, 0xB9, 0x6F, 0x16, 0x24, 0x7D, 0x91, 0x2D, 0x0A};
Serial.begin(115200);
delay(5000);
Serial.println("RAKwireless BLE Customer Services Example");
Serial.println("------------------------------------------------------");
api.ble.customer.init();
RAKBleService hrms = RAKBleService(base_uuid);
RAKBleCharacteristic bslc = RAKBleCharacteristic(UUID16_CHR_BODY_SENSOR_LOCATION);
hrms.begin();
hrmc.setProperties(RAK_CHR_PROPS_NOTIFY);
hrmc.setPermission(RAK_SET_OPEN);
hrmc.setFixedLen(2);
hrmc.setCccdWriteCallback(cccd_callback);
hrmc.begin();
delay(1000);
uint8_t hrmdata[2] = {0x39, 0x40};
hrmc.notify(hrmdata);
delay(1000);
//Body Sensor Location
// 0 = Other
// 1 = Chest
// 2 = Wrist
// 3 = Finger
// 4 = Hand
// 5 = Ear Lobe
// 6 = Foot
// 7:255 = Reserved
bslc.setProperties(RAK_CHR_PROPS_READ);
bslc.setPermission(RAK_SET_OPEN);
bslc.setFixedLen(1);
bslc.setWriteCallback(send_callback);
bslc.begin();
delay(1000);
uint8_t sensor_location[1] = {'2'};
bslc.write(sensor_location); // Set the characteristic to 'Wrist' (2)
api.ble.customer.start();
}
void loop()
{
}

write()

Data is written by the application to provide the peer connector for read data.

bslc.write(send_data)
NOTE

You should create your own instance to use this API.

RAKBleCharacteristic bslc = RAKBleCharacteristic(characteristicUUID)
Functionvoid write(uint8_t * send_data)
Parameterssend_data - an array to send as a series of bytes
Returnsvoid
Click to view the code
#include "Arduino.h"
#define UUID16_SVC_HEART_RATE 0x180D
#define UUID16_CHR_HEART_RATE_MEASUREMENT 0x2A37
#define UUID16_CHR_BODY_SENSOR_LOCATION 0x2A38
RAKBleCharacteristic hrmc = RAKBleCharacteristic(UUID16_CHR_HEART_RATE_MEASUREMENT);
void cccd_callback(uint16_t chars_uuid, uint8_t *cccd_value)
{
if (chars_uuid == UUID16_CHR_HEART_RATE_MEASUREMENT)
{
if (hrmc.notifyEnabled())
{
Serial.println("[Heart Rate Measurement 'Notify' enabled]");
}
else
{
Serial.println("[Heart Rate Measurement 'Notify' disabled]");
return;
}
}
//Serial.println((char *)cccd_value);
Serial.println("");
Serial.print("chars_uuid: ");
Serial.print("0x");
String uuid_str = String(chars_uuid, HEX);
Serial.println(uuid_str);
Serial.println("notify value:");
String cccd_value1 = String(cccd_value[0], HEX);
String cccd_value2 = String(cccd_value[1], HEX);
Serial.print("0x");
Serial.println(cccd_value1);
Serial.print("0x");
Serial.println(cccd_value2);
}
void send_callback(uint16_t chars_uuid, uint8_t *send_value)
{
if (chars_uuid == UUID16_CHR_BODY_SENSOR_LOCATION)
{
Serial.println("[Heart Rate - Body Sensor Location Read!]");
Serial.print("chars_uuid: ");
Serial.print("0x");
String uuid_str = String(chars_uuid, HEX);
Serial.println(uuid_str);
Serial.println("");
Serial.print("send value: ");
char send_str = send_value[0];
Serial.println(send_str);
}
}
void setup()
{
//Base 128-bit UUID : B320F8FA-5AFC-4C1B-B96F-16247D912D0A
//--The 3rd and 4th byte 'F8FA' means Service 16bit UUID
uint8_t base_uuid[]={0xB3, 0x20, 0xF8, 0xFA, 0x5A, 0xFC, 0x4C, 0x1B, 0xB9, 0x6F, 0x16, 0x24, 0x7D, 0x91, 0x2D, 0x0A};
Serial.begin(115200);
delay(5000);
Serial.println("RAKwireless BLE Customer Services Example");
Serial.println("------------------------------------------------------");
api.ble.customer.init();
RAKBleService hrms = RAKBleService(base_uuid);
RAKBleCharacteristic bslc = RAKBleCharacteristic(UUID16_CHR_BODY_SENSOR_LOCATION);
hrms.begin();
hrmc.setProperties(RAK_CHR_PROPS_NOTIFY);
hrmc.setPermission(RAK_SET_OPEN);
hrmc.setFixedLen(2);
hrmc.setCccdWriteCallback(cccd_callback);
hrmc.begin();
delay(1000);
uint8_t hrmdata[2] = {0x39, 0x40};
hrmc.notify(hrmdata);
delay(1000);
//Body Sensor Location
// 0 = Other
// 1 = Chest
// 2 = Wrist
// 3 = Finger
// 4 = Hand
// 5 = Ear Lobe
// 6 = Foot
// 7:255 = Reserved
bslc.setProperties(RAK_CHR_PROPS_READ);
bslc.setPermission(RAK_SET_OPEN);
bslc.setFixedLen(1);
bslc.setWriteCallback(send_callback);
bslc.begin();
delay(1000);
uint8_t sensor_location[1] = {'2'};
bslc.write(sensor_location); // Set the characteristic to 'Wrist' (2)
api.ble.customer.start();
}
void loop()
{
}

notifyEnabled()

This API confirms whether the current connection has enabled notification.

bslc.notifyEnabled()
NOTE

You should create your own instance to use this API.

RAKBleCharacteristic bslc = RAKBleCharacteristic(characteristicUUID)
Functionbool notifyEnabled(void)
Returnsvoid
Click to view the code
#include "Arduino.h"
#define UUID16_SVC_HEART_RATE 0x180D
#define UUID16_CHR_HEART_RATE_MEASUREMENT 0x2A37
#define UUID16_CHR_BODY_SENSOR_LOCATION 0x2A38
RAKBleCharacteristic hrmc = RAKBleCharacteristic(UUID16_CHR_HEART_RATE_MEASUREMENT);
void cccd_callback(uint16_t chars_uuid, uint8_t *cccd_value)
{
if (chars_uuid == UUID16_CHR_HEART_RATE_MEASUREMENT)
{
if (hrmc.notifyEnabled())
{
Serial.println("[Heart Rate Measurement 'Notify' enabled]");
}
else
{
Serial.println("[Heart Rate Measurement 'Notify' disabled]");
return;
}
}
//Serial.println((char *)cccd_value);
Serial.println("");
Serial.print("chars_uuid: ");
Serial.print("0x");
String uuid_str = String(chars_uuid, HEX);
Serial.println(uuid_str);
Serial.println("notify value:");
String cccd_value1 = String(cccd_value[0], HEX);
String cccd_value2 = String(cccd_value[1], HEX);
Serial.print("0x");
Serial.println(cccd_value1);
Serial.print("0x");
Serial.println(cccd_value2);
}
void send_callback(uint16_t chars_uuid, uint8_t *send_value)
{
if (chars_uuid == UUID16_CHR_BODY_SENSOR_LOCATION)
{
Serial.println("[Heart Rate - Body Sensor Location Read!]");
Serial.print("chars_uuid: ");
Serial.print("0x");
String uuid_str = String(chars_uuid, HEX);
Serial.println(uuid_str);
Serial.println("");
Serial.print("send value: ");
char send_str = send_value[0];
Serial.println(send_str);
}
}
void setup()
{
//Base 128-bit UUID : B320F8FA-5AFC-4C1B-B96F-16247D912D0A
//--The 3rd and 4th byte 'F8FA' means Service 16bit UUID
uint8_t base_uuid[]={0xB3, 0x20, 0xF8, 0xFA, 0x5A, 0xFC, 0x4C, 0x1B, 0xB9, 0x6F, 0x16, 0x24, 0x7D, 0x91, 0x2D, 0x0A};
Serial.begin(115200);
delay(5000);
Serial.println("RAKwireless BLE Customer Services Example");
Serial.println("------------------------------------------------------");
api.ble.customer.init();
RAKBleService hrms = RAKBleService(base_uuid);
RAKBleCharacteristic bslc = RAKBleCharacteristic(UUID16_CHR_BODY_SENSOR_LOCATION);
hrms.begin();
hrmc.setProperties(RAK_CHR_PROPS_NOTIFY);
hrmc.setPermission(RAK_SET_OPEN);
hrmc.setFixedLen(2);
hrmc.setCccdWriteCallback(cccd_callback);
hrmc.begin();
delay(1000);
uint8_t hrmdata[2] = {0x39, 0x40};
hrmc.notify(hrmdata);
delay(1000);
//Body Sensor Location
// 0 = Other
// 1 = Chest
// 2 = Wrist
// 3 = Finger
// 4 = Hand
// 5 = Ear Lobe
// 6 = Foot
// 7:255 = Reserved
bslc.setProperties(RAK_CHR_PROPS_READ);
bslc.setPermission(RAK_SET_OPEN);
bslc.setFixedLen(1);
bslc.setWriteCallback(send_callback);
bslc.begin();
delay(1000);
uint8_t sensor_location[1] = {'2'};
bslc.write(sensor_location); // Set the characteristic to 'Wrist' (2)
api.ble.customer.start();
}
void loop()
{
}

setCccdWriteCallback()

This API is used to register a callback function, so that application can be notified on BLE notify data to peer connector.

bslc.setCccdWriteCallback(userFunc)
NOTE

You should create your own instance to use this API.

RAKBleCharacteristic bslc = RAKBleCharacteristic(characteristicUUID)
Functionvoid setCccdWriteCallback(void(*)(uint16_t, uint8_t *) userFunc)
ParametersuserFunc - callback function
Returnsvoid
Click to view the code
#include "Arduino.h"
#define UUID16_SVC_HEART_RATE 0x180D
#define UUID16_CHR_HEART_RATE_MEASUREMENT 0x2A37
#define UUID16_CHR_BODY_SENSOR_LOCATION 0x2A38
RAKBleCharacteristic hrmc = RAKBleCharacteristic(UUID16_CHR_HEART_RATE_MEASUREMENT);
void cccd_callback(uint16_t chars_uuid, uint8_t *cccd_value)
{
if (chars_uuid == UUID16_CHR_HEART_RATE_MEASUREMENT)
{
if (hrmc.notifyEnabled())
{
Serial.println("[Heart Rate Measurement 'Notify' enabled]");
}
else
{
Serial.println("[Heart Rate Measurement 'Notify' disabled]");
return;
}
}
//Serial.println((char *)cccd_value);
Serial.println("");
Serial.print("chars_uuid: ");
Serial.print("0x");
String uuid_str = String(chars_uuid, HEX);
Serial.println(uuid_str);
Serial.println("notify value:");
String cccd_value1 = String(cccd_value[0], HEX);
String cccd_value2 = String(cccd_value[1], HEX);
Serial.print("0x");
Serial.println(cccd_value1);
Serial.print("0x");
Serial.println(cccd_value2);
}
void send_callback(uint16_t chars_uuid, uint8_t *send_value)
{
if (chars_uuid == UUID16_CHR_BODY_SENSOR_LOCATION)
{
Serial.println("[Heart Rate - Body Sensor Location Read!]");
Serial.print("chars_uuid: ");
Serial.print("0x");
String uuid_str = String(chars_uuid, HEX);
Serial.println(uuid_str);
Serial.println("");
Serial.print("send value: ");
char send_str = send_value[0];
Serial.println(send_str);
}
}
void setup()
{
//Base 128-bit UUID : B320F8FA-5AFC-4C1B-B96F-16247D912D0A
//--The 3rd and 4th byte 'F8FA' means Service 16bit UUID
uint8_t base_uuid[]={0xB3, 0x20, 0xF8, 0xFA, 0x5A, 0xFC, 0x4C, 0x1B, 0xB9, 0x6F, 0x16, 0x24, 0x7D, 0x91, 0x2D, 0x0A};
Serial.begin(115200);
delay(5000);
Serial.println("RAKwireless BLE Customer Services Example");
Serial.println("------------------------------------------------------");
api.ble.customer.init();
RAKBleService hrms = RAKBleService(base_uuid);
RAKBleCharacteristic bslc = RAKBleCharacteristic(UUID16_CHR_BODY_SENSOR_LOCATION);
hrms.begin();
hrmc.setProperties(RAK_CHR_PROPS_NOTIFY);
hrmc.setPermission(RAK_SET_OPEN);
hrmc.setFixedLen(2);
hrmc.setCccdWriteCallback(cccd_callback);
hrmc.begin();
delay(1000);
uint8_t hrmdata[2] = {0x39, 0x40};
hrmc.notify(hrmdata);
delay(1000);
//Body Sensor Location
// 0 = Other
// 1 = Chest
// 2 = Wrist
// 3 = Finger
// 4 = Hand
// 5 = Ear Lobe
// 6 = Foot
// 7:255 = Reserved
bslc.setProperties(RAK_CHR_PROPS_READ);
bslc.setPermission(RAK_SET_OPEN);
bslc.setFixedLen(1);
bslc.setWriteCallback(send_callback);
bslc.begin();
delay(1000);
uint8_t sensor_location[1] = {'2'};
bslc.write(sensor_location); // Set the characteristic to 'Wrist' (2)
api.ble.customer.start();
}
void loop()
{
}

setWriteCallback()

This API is used to register a callback function so that the application can trigger a notification event when the peer connector reads data. (Data is written by the application and ready to be read.)

bslc.setWriteCallback(userFunc)
NOTE

You should create your own instance to use this API.

RAKBleCharacteristic bslc = RAKBleCharacteristic(characteristicUUID)
Functionvoid setWriteCallback(void(*)(uint16_t, uint8_t *) userFunc)
ParametersuserFunc - callback function
Returnsvoid
Click to view the code
#include "Arduino.h"
#define UUID16_SVC_HEART_RATE 0x180D
#define UUID16_CHR_HEART_RATE_MEASUREMENT 0x2A37
#define UUID16_CHR_BODY_SENSOR_LOCATION 0x2A38
RAKBleCharacteristic hrmc = RAKBleCharacteristic(UUID16_CHR_HEART_RATE_MEASUREMENT);
void cccd_callback(uint16_t chars_uuid, uint8_t *cccd_value)
{
if (chars_uuid == UUID16_CHR_HEART_RATE_MEASUREMENT)
{
if (hrmc.notifyEnabled())
{
Serial.println("[Heart Rate Measurement 'Notify' enabled]");
}
else
{
Serial.println("[Heart Rate Measurement 'Notify' disabled]");
return;
}
}
//Serial.println((char *)cccd_value);
Serial.println("");
Serial.print("chars_uuid: ");
Serial.print("0x");
String uuid_str = String(chars_uuid, HEX);
Serial.println(uuid_str);
Serial.println("notify value:");
String cccd_value1 = String(cccd_value[0], HEX);
String cccd_value2 = String(cccd_value[1], HEX);
Serial.print("0x");
Serial.println(cccd_value1);
Serial.print("0x");
Serial.println(cccd_value2);
}
void send_callback(uint16_t chars_uuid, uint8_t *send_value)
{
if (chars_uuid == UUID16_CHR_BODY_SENSOR_LOCATION)
{
Serial.println("[Heart Rate - Body Sensor Location Read!]");
Serial.print("chars_uuid: ");
Serial.print("0x");
String uuid_str = String(chars_uuid, HEX);
Serial.println(uuid_str);
Serial.println("");
Serial.print("send value: ");
char send_str = send_value[0];
Serial.println(send_str);
}
}
void setup()
{
//Base 128-bit UUID : B320F8FA-5AFC-4C1B-B96F-16247D912D0A
//--The 3rd and 4th byte 'F8FA' means Service 16bit UUID
uint8_t base_uuid[]={0xB3, 0x20, 0xF8, 0xFA, 0x5A, 0xFC, 0x4C, 0x1B, 0xB9, 0x6F, 0x16, 0x24, 0x7D, 0x91, 0x2D, 0x0A};
Serial.begin(115200);
delay(5000);
Serial.println("RAKwireless BLE Customer Services Example");
Serial.println("------------------------------------------------------");
api.ble.customer.init();
RAKBleService hrms = RAKBleService(base_uuid);
RAKBleCharacteristic bslc = RAKBleCharacteristic(UUID16_CHR_BODY_SENSOR_LOCATION);
hrms.begin();
hrmc.setProperties(RAK_CHR_PROPS_NOTIFY);
hrmc.setPermission(RAK_SET_OPEN);
hrmc.setFixedLen(2);
hrmc.setCccdWriteCallback(cccd_callback);
hrmc.begin();
delay(1000);
uint8_t hrmdata[2] = {0x39, 0x40};
hrmc.notify(hrmdata);
delay(1000);
//Body Sensor Location
// 0 = Other
// 1 = Chest
// 2 = Wrist
// 3 = Finger
// 4 = Hand
// 5 = Ear Lobe
// 6 = Foot
// 7:255 = Reserved
bslc.setProperties(RAK_CHR_PROPS_READ);
bslc.setPermission(RAK_SET_OPEN);
bslc.setFixedLen(1);
bslc.setWriteCallback(send_callback);
bslc.begin();
delay(1000);
uint8_t sensor_location[1] = {'2'};
bslc.write(sensor_location); // Set the characteristic to 'Wrist' (2)
api.ble.customer.start();
}
void loop()
{
}

RAKBleCustomer

init()

This API initializes the basic work of BLE custom services.

api.ble.customer.init()
Functionvoid init()
Returnsvoid

start()

After completing all the services and characteristic settings, start the custom services.

api.ble.customer.start()
Functionvoid start()
Returnsvoid