テスト用です。

Dependencies:   mbed

Committer:
jksoft
Date:
Tue Oct 11 11:09:42 2016 +0000
Revision:
0:8468a4403fea
SB??ver;

Who changed what in which revision?

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