@@ -24,61 +24,6 @@ LOG_MODULE_DECLARE(app_main, LOG_LEVEL_INF);
2424#define MAX_NUM_RTT_SAMPLES 256
2525#define MAX_NUM_IQ_SAMPLES 256 * CONFIG_BT_RAS_MAX_ANTENNA_PATHS
2626
27- #define A1 (0)
28- #define A2 (1)
29- #define A3 (2)
30- #define A4 (3)
31-
32- /* Bluetooth Core Specification 6.0, Table 4.13, Antenna Path Permutation for N_AP=2.
33- * The last element corresponds to extension slot
34- */
35- static uint8_t antenna_path_lut_n_ap_2 [2 ][3 ] = {
36- {A1 , A2 , A2 },
37- {A2 , A1 , A1 },
38- };
39-
40- /* Bluetooth Core Specification 6.0, Table 4.14, Antenna Path Permutation for N_AP=3.
41- * The last element corresponds to extension slot
42- */
43- static uint8_t antenna_path_lut_n_ap_3 [6 ][4 ] = {
44- {A1 , A2 , A3 , A3 },
45- {A2 , A1 , A3 , A3 },
46- {A1 , A3 , A2 , A2 },
47- {A3 , A1 , A2 , A2 },
48- {A3 , A2 , A1 , A1 },
49- {A2 , A3 , A1 , A1 },
50- };
51-
52- /* Bluetooth Core Specification 6.0, Table 4.15, Antenna Path Permutation for N_AP=4.
53- * The last element corresponds to extension slot
54- */
55- static uint8_t antenna_path_lut_n_ap_4 [24 ][5 ] = {
56- {A1 , A2 , A3 , A4 , A4 },
57- {A2 , A1 , A3 , A4 , A4 },
58- {A1 , A3 , A2 , A4 , A4 },
59- {A3 , A1 , A2 , A4 , A4 },
60- {A3 , A2 , A1 , A4 , A4 },
61- {A2 , A3 , A1 , A4 , A4 },
62- {A1 , A2 , A4 , A3 , A3 },
63- {A2 , A1 , A4 , A3 , A3 },
64- {A1 , A4 , A2 , A3 , A3 },
65- {A4 , A1 , A2 , A3 , A3 },
66- {A4 , A2 , A1 , A3 , A3 },
67- {A2 , A4 , A1 , A3 , A3 },
68- {A1 , A4 , A3 , A2 , A2 },
69- {A4 , A1 , A3 , A2 , A2 },
70- {A1 , A3 , A4 , A2 , A2 },
71- {A3 , A1 , A4 , A2 , A2 },
72- {A3 , A4 , A1 , A2 , A2 },
73- {A4 , A3 , A1 , A2 , A2 },
74- {A4 , A2 , A3 , A1 , A1 },
75- {A2 , A4 , A3 , A1 , A1 },
76- {A4 , A3 , A2 , A1 , A1 },
77- {A3 , A4 , A2 , A1 , A1 },
78- {A3 , A2 , A4 , A1 , A1 },
79- {A2 , A3 , A4 , A1 , A1 },
80- };
81-
8227struct iq_sample_and_channel {
8328 bool failed ;
8429 uint8_t channel ;
@@ -103,22 +48,6 @@ struct processing_context {
10348 enum bt_conn_le_cs_role role ;
10449};
10550
106- static uint8_t get_antenna_path (uint8_t n_ap ,
107- uint8_t antenna_path_permutation_index ,
108- uint8_t antenna_index )
109- {
110- if (n_ap == 2 ) {
111- return antenna_path_lut_n_ap_2 [antenna_path_permutation_index ][antenna_index ];
112- }
113- if (n_ap == 3 ) {
114- return antenna_path_lut_n_ap_3 [antenna_path_permutation_index ][antenna_index ];
115- }
116- if (n_ap == 4 ) {
117- return antenna_path_lut_n_ap_4 [antenna_path_permutation_index ][antenna_index ];
118- }
119- return 0 ;
120- }
121-
12251static void calc_complex_product (int32_t z_a_real , int32_t z_a_imag , int32_t z_b_real ,
12352 int32_t z_b_imag , int32_t * z_out_real , int32_t * z_out_imag )
12453{
@@ -267,9 +196,17 @@ static void process_tone_info_data(struct processing_context *context,
267196 return ;
268197 }
269198
199+ int antenna_path = bt_le_cs_get_antenna_path (context -> n_ap ,
200+ antenna_permutation_index ,
201+ i );
202+ if (antenna_path < 0 ) {
203+ LOG_WRN ("Invalid antenna path" );
204+ return ;
205+ }
206+
270207 iq_sample_channel_data [context -> iq_sample_channel_data_index ].channel = channel ;
271208 iq_sample_channel_data [context -> iq_sample_channel_data_index ].antenna_path =
272- get_antenna_path ( context -> n_ap , antenna_permutation_index , i ) ;
209+ ( uint8_t ) antenna_path ;
273210 iq_sample_channel_data [context -> iq_sample_channel_data_index ].local_iq_sample =
274211 bt_le_cs_parse_pct (local_tone_info [i ].phase_correction_term );
275212 iq_sample_channel_data [context -> iq_sample_channel_data_index ].peer_iq_sample =
0 commit comments