Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of BLE_API by
Revision 1201:6dd8b141406e, committed 2016-07-08
- Comitter:
- marfife
- Date:
- Fri Jul 08 23:39:31 2016 +0000
- Parent:
- 1200:66159681aa21
- Commit message:
- init
Changed in this revision
--- a/ble/DiscoveredCharacteristic.h Wed Apr 06 19:16:08 2016 +0100
+++ b/ble/DiscoveredCharacteristic.h Fri Jul 08 23:39:31 2016 +0000
@@ -260,6 +260,20 @@
* BLE_ERROR_OPERATION_NOT_PERMITTED due to the characteristic's properties.
*/
ble_error_t write(uint16_t length, const uint8_t *value, const GattClient::WriteCallback_t& onWrite) const;
+
+ /**
+ * Request Server to send notify/inform messages for the characteristic
+ *
+ * @param type
+ * BLE_HVX_NOTIFICATION or BLE_HVX_INDICATION.
+ *
+ * @retval BLE_ERROR_NONE Successfully requested notification/informa messages
+ * BLE_ERROR_INVALID_STATE if some internal state about the connection is invalid, or
+ * BLE_STACK_BUSY if some client procedure already in progress, or
+ * BLE_ERROR_NO_MEM if there are no available buffers left to process the request, or
+ * BLE_ERROR_OPERATION_NOT_PERMITTED due to the characteristic's properties.
+ */
+ ble_error_t requestHVX(HVXType_t type) const;
void setupLongUUID(UUID::LongUUIDBytes_t longUUID, UUID::ByteOrder_t order = UUID::MSB) {
uuid.setupLong(longUUID, order);
--- a/ble/Gap.h Wed Apr 06 19:16:08 2016 +0100
+++ b/ble/Gap.h Fri Jul 08 23:39:31 2016 +0000
@@ -198,6 +198,7 @@
*/
struct AdvertisementCallbackParams_t {
BLEProtocol::AddressBytes_t peerAddr; /**< The peer's BLE address. */
+// BLEProtocol::AddressType_t peerAddrType; /**< The peer's BLE address type. */
int8_t rssi; /**< The advertisement packet RSSI value. */
bool isScanResponse; /**< Whether this packet is the response to a scan request. */
GapAdvertisingParams::AdvertisingType_t type; /**< The type of advertisement. */
@@ -1812,6 +1813,7 @@
* Pointer to the advertisement packet's data.
*/
void processAdvertisementReport(const BLEProtocol::AddressBytes_t peerAddr,
+// BLEProtocol::AddressType_t peerAddrType,
int8_t rssi,
bool isScanResponse,
GapAdvertisingParams::AdvertisingType_t type,
@@ -1819,6 +1821,7 @@
const uint8_t *advertisingData) {
AdvertisementCallbackParams_t params;
memcpy(params.peerAddr, peerAddr, ADDR_LEN);
+// params.peerAddrType = peerAddrType;
params.rssi = rssi;
params.isScanResponse = isScanResponse;
params.type = type;
--- 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) {
