just a fork
Fork of BLE_API by
Diff: source/DiscoveredCharacteristic.cpp
- Revision:
- 1201:6dd8b141406e
- Parent:
- 1135:22aada733dbd
--- a/source/DiscoveredCharacteristic.cpp Wed Apr 06 19:16:08 2016 +0100 +++ b/source/DiscoveredCharacteristic.cpp Fri Jul 08 23:39:31 2016 +0000 @@ -105,6 +105,28 @@ return gattc->write(GattClient::GATT_OP_WRITE_CMD, connHandle, valueHandle, length, value); } +ble_error_t +DiscoveredCharacteristic::requestHVX(HVXType_t type) const +{ + if (type == BLE_HVX_NOTIFICATION && !props.notify()) { + return BLE_ERROR_OPERATION_NOT_PERMITTED; + } + + if (type == BLE_HVX_INDICATION && !props.indicate()) { + return BLE_ERROR_OPERATION_NOT_PERMITTED; + } + + if (!gattc) { + return BLE_ERROR_INVALID_STATE; + } + + /* Cargo Culted from: https://developer.mbed.org/teams/Bluetooth-Low-Energy/code/BLE_ButtonSense/file/2dec89c76f68/main.cpp */ + /* HACK. We're assuming that CCCD descriptor immediately follows the value attribute. */ + /* TODO actually discover the handle for the CCCD descriptor */ + uint16_t value = (uint16_t)type; + return gattc->write(GattClient::GATT_OP_WRITE_REQ, connHandle, valueHandle + 1, sizeof(value), (const uint8_t*)(&value)); +} + struct OneShotWriteCallback { static void launch(GattClient* client, Gap::Handle_t connHandle, GattAttribute::Handle_t handle, const GattClient::WriteCallback_t& cb) {