setup save of GattClient pointer in DiscoveredClient
parent
5a4e62f169
commit
f49e3469ae
|
@ -56,7 +56,7 @@ void bleGattcEventHandler(const ble_evt_t *p_ble_evt)
|
|||
|
||||
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,
|
||||
|
|
|
@ -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;
|
||||
}
|
|
@ -120,7 +120,7 @@ public:
|
|||
}
|
||||
|
||||
public:
|
||||
nRF51GattClient() { /* need a default constructor because we've added a private copy constructor */
|
||||
nRF51GattClient() : discovery(this) {
|
||||
/* empty */
|
||||
}
|
||||
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -91,13 +91,13 @@ nRFServiceDiscovery::setupDiscoveredCharacteristics(const ble_gattc_evt_char_dis
|
|||
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,
|
||||
|
|
|
@ -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 @@ public:
|
|||
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 */
|
||||
}
|
||||
|
||||
|
@ -270,6 +275,9 @@ private:
|
|||
void progressCharacteristicDiscovery(void);
|
||||
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.*/
|
||||
|
|
Loading…
Reference in New Issue