Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
9 years, 4 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:
1 Answer
9 years, 3 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).
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 23 Aug 2015