8 years, 8 months ago.

Updating parameter of Payload during BLE advertisement.

Hello everybody,

My question is about BLE Advertising (GAP) I've followed the manual attached below but I'm interested to update the value of the param during advertising. Is that possible?

I mean can I stop the advertising, update value of one or two variables and start the advertising again.

Steps: 1.- Stop advertising ble.stopAdvertising();

2.- for example: according to the variable of manual, to change the value of the param from this advData [] = {0x01,0x02,0x03,0x04,0x05}; to advData[] = {0x11,0x12,0x11,0x14,0x15}; or other any value. ble.updateAdvertisingPayload(GapAdvertisingData::MANUFACTURER_SPECIFIC_DATA, advData, sizeof(advData));

3.- Start advertising. ble.startAdvertising();

Mbed tutorial : http://docs.mbed.org/docs/ble-intros/en/latest/AdvSamples/CustomGAP/

thanks in advance.

Question relating to:

BLE Nano is the smallest Bluetooth 4.1 Low Energy (BLE) development board in the market. The core is Nordic nRF51822 (an ARM Cortex-M0 SoC plus BLE capability) running at 16MHz …

1 Answer

8 years, 7 months ago.

I can not found Advertisement Payload update method, but Advertisement Payload clear method is present. So you should do on phase 2...

2': call clearAdvertisingPayload() method and completely regenerate Advertising Payload (You should call accumulateAdvertisingPayload(), setAdvertisingType() etc you needed).

Accepted Answer

you're right, in fact, I found the solution a couple of weeks ago by myself.

here a piece of code.

void resetAdvertisingBLE( BLE *ble, uint8_t valueSensor[]) { if(debug) printf(" Reseteando BLE.\n");

(*ble).stopAdvertising(); (*ble).clearAdvertisingPayload(); setup advertising (*ble).accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LOCAL_NAME, (uint8_t *)DEVICE_NAME, sizeof(DEVICE_NAME)); add name (*ble).accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LIST_16BIT_SERVICE_IDS, (uint8_t *)uuid16_list, sizeof(uuid16_list)); UUID's broadcast in advertising packet (*ble).accumulateAdvertisingPayload(GapAdvertisingData::MANUFACTURER_SPECIFIC_DATA, valueSensor, sizeof(valueSensor)); (*ble).setAdvertisingInterval(ADVERTISING_TIME);

start advertising (*ble).startAdvertising(); } watch out with reset BLE in that case you'll have a error not easy to debug.

posted by Miguel Alarcón Ortiz 23 Aug 2015