Skip to content

Commit a178b47

Browse files
committed
nimble/host: Update Channel Sounding API to handle CS results
Forward step results to the application layer. Update Channel Sounding HCI to the final release of Bluetooth spec 6.0.
1 parent 6a520ec commit a178b47

File tree

5 files changed

+601
-77
lines changed

5 files changed

+601
-77
lines changed

nimble/host/include/host/ble_cs.h

Lines changed: 71 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,35 +23,91 @@
2323
#define H_BLE_CS_
2424
#include "syscfg/syscfg.h"
2525

26+
#define BLE_HS_CS_MODE0 (0)
27+
#define BLE_HS_CS_MODE1 (1)
28+
#define BLE_HS_CS_MODE2 (2)
29+
#define BLE_HS_CS_MODE3 (3)
30+
#define BLE_HS_CS_MODE_UNUSED (0xff)
31+
#define BLE_HS_CS_SUBMODE_TYPE BLE_HS_CS_MODE_UNUSED
32+
33+
#define BLE_HS_CS_ROLE_INITIATOR (0)
34+
#define BLE_HS_CS_ROLE_REFLECTOR (1)
35+
2636
#define BLE_CS_EVENT_CS_PROCEDURE_COMPLETE (0)
37+
#define BLE_CS_EVENT_CS_STEP_DATA (1)
38+
39+
#define BLE_HS_CS_TOA_TOD_NOT_AVAILABLE (0x00008000)
40+
#define BLE_HS_CS_N_AP_MAX (4)
41+
42+
struct ble_cs_mode0_result {
43+
uint16_t measured_freq_offset;
44+
uint8_t packet_quality;
45+
uint8_t packet_rssi;
46+
uint8_t packet_antenna;
47+
uint8_t step_channel;
48+
};
49+
50+
struct ble_cs_mode1_result {
51+
uint32_t packet_pct1;
52+
uint32_t packet_pct2;
53+
int16_t toa_tod;
54+
uint8_t packet_quality;
55+
uint8_t packet_nadm;
56+
uint8_t packet_rssi;
57+
uint8_t packet_antenna;
58+
uint8_t step_channel;
59+
};
60+
61+
struct ble_cs_mode2_result {
62+
uint32_t tone_pct[BLE_HS_CS_N_AP_MAX + 1];
63+
uint8_t tone_quality_ind[BLE_HS_CS_N_AP_MAX + 1];
64+
uint8_t antenna_paths[4];
65+
uint8_t antenna_path_permutation_id;
66+
uint8_t step_channel;
67+
};
68+
69+
struct ble_cs_mode3_result {
70+
uint32_t packet_pct1;
71+
uint32_t packet_pct2;
72+
uint32_t tone_pct[BLE_HS_CS_N_AP_MAX + 1];
73+
uint8_t tone_quality_ind[BLE_HS_CS_N_AP_MAX + 1];
74+
uint8_t antenna_paths[4];
75+
int16_t toa_tod;
76+
uint8_t antenna_path_permutation_id;
77+
uint8_t packet_quality;
78+
uint8_t packet_nadm;
79+
uint8_t packet_rssi;
80+
uint8_t packet_antenna;
81+
uint8_t step_channel;
82+
};
2783

2884
struct ble_cs_event {
85+
uint16_t conn_handle;
86+
uint8_t status;
2987
uint8_t type;
30-
union
31-
{
32-
struct
33-
{
34-
uint16_t conn_handle;
35-
uint8_t status;
36-
} procedure_complete;
88+
union {
89+
struct {
90+
uint8_t role;
91+
uint8_t mode;
92+
uint8_t *data;
93+
} step_data;
3794
};
38-
3995
};
4096

4197
typedef int ble_cs_event_fn(struct ble_cs_event *event, void *arg);
4298

43-
struct ble_cs_initiator_procedure_start_params {
99+
struct ble_cs_procedure_start_params {
44100
uint16_t conn_handle;
45-
ble_cs_event_fn *cb;
46-
void *cb_arg;
47101
};
48102

49-
struct ble_cs_reflector_setup_params {
103+
struct ble_cs_setup_params {
104+
uint16_t conn_handle;
50105
ble_cs_event_fn *cb;
51106
void *cb_arg;
107+
uint8_t local_role;
52108
};
53109

54-
int ble_cs_initiator_procedure_start(const struct ble_cs_initiator_procedure_start_params *params);
55-
int ble_cs_initiator_procedure_terminate(uint16_t conn_handle);
56-
int ble_cs_reflector_setup(struct ble_cs_reflector_setup_params *params);
110+
int ble_cs_procedure_start(const struct ble_cs_procedure_start_params *params);
111+
int ble_cs_procedure_terminate(uint16_t conn_handle);
112+
int ble_cs_setup(struct ble_cs_setup_params *params);
57113
#endif

nimble/host/pkg.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,6 @@ pkg.req_apis:
5454

5555
pkg.down.BLE_HS_STOP_ON_SHUTDOWN:
5656
ble_hs_shutdown: 200
57+
58+
pkg.init.'BLE_CHANNEL_SOUNDING':
59+
ble_cs_init: $after:ble_transport_hs_init

0 commit comments

Comments
 (0)