fka mod

Fork of BLE_API by Bluetooth Low Energy

Committer:
carlescufi
Date:
Thu Aug 28 14:17:34 2014 +0200
Revision:
113:7e3fd573d87b
Parent:
106:a20be740075d
Child:
144:c025c8839682
Add optional descriptors to the char constructor

Who changed what in which revision?

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