|
43 | 43 | * indications and notification until the connection end. |
44 | 44 | */ |
45 | 45 | class GattClientProcess : private mbed::NonCopyable<GattClientProcess>, |
46 | | - public ble::Gap::EventHandler { |
| 46 | + public ble::Gap::EventHandler, |
| 47 | + public GattClient::EventHandler { |
47 | 48 |
|
48 | 49 | // Internal typedef to this class type. |
49 | 50 | // It is used as a shorthand to pass member function as callbacks. |
@@ -118,6 +119,13 @@ class GattClientProcess : private mbed::NonCopyable<GattClientProcess>, |
118 | 119 | return; |
119 | 120 | } |
120 | 121 |
|
| 122 | + // register as a handler for GattClient events |
| 123 | + _client->setEventHandler(this); |
| 124 | + |
| 125 | + // this might not result in a new value but if it does we will be informed through |
| 126 | + // an call in the event handler we just registered |
| 127 | + _client->negotiateAttMtu(_connection_handle); |
| 128 | + |
121 | 129 | printf("Client process started: initiate service discovery.\r\n"); |
122 | 130 | } |
123 | 131 |
|
@@ -170,6 +178,21 @@ class GattClientProcess : private mbed::NonCopyable<GattClientProcess>, |
170 | 178 | } |
171 | 179 | } |
172 | 180 |
|
| 181 | + /** |
| 182 | + * Implementation of GattClient::EventHandler::onAttMtuChange event |
| 183 | + */ |
| 184 | + virtual void onAttMtuChange( |
| 185 | + ble::connection_handle_t connectionHandle, |
| 186 | + uint16_t attMtuSize |
| 187 | + ) { |
| 188 | + printf( |
| 189 | + "ATT_MTU changed on the connection %d to a new value of %d.\r\n", |
| 190 | + connectionHandle, |
| 191 | + attMtuSize |
| 192 | + /* maximum size of an attribute written in a single operation is one less */ |
| 193 | + ); |
| 194 | + } |
| 195 | + |
173 | 196 | private: |
174 | 197 | //////////////////////////////////////////////////////////////////////////////// |
175 | 198 | // Service and characteristic discovery process. |
|
0 commit comments