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

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.