Comments (4)
Just for the record I have been using this extension to DiscoveredCharacteristics, which is very similar to your proposed DiscoveredCharacteristic::enableNotification():
ble_error_t
DiscoveredCharacteristic::requestHVX(HVXType_t type) const
{
if (!props.write()) {
return BLE_ERROR_OPERATION_NOT_PERMITTED;
}
if (!props.notify()) {
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));
}
I know it doesn't solve the real problem of descriptor discovery, but it does hide away the hack to somewhere that they can be worked on without effecting user code.
from ble.
And, of course, having posted that I see that the second test in not correct for indications, that have their own property. But you get the idea.
from ble.
Update, this is what I'm currently using:
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));
}
from ble.
ARM Internal Ref: IOTSFW-1033
from ble.
Related Issues (20)
- AdvertisementCallbackParams_t should include addressType for the peerAddr HOT 3
- GapState_t missing information? HOT 2
- GapAdvertisingData using deprecated type aliases HOT 1
- Time unit inconsistencies in GapScanningParams HOT 1
- Duplicated functionality in GapAdvertisingParams and GapScanningParams HOT 1
- BLE.h conflict with Nordic SDK ble.h HOT 5
- Using ANCS HOT 3
- Add error handling to GattClient procedures HOT 3
- Will we support BLE profiles? HOT 2
- "connection parameters update request" CALLBACK IS MISSING FROM MBED STACK HOT 12
- Possible Ticker BLE_API conflict causing problems with Nordic devices? HOT 7
- Link to documentation from README is broken
- NRF_52 Development Kit notification events don't fire on the central, when peripheral data changes HOT 24
- Linker error when using the Nordics Experimental Flash Data Storage API's. HOT 1
- NRF5: Byte order of characteristics with multi-byte data types incorrect HOT 4
- please implement missing key features HOT 1
- X-Nucleo-IDB05A1 Not Working HOT 4
- Can I control the channel the device is advertising on with this API?
- How to call BLE APIs from the board to host side using icetea?
- #include "mbed.h" where is it??? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ble.