This application demonstrates detailed uses of the GattClient APIs.

Revision:
5:331ef6ec71f5
Parent:
2:32be19c07874
--- a/source/main.cpp	Wed Feb 27 13:01:37 2019 +0000
+++ b/source/main.cpp	Tue Jul 23 12:02:37 2019 +0100
@@ -43,7 +43,8 @@
  * indications and notification until the connection end.
  */
 class GattClientProcess : private mbed::NonCopyable<GattClientProcess>,
-                          public ble::Gap::EventHandler {
+                          public ble::Gap::EventHandler,
+                          public GattClient::EventHandler {
 
     // Internal typedef to this class type.
     // It is used as a shorthand to pass member function as callbacks.
@@ -118,6 +119,13 @@
             return;
         }
 
+        // register as a handler for GattClient events
+        _client->setEventHandler(this);
+
+        // this might not result in a new value but if it does we will be informed through
+        // an call in the event handler we just registered
+        _client->negotiateAttMtu(_connection_handle);
+
         printf("Client process started: initiate service discovery.\r\n");
     }
 
@@ -170,6 +178,21 @@
         }
     }
 
+    /**
+     * Implementation of GattClient::EventHandler::onAttMtuChange event
+     */
+    virtual void onAttMtuChange(
+        ble::connection_handle_t connectionHandle,
+        uint16_t attMtuSize
+    ) {
+        printf(
+            "ATT_MTU changed on the connection %d to a new value of %d.\r\n",
+            connectionHandle,
+            attMtuSize
+            /* maximum size of an attribute written in a single operation is one less */
+        );
+    }
+
 private:
 ////////////////////////////////////////////////////////////////////////////////
 // Service and characteristic discovery process.