microbit: Persistance of BLE Service Chnaged metadata
BLE maintains metadata on its characterisitics, some of which record whether or not a central device (phone/tablet) wishes to receive notifications when a given BLE characteristic changes value. One such characterisitic is used as part of a core BLE service to indicate of the BLE profile of a device has changed. IOS is heavily reliant on this feature, and expects the state of this metadata to be persistent across device reboots. This patch ensures that this metadata is always set to allow Service Changed indications to be propagated to central devices.
This commit is contained in:
parent
6a7436e5c7
commit
99d7231945
1 changed files with 9 additions and 1 deletions
|
@ -52,7 +52,6 @@ static void bleDisconnectionCallback(const Gap::DisconnectionCallbackParams_t *r
|
|||
|
||||
if (manager)
|
||||
manager->advertise();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -60,7 +59,16 @@ static void bleDisconnectionCallback(const Gap::DisconnectionCallbackParams_t *r
|
|||
*/
|
||||
static void bleConnectionCallback(const Gap::ConnectionCallbackParams_t *reason)
|
||||
{
|
||||
|
||||
// Ensure that there's no stale, cached information in the client... invalidate all characteristics.
|
||||
uint16_t len = 8;
|
||||
|
||||
// Configure the ServiceChanged characteristic to receive service changed indications
|
||||
// TODO: This is really a workaround as we can't maintain persistent state on the micro:bit across USB
|
||||
// reprogramming flashes.... yet.
|
||||
uint8_t data[] = {0x0B,0x00,0x02,0x00,0x02,0x00,0xB8,0x46};
|
||||
|
||||
sd_ble_gatts_sys_attr_set(reason->handle, data, len, BLE_GATTS_SYS_ATTR_FLAG_SYS_SRVCS);
|
||||
sd_ble_gatts_service_changed(reason->handle, 0x000c, 0xffff);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue