just a fork
Fork of BLE_API by
ble/GattService.h@1179:4ab722f8dca0, 2016-04-06 (annotated)
- Committer:
- vcoubard
- Date:
- Wed Apr 06 19:15:30 2016 +0100
- Revision:
- 1179:4ab722f8dca0
- Parent:
- 1167:91c37c858f48
- Child:
- 1183:1589830dbdb7
Synchronized with git rev ca632aaf
Author: Andres Amaya Garcia
Update Gap state after advertising times out
The BLE API was not updating the Gap internal state when the advertising stops
because of a user timeout. This commit fixes the issue by updating the internal
state structure in Gap just before the registered callbacks are notified of the
advertising timeout.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
vcoubard | 1167:91c37c858f48 | 1 | /* mbed Microcontroller Library |
vcoubard | 1167:91c37c858f48 | 2 | * Copyright (c) 2006-2013 ARM Limited |
vcoubard | 1167:91c37c858f48 | 3 | * |
vcoubard | 1167:91c37c858f48 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
vcoubard | 1167:91c37c858f48 | 5 | * you may not use this file except in compliance with the License. |
vcoubard | 1167:91c37c858f48 | 6 | * You may obtain a copy of the License at |
vcoubard | 1167:91c37c858f48 | 7 | * |
vcoubard | 1167:91c37c858f48 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
vcoubard | 1167:91c37c858f48 | 9 | * |
vcoubard | 1167:91c37c858f48 | 10 | * Unless required by applicable law or agreed to in writing, software |
vcoubard | 1167:91c37c858f48 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
vcoubard | 1167:91c37c858f48 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
vcoubard | 1167:91c37c858f48 | 13 | * See the License for the specific language governing permissions and |
vcoubard | 1167:91c37c858f48 | 14 | * limitations under the License. |
vcoubard | 1167:91c37c858f48 | 15 | */ |
vcoubard | 1167:91c37c858f48 | 16 | |
vcoubard | 1167:91c37c858f48 | 17 | #ifndef __GATT_SERVICE_H__ |
vcoubard | 1167:91c37c858f48 | 18 | #define __GATT_SERVICE_H__ |
vcoubard | 1167:91c37c858f48 | 19 | |
vcoubard | 1167:91c37c858f48 | 20 | #include "UUID.h" |
vcoubard | 1167:91c37c858f48 | 21 | #include "GattCharacteristic.h" |
vcoubard | 1167:91c37c858f48 | 22 | |
vcoubard | 1167:91c37c858f48 | 23 | class GattService { |
vcoubard | 1167:91c37c858f48 | 24 | public: |
vcoubard | 1167:91c37c858f48 | 25 | enum { |
vcoubard | 1167:91c37c858f48 | 26 | UUID_ALERT_NOTIFICATION_SERVICE = 0x1811, |
vcoubard | 1167:91c37c858f48 | 27 | UUID_BATTERY_SERVICE = 0x180F, |
vcoubard | 1167:91c37c858f48 | 28 | UUID_BLOOD_PRESSURE_SERVICE = 0x1810, |
vcoubard | 1167:91c37c858f48 | 29 | UUID_CURRENT_TIME_SERVICE = 0x1805, |
vcoubard | 1167:91c37c858f48 | 30 | UUID_CYCLING_SPEED_AND_CADENCE = 0x1816, |
vcoubard | 1167:91c37c858f48 | 31 | UUID_DEVICE_INFORMATION_SERVICE = 0x180A, |
vcoubard | 1167:91c37c858f48 | 32 | UUID_ENVIRONMENTAL_SERVICE = 0x181A, |
vcoubard | 1167:91c37c858f48 | 33 | UUID_GLUCOSE_SERVICE = 0x1808, |
vcoubard | 1167:91c37c858f48 | 34 | UUID_HEALTH_THERMOMETER_SERVICE = 0x1809, |
vcoubard | 1167:91c37c858f48 | 35 | UUID_HEART_RATE_SERVICE = 0x180D, |
vcoubard | 1167:91c37c858f48 | 36 | UUID_HUMAN_INTERFACE_DEVICE_SERVICE = 0x1812, |
vcoubard | 1167:91c37c858f48 | 37 | UUID_IMMEDIATE_ALERT_SERVICE = 0x1802, |
vcoubard | 1167:91c37c858f48 | 38 | UUID_LINK_LOSS_SERVICE = 0x1803, |
vcoubard | 1167:91c37c858f48 | 39 | UUID_NEXT_DST_CHANGE_SERVICE = 0x1807, |
vcoubard | 1167:91c37c858f48 | 40 | UUID_PHONE_ALERT_STATUS_SERVICE = 0x180E, |
vcoubard | 1167:91c37c858f48 | 41 | UUID_REFERENCE_TIME_UPDATE_SERVICE = 0x1806, |
vcoubard | 1167:91c37c858f48 | 42 | UUID_RUNNING_SPEED_AND_CADENCE = 0x1814, |
vcoubard | 1167:91c37c858f48 | 43 | UUID_SCAN_PARAMETERS_SERVICE = 0x1813, |
vcoubard | 1167:91c37c858f48 | 44 | UUID_TX_POWER_SERVICE = 0x1804 |
vcoubard | 1167:91c37c858f48 | 45 | }; |
vcoubard | 1167:91c37c858f48 | 46 | |
vcoubard | 1167:91c37c858f48 | 47 | public: |
vcoubard | 1167:91c37c858f48 | 48 | /** |
vcoubard | 1167:91c37c858f48 | 49 | * @brief Creates a new GattService using the specified 16-bit |
vcoubard | 1167:91c37c858f48 | 50 | * UUID, value length, and properties. |
vcoubard | 1167:91c37c858f48 | 51 | * |
vcoubard | 1167:91c37c858f48 | 52 | * @note The UUID value must be unique and is normally >1. |
vcoubard | 1167:91c37c858f48 | 53 | * |
vcoubard | 1167:91c37c858f48 | 54 | * @param[in] uuid |
vcoubard | 1167:91c37c858f48 | 55 | * The UUID to use for this service. |
vcoubard | 1167:91c37c858f48 | 56 | * @param[in] characteristics |
vcoubard | 1167:91c37c858f48 | 57 | * A pointer to an array of characteristics to be included within this service. |
vcoubard | 1167:91c37c858f48 | 58 | * @param[in] numCharacteristics |
vcoubard | 1167:91c37c858f48 | 59 | * The number of characteristics. |
vcoubard | 1167:91c37c858f48 | 60 | */ |
vcoubard | 1167:91c37c858f48 | 61 | GattService(const UUID &uuid, GattCharacteristic *characteristics[], unsigned numCharacteristics) : |
vcoubard | 1179:4ab722f8dca0 | 62 | _primaryServiceID(uuid), _characteristicCount(numCharacteristics), _characteristics(characteristics), _handle(0) { |
vcoubard | 1167:91c37c858f48 | 63 | /* empty */ |
vcoubard | 1167:91c37c858f48 | 64 | } |
vcoubard | 1167:91c37c858f48 | 65 | |
vcoubard | 1179:4ab722f8dca0 | 66 | const UUID &getUUID(void) const {return _primaryServiceID; } |
vcoubard | 1179:4ab722f8dca0 | 67 | uint16_t getHandle(void) const {return _handle; } |
vcoubard | 1179:4ab722f8dca0 | 68 | uint8_t getCharacteristicCount(void) const {return _characteristicCount;} |
vcoubard | 1179:4ab722f8dca0 | 69 | void setHandle(uint16_t handle) {_handle = handle;} |
vcoubard | 1167:91c37c858f48 | 70 | |
vcoubard | 1167:91c37c858f48 | 71 | GattCharacteristic *getCharacteristic(uint8_t index) { |
vcoubard | 1167:91c37c858f48 | 72 | if (index >= _characteristicCount) { |
vcoubard | 1167:91c37c858f48 | 73 | return NULL; |
vcoubard | 1167:91c37c858f48 | 74 | } |
vcoubard | 1167:91c37c858f48 | 75 | |
vcoubard | 1167:91c37c858f48 | 76 | return _characteristics[index]; |
vcoubard | 1167:91c37c858f48 | 77 | } |
vcoubard | 1167:91c37c858f48 | 78 | |
vcoubard | 1167:91c37c858f48 | 79 | private: |
vcoubard | 1167:91c37c858f48 | 80 | UUID _primaryServiceID; |
vcoubard | 1167:91c37c858f48 | 81 | uint8_t _characteristicCount; |
vcoubard | 1167:91c37c858f48 | 82 | GattCharacteristic **_characteristics; |
vcoubard | 1167:91c37c858f48 | 83 | uint16_t _handle; |
vcoubard | 1167:91c37c858f48 | 84 | }; |
vcoubard | 1167:91c37c858f48 | 85 | |
vcoubard | 1179:4ab722f8dca0 | 86 | #endif // ifndef __GATT_SERVICE_H__ |