Official Sheffield ARMBand micro:bit program

Committer:
MrBedfordVan
Date:
Mon Oct 17 12:41:20 2016 +0000
Revision:
0:b9164b348919
Official Sheffield ARMBand Micro:bit program

Who changed what in which revision?

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