Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: HC_SR04_Ultrasonic_Library Servo mbed
Fork of FIP_REV1 by
BLE_BlueNRG/BlueNRGGattServer.h@2:b5166e24c7a6, 2015-05-19 (annotated)
- Committer:
- julientiron
- Date:
- Tue May 19 17:46:51 2015 +0000
- Revision:
- 2:b5166e24c7a6
- Parent:
- 0:3d641e170a74
?a marche BLE+capteur de distance;
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| julientiron | 0:3d641e170a74 | 1 | /* mbed Microcontroller Library |
| julientiron | 0:3d641e170a74 | 2 | * Copyright (c) 2006-2013 ARM Limited |
| julientiron | 0:3d641e170a74 | 3 | * |
| julientiron | 0:3d641e170a74 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| julientiron | 0:3d641e170a74 | 5 | * you may not use this file except in compliance with the License. |
| julientiron | 0:3d641e170a74 | 6 | * You may obtain a copy of the License at |
| julientiron | 0:3d641e170a74 | 7 | * |
| julientiron | 0:3d641e170a74 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| julientiron | 0:3d641e170a74 | 9 | * |
| julientiron | 0:3d641e170a74 | 10 | * Unless required by applicable law or agreed to in writing, software |
| julientiron | 0:3d641e170a74 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| julientiron | 0:3d641e170a74 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| julientiron | 0:3d641e170a74 | 13 | * See the License for the specific language governing permissions and |
| julientiron | 0:3d641e170a74 | 14 | * limitations under the License. |
| julientiron | 0:3d641e170a74 | 15 | */ |
| julientiron | 0:3d641e170a74 | 16 | |
| julientiron | 0:3d641e170a74 | 17 | #ifndef __BLUENRG_GATT_SERVER_H__ |
| julientiron | 0:3d641e170a74 | 18 | #define __BLUENRG_GATT_SERVER_H__ |
| julientiron | 0:3d641e170a74 | 19 | |
| julientiron | 0:3d641e170a74 | 20 | #include "mbed.h" |
| julientiron | 0:3d641e170a74 | 21 | #include "blecommon.h" |
| julientiron | 0:3d641e170a74 | 22 | #include "btle.h" |
| julientiron | 0:3d641e170a74 | 23 | #include "GattService.h" |
| julientiron | 0:3d641e170a74 | 24 | #include "public/GattServer.h" |
| julientiron | 0:3d641e170a74 | 25 | |
| julientiron | 0:3d641e170a74 | 26 | #define BLE_TOTAL_CHARACTERISTICS 10 |
| julientiron | 0:3d641e170a74 | 27 | |
| julientiron | 0:3d641e170a74 | 28 | class BlueNRGGattServer : public GattServer |
| julientiron | 0:3d641e170a74 | 29 | { |
| julientiron | 0:3d641e170a74 | 30 | public: |
| julientiron | 0:3d641e170a74 | 31 | static BlueNRGGattServer &getInstance() { |
| julientiron | 0:3d641e170a74 | 32 | static BlueNRGGattServer m_instance; |
| julientiron | 0:3d641e170a74 | 33 | return m_instance; |
| julientiron | 0:3d641e170a74 | 34 | } |
| julientiron | 0:3d641e170a74 | 35 | |
| julientiron | 0:3d641e170a74 | 36 | /* Functions that must be implemented from GattServer */ |
| julientiron | 0:3d641e170a74 | 37 | virtual ble_error_t addService(GattService &); |
| julientiron | 0:3d641e170a74 | 38 | virtual ble_error_t readValue(uint16_t handle, uint8_t buffer[], uint16_t *const lengthP); |
| julientiron | 0:3d641e170a74 | 39 | virtual ble_error_t updateValue(uint16_t, uint8_t[], uint16_t, bool localOnly = false); |
| julientiron | 0:3d641e170a74 | 40 | virtual ble_error_t setDeviceName(const uint8_t *deviceName); |
| julientiron | 0:3d641e170a74 | 41 | virtual ble_error_t getDeviceName(uint8_t *deviceName, unsigned *lengthP); |
| julientiron | 0:3d641e170a74 | 42 | virtual ble_error_t setAppearance(uint16_t appearance); |
| julientiron | 0:3d641e170a74 | 43 | virtual ble_error_t getAppearance(uint16_t *appearanceP); |
| julientiron | 0:3d641e170a74 | 44 | |
| julientiron | 0:3d641e170a74 | 45 | /* BlueNRG Functions */ |
| julientiron | 0:3d641e170a74 | 46 | void eventCallback(void); |
| julientiron | 0:3d641e170a74 | 47 | //void hwCallback(void *pckt); |
| julientiron | 0:3d641e170a74 | 48 | ble_error_t Read_Request_CB(tHalUint16 handle); |
| julientiron | 0:3d641e170a74 | 49 | GattCharacteristic* getCharacteristicFromHandle(tHalUint16 charHandle); |
| julientiron | 0:3d641e170a74 | 50 | |
| julientiron | 0:3d641e170a74 | 51 | private: |
| julientiron | 0:3d641e170a74 | 52 | |
| julientiron | 0:3d641e170a74 | 53 | uint8_t serviceCount; |
| julientiron | 0:3d641e170a74 | 54 | uint8_t characteristicCount; |
| julientiron | 0:3d641e170a74 | 55 | tHalUint16 hrmServHandle, hrmCharHandle; |
| julientiron | 0:3d641e170a74 | 56 | |
| julientiron | 0:3d641e170a74 | 57 | GattCharacteristic *p_characteristics[BLE_TOTAL_CHARACTERISTICS]; |
| julientiron | 0:3d641e170a74 | 58 | tHalUint16 bleCharacteristicHandles[BLE_TOTAL_CHARACTERISTICS]; |
| julientiron | 0:3d641e170a74 | 59 | |
| julientiron | 0:3d641e170a74 | 60 | uint8_t *DeviceName; |
| julientiron | 0:3d641e170a74 | 61 | uint8_t deviceAppearance[2]; |
| julientiron | 0:3d641e170a74 | 62 | |
| julientiron | 0:3d641e170a74 | 63 | BlueNRGGattServer() { |
| julientiron | 0:3d641e170a74 | 64 | serviceCount = 0; |
| julientiron | 0:3d641e170a74 | 65 | characteristicCount = 0; |
| julientiron | 0:3d641e170a74 | 66 | DeviceName = NULL; |
| julientiron | 0:3d641e170a74 | 67 | }; |
| julientiron | 0:3d641e170a74 | 68 | |
| julientiron | 0:3d641e170a74 | 69 | BlueNRGGattServer(BlueNRGGattServer const &); |
| julientiron | 0:3d641e170a74 | 70 | void operator=(BlueNRGGattServer const &); |
| julientiron | 0:3d641e170a74 | 71 | }; |
| julientiron | 0:3d641e170a74 | 72 | |
| julientiron | 0:3d641e170a74 | 73 | #endif |
