commit
0e70683f81
@ -0,0 +1,99 @@
|
||||
/* mbed Microcontroller Library
|
||||
* Copyright (c) 2006-2015 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.
|
||||
*/
|
||||
|
||||
#ifndef __CHARACTERISTIC_DESCRIPTOR_DISCOVERY_H__
|
||||
#define __CHARACTERISTIC_DESCRIPTOR_DISCOVERY_H__
|
||||
|
||||
#include "FunctionPointerWithContext.h"
|
||||
|
||||
class DiscoveredCharacteristic; // forward declaration
|
||||
class DiscoveredCharacteristicDescriptor; // forward declaration
|
||||
|
||||
/**
|
||||
* @brief Contain all definitions of callbacks and callbacks parameters types
|
||||
* related to characteristic descriptor discovery.
|
||||
*
|
||||
* @details This class act like a namespace for characteristic descriptor discovery
|
||||
* types. It act like ServiceDiscovery by providing callbacks and callbacks
|
||||
* parameters types related to the characteristic descriptor discovery process but
|
||||
* contrary to ServiceDiscovery class, it does not force the porter to use a
|
||||
* specific interface for the characteristic descriptor discovery process.
|
||||
*/
|
||||
class CharacteristicDescriptorDiscovery {
|
||||
public:
|
||||
/**
|
||||
* @brief Parameter type of CharacteristicDescriptorDiscovery::DiscoveryCallback_t.
|
||||
* @detail Every time a characteristic descriptor has been discovered, the callback
|
||||
* registered for the discovery operation through GattClient::discoverCharacteristicDescriptors
|
||||
* or DiscoveredCharacteristic::discoverDescriptors will be called with this parameter.
|
||||
*
|
||||
*/
|
||||
struct DiscoveryCallbackParams_t {
|
||||
/**
|
||||
* The characteristic owning the DiscoveredCharacteristicDescriptor
|
||||
*/
|
||||
const DiscoveredCharacteristic& characteristic;
|
||||
|
||||
/**
|
||||
* The characteristic descriptor discovered
|
||||
*/
|
||||
const DiscoveredCharacteristicDescriptor& descriptor;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Parameter type of CharacteristicDescriptorDiscovery::TerminationCallback_t.
|
||||
* @details Once a characteristic descriptor discovery process terminate, the termination
|
||||
* callback registered for the discovery operation through
|
||||
* GattClient::discoverCharacteristicDescriptors or DiscoveredCharacteristic::discoverDescriptors
|
||||
* will be called with this parameter.
|
||||
*/
|
||||
struct TerminationCallbackParams_t {
|
||||
/**
|
||||
* The characteristic for which the descriptors has been discovered
|
||||
*/
|
||||
const DiscoveredCharacteristic& characteristic;
|
||||
|
||||
/**
|
||||
* status of the discovery operation
|
||||
*/
|
||||
ble_error_t status;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Callback type for when a matching characteristic descriptor is found during
|
||||
* characteristic descriptor discovery.
|
||||
*
|
||||
* @param param A pointer to a DiscoveryCallbackParams_t object which will remain
|
||||
* valid for the lifetime of the callback. Memory for this object is owned by
|
||||
* the BLE_API eventing framework. The application can safely make a persistent
|
||||
* shallow-copy of this object in order to work with the service beyond the
|
||||
* callback.
|
||||
*/
|
||||
typedef FunctionPointerWithContext<const DiscoveryCallbackParams_t*> DiscoveryCallback_t;
|
||||
|
||||
/**
|
||||
* @brief Callback type for when characteristic descriptor discovery terminates.
|
||||
*
|
||||
* @param param A pointer to a TerminationCallbackParams_t object which will remain
|
||||
* valid for the lifetime of the callback. Memory for this object is owned by
|
||||
* the BLE_API eventing framework. The application can safely make a persistent
|
||||
* shallow-copy of this object in order to work with the service beyond the
|
||||
* callback.
|
||||
*/
|
||||
typedef FunctionPointerWithContext<const TerminationCallbackParams_t*> TerminationCallback_t;
|
||||
};
|
||||
|
||||
#endif // ifndef __CHARACTERISTIC_DESCRIPTOR_DISCOVERY_H__
|
@ -0,0 +1,111 @@
|
||||
/* 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.
|
||||
*/
|
||||
|
||||
#ifndef __DISCOVERED_CHARACTERISTIC_DESCRIPTOR_H__
|
||||
#define __DISCOVERED_CHARACTERISTIC_DESCRIPTOR_H__
|
||||
|
||||
#include "UUID.h"
|
||||
#include "Gap.h"
|
||||
#include "GattAttribute.h"
|
||||
#include "GattClient.h"
|
||||
#include "CharacteristicDescriptorDiscovery.h"
|
||||
|
||||
/**
|
||||
* @brief Representation of a descriptor discovered during a GattClient
|
||||
* discovery procedure (see GattClient::discoverCharacteristicDescriptors or
|
||||
* DiscoveredCharacteristic::discoverDescriptors ).
|
||||
*
|
||||
* @detail Provide detailed informations about a discovered characteristic descriptor
|
||||
* like:
|
||||
* - Its UUID (see #getUUID).
|
||||
* - Its handle (see #getAttributeHandle)
|
||||
* Basic read (see GattClient::read) and write (see GattClient::write) procedure from
|
||||
* GattClient can be used access the value of the descriptor.
|
||||
*
|
||||
* @todo read member function
|
||||
* @todo write member function
|
||||
* @todo enumeration of standard descriptors
|
||||
*/
|
||||
class DiscoveredCharacteristicDescriptor {
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* @brief construct a new instance of a DiscoveredCharacteristicDescriptor
|
||||
*
|
||||
* @param client The client from where the descriptor has been discovered
|
||||
* @param connectionHandle The connection handle on which the descriptor has
|
||||
* been discovered
|
||||
* @param attributeHandle The handle of the attribute containing this descriptor
|
||||
* @param uuid The UUID of the descriptor
|
||||
*/
|
||||
DiscoveredCharacteristicDescriptor(
|
||||
GattClient* client, Gap::Handle_t connectionHandle, GattAttribute::Handle_t attributeHandle, const UUID& uuid) :
|
||||
_client(client), _connectionHandle(connectionHandle), _uuid(uuid), _gattHandle(attributeHandle) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Return the GattClient which can operate on this descriptor.
|
||||
* @return The GattClient which can operate on this descriptor.
|
||||
*/
|
||||
GattClient* getGattClient() {
|
||||
return _client;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Return the GattClient which can operate on this descriptor.
|
||||
* @return The GattClient which can operate on this descriptor.
|
||||
*/
|
||||
const GattClient* getGattClient() const {
|
||||
return _client;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Return the connection handle to the GattServer which contain
|
||||
* this descriptor.
|
||||
* @return the connection handle to the GattServer which contain
|
||||
* this descriptor.
|
||||
*/
|
||||
Gap::Handle_t getConnectionHandle() const {
|
||||
return _connectionHandle;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Return the UUID of this descriptor
|
||||
* @return the UUID of this descriptor
|
||||
*/
|
||||
const UUID& getUUID(void) const {
|
||||
return _uuid;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Return the attribute handle to use to access to this descriptor
|
||||
* on the gatt server.
|
||||
* @return The attribute handle of the descriptor
|
||||
*/
|
||||
GattAttribute::Handle_t getAttributeHandle() const {
|
||||
return _gattHandle;
|
||||
}
|
||||
|
||||
private:
|
||||
GattClient *_client;
|
||||
Gap::Handle_t _connectionHandle;
|
||||
UUID _uuid;
|
||||
GattAttribute::Handle_t _gattHandle;
|
||||
};
|
||||
|
||||
#endif /*__DISCOVERED_CHARACTERISTIC_DESCRIPTOR_H__*/
|
Loading…
Reference in new issue