bluetooth: host: Dynamic bt_conn_le_create timeout

Extends the bt_conn_le_create_param struct to provide the option
to set a custom timeout for the initiation of the connection.

The logic for the default values of window_coded and interval_coded
were moved to conn.c in order to resolve all defaults for the
create_param struct at a single location.

Timeout is not added as a parameter to the BT_CONN_LE_CREATE_PARAM
macro due to the expectation that CONFIG_BT_CREATE_CONN_TIMEOUT
will be the typical value that users will expect.

Fixes #23468

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
This commit is contained in:
Jordan Yates 2020-03-30 19:23:16 +10:00 committed by Johan Hedberg
commit a038dc76f1
4 changed files with 62 additions and 20 deletions

View file

@ -328,6 +328,15 @@ struct bt_conn_le_create_param {
* Set zero to use same as LE 1M PHY scan window.
*/
u16_t window_coded;
/** Connection initiation timeout (N * 10 MS)
*
* Set zero to use the default :option:`CONFIG_BT_CREATE_CONN_TIMEOUT`
* timeout.
*
* @note Unused in @ref bt_conn_create_auto_le
*/
u16_t timeout;
};
/** Helper to declare create connection parameters inline
@ -343,6 +352,7 @@ struct bt_conn_le_create_param {
.window = (_window), \
.interval_coded = 0, \
.window_coded = 0, \
.timeout = 0, \
} })
/** Default LE create connection parameters.
@ -610,7 +620,8 @@ struct bt_conn_cb {
* - @ref BT_HCI_ERR_UNKNOWN_CONN_ID Creating the connection started by
* @ref bt_conn_create_le was canceled either by the user through
* @ref bt_conn_disconnect or by the timeout in the host through
* :option:`CONFIG_BT_CREATE_CONN_TIMEOUT`.
* @ref bt_conn_le_create_param timeout parameter, which defaults to
* :option:`CONFIG_BT_CREATE_CONN_TIMEOUT` seconds.
* - @p BT_HCI_ERR_ADV_TIMEOUT Directed advertiser started by @ref
* bt_conn_create_slave_le with high duty cycle timed out after 1.28
* seconds.