High level Bluetooth Low Energy API and radio abstraction layer
Fork of BLE_API by
ble/DiscoveredService.h@1209:dd7707bda534, 2017-03-28 (annotated)
- Committer:
- cordonn2
- Date:
- Tue Mar 28 19:09:54 2017 +0000
- Revision:
- 1209:dd7707bda534
- Parent:
- 1183:1589830dbdb7
Added ability to filter advertising channel programmatically
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
vcoubard | 1131:692ddf04fc42 | 1 | /* mbed Microcontroller Library |
vcoubard | 1131:692ddf04fc42 | 2 | * Copyright (c) 2006-2013 ARM Limited |
vcoubard | 1131:692ddf04fc42 | 3 | * |
vcoubard | 1131:692ddf04fc42 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
vcoubard | 1131:692ddf04fc42 | 5 | * you may not use this file except in compliance with the License. |
vcoubard | 1131:692ddf04fc42 | 6 | * You may obtain a copy of the License at |
vcoubard | 1131:692ddf04fc42 | 7 | * |
vcoubard | 1131:692ddf04fc42 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
vcoubard | 1131:692ddf04fc42 | 9 | * |
vcoubard | 1131:692ddf04fc42 | 10 | * Unless required by applicable law or agreed to in writing, software |
vcoubard | 1131:692ddf04fc42 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
vcoubard | 1131:692ddf04fc42 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
vcoubard | 1131:692ddf04fc42 | 13 | * See the License for the specific language governing permissions and |
vcoubard | 1131:692ddf04fc42 | 14 | * limitations under the License. |
vcoubard | 1131:692ddf04fc42 | 15 | */ |
vcoubard | 1131:692ddf04fc42 | 16 | |
vcoubard | 1131:692ddf04fc42 | 17 | #ifndef __DISCOVERED_SERVICE_H__ |
vcoubard | 1131:692ddf04fc42 | 18 | #define __DISCOVERED_SERVICE_H__ |
vcoubard | 1131:692ddf04fc42 | 19 | |
vcoubard | 1131:692ddf04fc42 | 20 | #include "UUID.h" |
vcoubard | 1131:692ddf04fc42 | 21 | #include "GattAttribute.h" |
vcoubard | 1131:692ddf04fc42 | 22 | |
vcoubard | 1131:692ddf04fc42 | 23 | /**@brief Type for holding information about the service and the characteristics found during |
vcoubard | 1131:692ddf04fc42 | 24 | * the discovery process. |
vcoubard | 1131:692ddf04fc42 | 25 | */ |
vcoubard | 1131:692ddf04fc42 | 26 | class DiscoveredService { |
vcoubard | 1131:692ddf04fc42 | 27 | public: |
vcoubard | 1183:1589830dbdb7 | 28 | /** |
vcoubard | 1183:1589830dbdb7 | 29 | * Set information about the discovered service. |
vcoubard | 1183:1589830dbdb7 | 30 | * |
vcoubard | 1183:1589830dbdb7 | 31 | * @param[in] uuidIn |
vcoubard | 1183:1589830dbdb7 | 32 | * The UUID of the discovered service. |
vcoubard | 1183:1589830dbdb7 | 33 | * @param[in] startHandleIn |
vcoubard | 1183:1589830dbdb7 | 34 | * The start handle of the discovered service in the peer's |
vcoubard | 1183:1589830dbdb7 | 35 | * ATT table. |
vcoubard | 1183:1589830dbdb7 | 36 | * @param[in] endHandleIn |
vcoubard | 1183:1589830dbdb7 | 37 | * The end handle of the discovered service in the peer's |
vcoubard | 1183:1589830dbdb7 | 38 | * ATT table. |
vcoubard | 1183:1589830dbdb7 | 39 | */ |
vcoubard | 1183:1589830dbdb7 | 40 | void setup(UUID uuidIn, GattAttribute::Handle_t startHandleIn, GattAttribute::Handle_t endHandleIn) { |
vcoubard | 1183:1589830dbdb7 | 41 | uuid = uuidIn; |
vcoubard | 1183:1589830dbdb7 | 42 | startHandle = startHandleIn; |
vcoubard | 1183:1589830dbdb7 | 43 | endHandle = endHandleIn; |
vcoubard | 1183:1589830dbdb7 | 44 | } |
vcoubard | 1131:692ddf04fc42 | 45 | |
vcoubard | 1183:1589830dbdb7 | 46 | /** |
vcoubard | 1183:1589830dbdb7 | 47 | * Set the start and end handle of the discovered service. |
vcoubard | 1183:1589830dbdb7 | 48 | * @param[in] startHandleIn |
vcoubard | 1183:1589830dbdb7 | 49 | * The start handle of the discovered service in the peer's |
vcoubard | 1183:1589830dbdb7 | 50 | * ATT table. |
vcoubard | 1183:1589830dbdb7 | 51 | * @param[in] endHandleIn |
vcoubard | 1183:1589830dbdb7 | 52 | * The end handle of the discovered service in the peer's |
vcoubard | 1183:1589830dbdb7 | 53 | * ATT table. |
vcoubard | 1183:1589830dbdb7 | 54 | */ |
vcoubard | 1183:1589830dbdb7 | 55 | void setup(GattAttribute::Handle_t startHandleIn, GattAttribute::Handle_t endHandleIn) { |
vcoubard | 1183:1589830dbdb7 | 56 | startHandle = startHandleIn; |
vcoubard | 1183:1589830dbdb7 | 57 | endHandle = endHandleIn; |
vcoubard | 1183:1589830dbdb7 | 58 | } |
vcoubard | 1131:692ddf04fc42 | 59 | |
vcoubard | 1183:1589830dbdb7 | 60 | /** |
vcoubard | 1183:1589830dbdb7 | 61 | * Set the long UUID of the discovered service. |
vcoubard | 1183:1589830dbdb7 | 62 | * |
vcoubard | 1183:1589830dbdb7 | 63 | * @param[in] longUUID |
vcoubard | 1183:1589830dbdb7 | 64 | * The long UUID of the discovered service. |
vcoubard | 1183:1589830dbdb7 | 65 | * @param[in] order |
vcoubard | 1183:1589830dbdb7 | 66 | * The byte ordering of @p longUUID. |
vcoubard | 1183:1589830dbdb7 | 67 | */ |
vcoubard | 1134:d540a48f650d | 68 | void setupLongUUID(UUID::LongUUIDBytes_t longUUID, UUID::ByteOrder_t order = UUID::MSB) { |
vcoubard | 1134:d540a48f650d | 69 | uuid.setupLong(longUUID, order); |
vcoubard | 1131:692ddf04fc42 | 70 | } |
vcoubard | 1131:692ddf04fc42 | 71 | |
vcoubard | 1131:692ddf04fc42 | 72 | public: |
vcoubard | 1183:1589830dbdb7 | 73 | /** |
vcoubard | 1183:1589830dbdb7 | 74 | * Get the UUID of the discovered service. |
vcoubard | 1183:1589830dbdb7 | 75 | * |
vcoubard | 1183:1589830dbdb7 | 76 | * @return A reference to the UUID of the discovered service. |
vcoubard | 1183:1589830dbdb7 | 77 | */ |
vcoubard | 1131:692ddf04fc42 | 78 | const UUID &getUUID(void) const { |
vcoubard | 1131:692ddf04fc42 | 79 | return uuid; |
vcoubard | 1131:692ddf04fc42 | 80 | } |
vcoubard | 1131:692ddf04fc42 | 81 | |
vcoubard | 1183:1589830dbdb7 | 82 | /** |
vcoubard | 1183:1589830dbdb7 | 83 | * Get the start handle of the discovered service in the peer's ATT table. |
vcoubard | 1183:1589830dbdb7 | 84 | * |
vcoubard | 1183:1589830dbdb7 | 85 | * @return A reference to the start handle. |
vcoubard | 1183:1589830dbdb7 | 86 | */ |
vcoubard | 1131:692ddf04fc42 | 87 | const GattAttribute::Handle_t& getStartHandle(void) const { |
vcoubard | 1131:692ddf04fc42 | 88 | return startHandle; |
vcoubard | 1131:692ddf04fc42 | 89 | } |
vcoubard | 1183:1589830dbdb7 | 90 | |
vcoubard | 1183:1589830dbdb7 | 91 | /** |
vcoubard | 1183:1589830dbdb7 | 92 | * Get the end handle of the discovered service in the peer's ATT table. |
vcoubard | 1183:1589830dbdb7 | 93 | * |
vcoubard | 1183:1589830dbdb7 | 94 | * @return A reference to the end handle. |
vcoubard | 1183:1589830dbdb7 | 95 | */ |
vcoubard | 1131:692ddf04fc42 | 96 | const GattAttribute::Handle_t& getEndHandle(void) const { |
vcoubard | 1131:692ddf04fc42 | 97 | return endHandle; |
vcoubard | 1131:692ddf04fc42 | 98 | } |
vcoubard | 1131:692ddf04fc42 | 99 | |
vcoubard | 1131:692ddf04fc42 | 100 | public: |
vcoubard | 1183:1589830dbdb7 | 101 | /** |
vcoubard | 1183:1589830dbdb7 | 102 | * Construct a DiscoveredService instance. |
vcoubard | 1183:1589830dbdb7 | 103 | */ |
vcoubard | 1131:692ddf04fc42 | 104 | DiscoveredService() : uuid(UUID::ShortUUIDBytes_t(0)), |
vcoubard | 1131:692ddf04fc42 | 105 | startHandle(GattAttribute::INVALID_HANDLE), |
vcoubard | 1131:692ddf04fc42 | 106 | endHandle(GattAttribute::INVALID_HANDLE) { |
vcoubard | 1131:692ddf04fc42 | 107 | /* empty */ |
vcoubard | 1131:692ddf04fc42 | 108 | } |
vcoubard | 1131:692ddf04fc42 | 109 | |
vcoubard | 1131:692ddf04fc42 | 110 | private: |
vcoubard | 1131:692ddf04fc42 | 111 | DiscoveredService(const DiscoveredService &); |
vcoubard | 1131:692ddf04fc42 | 112 | |
vcoubard | 1131:692ddf04fc42 | 113 | private: |
vcoubard | 1131:692ddf04fc42 | 114 | UUID uuid; /**< UUID of the service. */ |
vcoubard | 1131:692ddf04fc42 | 115 | GattAttribute::Handle_t startHandle; /**< Service Handle Range. */ |
vcoubard | 1131:692ddf04fc42 | 116 | GattAttribute::Handle_t endHandle; /**< Service Handle Range. */ |
vcoubard | 1131:692ddf04fc42 | 117 | }; |
vcoubard | 1131:692ddf04fc42 | 118 | |
rgrover1 | 716:11b41f651697 | 119 | #endif /*__DISCOVERED_SERVICE_H__*/ |