Changed the device name.
Dependents: BLE_Health_Thermometer_HeartRateMonitor
Fork of BLE_API_Native_IRC by
hw/nRF51822n/nRF51GattServer.h@17:d5600677d532, 2014-02-21 (annotated)
- Committer:
- ktownsend
- Date:
- Fri Feb 21 09:33:31 2014 +0000
- Revision:
- 17:d5600677d532
Added GATT callback support
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ktownsend | 17:d5600677d532 | 1 | /* mbed Microcontroller Library |
ktownsend | 17:d5600677d532 | 2 | * Copyright (c) 2006-2013 ARM Limited |
ktownsend | 17:d5600677d532 | 3 | * |
ktownsend | 17:d5600677d532 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
ktownsend | 17:d5600677d532 | 5 | * you may not use this file except in compliance with the License. |
ktownsend | 17:d5600677d532 | 6 | * You may obtain a copy of the License at |
ktownsend | 17:d5600677d532 | 7 | * |
ktownsend | 17:d5600677d532 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
ktownsend | 17:d5600677d532 | 9 | * |
ktownsend | 17:d5600677d532 | 10 | * Unless required by applicable law or agreed to in writing, software |
ktownsend | 17:d5600677d532 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
ktownsend | 17:d5600677d532 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
ktownsend | 17:d5600677d532 | 13 | * See the License for the specific language governing permissions and |
ktownsend | 17:d5600677d532 | 14 | * limitations under the License. |
ktownsend | 17:d5600677d532 | 15 | */ |
ktownsend | 17:d5600677d532 | 16 | |
ktownsend | 17:d5600677d532 | 17 | #ifndef __NRF51822_GATT_SERVER_H__ |
ktownsend | 17:d5600677d532 | 18 | #define __NRF51822_GATT_SERVER_H__ |
ktownsend | 17:d5600677d532 | 19 | |
ktownsend | 17:d5600677d532 | 20 | #include "mbed.h" |
ktownsend | 17:d5600677d532 | 21 | #include "blecommon.h" |
ktownsend | 17:d5600677d532 | 22 | #include "ble.h" /* nordic ble */ |
ktownsend | 17:d5600677d532 | 23 | #include "GattService.h" |
ktownsend | 17:d5600677d532 | 24 | #include "hw/GattServer.h" |
ktownsend | 17:d5600677d532 | 25 | |
ktownsend | 17:d5600677d532 | 26 | #define BLE_TOTAL_CHARACTERISTICS 10 |
ktownsend | 17:d5600677d532 | 27 | |
ktownsend | 17:d5600677d532 | 28 | /**************************************************************************/ |
ktownsend | 17:d5600677d532 | 29 | /*! |
ktownsend | 17:d5600677d532 | 30 | \brief |
ktownsend | 17:d5600677d532 | 31 | |
ktownsend | 17:d5600677d532 | 32 | */ |
ktownsend | 17:d5600677d532 | 33 | /**************************************************************************/ |
ktownsend | 17:d5600677d532 | 34 | class nRF51GattServer : public GattServer |
ktownsend | 17:d5600677d532 | 35 | { |
ktownsend | 17:d5600677d532 | 36 | public: |
ktownsend | 17:d5600677d532 | 37 | static nRF51GattServer& getInstance() |
ktownsend | 17:d5600677d532 | 38 | { |
ktownsend | 17:d5600677d532 | 39 | static nRF51GattServer m_instance; |
ktownsend | 17:d5600677d532 | 40 | return m_instance; |
ktownsend | 17:d5600677d532 | 41 | } |
ktownsend | 17:d5600677d532 | 42 | |
ktownsend | 17:d5600677d532 | 43 | /* Functions that must be implemented from GattServer */ |
ktownsend | 17:d5600677d532 | 44 | virtual ble_error_t addService(GattService &); |
ktownsend | 17:d5600677d532 | 45 | virtual ble_error_t readValue(uint16_t, uint8_t[], uint16_t); |
ktownsend | 17:d5600677d532 | 46 | virtual ble_error_t updateValue(uint16_t, uint8_t[], uint16_t); |
ktownsend | 17:d5600677d532 | 47 | |
ktownsend | 17:d5600677d532 | 48 | /* nRF51 Functions */ |
ktownsend | 17:d5600677d532 | 49 | void eventCallback(void); |
ktownsend | 17:d5600677d532 | 50 | void hwCallback(ble_evt_t * p_ble_evt); |
ktownsend | 17:d5600677d532 | 51 | |
ktownsend | 17:d5600677d532 | 52 | uint16_t m_connectionHandle; // TODO move to private |
ktownsend | 17:d5600677d532 | 53 | |
ktownsend | 17:d5600677d532 | 54 | private: |
ktownsend | 17:d5600677d532 | 55 | GattCharacteristic* p_characteristics[BLE_TOTAL_CHARACTERISTICS]; |
ktownsend | 17:d5600677d532 | 56 | ble_gatts_char_handles_t nrfCharacteristicHandles[BLE_TOTAL_CHARACTERISTICS]; |
ktownsend | 17:d5600677d532 | 57 | |
ktownsend | 17:d5600677d532 | 58 | nRF51GattServer() { serviceCount = 0; characteristicCount = 0; m_connectionHandle = BLE_CONN_HANDLE_INVALID; }; |
ktownsend | 17:d5600677d532 | 59 | |
ktownsend | 17:d5600677d532 | 60 | nRF51GattServer(nRF51GattServer const&); |
ktownsend | 17:d5600677d532 | 61 | void operator=(nRF51GattServer const&); |
ktownsend | 17:d5600677d532 | 62 | }; |
ktownsend | 17:d5600677d532 | 63 | |
ktownsend | 17:d5600677d532 | 64 | #endif |