Encryp_u
Dependencies: BLE_API_Encryp CyaSSL-Encryp eMPL_MPU6050 mbed
Fork of Encryptulator2 by
nRF51822/nRF51GattServer.h@4:bfb662bab28e, 2017-05-10 (annotated)
- Committer:
- vbahl2
- Date:
- Wed May 10 18:23:44 2017 +0000
- Revision:
- 4:bfb662bab28e
- Parent:
- 1:fc2f9d636751
en
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
yihui | 1:fc2f9d636751 | 1 | /* mbed Microcontroller Library |
yihui | 1:fc2f9d636751 | 2 | * Copyright (c) 2006-2013 ARM Limited |
yihui | 1:fc2f9d636751 | 3 | * |
yihui | 1:fc2f9d636751 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
yihui | 1:fc2f9d636751 | 5 | * you may not use this file except in compliance with the License. |
yihui | 1:fc2f9d636751 | 6 | * You may obtain a copy of the License at |
yihui | 1:fc2f9d636751 | 7 | * |
yihui | 1:fc2f9d636751 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
yihui | 1:fc2f9d636751 | 9 | * |
yihui | 1:fc2f9d636751 | 10 | * Unless required by applicable law or agreed to in writing, software |
yihui | 1:fc2f9d636751 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
yihui | 1:fc2f9d636751 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
yihui | 1:fc2f9d636751 | 13 | * See the License for the specific language governing permissions and |
yihui | 1:fc2f9d636751 | 14 | * limitations under the License. |
yihui | 1:fc2f9d636751 | 15 | */ |
yihui | 1:fc2f9d636751 | 16 | |
yihui | 1:fc2f9d636751 | 17 | #ifndef __NRF51822_GATT_SERVER_H__ |
yihui | 1:fc2f9d636751 | 18 | #define __NRF51822_GATT_SERVER_H__ |
yihui | 1:fc2f9d636751 | 19 | |
yihui | 1:fc2f9d636751 | 20 | #include <stddef.h> |
yihui | 1:fc2f9d636751 | 21 | |
yihui | 1:fc2f9d636751 | 22 | #include "blecommon.h" |
yihui | 1:fc2f9d636751 | 23 | #include "ble.h" /* nordic ble */ |
yihui | 1:fc2f9d636751 | 24 | #include "GattServer.h" |
yihui | 1:fc2f9d636751 | 25 | |
yihui | 1:fc2f9d636751 | 26 | class nRF51GattServer : public GattServer |
yihui | 1:fc2f9d636751 | 27 | { |
yihui | 1:fc2f9d636751 | 28 | public: |
yihui | 1:fc2f9d636751 | 29 | static nRF51GattServer &getInstance() { |
yihui | 1:fc2f9d636751 | 30 | static nRF51GattServer m_instance; |
yihui | 1:fc2f9d636751 | 31 | return m_instance; |
yihui | 1:fc2f9d636751 | 32 | } |
yihui | 1:fc2f9d636751 | 33 | |
yihui | 1:fc2f9d636751 | 34 | /* Functions that must be implemented from GattServer */ |
yihui | 1:fc2f9d636751 | 35 | virtual ble_error_t addService(GattService &); |
yihui | 1:fc2f9d636751 | 36 | virtual ble_error_t readValue(GattAttribute::Handle_t handle, uint8_t buffer[], uint16_t *const lengthP); |
yihui | 1:fc2f9d636751 | 37 | virtual ble_error_t updateValue(GattAttribute::Handle_t, const uint8_t[], uint16_t, bool localOnly = false); |
yihui | 1:fc2f9d636751 | 38 | virtual ble_error_t initializeGATTDatabase(void); |
yihui | 1:fc2f9d636751 | 39 | |
yihui | 1:fc2f9d636751 | 40 | /* nRF51 Functions */ |
yihui | 1:fc2f9d636751 | 41 | void eventCallback(void); |
yihui | 1:fc2f9d636751 | 42 | void hwCallback(ble_evt_t *p_ble_evt); |
yihui | 1:fc2f9d636751 | 43 | |
yihui | 1:fc2f9d636751 | 44 | private: |
yihui | 1:fc2f9d636751 | 45 | const static unsigned BLE_TOTAL_CHARACTERISTICS = 24; |
yihui | 1:fc2f9d636751 | 46 | const static unsigned BLE_TOTAL_DESCRIPTORS = 24; |
yihui | 1:fc2f9d636751 | 47 | |
yihui | 1:fc2f9d636751 | 48 | GattCharacteristic *p_characteristics[BLE_TOTAL_CHARACTERISTICS]; |
yihui | 1:fc2f9d636751 | 49 | ble_gatts_char_handles_t nrfCharacteristicHandles[BLE_TOTAL_CHARACTERISTICS]; |
yihui | 1:fc2f9d636751 | 50 | GattAttribute *p_descriptors[BLE_TOTAL_DESCRIPTORS]; |
yihui | 1:fc2f9d636751 | 51 | uint8_t descriptorCount; |
yihui | 1:fc2f9d636751 | 52 | uint16_t nrfDescriptorHandles[BLE_TOTAL_DESCRIPTORS]; |
yihui | 1:fc2f9d636751 | 53 | |
yihui | 1:fc2f9d636751 | 54 | nRF51GattServer() : GattServer(), p_characteristics(), nrfCharacteristicHandles(), p_descriptors(), descriptorCount(0), nrfDescriptorHandles() { |
yihui | 1:fc2f9d636751 | 55 | /* empty */ |
yihui | 1:fc2f9d636751 | 56 | } |
yihui | 1:fc2f9d636751 | 57 | |
yihui | 1:fc2f9d636751 | 58 | private: |
yihui | 1:fc2f9d636751 | 59 | nRF51GattServer(const nRF51GattServer &); |
yihui | 1:fc2f9d636751 | 60 | const nRF51GattServer& operator=(const nRF51GattServer &); |
yihui | 1:fc2f9d636751 | 61 | }; |
yihui | 1:fc2f9d636751 | 62 | |
yihui | 1:fc2f9d636751 | 63 | #endif // ifndef __NRF51822_GATT_SERVER_H__ |