@@ -32,33 +32,29 @@ namespace generic {
32
32
* It requires a pal::GattClient injected at construction site.
33
33
* @attention: Not part of the public interface of BLE API.
34
34
*/
35
- class GenericGattClient : public GattClient ,
36
- public pal::SigningEventMonitor,
37
- public pal::GattClient::EventHandler {
35
+ template <template <class > class TPalGattClient , class SigningMonitorEventHandler >
36
+ class GenericGattClient :
37
+ public interface::GattClient<GenericGattClient<TPalGattClient, SigningMonitorEventHandler> >,
38
+ public pal::SigningEventMonitor<GenericGattClient<TPalGattClient, SigningMonitorEventHandler>, SigningMonitorEventHandler>,
39
+ public pal::GattClientEventHandler<GenericGattClient<TPalGattClient, SigningMonitorEventHandler> > {
40
+
41
+ using interface::GattClient<GenericGattClient<TPalGattClient, SigningMonitorEventHandler> >::eventHandler;
42
+
38
43
public:
39
44
40
- /* *
41
- * @see pal::GattClient::EventHandler::on_att_mtu_change
42
- */
43
- virtual void on_att_mtu_change (
44
- ble::connection_handle_t connection_handle,
45
- uint16_t att_mtu_size
46
- )
47
- {
48
- if (eventHandler) {
49
- eventHandler->onAttMtuChange (connection_handle, att_mtu_size);
50
- }
51
- }
45
+ typedef interface::GattClient<GenericGattClient<TPalGattClient, SigningMonitorEventHandler> > Base;
46
+ typedef TPalGattClient<GenericGattClient> PalGattClient;
47
+ typedef typename Base::WriteOp_t WriteOp_t;
52
48
53
49
/* *
54
50
* Create a GenericGattClient from a pal::GattClient
55
51
*/
56
- GenericGattClient (pal::GattClient * pal_client);
52
+ GenericGattClient (PalGattClient * pal_client);
57
53
58
54
/* *
59
55
* @see GattClient::launchServiceDiscovery
60
56
*/
61
- virtual ble_error_t launchServiceDiscovery (
57
+ ble_error_t launchServiceDiscovery_ (
62
58
connection_handle_t connection_handle,
63
59
ServiceDiscovery::ServiceCallback_t service_callback,
64
60
ServiceDiscovery::CharacteristicCallback_t characteristic_callback,
@@ -69,17 +65,17 @@ class GenericGattClient : public GattClient,
69
65
/* *
70
66
* @see GattClient::isServiceDiscoveryActive
71
67
*/
72
- virtual bool isServiceDiscoveryActive () const ;
68
+ bool isServiceDiscoveryActive_ () const ;
73
69
74
70
/* *
75
71
* @see GattClient::terminateServiceDiscovery
76
72
*/
77
- virtual void terminateServiceDiscovery ();
73
+ void terminateServiceDiscovery_ ();
78
74
79
75
/* *
80
76
* @see GattClient::read
81
77
*/
82
- virtual ble_error_t read (
78
+ ble_error_t read_ (
83
79
connection_handle_t connection_handle,
84
80
GattAttribute::Handle_t attribute_handle,
85
81
uint16_t offset
@@ -88,8 +84,8 @@ class GenericGattClient : public GattClient,
88
84
/* *
89
85
* @see GattClient::write
90
86
*/
91
- virtual ble_error_t write (
92
- GattClient:: WriteOp_t cmd,
87
+ ble_error_t write_ (
88
+ WriteOp_t cmd,
93
89
connection_handle_t connection_handle,
94
90
GattAttribute::Handle_t attribute_handle,
95
91
size_t length,
@@ -99,14 +95,14 @@ class GenericGattClient : public GattClient,
99
95
/* *
100
96
* @see GattClient::onServiceDiscoveryTermination
101
97
*/
102
- virtual void onServiceDiscoveryTermination (
98
+ void onServiceDiscoveryTermination_ (
103
99
ServiceDiscovery::TerminationCallback_t callback
104
100
);
105
101
106
102
/* *
107
103
* @see GattClient::discoverCharacteristicDescriptors
108
104
*/
109
- virtual ble_error_t discoverCharacteristicDescriptors (
105
+ ble_error_t discoverCharacteristicDescriptors_ (
110
106
const DiscoveredCharacteristic& characteristic,
111
107
const CharacteristicDescriptorDiscovery::DiscoveryCallback_t& discoveryCallback,
112
108
const CharacteristicDescriptorDiscovery::TerminationCallback_t& terminationCallback
@@ -115,41 +111,41 @@ class GenericGattClient : public GattClient,
115
111
/* *
116
112
* @see GattClient::isCharacteristicDescriptorDiscoveryActive
117
113
*/
118
- virtual bool isCharacteristicDescriptorDiscoveryActive (
114
+ bool isCharacteristicDescriptorDiscoveryActive_ (
119
115
const DiscoveredCharacteristic& characteristic
120
116
) const ;
121
117
122
118
/* *
123
119
* @see GattClient::terminateCharacteristicDescriptorDiscovery
124
120
*/
125
- virtual void terminateCharacteristicDescriptorDiscovery (
121
+ void terminateCharacteristicDescriptorDiscovery_ (
126
122
const DiscoveredCharacteristic& characteristic
127
123
);
128
124
129
125
/* *
130
126
* @see GattClient::negotiateAttMtu
131
127
*/
132
- virtual ble_error_t negotiateAttMtu (
128
+ ble_error_t negotiateAttMtu_ (
133
129
connection_handle_t connection
134
130
);
135
131
136
132
/* *
137
133
* @see GattClient::reset
138
134
*/
139
- virtual ble_error_t reset (void );
135
+ ble_error_t reset_ (void );
140
136
141
137
/* *
142
138
* @see ble::pal::SigningEventMonitor::set_signing_event_handler
143
139
*/
144
- virtual void set_signing_event_handler (pal::SigningEventMonitor::EventHandler *signing_event_handler);
140
+ void set_signing_event_handler_ (SigningMonitorEventHandler *signing_event_handler);
145
141
146
142
/* *
147
- * Return the user registered event handler.
148
- * @return User registered event handler or NULL if none is present.
143
+ * @see pal::GattClient::EventHandler::on_att_mtu_change
149
144
*/
150
- ::GattClient::EventHandler* getEventHandler () {
151
- return eventHandler;
152
- }
145
+ void on_att_mtu_change_ (
146
+ ble::connection_handle_t connection_handle,
147
+ uint16_t att_mtu_size
148
+ );
153
149
154
150
private:
155
151
struct ProcedureControlBlock ;
@@ -171,14 +167,14 @@ class GenericGattClient : public GattClient,
171
167
172
168
uint16_t get_mtu (connection_handle_t connection) const ;
173
169
174
- pal::GattClient * const _pal_client;
170
+ PalGattClient * const _pal_client;
175
171
ServiceDiscovery::TerminationCallback_t _termination_callback;
176
- pal::SigningEventMonitor::EventHandler * _signing_event_handler;
172
+ SigningMonitorEventHandler * _signing_event_handler;
177
173
mutable ProcedureControlBlock* control_blocks;
178
174
bool _is_reseting;
179
175
};
180
176
181
- }
182
- }
177
+ } // generic
178
+ } // ble
183
179
184
180
#endif /* MBED_BLE_GENERIC_GATT_CLIENT */
0 commit comments