microbit: Added read capability to MicroBitDFUService::ControlPoint characteristic

Whilst Android devices permit explicit initiation of the BLE pairing process,
IOS based devices are only  capable of implicit initiation of pairing based
on accessing a protected characteristic. Adding read capability to the
ControlPoint characteristic provides a safe and convenient way for IOS devices
to initiate pairing.
This commit is contained in:
Joe Finney 2016-01-04 23:41:22 +00:00
parent 7a71b58bd4
commit e1f75b2c4c

View file

@ -44,7 +44,8 @@ MicroBitDFUService::MicroBitDFUService(BLEDevice &_ble) :
ble(_ble)
{
// Opcodes can be issued here to control the MicroBitDFU Service, as defined above.
WriteOnlyGattCharacteristic<uint8_t> microBitDFUServiceControlCharacteristic(MicroBitDFUServiceControlCharacteristicUUID, &controlByte);
GattCharacteristic microBitDFUServiceControlCharacteristic(MicroBitDFUServiceControlCharacteristicUUID, &controlByte, 0, sizeof(uint8_t),
GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_READ | GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_WRITE);
controlByte = 0x00;
@ -58,6 +59,7 @@ MicroBitDFUService::MicroBitDFUService(BLEDevice &_ble) :
microBitDFUServiceControlCharacteristicHandle = microBitDFUServiceControlCharacteristic.getValueHandle();
ble.gattServer().write(microBitDFUServiceControlCharacteristicHandle, &controlByte, sizeof(uint8_t));
ble.gattServer().onDataWritten(this, &MicroBitDFUService::onDataWritten);
}