19
19
#ifndef IMPL_GATT_CLIENT_H__
20
20
#define IMPL_GATT_CLIENT_H__
21
21
22
+ #include " ble/BLE.h"
23
+
22
24
#include " CallChainOfFunctionPointersWithContext.h"
23
25
#include < algorithm>
24
26
27
+
25
28
#include " ble/common/ble/blecommon.h"
26
29
#include " ble/common/ble/GattAttribute.h"
27
30
#include " ble/common/ble/ServiceDiscovery.h"
33
36
34
37
namespace ble {
35
38
39
+ class BLEInstanceBase ;
40
+
41
+ namespace impl {
42
+
36
43
class GattClient :
37
- public ble::interface::GattClient,
38
44
public PalSigningMonitor,
39
- public PalGattClientEventHandler
40
- {
45
+ public PalGattClientEventHandler {
41
46
friend PalSigningMonitor;
42
47
friend BLEInstanceBase;
43
48
public:
49
+ using EventHandler = ble::GattClient::EventHandler;
50
+ using WriteOp_t = ble::GattClient::WriteOp_t;
51
+ using HVXCallback_t = ble::GattClient::HVXCallback_t ;
52
+ using GattClientShutdownCallback_t = ble::GattClient::GattClientShutdownCallback_t ;
53
+ using GattClientShutdownCallbackChain_t = ble::GattClient::GattClientShutdownCallbackChain_t ;
54
+ using HVXCallbackChain_t = ble::GattClient::HVXCallbackChain_t ;
55
+ using ReadCallbackChain_t = ble::GattClient::ReadCallbackChain_t ;
56
+ using WriteCallbackChain_t = ble::GattClient::WriteCallbackChain_t ;
57
+
58
+
59
+
44
60
void setEventHandler (EventHandler *handler);
45
61
46
62
ble_error_t launchServiceDiscovery (
47
63
ble::connection_handle_t connectionHandle,
48
64
ServiceDiscovery::ServiceCallback_t sc = NULL ,
49
- ServiceDiscovery::CharacteristicCallback_t cc = NULL ,
65
+ ServiceDiscovery::CharacteristicCallback_t cc = NULL ,
50
66
const UUID &matchingServiceUUID = UUID::ShortUUIDBytes_t(BLE_UUID_UNKNOWN),
51
67
const UUID &matchingCharacteristicUUIDIn = UUID::ShortUUIDBytes_t(BLE_UUID_UNKNOWN)
52
68
);
@@ -86,28 +102,28 @@ class GattClient :
86
102
87
103
void onDataRead (ReadCallback_t callback);
88
104
89
- ReadCallbackChain_t& onDataRead ();
105
+ ReadCallbackChain_t & onDataRead ();
90
106
91
107
void onDataWritten (WriteCallback_t callback);
92
108
93
- WriteCallbackChain_t& onDataWritten ();
109
+ WriteCallbackChain_t & onDataWritten ();
94
110
95
111
void onServiceDiscoveryTermination (
96
112
ServiceDiscovery::TerminationCallback_t callback
97
113
);
98
114
99
115
ble_error_t discoverCharacteristicDescriptors (
100
- const DiscoveredCharacteristic& characteristic,
101
- const CharacteristicDescriptorDiscovery::DiscoveryCallback_t& discoveryCallback,
102
- const CharacteristicDescriptorDiscovery::TerminationCallback_t& terminationCallback
116
+ const DiscoveredCharacteristic & characteristic,
117
+ const CharacteristicDescriptorDiscovery::DiscoveryCallback_t & discoveryCallback,
118
+ const CharacteristicDescriptorDiscovery::TerminationCallback_t & terminationCallback
103
119
);
104
120
105
121
bool isCharacteristicDescriptorDiscoveryActive (
106
- const DiscoveredCharacteristic& characteristic
122
+ const DiscoveredCharacteristic & characteristic
107
123
) const ;
108
124
109
125
void terminateCharacteristicDescriptorDiscovery (
110
- const DiscoveredCharacteristic& characteristic
126
+ const DiscoveredCharacteristic & characteristic
111
127
);
112
128
113
129
ble_error_t negotiateAttMtu (ble::connection_handle_t connection);
@@ -122,14 +138,14 @@ class GattClient :
122
138
*/
123
139
void onHVX (HVXCallback_t callback);
124
140
125
- void onShutdown (const GattClientShutdownCallback_t& callback);
141
+ void onShutdown (const GattClientShutdownCallback_t & callback);
126
142
127
- template <typename T>
143
+ template <typename T>
128
144
void onShutdown (T *objPtr, void (T::*memberPtr)(const GattClient *));
129
145
130
- GattClientShutdownCallbackChain_t& onShutdown ();
146
+ GattClientShutdownCallbackChain_t & onShutdown ();
131
147
132
- HVXCallbackChain_t& onHVX ();
148
+ HVXCallbackChain_t & onHVX ();
133
149
134
150
ble_error_t reset (void );
135
151
@@ -144,7 +160,8 @@ class GattClient :
144
160
private:
145
161
/* Disallow copy and assignment. */
146
162
GattClient (const GattClient &);
147
- GattClient& operator =(const GattClient &);
163
+
164
+ GattClient &operator =(const GattClient &);
148
165
149
166
/* ===================================================================== */
150
167
/* private implementation follows */
@@ -179,15 +196,22 @@ class GattClient :
179
196
struct WriteControlBlock ;
180
197
struct DescriptorDiscoveryControlBlock ;
181
198
182
- ProcedureControlBlock* get_control_block (connection_handle_t connection);
183
- const ProcedureControlBlock* get_control_block (connection_handle_t connection) const ;
184
- void insert_control_block (ProcedureControlBlock* cb) const ;
185
- void remove_control_block (ProcedureControlBlock* cb) const ;
199
+ ProcedureControlBlock *get_control_block (connection_handle_t connection);
200
+
201
+ const ProcedureControlBlock *get_control_block (connection_handle_t connection) const ;
202
+
203
+ void insert_control_block (ProcedureControlBlock *cb) const ;
204
+
205
+ void remove_control_block (ProcedureControlBlock *cb) const ;
186
206
187
207
void on_termination (connection_handle_t connection_handle);
188
- void on_server_message_received (connection_handle_t , const AttServerMessage&);
189
- void on_server_response (connection_handle_t , const AttServerMessage&);
190
- void on_server_event (connection_handle_t , const AttServerMessage&);
208
+
209
+ void on_server_message_received (connection_handle_t , const AttServerMessage &);
210
+
211
+ void on_server_response (connection_handle_t , const AttServerMessage &);
212
+
213
+ void on_server_event (connection_handle_t , const AttServerMessage &);
214
+
191
215
void on_transaction_timeout (connection_handle_t );
192
216
193
217
uint16_t get_mtu (connection_handle_t connection) const ;
@@ -222,21 +246,27 @@ class GattClient :
222
246
*/
223
247
GattClientShutdownCallbackChain_t shutdownCallChain;
224
248
225
- PalGattClient& _pal_client;
249
+ PalGattClient & _pal_client;
226
250
ServiceDiscovery::TerminationCallback_t _termination_callback;
227
- PalSigningMonitorEventHandler* _signing_event_handler;
228
- mutable ProcedureControlBlock* control_blocks;
251
+ PalSigningMonitorEventHandler * _signing_event_handler;
252
+ mutable ProcedureControlBlock * control_blocks;
229
253
bool _is_reseting;
230
254
255
+ // TODO initialize
256
+ ::ble::GattClient *client;
257
+
231
258
private:
232
259
/* *
233
260
* Create a PalGattClient from a PalGattClient
234
261
*/
235
- GattClient (PalGattClient& pal_client);
262
+ GattClient (PalGattClient & pal_client);
236
263
237
- ~GattClient () { }
264
+ ~GattClient ()
265
+ {
266
+ }
238
267
};
239
268
269
+ } // namespace impl
240
270
} // namespace ble
241
271
242
272
#endif /* ifndef IMPL_GATT_CLIENT_H__ */
0 commit comments