test
Fork of nRF51822 by
Diff: btle/btle_discovery.h
- Revision:
- 315:044071756a8d
- Parent:
- 312:d55797e0d632
- Child:
- 316:1ccf6ee70900
--- a/btle/btle_discovery.h Fri Jun 19 15:55:30 2015 +0100 +++ b/btle/btle_discovery.h Fri Jun 19 15:55:30 2015 +0100 @@ -19,61 +19,10 @@ #include "ble.h" #include "ServiceDiscovery.h" +#include "nRFDiscoveredCharacteristic.h" void bleGattcEventHandler(const ble_evt_t *p_ble_evt); -class nRFDiscoveredCharacteristic : public DiscoveredCharacteristic { -public: - void setup(Gap::Handle_t connectionHandleIn, - Properties_t propsIn, - GattAttribute::Handle_t declHandleIn, - GattAttribute::Handle_t valueHandleIn) { - connHandle = connectionHandleIn; - props = propsIn; - declHandle = declHandleIn; - valueHandle = valueHandleIn; - } - - void setup(Gap::Handle_t connectionHandleIn, - UUID::ShortUUIDBytes_t uuidIn, - Properties_t propsIn, - GattAttribute::Handle_t declHandleIn, - GattAttribute::Handle_t valueHandleIn) { - connHandle = connectionHandleIn; - uuid = uuidIn; - props = propsIn; - declHandle = declHandleIn; - valueHandle = valueHandleIn; - } - -public: - /** - * Initiate (or continue) a read for the value attribute, optionally at a - * given offset. If the Characteristic or Descriptor to be read is longer - * than ATT_MTU - 1, this function must be called multiple times with - * appropriate offset to read the complete value. - * - * @return BLE_ERROR_NONE if a read has been initiated, else - * BLE_ERROR_INVALID_STATE if some internal state about the connection is invalid, or - * BLE_STACK_BUSY if some client procedure already in progress. - */ - virtual ble_error_t read(uint16_t offset = 0) { - uint32_t rc = sd_ble_gattc_read(connHandle, valueHandle, offset); - if (rc == NRF_SUCCESS) { - return BLE_ERROR_NONE; - } - switch (rc) { - case NRF_ERROR_BUSY: - return BLE_STACK_BUSY; - case BLE_ERROR_INVALID_CONN_HANDLE: - case NRF_ERROR_INVALID_STATE: - case NRF_ERROR_INVALID_ADDR: - default: - return BLE_ERROR_INVALID_STATE; - } - } -}; - class NordicServiceDiscovery : public ServiceDiscovery { public: