Go Down

Topic: Set Advertising to Service Data GAP type 0x16 for Eddystone (Read 551 times) previous topic - next topic


How do I set Advertising to Service Data GAP type 0x16 for Eddystone Broadcasting instead of Type 0x09 (Complete Local Name)?

I am making my Arduino 101 an Eddystone Beacon. I've looked over the history in the GitHub repo, and I think I'm close. I'm not sure how to cause the Advertising Type to switch from 0x09 to 0x16. I think the solution is in the Characteristic constructor. I am using the same UUID as I use for the Service ("FEAA") as the UUID for the Characteristic, but I don't know if that repetition of the Eddystone UUID in the Characteristic as well as in the Service is correct.

BLECharacteristic characteristic( "FEAA", BLEBroadcast, 20 );

Using the nRF Connect app for Android I can confirm that the device is Advertising, but clicking the *RAW* button reveals that the advertising data is being broadcast as TYPE 0x09 (Complete Local Name) instead of 0x16 (Service Data), as specified in the GAP Spec: https://www.bluetooth.com/specifications/assigned-numbers/generic-access-profile
I looked at the source in GitHub and the only place  BLEDeviceManager::instance()->setAdvertisedServiceData is called is in BLECharacteristic::writeValue.

I'm calling characteristic.writeValue and characteristic.broadcast() every 1000 ms in my loop method.

I've installed the Board Manager for Curie 2.0.2 and Libaray CurieBLE 2.0.0

I see that @bneedhamia did work to set the advertising data to Service Data last year and that work was added to the official repo but later removed, I think when BLEPeripheral was deprecated.


Solution: you must not set a local name with BLE.setLocalName (and a few other quirks listed below).

See my GitHub repo for a working EddystoneURL sample:

_advDataInit  method
checks if _local_name.length() > 0 and then sets the advertisement data 
next, when it checks _service_data_length > 0 it finds that there's not enough space so it doesn't add the Service Data.

A few other quirks:
-- Use Eddystone UUID ("FEAA") for both Service and Characteristic 
-- Only BLEBroadcast property is required in second BLECharacteristic constructor parameter (omit BLERead and BLEWrite if you prefer)
-- Be sure the third parameter in the BLECharacteristic constructor, valueSize, is at least as long as the Service Data array or the Service Data will be truncated
-- Do not set a Local Name for the BLE. If you do it prevents the advertisement from being configured as type ServiceData.
-- You must call characteristic.broadcast();
-- You must call characteristic.writeValue *after* calling characteristic.broadcast

Go Up