SimpleBLE example for mbed OS 5
Dependents: SimpleBLE-Example-mbedos5
Fork of SimpleBLE by
Diff: SimpleBLE.h
- Revision:
- 6:15ec6cd75928
- Parent:
- 5:9b33cae085cc
- Child:
- 8:450b780bb1de
diff -r 9b33cae085cc -r 15ec6cd75928 SimpleBLE.h --- a/SimpleBLE.h Mon Oct 10 12:12:21 2016 +0200 +++ b/SimpleBLE.h Mon Oct 10 12:43:15 2016 +0200 @@ -177,10 +177,6 @@ ble->init(this, &SimpleBLE::bleInitComplete); } - void onDisconnection(Gap::DisconnectionEventCallback_t callback) { - ble->gap().onDisconnection(callback); - } - void onConnection(Gap::ConnectionEventCallback_t callback) { ble->gap().onConnection(callback); } @@ -256,6 +252,8 @@ } } + ble.gap().onDisconnection(Gap::DisconnectionEventCallback_t(this, &SimpleBLE::disconnectionCallback)); + ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::BREDR_NOT_SUPPORTED | GapAdvertisingData::LE_GENERAL_DISCOVERABLE); ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LIST_16BIT_SERVICE_IDS, (uint8_t *)uuid16_list, uuid16_counter); ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LIST_128BIT_SERVICE_IDS, (uint8_t *)uuid128_list, uuid128_counter); @@ -267,6 +265,11 @@ if (logging) printf("Started advertising\r\n"); } + void disconnectionCallback(const Gap::DisconnectionCallbackParams_t *params) + { + BLE::Instance().gap().startAdvertising(); // restart advertising + } + void onDataWrittenCallback(const GattWriteCallbackParams *params) { // see if we know for which char this message is... typedef std::map<GattCharacteristic*, Updatable* >::iterator it_type;