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 nRF51822 by
Revision 333:8eedcd324853, committed 2015-06-19
- Comitter:
- rgrover1
- Date:
- Fri Jun 19 15:55:32 2015 +0100
- Parent:
- 332:b054000833d4
- Child:
- 334:5dcd58729c5b
- Commit message:
- Synchronized with git rev f49e3469
Author: Rohit Grover
setup save of GattClient pointer in DiscoveredClient
Changed in this revision
--- a/btle/btle_discovery.cpp Fri Jun 19 15:55:32 2015 +0100
+++ b/btle/btle_discovery.cpp Fri Jun 19 15:55:32 2015 +0100
@@ -56,7 +56,7 @@
case BLE_GATTC_EVT_READ_RSP:
if (DiscoveredCharacteristic::onDataReadCallback != NULL) {
- DiscoveredCharacteristic::ReadResponse_t response = {
+ GattClient::ReadResponse_t response = {
.handle = p_ble_evt->evt.gattc_evt.params.read_rsp.handle,
.offset = p_ble_evt->evt.gattc_evt.params.read_rsp.offset,
.len = p_ble_evt->evt.gattc_evt.params.read_rsp.len,
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/nRF51DiscoveredCharacteristic.cpp Fri Jun 19 15:55:32 2015 +0100
@@ -0,0 +1,63 @@
+/* mbed Microcontroller Library
+ * Copyright (c) 2006-2013 ARM Limited
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "nRFDiscoveredCharacteristic.h"
+#include "nRF51GattClient.h"
+#include "ble_gatt.h"
+
+void
+nRFDiscoveredCharacteristic::setup(nRF51GattClient *gattcIn,
+ Gap::Handle_t connectionHandleIn,
+ ble_gatt_char_props_t propsIn,
+ GattAttribute::Handle_t declHandleIn,
+ GattAttribute::Handle_t valueHandleIn)
+{
+ gattc = gattcIn;
+ connHandle = connectionHandleIn;
+ declHandle = declHandleIn;
+ valueHandle = valueHandleIn;
+
+ props._broadcast = propsIn.broadcast;
+ props._read = propsIn.read;
+ props._writeWoResp = propsIn.write_wo_resp;
+ props._write = propsIn.write;
+ props._notify = propsIn.notify;
+ props._indicate = propsIn.indicate;
+ props._authSignedWrite = propsIn.auth_signed_wr;
+}
+
+void
+nRFDiscoveredCharacteristic::setup(nRF51GattClient *gattcIn,
+ Gap::Handle_t connectionHandleIn,
+ UUID::ShortUUIDBytes_t uuidIn,
+ ble_gatt_char_props_t propsIn,
+ GattAttribute::Handle_t declHandleIn,
+ GattAttribute::Handle_t valueHandleIn)
+{
+ gattc = gattcIn;
+ connHandle = connectionHandleIn;
+ uuid = uuidIn;
+ declHandle = declHandleIn;
+ valueHandle = valueHandleIn;
+
+ props._broadcast = propsIn.broadcast;
+ props._read = propsIn.read;
+ props._writeWoResp = propsIn.write_wo_resp;
+ props._write = propsIn.write;
+ props._notify = propsIn.notify;
+ props._indicate = propsIn.indicate;
+ props._authSignedWrite = propsIn.auth_signed_wr;
+}
\ No newline at end of file
--- a/nRF51GattClient.h Fri Jun 19 15:55:32 2015 +0100
+++ b/nRF51GattClient.h Fri Jun 19 15:55:32 2015 +0100
@@ -120,7 +120,7 @@
}
public:
- nRF51GattClient() { /* need a default constructor because we've added a private copy constructor */
+ nRF51GattClient() : discovery(this) {
/* empty */
}
--- a/nRFDiscoveredCharacteristic.h Fri Jun 19 15:55:32 2015 +0100
+++ b/nRFDiscoveredCharacteristic.h Fri Jun 19 15:55:32 2015 +0100
@@ -17,49 +17,25 @@
#ifndef __NRF_DISCOVERED_CHARACTERISTIC_H__
#define __NRF_DISCOVERED_CHARACTERISTIC_H__
+#include "DiscoveredCharacteristic.h"
#include "ble_gatt.h"
+class nRF51GattClient; /* forward declaration */
+
class nRFDiscoveredCharacteristic : public DiscoveredCharacteristic {
public:
- void setup(GattClient *gattcIn,
+ void setup(nRF51GattClient *gattcIn,
Gap::Handle_t connectionHandleIn,
ble_gatt_char_props_t propsIn,
GattAttribute::Handle_t declHandleIn,
- GattAttribute::Handle_t valueHandleIn) {
- gattc = gattcIn;
- connHandle = connectionHandleIn;
- declHandle = declHandleIn;
- valueHandle = valueHandleIn;
+ GattAttribute::Handle_t valueHandleIn);
- props._broadcast = propsIn.broadcast;
- props._read = propsIn.read;
- props._writeWoResp = propsIn.write_wo_resp;
- props._write = propsIn.write;
- props._notify = propsIn.notify;
- props._indicate = propsIn.indicate;
- props._authSignedWrite = propsIn.auth_signed_wr;
- }
-
- void setup(GattClient *gattcIn,
+ void setup(nRF51GattClient *gattcIn,
Gap::Handle_t connectionHandleIn,
UUID::ShortUUIDBytes_t uuidIn,
ble_gatt_char_props_t propsIn,
GattAttribute::Handle_t declHandleIn,
- GattAttribute::Handle_t valueHandleIn) {
- gattc = gattcIn;
- connHandle = connectionHandleIn;
- uuid = uuidIn;
- declHandle = declHandleIn;
- valueHandle = valueHandleIn;
-
- props._broadcast = propsIn.broadcast;
- props._read = propsIn.read;
- props._writeWoResp = propsIn.write_wo_resp;
- props._write = propsIn.write;
- props._notify = propsIn.notify;
- props._indicate = propsIn.indicate;
- props._authSignedWrite = propsIn.auth_signed_wr;
- }
+ GattAttribute::Handle_t valueHandleIn);
#if 0
public:
--- a/nRFServiceDiscovery.cpp Fri Jun 19 15:55:32 2015 +0100
+++ b/nRFServiceDiscovery.cpp Fri Jun 19 15:55:32 2015 +0100
@@ -91,13 +91,13 @@
for (unsigned charIndex = 0; charIndex < numCharacteristics; charIndex++) {
if (response->chars[charIndex].uuid.type == BLE_UUID_TYPE_UNKNOWN) {
charUUIDDiscoveryQueue.enqueue(charIndex);
- characteristics[charIndex].setup(NULL, /* gattc FIX THIS */
+ characteristics[charIndex].setup(gattc,
connHandle,
response->chars[charIndex].char_props,
response->chars[charIndex].handle_decl,
response->chars[charIndex].handle_value);
} else {
- characteristics[charIndex].setup(NULL, /* gattc FIX THIS */
+ characteristics[charIndex].setup(gattc,
connHandle,
response->chars[charIndex].uuid.uuid,
response->chars[charIndex].char_props,
--- a/nRFServiceDiscovery.h Fri Jun 19 15:55:32 2015 +0100
+++ b/nRFServiceDiscovery.h Fri Jun 19 15:55:32 2015 +0100
@@ -18,11 +18,14 @@
#define __NRF_SERVICE_DISCOVERY_H__
#include "ServiceDiscovery.h"
+#include "DiscoveredService.h"
#include "nRFDiscoveredCharacteristic.h"
#include "ble.h"
#include "ble_gattc.h"
+class nRF51GattClient; /* forward declaration */
+
class nRFServiceDiscovery : public ServiceDiscovery
{
public:
@@ -34,16 +37,18 @@
static const unsigned BLE_DB_DISCOVERY_MAX_CHAR_PER_SRV = 4; /**< Maximum number of characteristics per service we can retain information for. */
public:
- nRFServiceDiscovery() : serviceIndex(0),
- numServices(0),
- characteristicIndex(0),
- numCharacteristics(0),
- state(INACTIVE),
- services(),
- characteristics(),
- serviceUUIDDiscoveryQueue(this),
- charUUIDDiscoveryQueue(this),
- onTerminationCallback(NULL) {
+ nRFServiceDiscovery(nRF51GattClient *gattcIn) :
+ gattc(gattcIn),
+ serviceIndex(0),
+ numServices(0),
+ characteristicIndex(0),
+ numCharacteristics(0),
+ state(INACTIVE),
+ services(),
+ characteristics(),
+ serviceUUIDDiscoveryQueue(this),
+ charUUIDDiscoveryQueue(this),
+ onTerminationCallback(NULL) {
/* empty */
}
@@ -271,6 +276,9 @@
void progressServiceDiscovery(void);
private:
+ nRF51GattClient *gattc;
+
+private:
uint8_t serviceIndex; /**< Index of the current service being discovered. This is intended for internal use during service discovery.*/
uint8_t numServices; /**< Number of services at the peers GATT database.*/
uint8_t characteristicIndex; /**< Index of the current characteristic being discovered. This is intended for internal use during service discovery.*/
