HW layer for the Nucleo board, it only work with old BLE_API

Dependents:   Hello_BLE F446RE-BLE

Fork of X_NUCLEO_IDB0XA1 by ST

Committer:
mridup
Date:
Fri Jul 25 06:56:02 2014 +0000
Revision:
5:31dedfa19a12
Parent:
2:a2b623661316
Child:
6:08cfc94b5f49
Initial implementation of GattServer. AddService and Characteristic implemented. 16bit UUID.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mridup 2:a2b623661316 1 /* mbed Microcontroller Library
mridup 2:a2b623661316 2 * Copyright (c) 2006-2013 ARM Limited
mridup 2:a2b623661316 3 *
mridup 2:a2b623661316 4 * Licensed under the Apache License, Version 2.0 (the "License");
mridup 2:a2b623661316 5 * you may not use this file except in compliance with the License.
mridup 2:a2b623661316 6 * You may obtain a copy of the License at
mridup 2:a2b623661316 7 *
mridup 2:a2b623661316 8 * http://www.apache.org/licenses/LICENSE-2.0
mridup 2:a2b623661316 9 *
mridup 2:a2b623661316 10 * Unless required by applicable law or agreed to in writing, software
mridup 2:a2b623661316 11 * distributed under the License is distributed on an "AS IS" BASIS,
mridup 2:a2b623661316 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
mridup 2:a2b623661316 13 * See the License for the specific language governing permissions and
mridup 2:a2b623661316 14 * limitations under the License.
mridup 2:a2b623661316 15 */
mridup 2:a2b623661316 16
mridup 2:a2b623661316 17 #ifndef __BLUENRG_GATT_SERVER_H__
mridup 2:a2b623661316 18 #define __BLUENRG_GATT_SERVER_H__
mridup 2:a2b623661316 19
mridup 2:a2b623661316 20 #include "mbed.h"
mridup 2:a2b623661316 21 #include "blecommon.h"
mridup 5:31dedfa19a12 22 #include "btle.h"
mridup 2:a2b623661316 23 #include "GattService.h"
mridup 2:a2b623661316 24 #include "hw/GattServer.h"
mridup 2:a2b623661316 25
mridup 2:a2b623661316 26 #define BLE_TOTAL_CHARACTERISTICS 10
mridup 2:a2b623661316 27
mridup 2:a2b623661316 28 class BlueNRGGattServer : public GattServer
mridup 2:a2b623661316 29 {
mridup 2:a2b623661316 30 public:
mridup 2:a2b623661316 31 static BlueNRGGattServer &getInstance() {
mridup 2:a2b623661316 32 static BlueNRGGattServer m_instance;
mridup 2:a2b623661316 33 return m_instance;
mridup 2:a2b623661316 34 }
mridup 2:a2b623661316 35
mridup 2:a2b623661316 36 /* Functions that must be implemented from GattServer */
mridup 2:a2b623661316 37 virtual ble_error_t addService(GattService &);
mridup 2:a2b623661316 38 virtual ble_error_t readValue(uint16_t handle, uint8_t buffer[], uint16_t *const lengthP);
mridup 2:a2b623661316 39 virtual ble_error_t updateValue(uint16_t, uint8_t[], uint16_t, bool localOnly = false);
mridup 2:a2b623661316 40
mridup 2:a2b623661316 41 /* nRF51 Functions */
mridup 2:a2b623661316 42 void eventCallback(void);
mridup 2:a2b623661316 43 //void hwCallback(ble_evt_t *p_ble_evt);
mridup 2:a2b623661316 44
mridup 2:a2b623661316 45 private:
mridup 2:a2b623661316 46
mridup 2:a2b623661316 47 uint8_t serviceCount;
mridup 2:a2b623661316 48 uint8_t characteristicCount;
mridup 5:31dedfa19a12 49 tHalUint16 hrmServHandle, hrmCharHandle;
mridup 2:a2b623661316 50
mridup 2:a2b623661316 51 GattCharacteristic *p_characteristics[BLE_TOTAL_CHARACTERISTICS];
mridup 2:a2b623661316 52 //ble_gatts_char_handles_t nrfCharacteristicHandles[BLE_TOTAL_CHARACTERISTICS];
mridup 2:a2b623661316 53
mridup 2:a2b623661316 54 BlueNRGGattServer() {
mridup 2:a2b623661316 55 serviceCount = 0;
mridup 2:a2b623661316 56 characteristicCount = 0;
mridup 2:a2b623661316 57 };
mridup 2:a2b623661316 58
mridup 2:a2b623661316 59 BlueNRGGattServer(BlueNRGGattServer const &);
mridup 2:a2b623661316 60 void operator=(BlueNRGGattServer const &);
mridup 2:a2b623661316 61 };
mridup 2:a2b623661316 62
mridup 2:a2b623661316 63 #endif