36
36
*/
37
37
38
38
/* *
39
- * Define procedures required for interracting with a distant GATT server.
39
+ * Define procedures required for interacting with a distant GATT server.
40
40
*
41
41
* @par Discovery procedures
42
42
*
43
- * A GATT server host a fixed set of services. These services are a logical
44
- * composition of Characteristic which may be discovered, read, written or also
43
+ * A GATT server hosts a fixed set of services. These services are a logical
44
+ * composition of characteristics that may be discovered, read, written or also
45
45
* broadcast their state to a connected client. These characteristics may also
46
- * contain meta information named characteristic descriptors. A characteristic
46
+ * contain metainformation named characteristic descriptors. A characteristic
47
47
* descriptor may be used to indicate the unit used for a characteristic value,
48
48
* describe in a textual form the characterisic purpose or allow a client to
49
49
* register for notification of updates of the characteristic value.
50
50
*
51
- * Prior to any interaction with server characteristic, a GATT client should
52
- * discover the layout of the services and characteristics present on the
51
+ * Prior to any interaction with server characteristic, a GATT client
52
+ * discovers the layout of the services and characteristics present on the
53
53
* server.
54
54
*
55
55
* The layout of the descriptors of a characteristic may also be issued to
56
56
* as an extra discovery step.
57
57
*
58
58
* @par Attribute manipulation
59
59
*
60
- * As a result of the discovery process the client can start interracting with
60
+ * As a result of the discovery process, the client can start interacting with
61
61
* the characteristic discovered. Depending on the characteristic properties
62
- * (acquired during discovery) a client can read or write the value of a given
62
+ * (acquired during discovery), a client can read or write the value of a given
63
63
* characteristic.
64
64
*
65
- * mbed BLE abstract most read and write operation to offer a single API which
65
+ * Mbed BLE abstracts most read and write operations to offer a single API that
66
66
* can be used to read or write characteristics values. Application code does not
67
67
* have to handle the fragmentation/reassembly process necessary if the attribute
68
68
* value to transported cannot fit in a single data packet.
69
69
*
70
70
* @par Server Initiated events
71
71
*
72
- * If a characteristic has the notify or indicate property set then a client may
73
- * register to notification or indication from the characteristic. When the
74
- * characteristic value is updated by the server , the server can forward the
72
+ * If a characteristic has to notify or indicate a property set; then, a client may
73
+ * register to a notification or indication from the characteristic. When the
74
+ * server updates the characteristic value , the server can forward the
75
75
* new value to the registered clients. The notification/indication mechanism
76
76
* prevents polling from the client and therefore minimize the transactions
77
77
* involved between a client and a server.
78
78
*
79
79
* Registration is made by writing the Client Characteristic Configuration
80
- * Descriptor which shall be present in the characteristic if the notify or
81
- * indicate properties are set. That descriptor shall be discovered by the client
80
+ * Descriptor, which is present in the characteristic if the notify or
81
+ * indicate properties are set. The client discovers that descriptor
82
82
* if it intends to register to server initiated events.
83
83
*/
84
84
class GattClient {
@@ -169,7 +169,7 @@ class GattClient {
169
169
170
170
/*
171
171
* The following functions are meant to be overridden in the platform
172
- * specific sub-class .
172
+ * specific subclass .
173
173
*/
174
174
public:
175
175
@@ -179,17 +179,17 @@ class GattClient {
179
179
* Launch the service and characteristic discovery procedure of a GATT server
180
180
* peer.
181
181
*
182
- * The procedure will invoke application callbacks for matching services or
182
+ * The procedure invokes application callbacks for matching services or
183
183
* characteristics. The process ends after all the services and
184
184
* characteristics present on the distant GATT server have been discovered.
185
185
* Termination callbacks registered with onServiceDiscoveryTermination() are
186
186
* invoked to notify the application of the termination of the procedure.
187
187
*
188
188
* Application code can track the status of the procedure by invoking the
189
- * function isServiceDiscoveryActive() which will return true if the
189
+ * function isServiceDiscoveryActive(), which returns true if the
190
190
* procedure is ongoing.
191
191
*
192
- * At any point application code can terminate prematurely the discovery
192
+ * At any point, application code can prematurely terminate the discovery
193
193
* procedure by calling terminateServiceDiscovery().
194
194
*
195
195
* @param[in] connectionHandle Handle of the connection with the peer GATT
@@ -199,27 +199,27 @@ class GattClient {
199
199
* @param[in] cc Characteristic discovered event handler invoked when a
200
200
* matching characteristic has been found. This parameter may be NULL.
201
201
* @param[in] matchingServiceUUID UUID of the service the caller is
202
- * interested in. If a service discovered matches this filter then @p sc is
203
- * invoked with it. The special value BLE_UUID_UNKNOWN act as a wildcard
202
+ * interested in. If a service discovered matches this filter, then @p sc is
203
+ * invoked with it. The special value BLE_UUID_UNKNOWN acts as a wildcard,
204
204
* which can be used to discover all services present on the peer GATT
205
205
* server.
206
206
* @param[in] matchingCharacteristicUUIDIn UUID of the characteristic the
207
207
* caller is interested in. If a characteristic discovered matches this
208
- * filter then @p cc is invoked with it. The special value BLE_UUID_UNKNOWN
209
- * act as a wildcard which can be used to discover all services present on
208
+ * filter, then @p cc is invoked with it. The special value BLE_UUID_UNKNOWN
209
+ * acts as a wildcard, which can be used to discover all services present on
210
210
* the peer GATT server.
211
211
*
212
212
* @par Discovery procedure implementation detail
213
213
*
214
214
* It is recommended to implement several strategies based on the
215
215
* combination of callbacks and filters passed in input to efficiently
216
216
* realize the discovery procedure:
217
- * - If @p sc and @p cc are NULL then it is not necessay to initiate any
218
- * discovery and the termination handlers can be invoked immediately.
219
- * - If @p matchingServiceUUID is set then the GATT discover services by
220
- * service UUID procedure should be used otherwise the GATT discover primary
221
- * services procedure should be used..
222
- * - If @p cc is NULL then the discovery process should end after the discovery
217
+ * - If @p sc and @p cc are NULL, then it is not necessay to initiate any
218
+ * discovery, and the termination handlers can be invoked immediately.
219
+ * - If @p matchingServiceUUID is set, then the GATT discover services by
220
+ * service UUID procedure should be used; otherwise, the GATT discover primary
221
+ * services procedure should be used.
222
+ * - If @p cc is NULL, then the discovery process should end after the discovery
223
223
* of the services.
224
224
*
225
225
* @return BLE_ERROR_NONE if the discovery procedure has been successfully
@@ -247,26 +247,26 @@ class GattClient {
247
247
/* *
248
248
* Launch the service discovery procedure of a GATT server peer.
249
249
*
250
- * The procedure will invoke the application callback for matching services.
250
+ * The procedure invokes the application callback for matching services.
251
251
* The process ends after all the services present on the distant GATT
252
252
* server have been discovered.
253
253
* Termination callbacks registered with onServiceDiscoveryTermination() are
254
254
* invoked to notify the application of the termination of the procedure.
255
255
*
256
256
* Application code can track the status of the procedure by invoking the
257
- * function isServiceDiscoveryActive() which will return true if the
257
+ * function isServiceDiscoveryActive(), which returns true if the
258
258
* procedure is ongoing.
259
259
*
260
- * At any point application code can terminate prematurely the discovery
260
+ * At any point, application code can prematurely terminate the discovery
261
261
* procedure by calling terminateServiceDiscovery().
262
262
*
263
263
* @param[in] connectionHandle Handle of the connection with the peer GATT
264
264
* server.
265
265
* @param[in] callback Service discovered event handler invoked when a
266
266
* matching service has been discovered. This parameter may be NULL.
267
267
* @param[in] matchingServiceUUID UUID of the service the caller is
268
- * interested in. If a service discovered match this filter then @p sc is
269
- * invoked with it. The special value BLE_UUID_UNKNOWN act is a wildcard
268
+ * interested in. If a service discovered matches this filter, then @p sc is
269
+ * invoked with it. The special value BLE_UUID_UNKNOWN act is a wildcard,
270
270
* which can be used to discover all services present on the peer GATT
271
271
* server.
272
272
*
@@ -279,7 +279,7 @@ class GattClient {
279
279
const UUID &matchingServiceUUID = UUID::ShortUUIDBytes_t(BLE_UUID_UNKNOWN)
280
280
) {
281
281
/* We take advantage of the property
282
- * that providing NULL for the characteristic callback will result in
282
+ * that providing NULL for the characteristic callback results in
283
283
* characteristic discovery being skipped for each matching
284
284
* service. This allows for an inexpensive method to discover only
285
285
* services. Porters are free to override this. */
@@ -298,10 +298,10 @@ class GattClient {
298
298
* invoked to notify the application of the termination of the procedure.
299
299
*
300
300
* Application code can track the status of the procedure by invoking the
301
- * function isServiceDiscoveryActive() which will return true if the
301
+ * function isServiceDiscoveryActive(), which returns true if the
302
302
* procedure is ongoing.
303
303
*
304
- * At any point application code can terminate prematurely the discovery
304
+ * At any point, application code can prematurely terminate the discovery
305
305
* procedure by calling terminateServiceDiscovery().
306
306
*
307
307
* @param[in] connectionHandle Handle of the connection with the peer GATT
@@ -358,7 +358,7 @@ class GattClient {
358
358
/* *
359
359
* Initiate the read procedure of an attribute handle.
360
360
*
361
- * Once the attribute value has been read in its entirety the process issues
361
+ * Once the attribute value has been read in its entirety, the process issues
362
362
* an attribute read event and passes it to all events handlers registered
363
363
* by onDataRead.
364
364
*
@@ -368,23 +368,23 @@ class GattClient {
368
368
* @param[in] offset The offset from the start of the attribute value to be
369
369
* read.
370
370
*
371
- * @return BLE_ERROR_NONE if read procedure was successfully started.
371
+ * @return BLE_ERROR_NONE if read procedure successfully started.
372
372
*
373
373
* @par Implementation notes:
374
374
*
375
375
* Reading the attribute value in its entirety may involve sending several
376
376
* GATT requests to the peer. The following algorithm may be used to
377
377
* implement the process:
378
378
*
379
- * If the offset is equal to 0 then send a read request otherwise send a
379
+ * If the offset is equal to 0, then send a read request; otherwise, send a
380
380
* read blob request at the specified offset.
381
381
*
382
382
* While the attribute data in the response are MTU - 1 long:
383
383
* - Concat the response to the value containing the previous responses.
384
384
* - Increment the value of the offset by MTU - 1.
385
385
* - Send a read blob request with the updated offset.
386
386
*
387
- * Finally concat the last response with the value containing all the
387
+ * Finally, concat the last response with the value containing all the
388
388
* previous responses and forward that value to the event handlers.
389
389
*/
390
390
virtual ble_error_t read (
@@ -405,39 +405,39 @@ class GattClient {
405
405
/* *
406
406
* Initiate a write procedure on an attribute value.
407
407
*
408
- * If @p cmd is equal to GATT_OP_WRITE_REQ then the status of the operation
409
- * is reported to the event handlers registered via onDataWritten().
408
+ * If @p cmd is equal to GATT_OP_WRITE_REQ, then the status of the operation
409
+ * is reported to the event handlers registered through onDataWritten().
410
410
*
411
411
* @param[in] cmd Type of the write procedure used. If GATT_OP_WRITE_CMD
412
- * is set then value length shall not be greater than the size of the mtu
412
+ * is set, then value length is not greater than the size of the mtu
413
413
* of connHandle minus three.
414
414
* @param[in] connHandle Handle of the connection used to send the write
415
415
* request or command.
416
416
* @param[in] attributeHandle Handle of the attribute value to write.
417
417
* @param[in] length Number of bytes present in @p value.
418
418
* @param[in] value Data buffer to write to attributeHandle.
419
419
*
420
- * @return BLE_ERROR_NONE if the write procedure was successfully started.
420
+ * @return BLE_ERROR_NONE if the write procedure successfully started.
421
421
*
422
422
* @par Implementation notes:
423
423
*
424
- * If the operation is a write command then an implementation shall use the
425
- * GATT write without response procedure and an error shall be returned if
424
+ * If the operation is a write command, then an implementation uses the
425
+ * GATT write without response procedure and an error is returned if
426
426
* the data buffer to write is larger than the size of the MTU - 3.
427
427
*
428
428
* If the operation is a write command and the size of the data buffer to
429
- * write is less than than the size of the MTU - 3 then the ATT write request
430
- * procedure shall be used and the response shall be reported to the handlers
429
+ * write is less than than the size of the MTU - 3, then the ATT write request
430
+ * procedure is used, and the response is reported to the handlers
431
431
* listening for write response.
432
432
*
433
- * Otherwise the data buffer to write shall be divided in chunks with a
434
- * maximum size of MTU - 5. Those chunks shall be sent sequentially to the
433
+ * Otherwise, the data buffer to write is divided in chunks with a
434
+ * maximum size of MTU - 5. Those chunks are sent sequentially to the
435
435
* peer in ATT prepare write requests. If an error response is received
436
- * during the process, the procedure shall end immediately, the prepared
437
- * write discarded and an error shall be reported to the application handlers.
438
- * Once all the chunks have been sent, the transaction shall be completed
439
- * by sending an execute write request to the peer. The peer response shall
440
- * be forwarded to the application handlers.
436
+ * during the process, the procedure ends immediately, the prepared
437
+ * write is discarded and an error is reported to the application handlers.
438
+ * Once all the chunks have been sent, the transaction is completed
439
+ * by sending an execute write request to the peer. The peer response is
440
+ * forwarded to the application handlers.
441
441
*/
442
442
virtual ble_error_t write (
443
443
GattClient::WriteOp_t cmd,
@@ -612,8 +612,8 @@ class GattClient {
612
612
/* *
613
613
* @brief Terminate an ongoing characteristic descriptor discovery procedure.
614
614
*
615
- * If the procedure is active then it shall end and the termination handler
616
- * associated with the procedure shall be called.
615
+ * If the procedure is active, then it ends, and the termination handler
616
+ * associated with the procedure is called.
617
617
*
618
618
* @param[in] characteristic The characteristic containing the descriptors
619
619
* being discovered.
@@ -642,8 +642,8 @@ class GattClient {
642
642
/* *
643
643
* Register a shutdown event handler.
644
644
*
645
- * The registered handler will be invoked when the GattClient instance is
646
- * about to be shutdown .
645
+ * The registered handler is invoked when the GattClient instance is
646
+ * about to be shut down .
647
647
*
648
648
* @param[in] callback Event handler to invoke when a shutdown event is
649
649
* available.
@@ -661,10 +661,10 @@ class GattClient {
661
661
/* *
662
662
* Register a shutdown event handler.
663
663
*
664
- * The registered handler will be invoked when the GattClient instance is
665
- * about to be shutdown .
664
+ * The registered handler is invoked when the GattClient instance is
665
+ * about to be shut down .
666
666
*
667
- * @param[in] objPtr Instance which will be used to invoke @p memberPtr.
667
+ * @param[in] objPtr Instance that will be used to invoke @p memberPtr.
668
668
* @param[in] memberPtr Event handler to invoke when a shutdown event is
669
669
* available.
670
670
*/
@@ -705,24 +705,23 @@ class GattClient {
705
705
/* *
706
706
* Reset the state of the GattClient instance.
707
707
*
708
- * Prior to any state modification shutdown event handlers shall be notified
709
- * that the GattClient instance is about to be shutdown. Then running
710
- * procedures shall be ended. Finally the state of the instance shall be
711
- * reset.
708
+ * Prior to any state modification, shutdown event handlers are notified
709
+ * that the GattClient instance is about to be shut down. Then, running
710
+ * procedures end. Finally, the state of the instance is reset.
712
711
*
713
712
* @par implementation note
714
713
*
715
714
* This function is meant to be overridden in the platform-specific
716
- * sub-class . Nevertheless, the sub-class is only expected to reset its
717
- * state and not the data held in GattClient members. This shall be achieved
718
- * by a call to GattClient::reset() from the sub-class ' reset()
715
+ * subclass . Nevertheless, the subclass only resets its
716
+ * state and not the data held in GattClient members. This is achieved
717
+ * by a call to GattClient::reset() from the subclass ' reset()
719
718
* implementation.
720
719
*
721
720
* @return BLE_ERROR_NONE on success.
722
721
*/
723
722
virtual ble_error_t reset (void )
724
723
{
725
- /* Notify that the instance is about to shutdown */
724
+ /* Notify that the instance is about to shut down. */
726
725
shutdownCallChain.call (this );
727
726
shutdownCallChain.clear ();
728
727
@@ -769,7 +768,7 @@ class GattClient {
769
768
}
770
769
771
770
/* *
772
- * Forward an Handle Value Notification or Indication event to all registered
771
+ * Forward a handle value notification or indication event to all registered
773
772
* handlers.
774
773
*
775
774
* @important This function is meant to be called from the vendor
0 commit comments