RAK11720 BLE beacon

I need to use my RAK11720 in beacon mode but with plain text, for example, ‘Hello World!’ without any Eddystone mode configured. Is there a way to make it work by loading the custom beacon payload? The problem is that if I don’t configure any of the Eddystone modes, the RAK doesn’t start the beacon. The issue is that the program loads onto the board, but the service doesn’t star!

example code:

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

api.ble.settings.blemode(RAK_BLE_BEACON_MODE);

uint8_t payload[10] = { '<', 'T', 'P', 'K', ':', '1', '2', '3', '4', '>' };

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

api.ble.advertise.start(0);

}
void loop()
{
}

Hello Andres,

Please check with following code. I prepared a payload for you.

uint8_t payload[] = {
    0x02, 0x01, // BLE specific constants
    0x06, // Flags
    0x0D, // Length (13-byte)
    0xFF, // Manufacturer specific data flag (1-byte)
    0xFF, 0xFE, // Company ID (0xFEFF) (2-byte)
    // Custom data packet (10-byte)
    '<', 'T', 'P', 'K', ':', '1', '2', '3', '4', '>' };

void setup()
{
    bool ret;

    uint32_t baudrate = Serial.getBaudrate();
    Serial.begin(baudrate);
    Serial6.begin(baudrate, RAK_AT_MODE); // BLE Serial
      
    Serial.println("RAKwireless RAK11720");
    Serial.println("------------------------------------------------------");

    api.ble.settings.blemode(RAK_BLE_BEACON_MODE);

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

    api.ble.advertise.start(0);
}

void loop()
{
}

Best regards,
Sercan.

1 Like

If I want to modify the payload, for example, 15 bytes, do I change byte 4 (length) to the new length? But should I add the manufacturer bytes and the 2 company ID bytes? Or should I only consider the 15 bytes in my payload?

For BLE advertisement, the rule is like that length, flag and data. For example,
0x02 → length (next two byte related to this frame)
0x01 → flag
0x06 → data

0x05 → length (1-byte for flag, 4-byte for data)
0xFF → flag
0x01, 0x02, 0x03, 0x04 → (0x01,0x02 - company id), (0x03, 0x04 - manufacturer data)

So, you must set byte 4 (length) according to the new length.

Thanks.