Bluetooth: Introduce a new connection parameter request callback

Introduce a new callback to bt_conn_cb that allows the application to
decide whether the accept or reject an incoming connection parameter
request. If the request is accepted the callback allows the
application to also adjust the values to what it thinks are more
appropriate.

The Zephyr Bluetooth API allows multiple registered connection
callbacks, so in principle there may be multiple le_param_req()
callbacks. It's recommended for an app to just use one (for clarity),
but if there are multiple the app is responsible for managing
potentially different requirements. In the case of multiple callbacks
each callback will receive the modified parameters in case a previous
callback modified them.

Jira: ZEP-1474

Change-Id: I098db5791aac521f1edfa9fefdf847db0a27e3a5
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This commit is contained in:
Johan Hedberg 2017-01-16 13:26:53 +02:00
commit 1adc58fd79
5 changed files with 67 additions and 10 deletions

View file

@ -318,6 +318,30 @@ struct bt_conn_cb {
*/
void (*disconnected)(struct bt_conn *conn, uint8_t reason);
/** @brief LE connection parameter update request.
*
* This callback notifies the application that a remote device
* is requesting to update the connection parameters. The
* application accepts the parameters by returning true, or
* rejects them by returning false. Before accepting, the
* application may also adjust the parameters to better suit
* its needs.
*
* It is recommended for an application to have just one of these
* callbacks for simplicity. However, if an application registers
* multiple it needs to manage the potentially different
* requirements for each callback. Each callback gets the
* parameters as returned by previous callbacks, i.e. they are not
* necessarily the same ones as the remote originally sent.
*
* @param conn Connection object.
* @param param Proposed connection parameters.
*
* @return true to accept the parameters, or false to reject them.
*/
bool (*le_param_req)(struct bt_conn *conn,
struct bt_le_conn_param *param);
/** @brief The parameters for an LE connection have been updated.
*
* This callback notifies the application that the connection