fork BLE_API to add update adv payload API
Fork of BLE_API by
Diff: ble/Gap.h
- Revision:
- 758:ce45c506a779
- Parent:
- 754:9b391fb5c5d7
--- a/ble/Gap.h Tue Jul 21 13:25:40 2015 +0100 +++ b/ble/Gap.h Fri Jul 31 09:09:50 2015 +0000 @@ -586,6 +586,27 @@ } /** + * Update the advertising payload filed which has the same adv type as the input + * parameter. Total length of the new data must be the same as the old one. + * + * @param type The type which describes the variable length data. + * @param data data bytes. + * @param len length of data. + */ + ble_error_t updateAdvertisingPayload(GapAdvertisingData::DataType type, const uint8_t *data, uint8_t len) { + if (type == GapAdvertisingData::COMPLETE_LOCAL_NAME) { + setDeviceName(data); + } + + ble_error_t rc; + if ((rc = _advPayload.updateData(type, data, len)) != BLE_ERROR_NONE) { + return rc; + } + + return setAdvertisingData(); + } + + /** * Setup a particular, user-constructed advertisement payload for the * underlying stack. It would be uncommon for this API to be used directly; * there are other APIs to build an advertisement payload (see above).