@@ -29,7 +29,8 @@ namespace pal {
29
29
* This class let vendors define their abstraction layer in term of an AttClient
30
30
* and adapt any AttClient into a GattClient.
31
31
*/
32
- class AttClientToGattClientAdapter : public GattClient {
32
+ template <class AttClient , class EventHandler >
33
+ class AttClientToGattClientAdapter : public GattClient <AttClientToGattClientAdapter<AttClient, EventHandler>, EventHandler > {
33
34
34
35
public:
35
36
static const uint16_t END_ATTRIBUTE_HANDLE = 0xFFFF ;
@@ -42,7 +43,7 @@ class AttClientToGattClientAdapter : public GattClient {
42
43
* @param client The client to adapt.
43
44
*/
44
45
AttClientToGattClientAdapter (AttClient& client) :
45
- GattClient (), _client(client) {
46
+ _client (client) {
46
47
_client.when_server_message_received (
47
48
mbed::callback (this , &AttClientToGattClientAdapter::on_server_event)
48
49
);
@@ -56,14 +57,14 @@ class AttClientToGattClientAdapter : public GattClient {
56
57
/* *
57
58
* @see ble::pal::GattClient::exchange_mtu
58
59
*/
59
- virtual ble_error_t exchange_mtu (connection_handle_t connection) {
60
+ ble_error_t exchange_mtu_ (connection_handle_t connection) {
60
61
return _client.exchange_mtu_request (connection);
61
62
}
62
63
63
64
/* *
64
65
* @see ble::pal::GattClient::get_mtu_size
65
66
*/
66
- virtual ble_error_t get_mtu_size (
67
+ ble_error_t get_mtu_size_ (
67
68
connection_handle_t connection_handle,
68
69
uint16_t & mtu_size
69
70
) {
@@ -73,7 +74,7 @@ class AttClientToGattClientAdapter : public GattClient {
73
74
/* *
74
75
* @see ble::pal::GattClient::discover_primary_service
75
76
*/
76
- virtual ble_error_t discover_primary_service (
77
+ ble_error_t discover_primary_service_ (
77
78
connection_handle_t connection,
78
79
attribute_handle_t discovery_range_begining
79
80
) {
@@ -87,7 +88,7 @@ class AttClientToGattClientAdapter : public GattClient {
87
88
/* *
88
89
* @see ble::pal::GattClient::discover_primary_service_by_service_uuid
89
90
*/
90
- virtual ble_error_t discover_primary_service_by_service_uuid (
91
+ ble_error_t discover_primary_service_by_service_uuid_ (
91
92
connection_handle_t connection_handle,
92
93
attribute_handle_t discovery_range_begining,
93
94
const UUID& uuid
@@ -106,7 +107,7 @@ class AttClientToGattClientAdapter : public GattClient {
106
107
/* *
107
108
* @see ble::pal::GattClient::find_included_service
108
109
*/
109
- virtual ble_error_t find_included_service (
110
+ ble_error_t find_included_service_ (
110
111
connection_handle_t connection_handle,
111
112
attribute_handle_range_t service_range
112
113
) {
@@ -120,7 +121,7 @@ class AttClientToGattClientAdapter : public GattClient {
120
121
/* *
121
122
* @see ble::pal::GattClient::discover_characteristics_of_a_service
122
123
*/
123
- virtual ble_error_t discover_characteristics_of_a_service (
124
+ ble_error_t discover_characteristics_of_a_service_ (
124
125
connection_handle_t connection_handle,
125
126
attribute_handle_range_t discovery_range
126
127
) {
@@ -134,7 +135,7 @@ class AttClientToGattClientAdapter : public GattClient {
134
135
/* *
135
136
* @see ble::pal::GattClient::discover_characteristics_descriptors
136
137
*/
137
- virtual ble_error_t discover_characteristics_descriptors (
138
+ ble_error_t discover_characteristics_descriptors_ (
138
139
connection_handle_t connection_handle,
139
140
attribute_handle_range_t descriptors_discovery_range
140
141
) {
@@ -147,7 +148,7 @@ class AttClientToGattClientAdapter : public GattClient {
147
148
/* *
148
149
* @see ble::pal::GattClient::read_attribute_value
149
150
*/
150
- virtual ble_error_t read_attribute_value (
151
+ ble_error_t read_attribute_value_ (
151
152
connection_handle_t connection_handle,
152
153
attribute_handle_t attribute_handle
153
154
) {
@@ -160,7 +161,7 @@ class AttClientToGattClientAdapter : public GattClient {
160
161
/* *
161
162
* @see ble::pal::GattClient::read_using_characteristic_uuid
162
163
*/
163
- virtual ble_error_t read_using_characteristic_uuid (
164
+ ble_error_t read_using_characteristic_uuid_ (
164
165
connection_handle_t connection_handle,
165
166
attribute_handle_range_t read_range,
166
167
const UUID& uuid
@@ -175,7 +176,7 @@ class AttClientToGattClientAdapter : public GattClient {
175
176
/* *
176
177
* @see ble::pal::GattClient::read_attribute_blob
177
178
*/
178
- virtual ble_error_t read_attribute_blob (
179
+ ble_error_t read_attribute_blob_ (
179
180
connection_handle_t connection_handle,
180
181
attribute_handle_t attribute_handle,
181
182
uint16_t offset
@@ -190,7 +191,7 @@ class AttClientToGattClientAdapter : public GattClient {
190
191
/* *
191
192
* @see ble::pal::GattClient::read_multiple_characteristic_values
192
193
*/
193
- virtual ble_error_t read_multiple_characteristic_values (
194
+ ble_error_t read_multiple_characteristic_values_ (
194
195
connection_handle_t connection_handle,
195
196
const ArrayView<const attribute_handle_t >& characteristic_value_handles
196
197
) {
@@ -203,7 +204,7 @@ class AttClientToGattClientAdapter : public GattClient {
203
204
/* *
204
205
* @see ble::pal::GattClient::write_without_response
205
206
*/
206
- virtual ble_error_t write_without_response (
207
+ ble_error_t write_without_response_ (
207
208
connection_handle_t connection_handle,
208
209
attribute_handle_t characteristic_value_handle,
209
210
const ArrayView<const uint8_t >& value
@@ -218,7 +219,7 @@ class AttClientToGattClientAdapter : public GattClient {
218
219
/* *
219
220
* @see ble::pal::GattClient::signed_write_without_response
220
221
*/
221
- virtual ble_error_t signed_write_without_response (
222
+ ble_error_t signed_write_without_response_ (
222
223
connection_handle_t connection_handle,
223
224
attribute_handle_t characteristic_value_handle,
224
225
const ArrayView<const uint8_t >& value
@@ -233,7 +234,7 @@ class AttClientToGattClientAdapter : public GattClient {
233
234
/* *
234
235
* @see ble::pal::GattClient::write_attribute
235
236
*/
236
- virtual ble_error_t write_attribute (
237
+ ble_error_t write_attribute_ (
237
238
connection_handle_t connection_handle,
238
239
attribute_handle_t attribute_handle,
239
240
const ArrayView<const uint8_t >& value
@@ -248,7 +249,7 @@ class AttClientToGattClientAdapter : public GattClient {
248
249
/* *
249
250
* @see ble::pal::GattClient::queue_prepare_write
250
251
*/
251
- virtual ble_error_t queue_prepare_write (
252
+ ble_error_t queue_prepare_write_ (
252
253
connection_handle_t connection_handle,
253
254
attribute_handle_t characteristic_value_handle,
254
255
const ArrayView<const uint8_t >& value,
@@ -265,7 +266,7 @@ class AttClientToGattClientAdapter : public GattClient {
265
266
/* *
266
267
* @see ble::pal::GattClient::execute_write_queue
267
268
*/
268
- virtual ble_error_t execute_write_queue (
269
+ ble_error_t execute_write_queue_ (
269
270
connection_handle_t connection_handle,
270
271
bool execute
271
272
) {
@@ -275,14 +276,14 @@ class AttClientToGattClientAdapter : public GattClient {
275
276
/* *
276
277
* @see ble::pal::GattClient::initialize
277
278
*/
278
- virtual ble_error_t initialize () {
279
+ ble_error_t initialize_ () {
279
280
return _client.initialize ();
280
281
}
281
282
282
283
/* *
283
284
* @see ble::pal::GattClient::terminate
284
285
*/
285
- virtual ble_error_t terminate () {
286
+ ble_error_t terminate_ () {
286
287
return _client.initialize ();
287
288
}
288
289
0 commit comments