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