Rtos API example

Committer:
marcozecchini
Date:
Sat Feb 23 12:13:36 2019 +0000
Revision:
0:9fca2b23d0ba
final commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
marcozecchini 0:9fca2b23d0ba 1 /* mbed Microcontroller Library
marcozecchini 0:9fca2b23d0ba 2 * Copyright (c) 2006-2013 ARM Limited
marcozecchini 0:9fca2b23d0ba 3 *
marcozecchini 0:9fca2b23d0ba 4 * Licensed under the Apache License, Version 2.0 (the "License");
marcozecchini 0:9fca2b23d0ba 5 * you may not use this file except in compliance with the License.
marcozecchini 0:9fca2b23d0ba 6 * You may obtain a copy of the License at
marcozecchini 0:9fca2b23d0ba 7 *
marcozecchini 0:9fca2b23d0ba 8 * http://www.apache.org/licenses/LICENSE-2.0
marcozecchini 0:9fca2b23d0ba 9 *
marcozecchini 0:9fca2b23d0ba 10 * Unless required by applicable law or agreed to in writing, software
marcozecchini 0:9fca2b23d0ba 11 * distributed under the License is distributed on an "AS IS" BASIS,
marcozecchini 0:9fca2b23d0ba 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
marcozecchini 0:9fca2b23d0ba 13 * See the License for the specific language governing permissions and
marcozecchini 0:9fca2b23d0ba 14 * limitations under the License.
marcozecchini 0:9fca2b23d0ba 15 */
marcozecchini 0:9fca2b23d0ba 16
marcozecchini 0:9fca2b23d0ba 17 #ifndef MBED_DISCOVERED_SERVICE_H__
marcozecchini 0:9fca2b23d0ba 18 #define MBED_DISCOVERED_SERVICE_H__
marcozecchini 0:9fca2b23d0ba 19
marcozecchini 0:9fca2b23d0ba 20 #include "UUID.h"
marcozecchini 0:9fca2b23d0ba 21 #include "GattAttribute.h"
marcozecchini 0:9fca2b23d0ba 22
marcozecchini 0:9fca2b23d0ba 23 /**
marcozecchini 0:9fca2b23d0ba 24 * @addtogroup ble
marcozecchini 0:9fca2b23d0ba 25 * @{
marcozecchini 0:9fca2b23d0ba 26 * @addtogroup gatt
marcozecchini 0:9fca2b23d0ba 27 * @{
marcozecchini 0:9fca2b23d0ba 28 * @addtogroup client
marcozecchini 0:9fca2b23d0ba 29 * @{
marcozecchini 0:9fca2b23d0ba 30 */
marcozecchini 0:9fca2b23d0ba 31
marcozecchini 0:9fca2b23d0ba 32 /**
marcozecchini 0:9fca2b23d0ba 33 * Representation of a GATT service discovered.
marcozecchini 0:9fca2b23d0ba 34 *
marcozecchini 0:9fca2b23d0ba 35 * The discovery procedure discovers GATT Services are discovered on distant
marcozecchini 0:9fca2b23d0ba 36 * GATT servers, which can be initiated by calling
marcozecchini 0:9fca2b23d0ba 37 * GattClient::launchServiceDiscovery() or GattClient::discoverServices(). The
marcozecchini 0:9fca2b23d0ba 38 * discovery process passes instances of this class to the callback handling
marcozecchini 0:9fca2b23d0ba 39 * service discovered.
marcozecchini 0:9fca2b23d0ba 40 *
marcozecchini 0:9fca2b23d0ba 41 * Discovered services are characterized by the UUID of the service discovered
marcozecchini 0:9fca2b23d0ba 42 * and the range of the GATT attributes belonging to the service.
marcozecchini 0:9fca2b23d0ba 43 *
marcozecchini 0:9fca2b23d0ba 44 * The UUID can be queried by calling getUUID() while the begining of the
marcozecchini 0:9fca2b23d0ba 45 * attribute range can be obtained through getStartHandle() and the end of the
marcozecchini 0:9fca2b23d0ba 46 * attribute range with a call to getEndHandle().
marcozecchini 0:9fca2b23d0ba 47 *
marcozecchini 0:9fca2b23d0ba 48 * The characteristics composing the service may be discovered by the function
marcozecchini 0:9fca2b23d0ba 49 * GattClient::launchServiceDiscovery().
marcozecchini 0:9fca2b23d0ba 50 */
marcozecchini 0:9fca2b23d0ba 51 class DiscoveredService {
marcozecchini 0:9fca2b23d0ba 52 public:
marcozecchini 0:9fca2b23d0ba 53 /**
marcozecchini 0:9fca2b23d0ba 54 * Get the UUID of the discovered service.
marcozecchini 0:9fca2b23d0ba 55 *
marcozecchini 0:9fca2b23d0ba 56 * @return A reference to the UUID of the discovered service.
marcozecchini 0:9fca2b23d0ba 57 */
marcozecchini 0:9fca2b23d0ba 58 const UUID &getUUID(void) const
marcozecchini 0:9fca2b23d0ba 59 {
marcozecchini 0:9fca2b23d0ba 60 return uuid;
marcozecchini 0:9fca2b23d0ba 61 }
marcozecchini 0:9fca2b23d0ba 62
marcozecchini 0:9fca2b23d0ba 63 /**
marcozecchini 0:9fca2b23d0ba 64 * Get the start handle of the discovered service in the peer's GATT server.
marcozecchini 0:9fca2b23d0ba 65 *
marcozecchini 0:9fca2b23d0ba 66 * @return A reference to the start handle.
marcozecchini 0:9fca2b23d0ba 67 */
marcozecchini 0:9fca2b23d0ba 68 const GattAttribute::Handle_t& getStartHandle(void) const
marcozecchini 0:9fca2b23d0ba 69 {
marcozecchini 0:9fca2b23d0ba 70 return startHandle;
marcozecchini 0:9fca2b23d0ba 71 }
marcozecchini 0:9fca2b23d0ba 72
marcozecchini 0:9fca2b23d0ba 73 /**
marcozecchini 0:9fca2b23d0ba 74 * Get the end handle of the discovered service in the peer's GATT server.
marcozecchini 0:9fca2b23d0ba 75 *
marcozecchini 0:9fca2b23d0ba 76 * @return A reference to the end handle.
marcozecchini 0:9fca2b23d0ba 77 */
marcozecchini 0:9fca2b23d0ba 78 const GattAttribute::Handle_t& getEndHandle(void) const
marcozecchini 0:9fca2b23d0ba 79 {
marcozecchini 0:9fca2b23d0ba 80 return endHandle;
marcozecchini 0:9fca2b23d0ba 81 }
marcozecchini 0:9fca2b23d0ba 82
marcozecchini 0:9fca2b23d0ba 83 public:
marcozecchini 0:9fca2b23d0ba 84 /**
marcozecchini 0:9fca2b23d0ba 85 * Construct a DiscoveredService instance.
marcozecchini 0:9fca2b23d0ba 86 *
marcozecchini 0:9fca2b23d0ba 87 * @important This API is not meant to be used publicly. It is meant to be
marcozecchini 0:9fca2b23d0ba 88 * used by internal APIs of Mbed BLE.
marcozecchini 0:9fca2b23d0ba 89 */
marcozecchini 0:9fca2b23d0ba 90 DiscoveredService() :
marcozecchini 0:9fca2b23d0ba 91 uuid(UUID::ShortUUIDBytes_t(0)),
marcozecchini 0:9fca2b23d0ba 92 startHandle(GattAttribute::INVALID_HANDLE),
marcozecchini 0:9fca2b23d0ba 93 endHandle(GattAttribute::INVALID_HANDLE) {
marcozecchini 0:9fca2b23d0ba 94 }
marcozecchini 0:9fca2b23d0ba 95
marcozecchini 0:9fca2b23d0ba 96 /**
marcozecchini 0:9fca2b23d0ba 97 * Set information about the discovered service.
marcozecchini 0:9fca2b23d0ba 98 *
marcozecchini 0:9fca2b23d0ba 99 * @important This API is not meant to be used publicly. It is meant to be
marcozecchini 0:9fca2b23d0ba 100 * used by internal APIs of Mbed BLE.
marcozecchini 0:9fca2b23d0ba 101 *
marcozecchini 0:9fca2b23d0ba 102 * @param[in] uuidIn The UUID of the discovered service.
marcozecchini 0:9fca2b23d0ba 103 * @param[in] startHandleIn The start handle of the discovered service in
marcozecchini 0:9fca2b23d0ba 104 * the peer's GATT server.
marcozecchini 0:9fca2b23d0ba 105 * @param[in] endHandleIn The end handle of the discovered service in the
marcozecchini 0:9fca2b23d0ba 106 * peer's GATT server.
marcozecchini 0:9fca2b23d0ba 107 */
marcozecchini 0:9fca2b23d0ba 108 void setup(
marcozecchini 0:9fca2b23d0ba 109 UUID uuidIn,
marcozecchini 0:9fca2b23d0ba 110 GattAttribute::Handle_t startHandleIn,
marcozecchini 0:9fca2b23d0ba 111 GattAttribute::Handle_t endHandleIn
marcozecchini 0:9fca2b23d0ba 112 ) {
marcozecchini 0:9fca2b23d0ba 113 uuid = uuidIn;
marcozecchini 0:9fca2b23d0ba 114 startHandle = startHandleIn;
marcozecchini 0:9fca2b23d0ba 115 endHandle = endHandleIn;
marcozecchini 0:9fca2b23d0ba 116 }
marcozecchini 0:9fca2b23d0ba 117
marcozecchini 0:9fca2b23d0ba 118 /**
marcozecchini 0:9fca2b23d0ba 119 * Set the start and end handle of the discovered service.
marcozecchini 0:9fca2b23d0ba 120 *
marcozecchini 0:9fca2b23d0ba 121 * @important This API is not meant to be used publicly. It is meant to be
marcozecchini 0:9fca2b23d0ba 122 * used by internal APIs of Mbed BLE.
marcozecchini 0:9fca2b23d0ba 123 *
marcozecchini 0:9fca2b23d0ba 124 * @param[in] startHandleIn The start handle of the discovered service in
marcozecchini 0:9fca2b23d0ba 125 * the peer's GATT server.
marcozecchini 0:9fca2b23d0ba 126 * @param[in] endHandleIn The end handle of the discovered service in the
marcozecchini 0:9fca2b23d0ba 127 * peer's GATT server.
marcozecchini 0:9fca2b23d0ba 128 */
marcozecchini 0:9fca2b23d0ba 129 void setup(
marcozecchini 0:9fca2b23d0ba 130 GattAttribute::Handle_t startHandleIn,
marcozecchini 0:9fca2b23d0ba 131 GattAttribute::Handle_t endHandleIn
marcozecchini 0:9fca2b23d0ba 132 ) {
marcozecchini 0:9fca2b23d0ba 133 startHandle = startHandleIn;
marcozecchini 0:9fca2b23d0ba 134 endHandle = endHandleIn;
marcozecchini 0:9fca2b23d0ba 135 }
marcozecchini 0:9fca2b23d0ba 136
marcozecchini 0:9fca2b23d0ba 137 /**
marcozecchini 0:9fca2b23d0ba 138 * Set the long UUID of the discovered service.
marcozecchini 0:9fca2b23d0ba 139 *
marcozecchini 0:9fca2b23d0ba 140 * @important This API is not meant to be used publicly. It is meant to be
marcozecchini 0:9fca2b23d0ba 141 * used by internal APIs of Mbed BLE.
marcozecchini 0:9fca2b23d0ba 142 *
marcozecchini 0:9fca2b23d0ba 143 * @param[in] longUUID The bytes composing the long UUID of this discovered
marcozecchini 0:9fca2b23d0ba 144 * service.
marcozecchini 0:9fca2b23d0ba 145 * @param[in] order The byte ordering of @p longUUID.
marcozecchini 0:9fca2b23d0ba 146 */
marcozecchini 0:9fca2b23d0ba 147 void setupLongUUID(
marcozecchini 0:9fca2b23d0ba 148 UUID::LongUUIDBytes_t longUUID,
marcozecchini 0:9fca2b23d0ba 149 UUID::ByteOrder_t order = UUID::MSB
marcozecchini 0:9fca2b23d0ba 150 ) {
marcozecchini 0:9fca2b23d0ba 151 uuid.setupLong(longUUID, order);
marcozecchini 0:9fca2b23d0ba 152 }
marcozecchini 0:9fca2b23d0ba 153
marcozecchini 0:9fca2b23d0ba 154
marcozecchini 0:9fca2b23d0ba 155 private:
marcozecchini 0:9fca2b23d0ba 156 DiscoveredService(const DiscoveredService &);
marcozecchini 0:9fca2b23d0ba 157
marcozecchini 0:9fca2b23d0ba 158 private:
marcozecchini 0:9fca2b23d0ba 159 /**
marcozecchini 0:9fca2b23d0ba 160 * UUID of the service.
marcozecchini 0:9fca2b23d0ba 161 */
marcozecchini 0:9fca2b23d0ba 162 UUID uuid;
marcozecchini 0:9fca2b23d0ba 163
marcozecchini 0:9fca2b23d0ba 164 /**
marcozecchini 0:9fca2b23d0ba 165 * Begining of the Service Handle Range.
marcozecchini 0:9fca2b23d0ba 166 */
marcozecchini 0:9fca2b23d0ba 167 GattAttribute::Handle_t startHandle;
marcozecchini 0:9fca2b23d0ba 168
marcozecchini 0:9fca2b23d0ba 169 /**
marcozecchini 0:9fca2b23d0ba 170 * Service Handle Range.
marcozecchini 0:9fca2b23d0ba 171 */
marcozecchini 0:9fca2b23d0ba 172 GattAttribute::Handle_t endHandle;
marcozecchini 0:9fca2b23d0ba 173 };
marcozecchini 0:9fca2b23d0ba 174
marcozecchini 0:9fca2b23d0ba 175 /**
marcozecchini 0:9fca2b23d0ba 176 * @}
marcozecchini 0:9fca2b23d0ba 177 * @}
marcozecchini 0:9fca2b23d0ba 178 * @}
marcozecchini 0:9fca2b23d0ba 179 */
marcozecchini 0:9fca2b23d0ba 180
marcozecchini 0:9fca2b23d0ba 181 #endif /* MBED_DISCOVERED_SERVICE_H__ */