IOTIO

Fork of Nucleo_BLE_API by ST Americas mbed Team

Committer:
16038618
Date:
Sat Oct 29 14:16:12 2016 +0000
Revision:
2:584d5bedac75
Parent:
0:289fd2dae405
IOTIO

Who changed what in which revision?

UserRevisionLine numberNew 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,
16038618 2:584d5bedac75 68 UUID_TX_POWER_SERVICE = 0x1804,
16038618 2:584d5bedac75 69 UUID_ENVIRONMENTAL_SENSING_SERVICE = 0x181A, //Check the adopted services -> https://developer.bluetooth.org/gatt/services/Pages/ServicesHome.aspx
sjallouli 0:289fd2dae405 70 };
sjallouli 0:289fd2dae405 71
sjallouli 0:289fd2dae405 72 const UUID &getUUID(void) const {
sjallouli 0:289fd2dae405 73 return _primaryServiceID;
sjallouli 0:289fd2dae405 74 }
sjallouli 0:289fd2dae405 75 uint16_t getHandle(void) const {
sjallouli 0:289fd2dae405 76 return _handle;
sjallouli 0:289fd2dae405 77 }
sjallouli 0:289fd2dae405 78 void setHandle(uint16_t handle) {
sjallouli 0:289fd2dae405 79 _handle = handle;
sjallouli 0:289fd2dae405 80 }
sjallouli 0:289fd2dae405 81 uint8_t getCharacteristicCount(void) const {
sjallouli 0:289fd2dae405 82 return _characteristicCount;
sjallouli 0:289fd2dae405 83 }
sjallouli 0:289fd2dae405 84 GattCharacteristic *getCharacteristic(uint8_t index) {
sjallouli 0:289fd2dae405 85 if (index >= _characteristicCount) {
sjallouli 0:289fd2dae405 86 return NULL;
sjallouli 0:289fd2dae405 87 }
sjallouli 0:289fd2dae405 88
sjallouli 0:289fd2dae405 89 return _characteristics[index];
sjallouli 0:289fd2dae405 90 }
sjallouli 0:289fd2dae405 91
sjallouli 0:289fd2dae405 92 private:
sjallouli 0:289fd2dae405 93 UUID _primaryServiceID;
sjallouli 0:289fd2dae405 94 uint8_t _characteristicCount;
sjallouli 0:289fd2dae405 95 GattCharacteristic **_characteristics;
sjallouli 0:289fd2dae405 96 uint16_t _handle;
sjallouli 0:289fd2dae405 97 };
sjallouli 0:289fd2dae405 98
sjallouli 0:289fd2dae405 99 #endif // ifndef __GATT_SERVICE_H__