High level Bluetooth Low Energy API and radio abstraction layer

Dependencies:   nRF51822

Dependents:   LinkNode_LIS3DH

Fork of BLE_API by Bluetooth Low Energy

Committer:
rgrover1
Date:
Fri Jun 19 15:52:58 2015 +0100
Revision:
646:1c59b84fd7e6
Parent:
501:ff6801633d2c
Child:
502:557c4a9276ae
Synchronized with git rev 1a9e68e1
Author: Rohit Grover
ReadCallback_t moves into GattClient.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
rgrover1 497:926d444599e8 1 /* mbed Microcontroller Library
rgrover1 497:926d444599e8 2 * Copyright (c) 2006-2013 ARM Limited
rgrover1 497:926d444599e8 3 *
rgrover1 497:926d444599e8 4 * Licensed under the Apache License, Version 2.0 (the "License");
rgrover1 497:926d444599e8 5 * you may not use this file except in compliance with the License.
rgrover1 497:926d444599e8 6 * You may obtain a copy of the License at
rgrover1 497:926d444599e8 7 *
rgrover1 497:926d444599e8 8 * http://www.apache.org/licenses/LICENSE-2.0
rgrover1 497:926d444599e8 9 *
rgrover1 497:926d444599e8 10 * Unless required by applicable law or agreed to in writing, software
rgrover1 497:926d444599e8 11 * distributed under the License is distributed on an "AS IS" BASIS,
rgrover1 497:926d444599e8 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
rgrover1 497:926d444599e8 13 * See the License for the specific language governing permissions and
rgrover1 497:926d444599e8 14 * limitations under the License.
rgrover1 497:926d444599e8 15 */
rgrover1 497:926d444599e8 16
rgrover1 497:926d444599e8 17 #include "DiscoveredCharacteristic.h"
rgrover1 497:926d444599e8 18 #include "GattClient.h"
rgrover1 497:926d444599e8 19
rgrover1 501:ff6801633d2c 20 GattClient::ReadCallback_t DiscoveredCharacteristic::onDataReadCallback;
rgrover1 497:926d444599e8 21
rgrover1 497:926d444599e8 22 ble_error_t
rgrover1 497:926d444599e8 23 DiscoveredCharacteristic::read(uint16_t offset) const
rgrover1 497:926d444599e8 24 {
rgrover1 497:926d444599e8 25 if (!props.read()) {
rgrover1 497:926d444599e8 26 return BLE_ERROR_OPERATION_NOT_PERMITTED;
rgrover1 497:926d444599e8 27 }
rgrover1 497:926d444599e8 28
rgrover1 498:f3cd1e9e1ebc 29 if (!gattc) {
rgrover1 498:f3cd1e9e1ebc 30 return BLE_ERROR_INVALID_STATE;
rgrover1 498:f3cd1e9e1ebc 31 }
rgrover1 498:f3cd1e9e1ebc 32
rgrover1 497:926d444599e8 33 return gattc->read(connHandle, valueHandle, offset);
rgrover1 497:926d444599e8 34 }
rgrover1 497:926d444599e8 35
rgrover1 497:926d444599e8 36 ble_error_t
rgrover1 497:926d444599e8 37 DiscoveredCharacteristic::writeWoResponse(uint16_t length, const uint8_t *value) const
rgrover1 497:926d444599e8 38 {
rgrover1 497:926d444599e8 39 if (!props.writeWoResp()) {
rgrover1 497:926d444599e8 40 return BLE_ERROR_OPERATION_NOT_PERMITTED;
rgrover1 497:926d444599e8 41 }
rgrover1 497:926d444599e8 42
rgrover1 497:926d444599e8 43 return gattc->write(GattClient::OP_WRITE_CMD, connHandle, length, value);
rgrover1 497:926d444599e8 44 }