17
17
#ifndef BLE_PAL_ATTCLIENT_H_
18
18
#define BLE_PAL_ATTCLIENT_H_
19
19
20
+ #include " ble/common/StaticInterface.h"
20
21
#include " ble/UUID.h"
21
22
#include " ble/BLETypes.h"
22
23
#include " ble/ArrayView.h"
@@ -39,7 +40,15 @@ namespace pal {
39
40
*
40
41
* @note see BLUETOOTH SPECIFICATION Version 5.0 | Vol 3, Part F
41
42
*/
42
- struct AttClient {
43
+ template <class Impl >
44
+ struct AttClient : public StaticInterface <Impl, AttClient> {
45
+ private:
46
+
47
+ using StaticInterface<Impl, ble::pal::AttClient>::impl;
48
+
49
+ public:
50
+
51
+
43
52
/* *
44
53
* Initialization of the instance. An implementation can use this function
45
54
* to initialise the subsystems needed to realize the ATT operations of this
@@ -50,7 +59,9 @@ struct AttClient {
50
59
* @return BLE_ERROR_NONE if the request has been successfully sent or the
51
60
* appropriate error otherwise.
52
61
*/
53
- virtual ble_error_t initialize () = 0;
62
+ ble_error_t initialize () {
63
+ return impl ()->initialize_ ();
64
+ }
54
65
55
66
/* *
56
67
* Termination of the instance. An implementation can use this function
@@ -63,7 +74,9 @@ struct AttClient {
63
74
* @return BLE_ERROR_NONE if the request has been successfully sent or the
64
75
* appropriate error otherwise.
65
76
*/
66
- virtual ble_error_t terminate () = 0;
77
+ ble_error_t terminate () {
78
+ return impl ()->terminate_ ();
79
+ }
67
80
68
81
/* *
69
82
* Send an exchange MTU request which negotiate the size of the MTU used by
@@ -89,7 +102,9 @@ struct AttClient {
89
102
*
90
103
* @note see BLUETOOTH SPECIFICATION Version 5.0 | Vol 3, Part F Section 3.4.2.1
91
104
*/
92
- virtual ble_error_t exchange_mtu_request (connection_handle_t connection) = 0;
105
+ ble_error_t exchange_mtu_request (connection_handle_t connection) {
106
+ return impl ()->exchange_mtu_request_ (connection);
107
+ }
93
108
94
109
/* *
95
110
* Acquire the size of the mtu for a given connection.
@@ -102,10 +117,12 @@ struct AttClient {
102
117
* @return BLE_ERROR_NONE if the MTU size has been acquired or the
103
118
* appropriate error otherwise.
104
119
*/
105
- virtual ble_error_t get_mtu_size (
120
+ ble_error_t get_mtu_size (
106
121
connection_handle_t connection_handle,
107
122
uint16_t & mtu_size
108
- ) = 0;
123
+ ) {
124
+ return impl ()->get_mtu_size_ (connection_handle, mtu_size);
125
+ }
109
126
110
127
/* *
111
128
* Send a find information request to a server in order to obtain the
@@ -138,10 +155,12 @@ struct AttClient {
138
155
*
139
156
* @note see BLUETOOTH SPECIFICATION Version 5.0 | Vol 3, Part F Section 3.4.3.1
140
157
*/
141
- virtual ble_error_t find_information_request (
158
+ ble_error_t find_information_request (
142
159
connection_handle_t connection_handle,
143
160
attribute_handle_range_t discovery_range
144
- ) = 0;
161
+ ) {
162
+ return impl ()->find_information_request_ (connection_handle, discovery_range);
163
+ }
145
164
146
165
/* *
147
166
* Send a Find By Type Value Request which retrieve the handles of attributes
@@ -174,12 +193,19 @@ struct AttClient {
174
193
*
175
194
* @note see BLUETOOTH SPECIFICATION Version 5.0 | Vol 3, Part F Section 3.4.3.3
176
195
*/
177
- virtual ble_error_t find_by_type_value_request (
196
+ ble_error_t find_by_type_value_request (
178
197
connection_handle_t connection_handle,
179
198
attribute_handle_range_t discovery_range,
180
199
uint16_t type,
181
200
const ArrayView<const uint8_t >& value
182
- ) = 0;
201
+ ) {
202
+ return impl ()->find_by_type_value_request_ (
203
+ connection_handle,
204
+ discovery_range,
205
+ type,
206
+ value
207
+ );
208
+ }
183
209
184
210
/* *
185
211
* Send a Read By Type Request used to obtain the values of attributes where
@@ -218,11 +244,13 @@ struct AttClient {
218
244
*
219
245
* @note see BLUETOOTH SPECIFICATION Version 5.0 | Vol 3, Part F Section 3.4.4.1
220
246
*/
221
- virtual ble_error_t read_by_type_request (
247
+ ble_error_t read_by_type_request (
222
248
connection_handle_t connection_handle,
223
249
attribute_handle_range_t read_range,
224
250
const UUID& type
225
- ) = 0;
251
+ ) {
252
+ return impl ()->read_by_type_request_ (connection_handle, read_range, type);
253
+ }
226
254
227
255
/* *
228
256
* Send a Read Request to read the value of an attribute in the server.
@@ -257,10 +285,12 @@ struct AttClient {
257
285
*
258
286
* @note see BLUETOOTH SPECIFICATION Version 5.0 | Vol 3, Part F Section 3.4.4.3
259
287
*/
260
- virtual ble_error_t read_request (
288
+ ble_error_t read_request (
261
289
connection_handle_t connection_handle,
262
290
attribute_handle_t attribute_handle
263
- ) = 0;
291
+ ) {
292
+ return impl ()->read_request_ (connection_handle, attribute_handle);
293
+ }
264
294
265
295
/* *
266
296
* Send a read blob request to a server to read a part of the value of an
@@ -303,11 +333,13 @@ struct AttClient {
303
333
*
304
334
* @note see BLUETOOTH SPECIFICATION Version 5.0 | Vol 3, Part F Section 3.4.4.5
305
335
*/
306
- virtual ble_error_t read_blob_request (
336
+ ble_error_t read_blob_request (
307
337
connection_handle_t connection_handle,
308
338
attribute_handle_t attribute_handle,
309
339
uint16_t offset
310
- ) = 0;
340
+ ) {
341
+ return impl ()->read_blob_request_ (connection_handle, attribute_handle, offset);
342
+ }
311
343
312
344
/* *
313
345
* Send a read multiple request to the server. It is used to read two or more
@@ -347,10 +379,12 @@ struct AttClient {
347
379
*
348
380
* @note see BLUETOOTH SPECIFICATION Version 5.0 | Vol 3, Part F Section 3.4.4.7
349
381
*/
350
- virtual ble_error_t read_multiple_request (
382
+ ble_error_t read_multiple_request (
351
383
connection_handle_t connection_handle,
352
384
const ArrayView<const attribute_handle_t >& attribute_handles
353
- ) = 0;
385
+ ) {
386
+ return impl ()->read_multiple_request_ (connection_handle, attribute_handles);
387
+ }
354
388
355
389
/* *
356
390
* Send a read by group type request to the server. It is used to get
@@ -397,11 +431,13 @@ struct AttClient {
397
431
*
398
432
* @note see BLUETOOTH SPECIFICATION Version 5.0 | Vol 3, Part F Section 3.4.4.9
399
433
*/
400
- virtual ble_error_t read_by_group_type_request (
434
+ ble_error_t read_by_group_type_request (
401
435
connection_handle_t connection_handle,
402
436
attribute_handle_range_t read_range,
403
437
const UUID& group_type
404
- ) = 0;
438
+ ) {
439
+ return impl ()->read_by_group_type_request_ (connection_handle, read_range, group_type);
440
+ }
405
441
406
442
/* *
407
443
* Send a write request to the server to write the value of an attribute.
@@ -450,11 +486,13 @@ struct AttClient {
450
486
*
451
487
* @note see BLUETOOTH SPECIFICATION Version 5.0 | Vol 3, Part F Section 3.4.5.1
452
488
*/
453
- virtual ble_error_t write_request (
489
+ ble_error_t write_request (
454
490
connection_handle_t connection_handle,
455
491
attribute_handle_t attribute_handle,
456
492
const ArrayView<const uint8_t >& value
457
- ) = 0;
493
+ ) {
494
+ return impl ()->write_request_ (connection_handle, attribute_handle, value);
495
+ }
458
496
459
497
/* *
460
498
* Send a write command to the server. A write command is similar to a write
@@ -470,11 +508,13 @@ struct AttClient {
470
508
*
471
509
* @note see BLUETOOTH SPECIFICATION Version 5.0 | Vol 3, Part F Section 3.4.5.3
472
510
*/
473
- virtual ble_error_t write_command (
511
+ ble_error_t write_command (
474
512
connection_handle_t connection_handle,
475
513
attribute_handle_t attribute_handle,
476
514
const ArrayView<const uint8_t >& value
477
- ) = 0;
515
+ ) {
516
+ return impl ()->write_command_ (connection_handle, attribute_handle, value);
517
+ }
478
518
479
519
/* *
480
520
* Send a signed write command to the server. Behaviour is similar to a write
@@ -495,11 +535,13 @@ struct AttClient {
495
535
*
496
536
* @note see BLUETOOTH SPECIFICATION Version 5.0 | Vol 3, Part F Section 3.4.5.4
497
537
*/
498
- virtual ble_error_t signed_write_command (
538
+ ble_error_t signed_write_command (
499
539
connection_handle_t connection_handle,
500
540
attribute_handle_t attribute_handle,
501
541
const ArrayView<const uint8_t >& value
502
- ) = 0;
542
+ ) {
543
+ return impl ()->signed_write_command_ (connection_handle, attribute_handle, value);
544
+ }
503
545
504
546
/* *
505
547
* The Prepare Write Request is used to request the server to prepare to
@@ -547,12 +589,19 @@ struct AttClient {
547
589
* @note see BLUETOOTH SPECIFICATION Version 5.0 | Vol 3, Part F Section 3.4.6.1
548
590
*
549
591
*/
550
- virtual ble_error_t prepare_write_request (
592
+ ble_error_t prepare_write_request (
551
593
connection_handle_t connection_handle,
552
594
attribute_handle_t attribute_handle,
553
595
uint16_t offset,
554
596
const ArrayView<const uint8_t >& value
555
- ) = 0;
597
+ ) {
598
+ return impl ()->prepare_write_request_ (
599
+ connection_handle,
600
+ attribute_handle,
601
+ offset,
602
+ value
603
+ );
604
+ }
556
605
557
606
/* *
558
607
* Send an Execute Write Request to the server. This request will instruct
@@ -591,10 +640,12 @@ struct AttClient {
591
640
*
592
641
* @note see BLUETOOTH SPECIFICATION Version 5.0 | Vol 3, Part F Section 3.4.6.3
593
642
*/
594
- virtual ble_error_t execute_write_request (
643
+ ble_error_t execute_write_request (
595
644
connection_handle_t connection_handle,
596
645
bool execute
597
- ) = 0;
646
+ ) {
647
+ return impl ()->execute_write_request_ (connection_handle, execute);
648
+ }
598
649
599
650
/* *
600
651
* Register a callback which will handle messages from the server.
@@ -630,7 +681,7 @@ struct AttClient {
630
681
protected:
631
682
AttClient () { }
632
683
633
- virtual ~AttClient () { }
684
+ ~AttClient () { }
634
685
635
686
/* *
636
687
* Upon server message reception an implementation shall call this function.
0 commit comments