fork

Fork of nRF51822 by Nordic Semiconductor

Committer:
rgrover1
Date:
Fri Jun 19 15:55:32 2015 +0100
Revision:
329:d11ef9cc041b
Parent:
328:f3aa0fddaa79
Child:
331:352bc4a36ea0
Synchronized with git rev 9d503040
Author: Rohit Grover
add read() to nRFGattClient.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
rgrover1 328:f3aa0fddaa79 1 /* mbed Microcontroller Library
rgrover1 328:f3aa0fddaa79 2 * Copyright (c) 2006-2013 ARM Limited
rgrover1 328:f3aa0fddaa79 3 *
rgrover1 328:f3aa0fddaa79 4 * Licensed under the Apache License, Version 2.0 (the "License");
rgrover1 328:f3aa0fddaa79 5 * you may not use this file except in compliance with the License.
rgrover1 328:f3aa0fddaa79 6 * You may obtain a copy of the License at
rgrover1 328:f3aa0fddaa79 7 *
rgrover1 328:f3aa0fddaa79 8 * http://www.apache.org/licenses/LICENSE-2.0
rgrover1 328:f3aa0fddaa79 9 *
rgrover1 328:f3aa0fddaa79 10 * Unless required by applicable law or agreed to in writing, software
rgrover1 328:f3aa0fddaa79 11 * distributed under the License is distributed on an "AS IS" BASIS,
rgrover1 328:f3aa0fddaa79 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
rgrover1 328:f3aa0fddaa79 13 * See the License for the specific language governing permissions and
rgrover1 328:f3aa0fddaa79 14 * limitations under the License.
rgrover1 328:f3aa0fddaa79 15 */
rgrover1 328:f3aa0fddaa79 16
rgrover1 328:f3aa0fddaa79 17 #ifndef __NRF51822_GATT_CLIENT_H__
rgrover1 328:f3aa0fddaa79 18 #define __NRF51822_GATT_CLIENT_H__
rgrover1 328:f3aa0fddaa79 19
rgrover1 328:f3aa0fddaa79 20 #include "GattClient.h"
rgrover1 328:f3aa0fddaa79 21
rgrover1 329:d11ef9cc041b 22 #include "blecommon.h"
rgrover1 329:d11ef9cc041b 23 #include "ble_err.h"
rgrover1 329:d11ef9cc041b 24 #include "ble_gattc.h"
rgrover1 329:d11ef9cc041b 25
rgrover1 328:f3aa0fddaa79 26 class nRF51GattClient : public GattClient
rgrover1 328:f3aa0fddaa79 27 {
rgrover1 328:f3aa0fddaa79 28 public:
rgrover1 328:f3aa0fddaa79 29 static nRF51GattClient &getInstance();
rgrover1 328:f3aa0fddaa79 30
rgrover1 329:d11ef9cc041b 31 virtual ble_error_t read(Gap::Handle_t connHandle, GattAttribute::Handle_t attributeHandle, uint16_t offset) const {
rgrover1 329:d11ef9cc041b 32 uint32_t rc = sd_ble_gattc_read(connHandle, attributeHandle, offset);
rgrover1 329:d11ef9cc041b 33 if (rc == NRF_SUCCESS) {
rgrover1 329:d11ef9cc041b 34 return BLE_ERROR_NONE;
rgrover1 329:d11ef9cc041b 35 }
rgrover1 329:d11ef9cc041b 36 switch (rc) {
rgrover1 329:d11ef9cc041b 37 case NRF_ERROR_BUSY:
rgrover1 329:d11ef9cc041b 38 return BLE_STACK_BUSY;
rgrover1 329:d11ef9cc041b 39 case BLE_ERROR_INVALID_CONN_HANDLE:
rgrover1 329:d11ef9cc041b 40 case NRF_ERROR_INVALID_STATE:
rgrover1 329:d11ef9cc041b 41 case NRF_ERROR_INVALID_ADDR:
rgrover1 329:d11ef9cc041b 42 default:
rgrover1 329:d11ef9cc041b 43 return BLE_ERROR_INVALID_STATE;
rgrover1 329:d11ef9cc041b 44 }
rgrover1 329:d11ef9cc041b 45 }
rgrover1 329:d11ef9cc041b 46
rgrover1 328:f3aa0fddaa79 47 #if 0
rgrover1 328:f3aa0fddaa79 48 /* Functions that must be implemented from GattClient */
rgrover1 328:f3aa0fddaa79 49 virtual ble_error_t addService(GattService &);
rgrover1 328:f3aa0fddaa79 50 virtual ble_error_t readValue(GattAttribute::Handle_t attributeHandle, uint8_t buffer[], uint16_t *lengthP);
rgrover1 328:f3aa0fddaa79 51 virtual ble_error_t readValue(Gap::Handle_t connectionHandle, GattAttribute::Handle_t attributeHandle, uint8_t buffer[], uint16_t *lengthP);
rgrover1 328:f3aa0fddaa79 52 virtual ble_error_t updateValue(GattAttribute::Handle_t, const uint8_t[], uint16_t, bool localOnly = false);
rgrover1 328:f3aa0fddaa79 53 virtual ble_error_t updateValue(Gap::Handle_t connectionHandle, GattAttribute::Handle_t, const uint8_t[], uint16_t, bool localOnly = false);
rgrover1 328:f3aa0fddaa79 54 virtual ble_error_t initializeGATTDatabase(void);
rgrover1 328:f3aa0fddaa79 55
rgrover1 328:f3aa0fddaa79 56 /* nRF51 Functions */
rgrover1 328:f3aa0fddaa79 57 void eventCallback(void);
rgrover1 328:f3aa0fddaa79 58 void hwCallback(ble_evt_t *p_ble_evt);
rgrover1 328:f3aa0fddaa79 59
rgrover1 328:f3aa0fddaa79 60 private:
rgrover1 328:f3aa0fddaa79 61 #endif
rgrover1 328:f3aa0fddaa79 62
rgrover1 328:f3aa0fddaa79 63 public:
rgrover1 328:f3aa0fddaa79 64 nRF51GattClient() {
rgrover1 328:f3aa0fddaa79 65 /* empty */
rgrover1 328:f3aa0fddaa79 66 }
rgrover1 328:f3aa0fddaa79 67
rgrover1 328:f3aa0fddaa79 68 private:
rgrover1 328:f3aa0fddaa79 69 nRF51GattClient(const nRF51GattClient &);
rgrover1 328:f3aa0fddaa79 70 const nRF51GattClient& operator=(const nRF51GattClient &);
rgrover1 328:f3aa0fddaa79 71 };
rgrover1 328:f3aa0fddaa79 72
rgrover1 328:f3aa0fddaa79 73 #endif // ifndef __NRF51822_GATT_CLIENT_H__