Skip to content

Commit fe97a98

Browse files
ryanjhrlubos
authored andcommitted
[nrf fromtree] 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 <[email protected]> (cherry picked from commit c9240cc)
1 parent b040cf4 commit fe97a98

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
@@ -1847,35 +1847,50 @@ struct bt_conn_cb {
18471847
#if defined(CONFIG_BT_CHANNEL_SOUNDING)
18481848
/** @brief LE CS Read Remote Supported Capabilities Complete event.
18491849
*
1850-
* This callback notifies the application that the remote channel
1850+
* This callback notifies the application that a Channel Sounding
1851+
* Capabilities Exchange procedure has completed.
1852+
*
1853+
* If status is BT_HCI_ERR_SUCCESS, the remote channel
18511854
* sounding capabilities have been received from the peer.
18521855
*
18531856
* @param conn Connection object.
1854-
* @param remote_cs_capabilities Remote Channel Sounding Capabilities.
1857+
* @param status HCI status of complete event.
1858+
* @param remote_cs_capabilities Pointer to CS Capabilities on success or NULL otherwise.
18551859
*/
1856-
void (*le_cs_remote_capabilities_available)(struct bt_conn *conn,
1857-
struct bt_conn_le_cs_capabilities *params);
1860+
void (*le_cs_read_remote_capabilities_complete)(struct bt_conn *conn,
1861+
uint8_t status,
1862+
struct bt_conn_le_cs_capabilities *params);
18581863

18591864
/** @brief LE CS Read Remote FAE Table Complete event.
18601865
*
1861-
* This callback notifies the application that the remote mode-0
1866+
* This callback notifies the application that a Channel Sounding
1867+
* Mode-0 FAE Table Request procedure has completed.
1868+
*
1869+
* If status is BT_HCI_ERR_SUCCESS, the remote mode-0
18621870
* FAE Table has been received from the peer.
18631871
*
18641872
* @param conn Connection object.
1865-
* @param params FAE Table.
1873+
* @param status HCI status of complete event.
1874+
* @param params Pointer to FAE Table on success or NULL otherwise.
18661875
*/
1867-
void (*le_cs_remote_fae_table_available)(struct bt_conn *conn,
1868-
struct bt_conn_le_cs_fae_table *params);
1876+
void (*le_cs_read_remote_fae_table_complete)(struct bt_conn *conn,
1877+
uint8_t status,
1878+
struct bt_conn_le_cs_fae_table *params);
18691879

18701880
/** @brief LE CS Config created.
18711881
*
18721882
* This callback notifies the application that a Channel Sounding
1873-
* Configuration procedure has completed and a new CS config is created
1883+
* Configuration procedure has completed.
1884+
*
1885+
* If status is BT_HCI_ERR_SUCCESS, a new CS config is created.
18741886
*
18751887
* @param conn Connection object.
1876-
* @param config CS configuration.
1888+
* @param status HCI status of complete event.
1889+
* @param config Pointer to CS configuration on success or NULL otherwise.
18771890
*/
1878-
void (*le_cs_config_created)(struct bt_conn *conn, struct bt_conn_le_cs_config *config);
1891+
void (*le_cs_config_complete)(struct bt_conn *conn,
1892+
uint8_t status,
1893+
struct bt_conn_le_cs_config *config);
18791894

18801895
/** @brief LE CS Config removed.
18811896
*
@@ -1901,22 +1916,29 @@ struct bt_conn_cb {
19011916
/** @brief LE CS Security Enabled.
19021917
*
19031918
* This callback notifies the application that a Channel Sounding
1904-
* Security Enable procedure has completed
1919+
* Security Enable procedure has completed.
1920+
*
1921+
* If status is BT_HCI_ERR_SUCCESS, CS Security is enabled.
19051922
*
19061923
* @param conn Connection object.
1924+
* @param status HCI status of complete event.
19071925
*/
1908-
void (*le_cs_security_enabled)(struct bt_conn *conn);
1926+
void (*le_cs_security_enable_complete)(struct bt_conn *conn, uint8_t status);
19091927

19101928
/** @brief LE CS Procedure Enabled.
19111929
*
19121930
* This callback notifies the application that a Channel Sounding
1913-
* Procedure Enable procedure has completed
1931+
* Procedure Enable procedure has completed.
1932+
*
1933+
* If status is BT_HCI_ERR_SUCCESS, CS procedure is enabled.
19141934
*
19151935
* @param conn Connection object.
1916-
* @param params CS Procedure Enable parameters
1936+
* @param status HCI status.
1937+
* @param params Pointer to CS Procedure Enable parameters on success or NULL otherwise.
19171938
*/
1918-
void (*le_cs_procedure_enabled)(
1919-
struct bt_conn *conn, struct bt_conn_le_cs_procedure_enable_complete *params);
1939+
void (*le_cs_procedure_enable_complete)(
1940+
struct bt_conn *conn, uint8_t status,
1941+
struct bt_conn_le_cs_procedure_enable_complete *params);
19201942

19211943
#endif
19221944

subsys/bluetooth/host/conn.c

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

33423342
#if defined(CONFIG_BT_CHANNEL_SOUNDING)
3343-
void notify_remote_cs_capabilities(struct bt_conn *conn, struct bt_conn_le_cs_capabilities params)
3343+
void notify_remote_cs_capabilities(struct bt_conn *conn, uint8_t status,
3344+
struct bt_conn_le_cs_capabilities *params)
33443345
{
33453346
struct bt_conn_cb *callback;
33463347

33473348
SYS_SLIST_FOR_EACH_CONTAINER(&conn_cbs, callback, _node) {
3348-
if (callback->le_cs_remote_capabilities_available) {
3349-
callback->le_cs_remote_capabilities_available(conn, &params);
3349+
if (callback->le_cs_read_remote_capabilities_complete) {
3350+
callback->le_cs_read_remote_capabilities_complete(conn, status, params);
33503351
}
33513352
}
33523353

33533354
STRUCT_SECTION_FOREACH(bt_conn_cb, cb) {
3354-
if (cb->le_cs_remote_capabilities_available) {
3355-
cb->le_cs_remote_capabilities_available(conn, &params);
3355+
if (cb->le_cs_read_remote_capabilities_complete) {
3356+
cb->le_cs_read_remote_capabilities_complete(conn, status, params);
33563357
}
33573358
}
33583359
}
33593360

3360-
void notify_remote_cs_fae_table(struct bt_conn *conn, struct bt_conn_le_cs_fae_table params)
3361+
void notify_remote_cs_fae_table(struct bt_conn *conn, uint8_t status,
3362+
struct bt_conn_le_cs_fae_table *params)
33613363
{
33623364
struct bt_conn_cb *callback;
33633365

33643366
SYS_SLIST_FOR_EACH_CONTAINER(&conn_cbs, callback, _node) {
3365-
if (callback->le_cs_remote_fae_table_available) {
3366-
callback->le_cs_remote_fae_table_available(conn, &params);
3367+
if (callback->le_cs_read_remote_fae_table_complete) {
3368+
callback->le_cs_read_remote_fae_table_complete(conn, status, params);
33673369
}
33683370
}
33693371

33703372
STRUCT_SECTION_FOREACH(bt_conn_cb, cb) {
3371-
if (cb->le_cs_remote_fae_table_available) {
3372-
cb->le_cs_remote_fae_table_available(conn, &params);
3373+
if (cb->le_cs_read_remote_fae_table_complete) {
3374+
cb->le_cs_read_remote_fae_table_complete(conn, status, params);
33733375
}
33743376
}
33753377
}
33763378

3377-
void notify_cs_config_created(struct bt_conn *conn, struct bt_conn_le_cs_config *params)
3379+
void notify_cs_config_created(struct bt_conn *conn, uint8_t status,
3380+
struct bt_conn_le_cs_config *params)
33783381
{
33793382
struct bt_conn_cb *callback;
33803383

33813384
SYS_SLIST_FOR_EACH_CONTAINER(&conn_cbs, callback, _node) {
3382-
if (callback->le_cs_config_created) {
3383-
callback->le_cs_config_created(conn, params);
3385+
if (callback->le_cs_config_complete) {
3386+
callback->le_cs_config_complete(conn, status, params);
33843387
}
33853388
}
33863389

33873390
STRUCT_SECTION_FOREACH(bt_conn_cb, cb) {
3388-
if (cb->le_cs_config_created) {
3389-
cb->le_cs_config_created(conn, params);
3391+
if (cb->le_cs_config_complete) {
3392+
cb->le_cs_config_complete(conn, status, params);
33903393
}
33913394
}
33923395
}
@@ -3408,37 +3411,37 @@ void notify_cs_config_removed(struct bt_conn *conn, uint8_t config_id)
34083411
}
34093412
}
34103413

3411-
void notify_cs_security_enable_available(struct bt_conn *conn)
3414+
void notify_cs_security_enable_available(struct bt_conn *conn, uint8_t status)
34123415
{
34133416
struct bt_conn_cb *callback;
34143417

34153418
SYS_SLIST_FOR_EACH_CONTAINER(&conn_cbs, callback, _node) {
3416-
if (callback->le_cs_security_enabled) {
3417-
callback->le_cs_security_enabled(conn);
3419+
if (callback->le_cs_security_enable_complete) {
3420+
callback->le_cs_security_enable_complete(conn, status);
34183421
}
34193422
}
34203423

34213424
STRUCT_SECTION_FOREACH(bt_conn_cb, cb) {
3422-
if (cb->le_cs_security_enabled) {
3423-
cb->le_cs_security_enabled(conn);
3425+
if (cb->le_cs_security_enable_complete) {
3426+
cb->le_cs_security_enable_complete(conn, status);
34243427
}
34253428
}
34263429
}
34273430

3428-
void notify_cs_procedure_enable_available(struct bt_conn *conn,
3431+
void notify_cs_procedure_enable_available(struct bt_conn *conn, uint8_t status,
34293432
struct bt_conn_le_cs_procedure_enable_complete *params)
34303433
{
34313434
struct bt_conn_cb *callback;
34323435

34333436
SYS_SLIST_FOR_EACH_CONTAINER(&conn_cbs, callback, _node) {
3434-
if (callback->le_cs_procedure_enabled) {
3435-
callback->le_cs_procedure_enabled(conn, params);
3437+
if (callback->le_cs_procedure_enable_complete) {
3438+
callback->le_cs_procedure_enable_complete(conn, status, params);
34363439
}
34373440
}
34383441

34393442
STRUCT_SECTION_FOREACH(bt_conn_cb, cb) {
3440-
if (cb->le_cs_procedure_enabled) {
3441-
cb->le_cs_procedure_enabled(conn, params);
3443+
if (cb->le_cs_procedure_enable_complete) {
3444+
cb->le_cs_procedure_enable_complete(conn, status, params);
34423445
}
34433446
}
34443447
}

subsys/bluetooth/host/conn_internal.h

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

500500
void notify_remote_cs_capabilities(struct bt_conn *conn,
501-
struct bt_conn_le_cs_capabilities params);
501+
uint8_t status,
502+
struct bt_conn_le_cs_capabilities *params);
502503

503504
void notify_remote_cs_fae_table(struct bt_conn *conn,
504-
struct bt_conn_le_cs_fae_table params);
505+
uint8_t status,
506+
struct bt_conn_le_cs_fae_table *params);
505507

506-
void notify_cs_config_created(struct bt_conn *conn, struct bt_conn_le_cs_config *params);
508+
void notify_cs_config_created(struct bt_conn *conn,
509+
uint8_t status,
510+
struct bt_conn_le_cs_config *params);
507511

508512
void notify_cs_config_removed(struct bt_conn *conn, uint8_t config_id);
509513

510514
void notify_cs_subevent_result(struct bt_conn *conn, struct bt_conn_le_cs_subevent_result *result);
511515

512-
void notify_cs_security_enable_available(struct bt_conn *conn);
516+
void notify_cs_security_enable_available(struct bt_conn *conn, uint8_t status);
513517

514518
void notify_cs_procedure_enable_available(struct bt_conn *conn,
519+
uint8_t status,
515520
struct bt_conn_le_cs_procedure_enable_complete *params);
516521

517522
#if defined(CONFIG_BT_SMP)

0 commit comments

Comments
 (0)