fork

Fork of nRF51822 by Nordic Semiconductor

Committer:
rgrover1
Date:
Fri Jun 19 15:55:32 2015 +0100
Revision:
331:352bc4a36ea0
Parent:
329:d11ef9cc041b
Child:
332:b054000833d4
Synchronized with git rev 093cc129
Author: Rohit Grover
nRFDiscovery is now a part of the nRFGattClient object.

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 331:352bc4a36ea0 21 #include "nRFServiceDiscovery.h"
rgrover1 328:f3aa0fddaa79 22
rgrover1 329:d11ef9cc041b 23 #include "blecommon.h"
rgrover1 329:d11ef9cc041b 24 #include "ble_err.h"
rgrover1 329:d11ef9cc041b 25 #include "ble_gattc.h"
rgrover1 329:d11ef9cc041b 26
rgrover1 328:f3aa0fddaa79 27 class nRF51GattClient : public GattClient
rgrover1 328:f3aa0fddaa79 28 {
rgrover1 328:f3aa0fddaa79 29 public:
rgrover1 328:f3aa0fddaa79 30 static nRF51GattClient &getInstance();
rgrover1 328:f3aa0fddaa79 31
rgrover1 329:d11ef9cc041b 32 virtual ble_error_t read(Gap::Handle_t connHandle, GattAttribute::Handle_t attributeHandle, uint16_t offset) const {
rgrover1 329:d11ef9cc041b 33 uint32_t rc = sd_ble_gattc_read(connHandle, attributeHandle, offset);
rgrover1 329:d11ef9cc041b 34 if (rc == NRF_SUCCESS) {
rgrover1 329:d11ef9cc041b 35 return BLE_ERROR_NONE;
rgrover1 329:d11ef9cc041b 36 }
rgrover1 329:d11ef9cc041b 37 switch (rc) {
rgrover1 329:d11ef9cc041b 38 case NRF_ERROR_BUSY:
rgrover1 329:d11ef9cc041b 39 return BLE_STACK_BUSY;
rgrover1 329:d11ef9cc041b 40 case BLE_ERROR_INVALID_CONN_HANDLE:
rgrover1 329:d11ef9cc041b 41 case NRF_ERROR_INVALID_STATE:
rgrover1 329:d11ef9cc041b 42 case NRF_ERROR_INVALID_ADDR:
rgrover1 329:d11ef9cc041b 43 default:
rgrover1 329:d11ef9cc041b 44 return BLE_ERROR_INVALID_STATE;
rgrover1 329:d11ef9cc041b 45 }
rgrover1 329:d11ef9cc041b 46 }
rgrover1 329:d11ef9cc041b 47
rgrover1 328:f3aa0fddaa79 48 #if 0
rgrover1 328:f3aa0fddaa79 49 /* Functions that must be implemented from GattClient */
rgrover1 328:f3aa0fddaa79 50 virtual ble_error_t addService(GattService &);
rgrover1 328:f3aa0fddaa79 51 virtual ble_error_t readValue(GattAttribute::Handle_t attributeHandle, uint8_t buffer[], uint16_t *lengthP);
rgrover1 328:f3aa0fddaa79 52 virtual ble_error_t readValue(Gap::Handle_t connectionHandle, GattAttribute::Handle_t attributeHandle, uint8_t buffer[], uint16_t *lengthP);
rgrover1 328:f3aa0fddaa79 53 virtual ble_error_t updateValue(GattAttribute::Handle_t, const uint8_t[], uint16_t, bool localOnly = false);
rgrover1 328:f3aa0fddaa79 54 virtual ble_error_t updateValue(Gap::Handle_t connectionHandle, GattAttribute::Handle_t, const uint8_t[], uint16_t, bool localOnly = false);
rgrover1 328:f3aa0fddaa79 55 virtual ble_error_t initializeGATTDatabase(void);
rgrover1 328:f3aa0fddaa79 56
rgrover1 328:f3aa0fddaa79 57 /* nRF51 Functions */
rgrover1 328:f3aa0fddaa79 58 void eventCallback(void);
rgrover1 328:f3aa0fddaa79 59 void hwCallback(ble_evt_t *p_ble_evt);
rgrover1 328:f3aa0fddaa79 60
rgrover1 328:f3aa0fddaa79 61 private:
rgrover1 328:f3aa0fddaa79 62 #endif
rgrover1 328:f3aa0fddaa79 63
rgrover1 328:f3aa0fddaa79 64 public:
rgrover1 328:f3aa0fddaa79 65 nRF51GattClient() {
rgrover1 328:f3aa0fddaa79 66 /* empty */
rgrover1 328:f3aa0fddaa79 67 }
rgrover1 328:f3aa0fddaa79 68
rgrover1 328:f3aa0fddaa79 69 private:
rgrover1 328:f3aa0fddaa79 70 nRF51GattClient(const nRF51GattClient &);
rgrover1 328:f3aa0fddaa79 71 const nRF51GattClient& operator=(const nRF51GattClient &);
rgrover1 331:352bc4a36ea0 72
rgrover1 331:352bc4a36ea0 73 private:
rgrover1 331:352bc4a36ea0 74 nRFServiceDiscovery discovery;
rgrover1 328:f3aa0fddaa79 75 };
rgrover1 328:f3aa0fddaa79 76
rgrover1 328:f3aa0fddaa79 77 #endif // ifndef __NRF51822_GATT_CLIENT_H__