Official Sheffield ARMBand micro:bit program
microbit/microbit-dal/BLE_API/ble/DiscoveredService.h@0:b9164b348919, 2016-10-17 (annotated)
- 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?
User | Revision | Line number | New 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 __DISCOVERED_SERVICE_H__ |
MrBedfordVan | 0:b9164b348919 | 18 | #define __DISCOVERED_SERVICE_H__ |
MrBedfordVan | 0:b9164b348919 | 19 | |
MrBedfordVan | 0:b9164b348919 | 20 | #include "UUID.h" |
MrBedfordVan | 0:b9164b348919 | 21 | #include "GattAttribute.h" |
MrBedfordVan | 0:b9164b348919 | 22 | |
MrBedfordVan | 0:b9164b348919 | 23 | /**@brief Type for holding information about the service and the characteristics found during |
MrBedfordVan | 0:b9164b348919 | 24 | * the discovery process. |
MrBedfordVan | 0:b9164b348919 | 25 | */ |
MrBedfordVan | 0:b9164b348919 | 26 | class DiscoveredService { |
MrBedfordVan | 0:b9164b348919 | 27 | public: |
MrBedfordVan | 0:b9164b348919 | 28 | void setup(UUID uuidIn, GattAttribute::Handle_t startHandleIn, GattAttribute::Handle_t endHandleIn) { |
MrBedfordVan | 0:b9164b348919 | 29 | uuid = uuidIn; |
MrBedfordVan | 0:b9164b348919 | 30 | startHandle = startHandleIn; |
MrBedfordVan | 0:b9164b348919 | 31 | endHandle = endHandleIn; |
MrBedfordVan | 0:b9164b348919 | 32 | } |
MrBedfordVan | 0:b9164b348919 | 33 | |
MrBedfordVan | 0:b9164b348919 | 34 | void setup(GattAttribute::Handle_t startHandleIn, GattAttribute::Handle_t endHandleIn) { |
MrBedfordVan | 0:b9164b348919 | 35 | startHandle = startHandleIn; |
MrBedfordVan | 0:b9164b348919 | 36 | endHandle = endHandleIn; |
MrBedfordVan | 0:b9164b348919 | 37 | } |
MrBedfordVan | 0:b9164b348919 | 38 | |
MrBedfordVan | 0:b9164b348919 | 39 | void setupLongUUID(UUID::LongUUIDBytes_t longUUID, UUID::ByteOrder_t order = UUID::MSB) { |
MrBedfordVan | 0:b9164b348919 | 40 | uuid.setupLong(longUUID, order); |
MrBedfordVan | 0:b9164b348919 | 41 | } |
MrBedfordVan | 0:b9164b348919 | 42 | |
MrBedfordVan | 0:b9164b348919 | 43 | public: |
MrBedfordVan | 0:b9164b348919 | 44 | const UUID &getUUID(void) const { |
MrBedfordVan | 0:b9164b348919 | 45 | return uuid; |
MrBedfordVan | 0:b9164b348919 | 46 | } |
MrBedfordVan | 0:b9164b348919 | 47 | |
MrBedfordVan | 0:b9164b348919 | 48 | const GattAttribute::Handle_t& getStartHandle(void) const { |
MrBedfordVan | 0:b9164b348919 | 49 | return startHandle; |
MrBedfordVan | 0:b9164b348919 | 50 | } |
MrBedfordVan | 0:b9164b348919 | 51 | const GattAttribute::Handle_t& getEndHandle(void) const { |
MrBedfordVan | 0:b9164b348919 | 52 | return endHandle; |
MrBedfordVan | 0:b9164b348919 | 53 | } |
MrBedfordVan | 0:b9164b348919 | 54 | |
MrBedfordVan | 0:b9164b348919 | 55 | public: |
MrBedfordVan | 0:b9164b348919 | 56 | DiscoveredService() : uuid(UUID::ShortUUIDBytes_t(0)), |
MrBedfordVan | 0:b9164b348919 | 57 | startHandle(GattAttribute::INVALID_HANDLE), |
MrBedfordVan | 0:b9164b348919 | 58 | endHandle(GattAttribute::INVALID_HANDLE) { |
MrBedfordVan | 0:b9164b348919 | 59 | /* empty */ |
MrBedfordVan | 0:b9164b348919 | 60 | } |
MrBedfordVan | 0:b9164b348919 | 61 | |
MrBedfordVan | 0:b9164b348919 | 62 | private: |
MrBedfordVan | 0:b9164b348919 | 63 | DiscoveredService(const DiscoveredService &); |
MrBedfordVan | 0:b9164b348919 | 64 | |
MrBedfordVan | 0:b9164b348919 | 65 | private: |
MrBedfordVan | 0:b9164b348919 | 66 | UUID uuid; /**< UUID of the service. */ |
MrBedfordVan | 0:b9164b348919 | 67 | GattAttribute::Handle_t startHandle; /**< Service Handle Range. */ |
MrBedfordVan | 0:b9164b348919 | 68 | GattAttribute::Handle_t endHandle; /**< Service Handle Range. */ |
MrBedfordVan | 0:b9164b348919 | 69 | }; |
MrBedfordVan | 0:b9164b348919 | 70 | |
MrBedfordVan | 0:b9164b348919 | 71 | #endif /*__DISCOVERED_SERVICE_H__*/ |