vo dung
/
eddystone_URL
first commit
Fork of BLE_WallbotBLE_Challenge by
BLE_API/public/GattService.h@5:984cc7e96073, 2017-12-21 (annotated)
- Committer:
- tridung141196
- Date:
- Thu Dec 21 03:40:35 2017 +0000
- Revision:
- 5:984cc7e96073
- Parent:
- 0:76dfa9657d9d
eddystone url
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jksoft | 0:76dfa9657d9d | 1 | /* mbed Microcontroller Library |
jksoft | 0:76dfa9657d9d | 2 | * Copyright (c) 2006-2013 ARM Limited |
jksoft | 0:76dfa9657d9d | 3 | * |
jksoft | 0:76dfa9657d9d | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
jksoft | 0:76dfa9657d9d | 5 | * you may not use this file except in compliance with the License. |
jksoft | 0:76dfa9657d9d | 6 | * You may obtain a copy of the License at |
jksoft | 0:76dfa9657d9d | 7 | * |
jksoft | 0:76dfa9657d9d | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
jksoft | 0:76dfa9657d9d | 9 | * |
jksoft | 0:76dfa9657d9d | 10 | * Unless required by applicable law or agreed to in writing, software |
jksoft | 0:76dfa9657d9d | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
jksoft | 0:76dfa9657d9d | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
jksoft | 0:76dfa9657d9d | 13 | * See the License for the specific language governing permissions and |
jksoft | 0:76dfa9657d9d | 14 | * limitations under the License. |
jksoft | 0:76dfa9657d9d | 15 | */ |
jksoft | 0:76dfa9657d9d | 16 | |
jksoft | 0:76dfa9657d9d | 17 | |
jksoft | 0:76dfa9657d9d | 18 | #ifndef __GATT_SERVICE_H__ |
jksoft | 0:76dfa9657d9d | 19 | #define __GATT_SERVICE_H__ |
jksoft | 0:76dfa9657d9d | 20 | |
jksoft | 0:76dfa9657d9d | 21 | #include "blecommon.h" |
jksoft | 0:76dfa9657d9d | 22 | #include "UUID.h" |
jksoft | 0:76dfa9657d9d | 23 | #include "GattCharacteristic.h" |
jksoft | 0:76dfa9657d9d | 24 | |
jksoft | 0:76dfa9657d9d | 25 | |
jksoft | 0:76dfa9657d9d | 26 | /**************************************************************************/ |
jksoft | 0:76dfa9657d9d | 27 | /*! |
jksoft | 0:76dfa9657d9d | 28 | \brief GATT service |
jksoft | 0:76dfa9657d9d | 29 | */ |
jksoft | 0:76dfa9657d9d | 30 | /**************************************************************************/ |
jksoft | 0:76dfa9657d9d | 31 | class GattService |
jksoft | 0:76dfa9657d9d | 32 | { |
jksoft | 0:76dfa9657d9d | 33 | public: |
jksoft | 0:76dfa9657d9d | 34 | /** |
jksoft | 0:76dfa9657d9d | 35 | * @brief Creates a new GattCharacteristic using the specified 16-bit |
jksoft | 0:76dfa9657d9d | 36 | * UUID, value length, and properties |
jksoft | 0:76dfa9657d9d | 37 | * |
jksoft | 0:76dfa9657d9d | 38 | * @note The UUID value must be unique in the service and is normally >1 |
jksoft | 0:76dfa9657d9d | 39 | * |
jksoft | 0:76dfa9657d9d | 40 | * @param[in] uuid |
jksoft | 0:76dfa9657d9d | 41 | * The UUID to use for this characteristic |
jksoft | 0:76dfa9657d9d | 42 | * @param[in] characteristics |
jksoft | 0:76dfa9657d9d | 43 | * A pointer to an array of characteristics to be included within this service |
jksoft | 0:76dfa9657d9d | 44 | * @param[in] numCharacteristics |
jksoft | 0:76dfa9657d9d | 45 | * The number of characteristics |
jksoft | 0:76dfa9657d9d | 46 | */ |
jksoft | 0:76dfa9657d9d | 47 | /**************************************************************************/ |
jksoft | 0:76dfa9657d9d | 48 | GattService(const UUID &uuid, GattCharacteristic *characteristics[], unsigned numCharacteristics); |
jksoft | 0:76dfa9657d9d | 49 | |
jksoft | 0:76dfa9657d9d | 50 | enum { |
jksoft | 0:76dfa9657d9d | 51 | UUID_ALERT_NOTIFICATION_SERVICE = 0x1811, |
jksoft | 0:76dfa9657d9d | 52 | UUID_BATTERY_SERVICE = 0x180F, |
jksoft | 0:76dfa9657d9d | 53 | UUID_BLOOD_PRESSURE_SERVICE = 0x1810, |
jksoft | 0:76dfa9657d9d | 54 | UUID_CURRENT_TIME_SERVICE = 0x1805, |
jksoft | 0:76dfa9657d9d | 55 | UUID_CYCLING_SPEED_AND_CADENCE = 0x1816, |
jksoft | 0:76dfa9657d9d | 56 | UUID_DEVICE_INFORMATION_SERVICE = 0x180A, |
jksoft | 0:76dfa9657d9d | 57 | UUID_GLUCOSE_SERVICE = 0x1808, |
jksoft | 0:76dfa9657d9d | 58 | UUID_HEALTH_THERMOMETER_SERVICE = 0x1809, |
jksoft | 0:76dfa9657d9d | 59 | UUID_HEART_RATE_SERVICE = 0x180D, |
jksoft | 0:76dfa9657d9d | 60 | UUID_HUMAN_INTERFACE_DEVICE_SERVICE = 0x1812, |
jksoft | 0:76dfa9657d9d | 61 | UUID_IMMEDIATE_ALERT_SERVICE = 0x1802, |
jksoft | 0:76dfa9657d9d | 62 | UUID_LINK_LOSS_SERVICE = 0x1803, |
jksoft | 0:76dfa9657d9d | 63 | UUID_NEXT_DST_CHANGE_SERVICE = 0x1807, |
jksoft | 0:76dfa9657d9d | 64 | UUID_PHONE_ALERT_STATUS_SERVICE = 0x180E, |
jksoft | 0:76dfa9657d9d | 65 | UUID_REFERENCE_TIME_UPDATE_SERVICE = 0x1806, |
jksoft | 0:76dfa9657d9d | 66 | UUID_RUNNING_SPEED_AND_CADENCE = 0x1814, |
jksoft | 0:76dfa9657d9d | 67 | UUID_SCAN_PARAMETERS_SERVICE = 0x1813, |
jksoft | 0:76dfa9657d9d | 68 | UUID_TX_POWER_SERVICE = 0x1804 |
jksoft | 0:76dfa9657d9d | 69 | }; |
jksoft | 0:76dfa9657d9d | 70 | |
jksoft | 0:76dfa9657d9d | 71 | const UUID &getUUID(void) const { |
jksoft | 0:76dfa9657d9d | 72 | return _primaryServiceID; |
jksoft | 0:76dfa9657d9d | 73 | } |
jksoft | 0:76dfa9657d9d | 74 | uint16_t getHandle(void) const { |
jksoft | 0:76dfa9657d9d | 75 | return _handle; |
jksoft | 0:76dfa9657d9d | 76 | } |
jksoft | 0:76dfa9657d9d | 77 | void setHandle(uint16_t handle) { |
jksoft | 0:76dfa9657d9d | 78 | _handle = handle; |
jksoft | 0:76dfa9657d9d | 79 | } |
jksoft | 0:76dfa9657d9d | 80 | uint8_t getCharacteristicCount(void) const { |
jksoft | 0:76dfa9657d9d | 81 | return _characteristicCount; |
jksoft | 0:76dfa9657d9d | 82 | } |
jksoft | 0:76dfa9657d9d | 83 | GattCharacteristic *getCharacteristic(uint8_t index) { |
jksoft | 0:76dfa9657d9d | 84 | if (index >= _characteristicCount) { |
jksoft | 0:76dfa9657d9d | 85 | return NULL; |
jksoft | 0:76dfa9657d9d | 86 | } |
jksoft | 0:76dfa9657d9d | 87 | |
jksoft | 0:76dfa9657d9d | 88 | return _characteristics[index]; |
jksoft | 0:76dfa9657d9d | 89 | } |
jksoft | 0:76dfa9657d9d | 90 | |
jksoft | 0:76dfa9657d9d | 91 | private: |
jksoft | 0:76dfa9657d9d | 92 | UUID _primaryServiceID; |
jksoft | 0:76dfa9657d9d | 93 | uint8_t _characteristicCount; |
jksoft | 0:76dfa9657d9d | 94 | GattCharacteristic **_characteristics; |
jksoft | 0:76dfa9657d9d | 95 | uint16_t _handle; |
jksoft | 0:76dfa9657d9d | 96 | }; |
jksoft | 0:76dfa9657d9d | 97 | |
jksoft | 0:76dfa9657d9d | 98 | #endif // ifndef __GATT_SERVICE_H__ |