Bluetooth: gatt: callbacks on ATT MTU update

Adds a new callback structure to `<gatt.h>` for receiving notifications
of ATT MTU updates. This callback is called regardless of whether the
MTU update was initiated locally or remotely.

Fixes #32035.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
This commit is contained in:
Jordan Yates 2021-02-06 11:21:46 +10:00 committed by Carles Cufí
commit 43b2400688
4 changed files with 77 additions and 0 deletions

View file

@ -18,6 +18,7 @@
*/
#include <stddef.h>
#include <sys/slist.h>
#include <sys/types.h>
#include <sys/util.h>
#include <bluetooth/conn.h>
@ -181,6 +182,22 @@ struct bt_gatt_include {
uint16_t end_handle;
};
/** @brief GATT callback structure. */
struct bt_gatt_cb {
/** @brief The maximum ATT MTU on a connection has changed.
*
* This callback notifies the application that the maximum TX or RX
* ATT MTU has increased.
*
* @param conn Connection object.
* @param tx Updated TX ATT MTU.
* @param rx Updated RX ATT MTU.
*/
void (*att_mtu_updated)(struct bt_conn *conn, uint16_t tx, uint16_t rx);
sys_snode_t node;
};
/** Characteristic Properties Bit field values */
/** @def BT_GATT_CHRC_BROADCAST
@ -314,6 +331,14 @@ struct bt_gatt_cpf {
* @{
*/
/** @brief Register GATT callbacks.
*
* Register callbacks to monitor the state of GATT.
*
* @param cb Callback struct.
*/
void bt_gatt_cb_register(struct bt_gatt_cb *cb);
/** @brief Register GATT service.
*
* Register GATT service. Applications can make use of