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