Skip to content

Commit c9240cc

Browse files
ryanjhkartben
authored andcommitted
bluetooth: host: Report status of Channel Sounding complete events
If the HCI status of a complete event is not BT_HCI_ERR_SUCCESS, the remaining parameters could be invalid. In this case, the params is passed as NULL pointer to the callbacks. - LE CS Read Remote Supported Capabilities Complete event - LE CS Read Remote FAE Table Complete event - LE CS Config Complete event - LE CS Security Enable Complete event - LE CS Procedure Enable Complete event This change avoids forwarding the invalid fileds to the applications. Signed-off-by: Ryan Chu <ryan.chu@nordicsemi.no>
1 parent aaeb015 commit c9240cc

File tree

6 files changed

+223
-170
lines changed

6 files changed

+223
-170
lines changed

include/zephyr/bluetooth/conn.h

Lines changed: 39 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1876,35 +1876,50 @@ struct bt_conn_cb {
18761876
#if defined(CONFIG_BT_CHANNEL_SOUNDING)
18771877
/** @brief LE CS Read Remote Supported Capabilities Complete event.
18781878
*
1879-
* This callback notifies the application that the remote channel
1879+
* This callback notifies the application that a Channel Sounding
1880+
* Capabilities Exchange procedure has completed.
1881+
*
1882+
* If status is BT_HCI_ERR_SUCCESS, the remote channel
18801883
* sounding capabilities have been received from the peer.
18811884
*
18821885
* @param conn Connection object.
1883-
* @param remote_cs_capabilities Remote Channel Sounding Capabilities.
1886+
* @param status HCI status of complete event.
1887+
* @param remote_cs_capabilities Pointer to CS Capabilities on success or NULL otherwise.
18841888
*/
1885-
void (*le_cs_remote_capabilities_available)(struct bt_conn *conn,
1886-
struct bt_conn_le_cs_capabilities *params);
1889+
void (*le_cs_read_remote_capabilities_complete)(struct bt_conn *conn,
1890+
uint8_t status,
1891+
struct bt_conn_le_cs_capabilities *params);
18871892

18881893
/** @brief LE CS Read Remote FAE Table Complete event.
18891894
*
1890-
* This callback notifies the application that the remote mode-0
1895+
* This callback notifies the application that a Channel Sounding
1896+
* Mode-0 FAE Table Request procedure has completed.
1897+
*
1898+
* If status is BT_HCI_ERR_SUCCESS, the remote mode-0
18911899
* FAE Table has been received from the peer.
18921900
*
18931901
* @param conn Connection object.
1894-
* @param params FAE Table.
1902+
* @param status HCI status of complete event.
1903+
* @param params Pointer to FAE Table on success or NULL otherwise.
18951904
*/
1896-
void (*le_cs_remote_fae_table_available)(struct bt_conn *conn,
1897-
struct bt_conn_le_cs_fae_table *params);
1905+
void (*le_cs_read_remote_fae_table_complete)(struct bt_conn *conn,
1906+
uint8_t status,
1907+
struct bt_conn_le_cs_fae_table *params);
18981908

18991909
/** @brief LE CS Config created.
19001910
*
19011911
* This callback notifies the application that a Channel Sounding
1902-
* Configuration procedure has completed and a new CS config is created
1912+
* Configuration procedure has completed.
1913+
*
1914+
* If status is BT_HCI_ERR_SUCCESS, a new CS config is created.
19031915
*
19041916
* @param conn Connection object.
1905-
* @param config CS configuration.
1917+
* @param status HCI status of complete event.
1918+
* @param config Pointer to CS configuration on success or NULL otherwise.
19061919
*/
1907-
void (*le_cs_config_created)(struct bt_conn *conn, struct bt_conn_le_cs_config *config);
1920+
void (*le_cs_config_complete)(struct bt_conn *conn,
1921+
uint8_t status,
1922+
struct bt_conn_le_cs_config *config);
19081923

19091924
/** @brief LE CS Config removed.
19101925
*
@@ -1930,22 +1945,29 @@ struct bt_conn_cb {
19301945
/** @brief LE CS Security Enabled.
19311946
*
19321947
* This callback notifies the application that a Channel Sounding
1933-
* Security Enable procedure has completed
1948+
* Security Enable procedure has completed.
1949+
*
1950+
* If status is BT_HCI_ERR_SUCCESS, CS Security is enabled.
19341951
*
19351952
* @param conn Connection object.
1953+
* @param status HCI status of complete event.
19361954
*/
1937-
void (*le_cs_security_enabled)(struct bt_conn *conn);
1955+
void (*le_cs_security_enable_complete)(struct bt_conn *conn, uint8_t status);
19381956

19391957
/** @brief LE CS Procedure Enabled.
19401958
*
19411959
* This callback notifies the application that a Channel Sounding
1942-
* Procedure Enable procedure has completed
1960+
* Procedure Enable procedure has completed.
1961+
*
1962+
* If status is BT_HCI_ERR_SUCCESS, CS procedure is enabled.
19431963
*
19441964
* @param conn Connection object.
1945-
* @param params CS Procedure Enable parameters
1965+
* @param status HCI status.
1966+
* @param params Pointer to CS Procedure Enable parameters on success or NULL otherwise.
19461967
*/
1947-
void (*le_cs_procedure_enabled)(
1948-
struct bt_conn *conn, struct bt_conn_le_cs_procedure_enable_complete *params);
1968+
void (*le_cs_procedure_enable_complete)(
1969+
struct bt_conn *conn, uint8_t status,
1970+
struct bt_conn_le_cs_procedure_enable_complete *params);
19491971

19501972
#endif
19511973

subsys/bluetooth/host/conn.c

Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3319,53 +3319,56 @@ int bt_conn_le_subrate_request(struct bt_conn *conn,
33193319
#endif /* CONFIG_BT_SUBRATING */
33203320

33213321
#if defined(CONFIG_BT_CHANNEL_SOUNDING)
3322-
void notify_remote_cs_capabilities(struct bt_conn *conn, struct bt_conn_le_cs_capabilities params)
3322+
void notify_remote_cs_capabilities(struct bt_conn *conn, uint8_t status,
3323+
struct bt_conn_le_cs_capabilities *params)
33233324
{
33243325
struct bt_conn_cb *callback;
33253326

33263327
SYS_SLIST_FOR_EACH_CONTAINER(&conn_cbs, callback, _node) {
3327-
if (callback->le_cs_remote_capabilities_available) {
3328-
callback->le_cs_remote_capabilities_available(conn, &params);
3328+
if (callback->le_cs_read_remote_capabilities_complete) {
3329+
callback->le_cs_read_remote_capabilities_complete(conn, status, params);
33293330
}
33303331
}
33313332

33323333
STRUCT_SECTION_FOREACH(bt_conn_cb, cb) {
3333-
if (cb->le_cs_remote_capabilities_available) {
3334-
cb->le_cs_remote_capabilities_available(conn, &params);
3334+
if (cb->le_cs_read_remote_capabilities_complete) {
3335+
cb->le_cs_read_remote_capabilities_complete(conn, status, params);
33353336
}
33363337
}
33373338
}
33383339

3339-
void notify_remote_cs_fae_table(struct bt_conn *conn, struct bt_conn_le_cs_fae_table params)
3340+
void notify_remote_cs_fae_table(struct bt_conn *conn, uint8_t status,
3341+
struct bt_conn_le_cs_fae_table *params)
33403342
{
33413343
struct bt_conn_cb *callback;
33423344

33433345
SYS_SLIST_FOR_EACH_CONTAINER(&conn_cbs, callback, _node) {
3344-
if (callback->le_cs_remote_fae_table_available) {
3345-
callback->le_cs_remote_fae_table_available(conn, &params);
3346+
if (callback->le_cs_read_remote_fae_table_complete) {
3347+
callback->le_cs_read_remote_fae_table_complete(conn, status, params);
33463348
}
33473349
}
33483350

33493351
STRUCT_SECTION_FOREACH(bt_conn_cb, cb) {
3350-
if (cb->le_cs_remote_fae_table_available) {
3351-
cb->le_cs_remote_fae_table_available(conn, &params);
3352+
if (cb->le_cs_read_remote_fae_table_complete) {
3353+
cb->le_cs_read_remote_fae_table_complete(conn, status, params);
33523354
}
33533355
}
33543356
}
33553357

3356-
void notify_cs_config_created(struct bt_conn *conn, struct bt_conn_le_cs_config *params)
3358+
void notify_cs_config_created(struct bt_conn *conn, uint8_t status,
3359+
struct bt_conn_le_cs_config *params)
33573360
{
33583361
struct bt_conn_cb *callback;
33593362

33603363
SYS_SLIST_FOR_EACH_CONTAINER(&conn_cbs, callback, _node) {
3361-
if (callback->le_cs_config_created) {
3362-
callback->le_cs_config_created(conn, params);
3364+
if (callback->le_cs_config_complete) {
3365+
callback->le_cs_config_complete(conn, status, params);
33633366
}
33643367
}
33653368

33663369
STRUCT_SECTION_FOREACH(bt_conn_cb, cb) {
3367-
if (cb->le_cs_config_created) {
3368-
cb->le_cs_config_created(conn, params);
3370+
if (cb->le_cs_config_complete) {
3371+
cb->le_cs_config_complete(conn, status, params);
33693372
}
33703373
}
33713374
}
@@ -3387,37 +3390,37 @@ void notify_cs_config_removed(struct bt_conn *conn, uint8_t config_id)
33873390
}
33883391
}
33893392

3390-
void notify_cs_security_enable_available(struct bt_conn *conn)
3393+
void notify_cs_security_enable_available(struct bt_conn *conn, uint8_t status)
33913394
{
33923395
struct bt_conn_cb *callback;
33933396

33943397
SYS_SLIST_FOR_EACH_CONTAINER(&conn_cbs, callback, _node) {
3395-
if (callback->le_cs_security_enabled) {
3396-
callback->le_cs_security_enabled(conn);
3398+
if (callback->le_cs_security_enable_complete) {
3399+
callback->le_cs_security_enable_complete(conn, status);
33973400
}
33983401
}
33993402

34003403
STRUCT_SECTION_FOREACH(bt_conn_cb, cb) {
3401-
if (cb->le_cs_security_enabled) {
3402-
cb->le_cs_security_enabled(conn);
3404+
if (cb->le_cs_security_enable_complete) {
3405+
cb->le_cs_security_enable_complete(conn, status);
34033406
}
34043407
}
34053408
}
34063409

3407-
void notify_cs_procedure_enable_available(struct bt_conn *conn,
3410+
void notify_cs_procedure_enable_available(struct bt_conn *conn, uint8_t status,
34083411
struct bt_conn_le_cs_procedure_enable_complete *params)
34093412
{
34103413
struct bt_conn_cb *callback;
34113414

34123415
SYS_SLIST_FOR_EACH_CONTAINER(&conn_cbs, callback, _node) {
3413-
if (callback->le_cs_procedure_enabled) {
3414-
callback->le_cs_procedure_enabled(conn, params);
3416+
if (callback->le_cs_procedure_enable_complete) {
3417+
callback->le_cs_procedure_enable_complete(conn, status, params);
34153418
}
34163419
}
34173420

34183421
STRUCT_SECTION_FOREACH(bt_conn_cb, cb) {
3419-
if (cb->le_cs_procedure_enabled) {
3420-
cb->le_cs_procedure_enabled(conn, params);
3422+
if (cb->le_cs_procedure_enable_complete) {
3423+
cb->le_cs_procedure_enable_complete(conn, status, params);
34213424
}
34223425
}
34233426
}

subsys/bluetooth/host/conn_internal.h

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -495,20 +495,25 @@ void notify_subrate_change(struct bt_conn *conn,
495495
struct bt_conn_le_subrate_changed params);
496496

497497
void notify_remote_cs_capabilities(struct bt_conn *conn,
498-
struct bt_conn_le_cs_capabilities params);
498+
uint8_t status,
499+
struct bt_conn_le_cs_capabilities *params);
499500

500501
void notify_remote_cs_fae_table(struct bt_conn *conn,
501-
struct bt_conn_le_cs_fae_table params);
502+
uint8_t status,
503+
struct bt_conn_le_cs_fae_table *params);
502504

503-
void notify_cs_config_created(struct bt_conn *conn, struct bt_conn_le_cs_config *params);
505+
void notify_cs_config_created(struct bt_conn *conn,
506+
uint8_t status,
507+
struct bt_conn_le_cs_config *params);
504508

505509
void notify_cs_config_removed(struct bt_conn *conn, uint8_t config_id);
506510

507511
void notify_cs_subevent_result(struct bt_conn *conn, struct bt_conn_le_cs_subevent_result *result);
508512

509-
void notify_cs_security_enable_available(struct bt_conn *conn);
513+
void notify_cs_security_enable_available(struct bt_conn *conn, uint8_t status);
510514

511515
void notify_cs_procedure_enable_available(struct bt_conn *conn,
516+
uint8_t status,
512517
struct bt_conn_le_cs_procedure_enable_complete *params);
513518

514519
#if defined(CONFIG_BT_SMP)

0 commit comments

Comments
 (0)