24
24
#include " source/pal/PalAttClient.h"
25
25
26
26
namespace ble {
27
+ namespace cordio {
27
28
28
- class PalAttClient : public interface ::PalAttClient {
29
+ class PalAttClient final : public ble ::PalAttClient {
29
30
30
31
public:
31
32
PalAttClient ();
@@ -35,23 +36,23 @@ class PalAttClient : public interface::PalAttClient {
35
36
/* *
36
37
* @see ble::PalAttClient::exchange_mtu_request
37
38
*/
38
- ble_error_t exchange_mtu_request (connection_handle_t connection);
39
+ ble_error_t exchange_mtu_request (connection_handle_t connection) final ;
39
40
40
41
/* *
41
42
* @see ble::PalGattClient::get_mtu_size
42
43
*/
43
44
ble_error_t get_mtu_size (
44
45
connection_handle_t connection_handle,
45
- uint16_t & mtu_size
46
- );
46
+ uint16_t & mtu_size
47
+ ) final ;
47
48
48
49
/* *
49
50
* @see ble::PalAttClient::find_information_request
50
51
*/
51
52
ble_error_t find_information_request (
52
53
connection_handle_t connection_handle,
53
54
attribute_handle_range_t discovery_range
54
- );
55
+ ) final ;
55
56
56
57
/* *
57
58
* @see ble::PalAttClient::find_by_type_value_request
@@ -60,25 +61,25 @@ class PalAttClient : public interface::PalAttClient {
60
61
connection_handle_t connection_handle,
61
62
attribute_handle_range_t discovery_range,
62
63
uint16_t type,
63
- const Span<const uint8_t >& value
64
- );
64
+ const Span<const uint8_t > & value
65
+ ) final ;
65
66
66
67
/* *
67
68
* @see ble::PalAttClient::read_by_type_request
68
69
*/
69
70
ble_error_t read_by_type_request (
70
71
connection_handle_t connection_handle,
71
72
attribute_handle_range_t read_range,
72
- const UUID& type
73
- );
73
+ const UUID & type
74
+ ) final ;
74
75
75
76
/* *
76
77
* @see ble::PalAttClient::read_request
77
78
*/
78
79
ble_error_t read_request (
79
80
connection_handle_t connection_handle,
80
81
attribute_handle_t attribute_handle
81
- );
82
+ ) final ;
82
83
83
84
/* *
84
85
* @see ble::PalAttClient::read_blob_request
@@ -87,51 +88,51 @@ class PalAttClient : public interface::PalAttClient {
87
88
connection_handle_t connection_handle,
88
89
attribute_handle_t attribute_handle,
89
90
uint16_t offset
90
- );
91
+ ) final ;
91
92
92
93
/* *
93
94
* @see ble::PalAttClient::read_multiple_request
94
95
*/
95
96
ble_error_t read_multiple_request (
96
97
connection_handle_t connection_handle,
97
- const Span<const attribute_handle_t >& attribute_handles
98
- );
98
+ const Span<const attribute_handle_t > & attribute_handles
99
+ ) final ;
99
100
100
101
/* *
101
102
* @see ble::PalAttClient::read_by_group_type_request
102
103
*/
103
104
ble_error_t read_by_group_type_request (
104
105
connection_handle_t connection_handle,
105
106
attribute_handle_range_t read_range,
106
- const UUID& group_type
107
- );
107
+ const UUID & group_type
108
+ ) final ;
108
109
109
110
/* *
110
111
* @see ble::PalAttClient::write_request
111
112
*/
112
113
ble_error_t write_request (
113
114
connection_handle_t connection_handle,
114
115
attribute_handle_t attribute_handle,
115
- const Span<const uint8_t >& value
116
- );
116
+ const Span<const uint8_t > & value
117
+ ) final ;
117
118
118
119
/* *
119
120
* @see ble::PalAttClient::write_command
120
121
*/
121
122
ble_error_t write_command (
122
123
connection_handle_t connection_handle,
123
124
attribute_handle_t attribute_handle,
124
- const Span<const uint8_t >& value
125
- );
125
+ const Span<const uint8_t > & value
126
+ ) final ;
126
127
127
128
/* *
128
129
* @see ble::PalAttClient::signed_write_command
129
130
*/
130
131
ble_error_t signed_write_command (
131
132
connection_handle_t connection_handle,
132
133
attribute_handle_t attribute_handle,
133
- const Span<const uint8_t >& value
134
- );
134
+ const Span<const uint8_t > & value
135
+ ) final ;
135
136
136
137
/* *
137
138
* Initialises the counter used to sign messages. Counter will be incremented every
@@ -150,54 +151,54 @@ class PalAttClient : public interface::PalAttClient {
150
151
connection_handle_t connection_handle,
151
152
attribute_handle_t attribute_handle,
152
153
uint16_t offset,
153
- const Span<const uint8_t >& value
154
- );
154
+ const Span<const uint8_t > & value
155
+ ) final ;
155
156
156
157
/* *
157
158
* @see ble::PalAttClient::execute_write_request
158
159
*/
159
160
ble_error_t execute_write_request (
160
161
connection_handle_t connection_handle,
161
162
bool execute
162
- );
163
+ ) final ;
163
164
164
165
/* *
165
166
* @see ble::PalAttClient::initialize
166
167
*/
167
- ble_error_t initialize ();
168
+ ble_error_t initialize () final ;
168
169
169
170
/* *
170
171
* @see ble::PalAttClient::terminate
171
172
*/
172
- ble_error_t terminate ();
173
+ ble_error_t terminate () final ;
173
174
174
175
// singleton of the ARM Cordio client
175
- static PalAttClient& get_client ();
176
+ static PalAttClient & get_client ();
176
177
177
178
void when_server_message_received (
178
- mbed::Callback<void (connection_handle_t , const AttServerMessage&)> cb
179
- );
179
+ mbed::Callback<void (connection_handle_t , const AttServerMessage &)> cb
180
+ ) final ;
180
181
181
182
void when_transaction_timeout (
182
- mbed::Callback<void (connection_handle_t )> cb
183
- );
183
+ mbed::Callback<void (connection_handle_t )> cb
184
+ ) final ;
184
185
185
186
private:
186
187
// convert an array of byte to an uint16_t
187
- static uint16_t to_uint16_t (const uint8_t * array);
188
+ static uint16_t to_uint16_t (const uint8_t * array);
188
189
189
190
/* *
190
191
* Type of an event handler.
191
192
* @param The event to handle
192
193
* @return true if the event has been handled and false otherwise.
193
194
*/
194
- typedef bool (*event_handler_t )(const attEvt_t*);
195
+ typedef bool (*event_handler_t )(const attEvt_t *);
195
196
196
197
public:
197
198
/* *
198
199
* Callback which handle attEvt_t and forward them to on_server_event.
199
200
*/
200
- static void att_client_handler (const attEvt_t* event);
201
+ static void att_client_handler (const attEvt_t * event);
201
202
202
203
private:
203
204
/* *
@@ -212,23 +213,23 @@ class PalAttClient : public interface::PalAttClient {
212
213
* @return
213
214
*/
214
215
template <typename T>
215
- static bool event_handler (const attEvt_t* event);
216
+ static bool event_handler (const attEvt_t * event);
216
217
217
- static bool timeout_event_handler (const attEvt_t* event);
218
+ static bool timeout_event_handler (const attEvt_t * event);
218
219
219
220
template <typename ResultType>
220
221
static void generated_handler (
221
- const attEvt_t* event, ResultType (*convert)(const attEvt_t*)
222
+ const attEvt_t * event, ResultType (*convert)(const attEvt_t *)
222
223
);
223
224
224
225
/* *
225
226
* Traits defining can_convert for non ErrorResponse events.
226
227
*/
227
228
template <uint8_t RequestID>
228
229
struct ResponseConverter {
229
- static bool can_convert (const attEvt_t* event)
230
+ static bool can_convert (const attEvt_t * event)
230
231
{
231
- if (event->hdr .status == ATT_SUCCESS && event->hdr .event == RequestID) {
232
+ if (event->hdr .status == ATT_SUCCESS && event->hdr .event == RequestID) {
232
233
return true ;
233
234
}
234
235
return false ;
@@ -239,15 +240,15 @@ class PalAttClient : public interface::PalAttClient {
239
240
* Converter for an AttErrorResponse.
240
241
*/
241
242
struct ErrorResponseConverter {
242
- static bool can_convert (const attEvt_t* event)
243
+ static bool can_convert (const attEvt_t * event)
243
244
{
244
- if (event->hdr .status != ATT_SUCCESS) {
245
+ if (event->hdr .status != ATT_SUCCESS) {
245
246
return true ;
246
247
}
247
248
return false ;
248
249
}
249
250
250
- static AttErrorResponse convert (const attEvt_t* event)
251
+ static AttErrorResponse convert (const attEvt_t * event)
251
252
{
252
253
return AttErrorResponse (
253
254
static_cast <AttributeOpcode::Code>(event->hdr .event * 2 ),
@@ -261,7 +262,7 @@ class PalAttClient : public interface::PalAttClient {
261
262
* Converter for a PalSimpleAttFindInformationResponse.
262
263
*/
263
264
struct FindInformationResponseConverter : ResponseConverter<ATTC_FIND_INFO_RSP> {
264
- static PalSimpleAttFindInformationResponse convert (const attEvt_t* event)
265
+ static PalSimpleAttFindInformationResponse convert (const attEvt_t * event)
265
266
{
266
267
return PalSimpleAttFindInformationResponse (
267
268
static_cast <PalSimpleAttFindInformationResponse::Format>(event->pValue [0 ]),
@@ -277,7 +278,7 @@ class PalAttClient : public interface::PalAttClient {
277
278
* Converter for a PalSimpleAttFindByTypeValueResponse.
278
279
*/
279
280
struct FindByTypeValueResponseConverter : ResponseConverter<ATTC_FIND_BY_TYPE_VALUE_RSP> {
280
- static PalSimpleAttFindByTypeValueResponse convert (const attEvt_t* event)
281
+ static PalSimpleAttFindByTypeValueResponse convert (const attEvt_t * event)
281
282
{
282
283
return PalSimpleAttFindByTypeValueResponse (
283
284
make_const_Span (
@@ -292,7 +293,7 @@ class PalAttClient : public interface::PalAttClient {
292
293
* Converter for a PalSimpleAttReadByTypeResponse.
293
294
*/
294
295
struct ReadByTypeResponseConverter : ResponseConverter<ATTC_READ_BY_TYPE_RSP> {
295
- static PalSimpleAttReadByTypeResponse convert (const attEvt_t* event)
296
+ static PalSimpleAttReadByTypeResponse convert (const attEvt_t * event)
296
297
{
297
298
return PalSimpleAttReadByTypeResponse (
298
299
event->pValue [0 ],
@@ -308,7 +309,7 @@ class PalAttClient : public interface::PalAttClient {
308
309
* Converter for a AttReadResponse.
309
310
*/
310
311
struct ReadResponseConverter : ResponseConverter<ATTC_READ_RSP> {
311
- static AttReadResponse convert (const attEvt_t* event)
312
+ static AttReadResponse convert (const attEvt_t * event)
312
313
{
313
314
return AttReadResponse (
314
315
make_const_Span (
@@ -323,7 +324,7 @@ class PalAttClient : public interface::PalAttClient {
323
324
* Converter for a AttReadBlobResponse.
324
325
*/
325
326
struct ReadBlobResponseConverter : ResponseConverter<ATTC_READ_LONG_RSP> {
326
- static AttReadBlobResponse convert (const attEvt_t* event)
327
+ static AttReadBlobResponse convert (const attEvt_t * event)
327
328
{
328
329
return AttReadBlobResponse (
329
330
make_const_Span (
@@ -338,7 +339,7 @@ class PalAttClient : public interface::PalAttClient {
338
339
* Converter for a AttReadMultipleResponse.
339
340
*/
340
341
struct ReadMultipleResponseConverter : ResponseConverter<ATTC_READ_MULTIPLE_RSP> {
341
- static AttReadMultipleResponse convert (const attEvt_t* event)
342
+ static AttReadMultipleResponse convert (const attEvt_t * event)
342
343
{
343
344
return AttReadMultipleResponse (
344
345
make_const_Span (
@@ -353,7 +354,7 @@ class PalAttClient : public interface::PalAttClient {
353
354
* Converter for a PalSimpleAttReadByGroupTypeResponse.
354
355
*/
355
356
struct ReadBygroupTypeResponseConverter : ResponseConverter<ATTC_READ_BY_GROUP_TYPE_RSP> {
356
- static PalSimpleAttReadByGroupTypeResponse convert (const attEvt_t* event)
357
+ static PalSimpleAttReadByGroupTypeResponse convert (const attEvt_t * event)
357
358
{
358
359
return PalSimpleAttReadByGroupTypeResponse (
359
360
event->pValue [0 ],
@@ -369,7 +370,7 @@ class PalAttClient : public interface::PalAttClient {
369
370
* Converter for a AttWriteResponse.
370
371
*/
371
372
struct WriteResponseConverter : ResponseConverter<ATTC_WRITE_RSP> {
372
- static AttWriteResponse convert (const attEvt_t* event)
373
+ static AttWriteResponse convert (const attEvt_t * event)
373
374
{
374
375
return AttWriteResponse ();
375
376
}
@@ -379,7 +380,7 @@ class PalAttClient : public interface::PalAttClient {
379
380
* Converter for a AttPrepareWriteResponse.
380
381
*/
381
382
struct PrepareWriteResponseConverter : ResponseConverter<ATTC_PREPARE_WRITE_RSP> {
382
- static AttPrepareWriteResponse convert (const attEvt_t* event)
383
+ static AttPrepareWriteResponse convert (const attEvt_t * event)
383
384
{
384
385
return AttPrepareWriteResponse (
385
386
event->handle ,
@@ -396,7 +397,7 @@ class PalAttClient : public interface::PalAttClient {
396
397
* Converter for a AttExecuteWriteResponse.
397
398
*/
398
399
struct ExecuteWriteResponseConverter : ResponseConverter<ATTC_EXECUTE_WRITE_RSP> {
399
- static AttExecuteWriteResponse convert (const attEvt_t* event)
400
+ static AttExecuteWriteResponse convert (const attEvt_t * event)
400
401
{
401
402
return AttExecuteWriteResponse ();
402
403
}
@@ -406,7 +407,7 @@ class PalAttClient : public interface::PalAttClient {
406
407
* Converter for a AttHandleValueNotification.
407
408
*/
408
409
struct HandleValueNotificationConverter : ResponseConverter<ATTC_HANDLE_VALUE_NTF> {
409
- static AttHandleValueNotification convert (const attEvt_t* event)
410
+ static AttHandleValueNotification convert (const attEvt_t * event)
410
411
{
411
412
return AttHandleValueNotification (
412
413
event->handle ,
@@ -422,7 +423,7 @@ class PalAttClient : public interface::PalAttClient {
422
423
* Converter for a AttHandleValueIndication.
423
424
*/
424
425
struct HandleValueIndicationConverter : ResponseConverter<ATTC_HANDLE_VALUE_IND> {
425
- static AttHandleValueIndication convert (const attEvt_t* event)
426
+ static AttHandleValueIndication convert (const attEvt_t * event)
426
427
{
427
428
return AttHandleValueIndication (
428
429
event->handle ,
@@ -433,6 +434,7 @@ class PalAttClient : public interface::PalAttClient {
433
434
);
434
435
}
435
436
};
437
+
436
438
private:
437
439
/* *
438
440
* Upon server message reception an implementation shall call this function.
@@ -443,7 +445,7 @@ class PalAttClient : public interface::PalAttClient {
443
445
*/
444
446
void on_server_event (
445
447
connection_handle_t connection_handle,
446
- const AttServerMessage& server_message
448
+ const AttServerMessage & server_message
447
449
);
448
450
449
451
/* *
@@ -457,20 +459,22 @@ class PalAttClient : public interface::PalAttClient {
457
459
void on_transaction_timeout (
458
460
connection_handle_t connection_handle
459
461
);
462
+
460
463
private:
461
464
sign_count_t _local_sign_counter;
462
465
463
466
/* *
464
467
* Callback called when the client receive a message from the server.
465
468
*/
466
- mbed::Callback<void (connection_handle_t , const AttServerMessage&)> _server_message_cb;
469
+ mbed::Callback<void (connection_handle_t , const AttServerMessage &)> _server_message_cb;
467
470
468
471
/* *
469
472
* Callback called when a transaction times out.
470
473
*/
471
474
mbed::Callback<void (connection_handle_t )> _transaction_timeout_cb;
472
475
};
473
476
474
- } // ble
477
+ } // namespace cordio
478
+ } // namespace ble
475
479
476
480
#endif /* IMPL_PAL_ATT_CLIENT_ */
0 commit comments