Added support for obtaining BLE device name by parsing advertising data.
Fork of BLE_BlueNRG by
BlueNRGGattServer.h@2:a2b623661316, 2014-07-21 (annotated)
- Committer:
- mridup
- Date:
- Mon Jul 21 08:28:47 2014 +0000
- Revision:
- 2:a2b623661316
- Child:
- 5:31dedfa19a12
Latest Changes 21/07
Who changed what in which revision?
User | Revision | Line number | New 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 | 2:a2b623661316 | 22 | //#include "ble.h" /* nordic ble */ |
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 | 2:a2b623661316 | 49 | |
mridup | 2:a2b623661316 | 50 | GattCharacteristic *p_characteristics[BLE_TOTAL_CHARACTERISTICS]; |
mridup | 2:a2b623661316 | 51 | //ble_gatts_char_handles_t nrfCharacteristicHandles[BLE_TOTAL_CHARACTERISTICS]; |
mridup | 2:a2b623661316 | 52 | |
mridup | 2:a2b623661316 | 53 | BlueNRGGattServer() { |
mridup | 2:a2b623661316 | 54 | serviceCount = 0; |
mridup | 2:a2b623661316 | 55 | characteristicCount = 0; |
mridup | 2:a2b623661316 | 56 | }; |
mridup | 2:a2b623661316 | 57 | |
mridup | 2:a2b623661316 | 58 | BlueNRGGattServer(BlueNRGGattServer const &); |
mridup | 2:a2b623661316 | 59 | void operator=(BlueNRGGattServer const &); |
mridup | 2:a2b623661316 | 60 | }; |
mridup | 2:a2b623661316 | 61 | |
mridup | 2:a2b623661316 | 62 | #endif |