just a fork

Fork of BLE_API by Bluetooth Low Energy

Committer:
vcoubard
Date:
Wed Apr 06 19:15:07 2016 +0100
Revision:
1167:91c37c858f48
Parent:
1048:efb29faf12fc
Child:
1179:4ab722f8dca0
Synchronized with git rev a757410e
Author: Andres Amaya Garcia
Add missing docs and fix doxy warnings in GattService.h

Who changed what in which revision?

UserRevisionLine numberNew 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 1167:91c37c858f48 62 _primaryServiceID(uuid),
vcoubard 1167:91c37c858f48 63 _characteristicCount(numCharacteristics),
vcoubard 1167:91c37c858f48 64 _characteristics(characteristics),
vcoubard 1167:91c37c858f48 65 _handle(0) {
vcoubard 1167:91c37c858f48 66 /* empty */
vcoubard 1167:91c37c858f48 67 }
vcoubard 1167:91c37c858f48 68
vcoubard 1167:91c37c858f48 69 /**
vcoubard 1167:91c37c858f48 70 * Get this service's UUID.
vcoubard 1167:91c37c858f48 71 *
vcoubard 1167:91c37c858f48 72 * @return A reference to the service's UUID.
vcoubard 1167:91c37c858f48 73 */
vcoubard 1167:91c37c858f48 74 const UUID &getUUID(void) const {
vcoubard 1167:91c37c858f48 75 return _primaryServiceID;
vcoubard 1167:91c37c858f48 76 }
vcoubard 1167:91c37c858f48 77
vcoubard 1167:91c37c858f48 78 /**
vcoubard 1167:91c37c858f48 79 * Get handle of the service declaration attribute in the ATT table.
vcoubard 1167:91c37c858f48 80 *
vcoubard 1167:91c37c858f48 81 * @return The service's handle.
vcoubard 1167:91c37c858f48 82 */
vcoubard 1167:91c37c858f48 83 uint16_t getHandle(void) const {
vcoubard 1167:91c37c858f48 84 return _handle;
vcoubard 1167:91c37c858f48 85 }
vcoubard 1167:91c37c858f48 86
vcoubard 1167:91c37c858f48 87 /**
vcoubard 1167:91c37c858f48 88 * Get the total number of characteristics within this service.
vcoubard 1167:91c37c858f48 89 *
vcoubard 1167:91c37c858f48 90 * @return The total number of characteristics within this service.
vcoubard 1167:91c37c858f48 91 */
vcoubard 1167:91c37c858f48 92 uint8_t getCharacteristicCount(void) const {
vcoubard 1167:91c37c858f48 93 return _characteristicCount;
vcoubard 1167:91c37c858f48 94 }
vcoubard 1167:91c37c858f48 95
vcoubard 1167:91c37c858f48 96 /**
vcoubard 1167:91c37c858f48 97 * Set the handle of the service declaration attribute in the ATT table.
vcoubard 1167:91c37c858f48 98 *
vcoubard 1167:91c37c858f48 99 * @param[in] handle
vcoubard 1167:91c37c858f48 100 * The service's handle.
vcoubard 1167:91c37c858f48 101 */
vcoubard 1167:91c37c858f48 102 void setHandle(uint16_t handle) {
vcoubard 1167:91c37c858f48 103 _handle = handle;
vcoubard 1167:91c37c858f48 104 }
vcoubard 1167:91c37c858f48 105
vcoubard 1167:91c37c858f48 106 /**
vcoubard 1167:91c37c858f48 107 * Get this service's characteristic at a specific index.
vcoubard 1167:91c37c858f48 108 *
vcoubard 1167:91c37c858f48 109 * @param[in] index
vcoubard 1167:91c37c858f48 110 * The index of the characteristic.
vcoubard 1167:91c37c858f48 111 *
vcoubard 1167:91c37c858f48 112 * @return A pointer to the characterisitic at index @p index.
vcoubard 1167:91c37c858f48 113 */
vcoubard 1167:91c37c858f48 114 GattCharacteristic *getCharacteristic(uint8_t index) {
vcoubard 1167:91c37c858f48 115 if (index >= _characteristicCount) {
vcoubard 1167:91c37c858f48 116 return NULL;
vcoubard 1167:91c37c858f48 117 }
vcoubard 1167:91c37c858f48 118
vcoubard 1167:91c37c858f48 119 return _characteristics[index];
vcoubard 1167:91c37c858f48 120 }
vcoubard 1167:91c37c858f48 121
vcoubard 1167:91c37c858f48 122 private:
vcoubard 1167:91c37c858f48 123 /**
vcoubard 1167:91c37c858f48 124 * This service's UUID.
vcoubard 1167:91c37c858f48 125 */
vcoubard 1167:91c37c858f48 126 UUID _primaryServiceID;
vcoubard 1167:91c37c858f48 127 /**
vcoubard 1167:91c37c858f48 128 * Total number of characteristics within this service.
vcoubard 1167:91c37c858f48 129 */
vcoubard 1167:91c37c858f48 130 uint8_t _characteristicCount;
vcoubard 1167:91c37c858f48 131 /**
vcoubard 1167:91c37c858f48 132 * An array with pointers to the characteristics added to this service.
vcoubard 1167:91c37c858f48 133 */
vcoubard 1167:91c37c858f48 134 GattCharacteristic **_characteristics;
vcoubard 1167:91c37c858f48 135 /**
vcoubard 1167:91c37c858f48 136 * Handle of the service declaration attribute in the ATT table.
vcoubard 1167:91c37c858f48 137 *
vcoubard 1167:91c37c858f48 138 * @note This handle is generally assigned by the underlying BLE stack when the
vcoubard 1167:91c37c858f48 139 * service is added to the ATT table.
vcoubard 1167:91c37c858f48 140 */
vcoubard 1167:91c37c858f48 141 uint16_t _handle;
vcoubard 1167:91c37c858f48 142 };
vcoubard 1167:91c37c858f48 143
vcoubard 1167:91c37c858f48 144 #endif /* ifndef __GATT_SERVICE_H__ */