xref: /aosp_15_r20/hardware/interfaces/wifi/legacy_headers/include/hardware_legacy/rtt.h (revision 4d7e907c777eeecc4c5bd7cf640a754fac206ff7)
1 
2 #include "wifi_hal.h"
3 #include "gscan.h"
4 
5 #ifndef __WIFI_HAL_RTT_H__
6 #define __WIFI_HAL_RTT_H__
7 
8 /* Ranging status */
9 typedef enum {
10     RTT_STATUS_SUCCESS = 0,
11     RTT_STATUS_FAILURE = 1,        // general failure status
12     RTT_STATUS_FAIL_NO_RSP = 2,    // target STA does not respond to request
13     RTT_STATUS_FAIL_REJECTED = 3,  // request rejected. Applies to 2-sided RTT only
14     RTT_STATUS_FAIL_NOT_SCHEDULED_YET = 4,
15     RTT_STATUS_FAIL_TM_TIMEOUT = 5,          // timing measurement times out
16     RTT_STATUS_FAIL_AP_ON_DIFF_CHANNEL = 6,  // Target on different channel, cannot range
17     RTT_STATUS_FAIL_NO_CAPABILITY = 7,       // ranging not supported
18     RTT_STATUS_ABORTED = 8,                  // request aborted for unknown reason
19     RTT_STATUS_FAIL_INVALID_TS = 9,          // Invalid T1-T4 timestamp
20     RTT_STATUS_FAIL_PROTOCOL = 10,           // 11mc protocol failed
21     RTT_STATUS_FAIL_SCHEDULE = 11,           // request could not be scheduled
22     RTT_STATUS_FAIL_BUSY_TRY_LATER = 12,     // responder cannot collaborate at time of request
23     RTT_STATUS_INVALID_REQ = 13,             // bad request args
24     RTT_STATUS_NO_WIFI = 14,                 // WiFi not enabled
25     RTT_STATUS_FAIL_FTM_PARAM_OVERRIDE =
26             15,  // Responder overrides param info, cannot range with new params
27     RTT_STATUS_NAN_RANGING_PROTOCOL_FAILURE = 16,           // Negotiation failure
28     RTT_STATUS_NAN_RANGING_CONCURRENCY_NOT_SUPPORTED = 17,  // concurrency not supported (NDP+RTT)
29     RTT_STATUS_SECURE_RANGING_FAILURE_INVALID_AKM = 18,  // Secure Ranging failed due to invalid AKM
30                                                          // (Authentication and Key Management)
31     RTT_STATUS_SECURE_RANGING_FAILURE_INVALID_CIPHER = 19,  // Secure Ranging failed due to invalid
32                                                             // Cipher
33     RTT_STATUS_SECURE_RANGING_FAILURE_INVALID_CONFIG = 20,  // Secure Ranging failed due to invalid
34                                                             // configuration
35     RTT_STATUS_SECURE_RANGING_FAILURE_REJECTED = 21,        // Secure ranging rejected by the AP.2
36     RTT_STATUS_SECURE_RANGING_FAILURE_UNKNOWN = 22,         // Secure ranging failure unknown
37 } wifi_rtt_status;
38 
39 /* RTT peer type */
40 typedef enum {
41     RTT_PEER_AP         = 0x1,
42     RTT_PEER_STA        = 0x2,
43     RTT_PEER_P2P_GO     = 0x3,
44     RTT_PEER_P2P_CLIENT = 0x4,
45     RTT_PEER_NAN        = 0x5
46 } rtt_peer_type;
47 
48 /* RTT Measurement Bandwidth */
49 typedef enum {
50     WIFI_RTT_BW_UNSPECIFIED = 0x00,
51     WIFI_RTT_BW_5           = 0x01,
52     WIFI_RTT_BW_10          = 0x02,
53     WIFI_RTT_BW_20          = 0x04,
54     WIFI_RTT_BW_40          = 0x08,
55     WIFI_RTT_BW_80          = 0x10,
56     WIFI_RTT_BW_160         = 0x20,
57     WIFI_RTT_BW_320         = 0x40
58 } wifi_rtt_bw;
59 
60 /* RTT Measurement Preamble */
61 typedef enum {
62     WIFI_RTT_PREAMBLE_INVALID = 0x0,
63     WIFI_RTT_PREAMBLE_LEGACY  = 0x1,
64     WIFI_RTT_PREAMBLE_HT      = 0x2,
65     WIFI_RTT_PREAMBLE_VHT     = 0x4,
66     WIFI_RTT_PREAMBLE_HE      = 0x8,
67     WIFI_RTT_PREAMBLE_EHT     = 0x10,
68 } wifi_rtt_preamble ;
69 
70 /* RTT Type */
71 typedef enum {
72     RTT_TYPE_1_SIDED = 0x1,
73     /* Deprecated. Use RTT_TYPE_2_SIDED_11MC instead. */
74     RTT_TYPE_2_SIDED = 0x2,
75     RTT_TYPE_2_SIDED_11MC = RTT_TYPE_2_SIDED,
76     RTT_TYPE_2_SIDED_11AZ_NTB = 0x3,
77     RTT_TYPE_2_SIDED_11AZ_NTB_SECURE = 0x4,
78 } wifi_rtt_type;
79 
80 /* RTT AKM type */
81 typedef enum {
82     WPA_KEY_MGMT_NONE = 0x0,
83     WPA_KEY_MGMT_PASN = 0x1,
84     WPA_KEY_MGMT_SAE = 0x2,
85     WPA_KEY_MGMT_EAP_FT_SHA256 = 0x4,
86     WPA_KEY_MGMT_FT_PSK_SHA256 = 0x8,
87     WPA_KEY_MGMT_EAP_FT_SHA384 = 0x10,
88     WPA_KEY_MGMT_FT_PSK_SHA384 = 0x20,
89     WPA_KEY_MGMT_EAP_FILS_SHA256 = 0x40,
90     WPA_KEY_MGMT_EAP_FILS_SHA384 = 0x80
91 } wifi_rtt_akm;
92 
93 typedef enum {
94     WPA_CIPHER_NONE = 0x0,
95     WPA_CIPHER_CCMP_128 = 0x1,
96     WPA_CIPHER_CCMP_256 = 0x2,
97     WPA_CIPHER_GCMP_128 = 0x4,
98     WPA_CIPHER_GCMP_256 = 0x8,
99 } wifi_rtt_cipher_suite;
100 
101 #define RTT_SECURITY_MAX_PASSPHRASE_LEN 63
102 #define PMKID_LEN 16
103 #define RTT_MAX_COOKIE_LEN 255
104 
105 typedef struct {
106     wifi_rtt_akm base_akm;  // Base Authentication and Key Management (AKM) protocol used for PASN
107     wifi_rtt_cipher_suite pairwise_cipher_suite;  // Pairwise cipher suite used for the PTKSA
108                                                   // (Pairwise Transient Key Security Association)
109     u32 passphrase_len;
110     u8 passphrase[RTT_SECURITY_MAX_PASSPHRASE_LEN];  // Passphrase for the base AKM. This can be
111                                                      // empty based on the AKM type.
112     u32 pmkid_len;
113     u8 pmkid[PMKID_LEN];  // PMKID corresponding to the cached PMK from the base AKM. PMKID can be
114                           // null if no cached PMK is present.
115     u8 comeback_cookie_len;  // Comeback cookie length. If the length is 0, it indicates there is no
116                              // cookie.
117     u8 comeback_cookie[RTT_MAX_COOKIE_LEN];  // Comeback cookie indicated over wifi_rtt_result_v4.
118 } wifi_rtt_pasn_config;
119 
120 typedef struct {
121     wifi_rtt_pasn_config pasn_config;
122     bool enable_secure_he_ltf;
123     bool enable_ranging_frame_protection;
124 } wifi_rtt_secure_config;
125 
126 /* RTT configuration */
127 typedef struct {
128     mac_addr addr;                 // peer device mac address
129     wifi_rtt_type type;            // 1-sided or 2-sided RTT (11mc and 11az)
130     rtt_peer_type peer;            // optional - peer device hint (STA, P2P, AP)
131     wifi_channel_info channel;     // Required for STA-AP mode, optional for P2P, NBD etc.
132     unsigned burst_period;         // Time interval between bursts (units: 100 ms).
133                                    // Applies to 1-sided and 2-sided RTT multi-burst requests.
134                                    // Range: 0-31, 0: no preference by initiator (2-sided RTT)
135                                    // Note: Applicable for 11mc only.
136     unsigned num_burst;            // Total number of RTT bursts to be executed. It will be
137                                    // specified in the same way as the parameter "Number of
138                                    // Burst Exponent" found in the FTM frame format. It
139                                    // applies to both: 1-sided RTT and 2-sided RTT. Valid
140                                    // values are 0 to 15 as defined in 802.11mc std.
141                                    // 0 means single shot
142                                    // The implication of this parameter on the maximum
143                                    // number of RTT results is the following:
144                                    // for 1-sided RTT: max num of RTT results = (2^num_burst)*(num_frames_per_burst)
145                                    // for 2-sided RTT: max num of RTT results = (2^num_burst)*(num_frames_per_burst - 1)
146                                    // Note: Applicable for 11mc only.
147     unsigned num_frames_per_burst; // num of frames per burst.
148                                    // Minimum value = 1, Maximum value = 31
149                                    // For 2-sided this equals the number of FTM frames
150                                    // to be attempted in a single burst. This also
151                                    // equals the number of FTM frames that the
152                                    // initiator will request that the responder send
153                                    // in a single frame.
154                                    // Note: Applicable for 11mc only.
155     unsigned num_retries_per_rtt_frame; // number of retries for a failed RTT frame. Applies
156                                         // to 1-sided RTT only. Minimum value = 0, Maximum value = 3
157 
158     //following fields are only valid for 2-side RTT
159     unsigned num_retries_per_ftmr; // Maximum number of retries that the initiator can
160                                    // retry an FTMR frame.
161                                    // Minimum value = 0, Maximum value = 3
162     byte LCI_request;              // 1: request LCI, 0: do not request LCI
163     byte LCR_request;              // 1: request LCR, 0: do not request LCR
164     unsigned burst_duration;       // Applies to 1-sided and 2-sided 11mc RTT. Valid values will
165                                    // be 2-11 and 15 as specified by the 802.11mc std for
166                                    // the FTM parameter burst duration. In a multi-burst
167                                    // request, if responder overrides with larger value,
168                                    // the initiator will return failure. In a single-burst
169                                    // request if responder overrides with larger value,
170                                    // the initiator will sent TMR_STOP to terminate RTT
171                                    // at the end of the burst_duration it requested.
172     wifi_rtt_preamble preamble;    // RTT preamble to be used in the RTT frames
173     wifi_rtt_bw bw;                // RTT BW to be used in the RTT frames
174 } wifi_rtt_config;
175 
176 /* RTT configuration v3 (11az support)*/
177 typedef struct {
178     wifi_rtt_config rtt_config;
179     u64 ntb_min_measurement_time; // 11az Non-Trigger-based (non-TB) minimum measurement time in
180                                   // units of 100 microseconds
181     u64 ntb_max_measurement_time; // 11az Non-Trigger-based (non-TB) maximum measurement time in
182                                   // units of 10 milliseconds
183 } wifi_rtt_config_v3;
184 
185 typedef struct {
186     wifi_rtt_config_v3 rtt_config;
187     wifi_rtt_secure_config rtt_secure_config;
188 } wifi_rtt_config_v4;
189 
190 /* RTT results */
191 typedef struct {
192     mac_addr addr;                // device mac address
193     unsigned burst_num;           // burst number in a multi-burst request. Note: Applicable to
194                                   // 1-sided RTT and 2-sided IEEE 802.11mc only.
195     unsigned measurement_number;  // Total RTT measurement frames attempted
196     unsigned success_number;      // Total successful RTT measurement frames
197     byte  number_per_burst_peer;  // Maximum number of "FTM frames per burst" supported by
198                                   // the responder STA. Applies to 2-sided RTT only.
199                                   // If reponder overrides with larger value:
200                                   // - for single-burst request initiator will truncate the
201                                   // larger value and send a TMR_STOP after receiving as
202                                   // many frames as originally requested.
203                                   // - for multi-burst request, initiator will return
204                                   // failure right away.
205     wifi_rtt_status status;       // ranging status
206     byte retry_after_duration;    // When status == RTT_STATUS_FAIL_BUSY_TRY_LATER,
207                                   // this will be the time provided by the responder as to
208                                   // when the request can be tried again. Applies to 2-sided
209                                   // RTT only. In sec, 1-31sec.
210     wifi_rtt_type type;           // RTT type
211     wifi_rssi rssi;               // average rssi in 0.5 dB steps e.g. 143 implies -71.5 dB
212     wifi_rssi rssi_spread;        // rssi spread in 0.5 dB steps e.g. 5 implies 2.5 dB spread (optional)
213     wifi_rate tx_rate;            // 1-sided RTT: TX rate of RTT frame.
214                                   // 2-sided RTT: TX rate of initiator's Ack in response to FTM frame.
215     wifi_rate rx_rate;            // 1-sided RTT: TX rate of Ack from other side.
216                                   // 2-sided RTT: TX rate of FTM frame coming from responder.
217     wifi_timespan rtt;            // round trip time in picoseconds
218     wifi_timespan rtt_sd;         // rtt standard deviation in picoseconds
219     wifi_timespan rtt_spread;     // difference between max and min rtt times recorded in picoseconds
220                                   // Note: Only applicable for IEEE 802.11mc
221     int distance_mm;              // distance in mm (optional)
222     int distance_sd_mm;           // standard deviation in mm (optional)
223     int distance_spread_mm;       // difference between max and min distance recorded in mm (optional)
224     wifi_timestamp ts;            // time of the measurement (in microseconds since boot)
225     int burst_duration;           // in ms, actual time taken by the FW to finish one burst
226                                   // measurement. Applies to 1-sided and 2-sided RTT.
227     int negotiated_burst_num;     // Number of bursts allowed by the responder. Applies
228                                   // to 2-sided 11mc RTT only.
229     wifi_information_element *LCI; // for 11mc and 11az only
230     wifi_information_element *LCR; // for 11mc and 11az only
231 } wifi_rtt_result;
232 
233 /* RTT results version 2 */
234 typedef struct {
235     wifi_rtt_result rtt_result;   // Legacy wifi rtt result structure
236     wifi_channel frequency;       // primary channel frequency (MHz) used for ranging measurements
237                                   // If frequency is unknown, this will be set to |UNSPECIFIED(-1)|
238     wifi_rtt_bw packet_bw;        // RTT packet bandwidth is an average BW of the BWs of RTT frames.
239                                   // Cap the average close to a specific valid RttBw.
240 } wifi_rtt_result_v2;
241 
242 /* RTT results v3 (11az support)*/
243 typedef struct {
244   wifi_rtt_result_v2 rtt_result;
245   byte i2r_tx_ltf_repetition_count;// Multiple transmissions of HE-LTF symbols in an HE (I2R)
246                                    // Ranging NDP. An HE-LTF repetition value of 1 indicates no
247                                    // repetitions.
248   byte r2i_tx_ltf_repetition_count;// Multiple transmissions of HE-LTF symbols in an HE (R2I)
249                                    // Ranging NDP. An HE-LTF repetition value of 1 indicates no
250                                    // repetitions.
251   u64 ntb_min_measurement_time;    // Minimum non-trigger based (non-TB) dynamic measurement time
252                                    // in units of 100 microseconds assigned by the 11az responder.
253   u64 ntb_max_measurement_time;    // Maximum non-trigger based (non-TB) dynamic measurement
254                                    // time in units of 10 milliseconds assigned by the 11az
255                                    // responder.
256   byte num_tx_sts;                 // Number of transmit space-time streams used.
257   byte num_rx_sts;                 // Number of receive space-time streams used.
258 } wifi_rtt_result_v3;
259 
260 typedef struct {
261     wifi_rtt_result_v3 rtt_result_v3;
262     bool is_ranging_protection_enabled;
263     bool is_secure_he_ltf_enabled;
264     wifi_rtt_akm base_akm;
265     wifi_rtt_cipher_suite cipher_suite;
266     int secure_he_ltf_protocol_version;
267     u16 pasn_comeback_after_millis;  // The time in milliseconds after which the non-AP STA is
268                                      // requested to retry the PASN authentication.
269     u8 pasn_comeback_cookie_len;  // Comeback cookie length. If the length is 0, it indicates there
270                                   // is no cookie.
271     u8 pasn_comeback_cookie[RTT_MAX_COOKIE_LEN];  // Comeback cookie octets.
272 } wifi_rtt_result_v4;
273 
274 /* RTT result callbacks */
275 typedef struct {
276     /*
277      * This callback is deprecated on Android 14 and onwards. Newer implementations should support
278      * on_rtt_results_v2 callback.
279      */
280     void (*on_rtt_results) (wifi_request_id id,
281                             unsigned num_results,
282                             wifi_rtt_result *rtt_result[]);
283 
284     /*
285      * Called when vendor implementation supports sending RTT results version 2.
286      *
287      * Note: This callback is deprecated on Android 15 onwards. Newer implementation should support
288      * on_rtt_results_v3.
289      */
290     void (*on_rtt_results_v2) (wifi_request_id id,
291                                unsigned num_results,
292                                wifi_rtt_result_v2 *rtt_result_v2[]);
293 } wifi_rtt_event_handler;
294 
295 /* API to request RTT measurement */
296 wifi_error wifi_rtt_range_request(wifi_request_id id, wifi_interface_handle iface,
297         unsigned num_rtt_config, wifi_rtt_config rtt_config[], wifi_rtt_event_handler handler);
298 
299 /* RTT result v3 callback (11az support) */
300 typedef struct {
301     /*
302      * Called when vendor implementation supports sending RTT results version 3 (Added support for
303      * 11az ranging)
304      */
305     void (*on_rtt_results_v3) (wifi_request_id id,
306                                unsigned num_results,
307                                wifi_rtt_result_v3 *rtt_result_v3[]);
308 } wifi_rtt_event_handler_v3;
309 
310 /* RTT result v4 callback (secure ranging support) */
311 typedef struct {
312     /*
313      * Called when vendor implementation supports sending RTT results version 4 (Added support for
314      * secure 11az ranging)
315      */
316     void (*on_rtt_results_v4)(wifi_request_id id, unsigned num_results,
317                               wifi_rtt_result_v4* rtt_result_v4[]);
318 } wifi_rtt_event_handler_v4;
319 
320 /* v3 API to request RTT measurement(11az support).  */
321 wifi_error wifi_rtt_range_request_v3(wifi_request_id id,
322                                      wifi_interface_handle iface,
323                                      unsigned num_rtt_config,
324                                      wifi_rtt_config_v3 rtt_config_v3[],
325                                      wifi_rtt_event_handler_v3 handler);
326 
327 /* v4 API to request RTT measurement(11az security support). */
328 wifi_error wifi_rtt_range_request_v4(wifi_request_id id, wifi_interface_handle iface,
329                                      unsigned num_rtt_config, wifi_rtt_config_v4 rtt_config_v4[],
330                                      wifi_rtt_event_handler_v4 handler);
331 
332 /* API to cancel RTT measurements */
333 wifi_error wifi_rtt_range_cancel(wifi_request_id id,  wifi_interface_handle iface,
334         unsigned num_devices, mac_addr addr[]);
335 
336 /* NBD ranging channel map */
337 typedef struct {
338     wifi_channel availablity[32]; // specifies the channel map for each of the 16 TU windows
339     // frequency of 0 => unspecified; which means firmware is
340     // free to do whatever it wants in this window.
341 } wifi_channel_map;
342 
343 /* API to start publishing the channel map on responder device in a NBD cluster.
344    Responder device will take this request and schedule broadcasting the channel map
345    in a NBD ranging attribute in a SDF. DE will automatically remove the ranging
346    attribute from the OTA queue after number of DW specified by num_dw
347    where Each DW is 512 TUs apart */
348 wifi_error wifi_rtt_channel_map_set(wifi_request_id id,
349         wifi_interface_handle iface, wifi_channel_map *params, unsigned num_dw);
350 
351 /* API to clear the channel map on the responder device in a NBD cluster.
352    Responder device will cancel future ranging channel request, starting from “next”
353    DW interval and will also stop broadcasting NBD ranging attribute in SDF */
354 wifi_error wifi_rtt_channel_map_clear(wifi_request_id id,  wifi_interface_handle iface);
355 
356 // Preamble definition for bit mask used in wifi_rtt_capabilities
357 #define PREAMBLE_LEGACY 0x1
358 #define PREAMBLE_HT     0x2
359 #define PREAMBLE_VHT    0x4
360 #define PREAMBLE_HE     0x8
361 #define PREAMBLE_EHT    0x10
362 
363 // BW definition for bit mask used in wifi_rtt_capabilities
364 #define BW_5_SUPPORT   0x1
365 #define BW_10_SUPPORT  0x2
366 #define BW_20_SUPPORT  0x4
367 #define BW_40_SUPPORT  0x8
368 #define BW_80_SUPPORT  0x10
369 #define BW_160_SUPPORT 0x20
370 #define BW_320_SUPPORT 0x40
371 
372 /* RTT Capabilities */
373 typedef struct {
374     byte rtt_one_sided_supported;  // if 1-sided rtt data collection is supported
375     byte rtt_ftm_supported;        // if ftm rtt data collection is supported
376     byte lci_support;              // if initiator supports LCI request. Applies to 2-sided RTT
377                                    // (applies to both 11mc and 11az).
378     byte lcr_support;              // if initiator supports LCR request. Applies to 2-sided RTT
379                                    // (applies to both 11mc and 11az).
380     byte preamble_support;         // bit mask indicates what preamble is supported by 11mc
381                                    // initiator
382     byte bw_support;               // bit mask indicates what BW is supported by 11mc initiator
383     byte responder_supported;      // if 11mc responder mode is supported
384     byte mc_version;               // draft 11mc spec version supported by chip. For instance,
385                                    // version 4.0 should be 40 and version 4.3 should be 43 etc.
386 } wifi_rtt_capabilities;
387 
388 
389 /*  RTT capabilities of the device */
390 wifi_error wifi_get_rtt_capabilities(wifi_interface_handle iface,
391                                      wifi_rtt_capabilities *capabilities);
392 
393 /* RTT Capabilities v3 (11az support) */
394 typedef struct {
395     wifi_rtt_capabilities rtt_capab;
396     byte az_preamble_support;       // bit mask indicates what preamble is supported by the 11az
397                                     // initiator
398     byte az_bw_support;             // bit mask indicates what BW is supported by 11az initiator
399     byte ntb_initiator_supported;   // if 11az non-TB initiator is supported
400     byte ntb_responder_supported;   // if 11az non-TB responder is supported
401 } wifi_rtt_capabilities_v3;
402 
403 /* RTT Capabilities v4 (11az secure support) */
404 typedef struct {
405     wifi_rtt_capabilities_v3 rtt_capab_v3;
406     bool secure_he_ltf_supported;
407     int max_supported_secure_he_ltf_protocol_ver;  // Maximum supported secure HE-LTF protocol
408                                                    // version.
409     bool ranging_fame_protection_supported;
410     wifi_rtt_akm supported_akms;  // Bitmap of wifi_rtt_akm values indicating the set of supported
411                                   // AKMs.
412     wifi_rtt_cipher_suite
413             supported_cipher_suites;  // Bitmap of wifi_rtt_cipher_suite values
414                                       // indicating the set of supported pairwise cipher suites.
415 } wifi_rtt_capabilities_v4;
416 
417 /*  RTT capabilities v3 of the device (11az support) */
418 wifi_error wifi_get_rtt_capabilities_v3(wifi_interface_handle iface,
419                                         wifi_rtt_capabilities_v3 *capabilities);
420 
421 /*  RTT capabilities v4 of the device (11az secure support) */
422 wifi_error wifi_get_rtt_capabilities_v4(wifi_interface_handle iface,
423                                         wifi_rtt_capabilities_v4* capabilities);
424 
425 /* debugging definitions */
426 enum {
427     RTT_DEBUG_DISABLE,
428     RTT_DEBUG_LOG,
429     RTT_DEBUG_PROTO,
430     RTT_DEBUG_BURST,
431     RTT_DEBUG_ACCURACY,
432     RTT_DEBUG_LOGDETAIL
433 };  //rtt debug type
434 
435 enum {
436     RTT_DEBUG_FORMAT_TXT,
437     RTT_DEBUG_FORMAT_BINARY
438 }; //rtt debug format
439 
440 typedef struct rtt_debug {
441     unsigned version;
442     unsigned len; // total length of after len field
443     unsigned type;  // rtt debug type
444     unsigned format; //rtt debug format
445     char dbuf[0]; // debug content
446 } rtt_debug_t;
447 
448 /* set configuration for debug */
449 wifi_error wifi_rtt_debug_cfg(wifi_interface_handle h, unsigned rtt_dbg_type, char *cfgbuf, unsigned cfg_buf_size);
450 /* get the debug information */
451 wifi_error wifi_rtt_debug_get(wifi_interface_handle h, rtt_debug_t **debugbuf);
452 /* free the debug buffer */
453 wifi_error wifi_rtt_debug_free(wifi_interface_handle h, rtt_debug_t *debugbuf);
454 
455 /* API for setting LCI/LCR information to be provided to a requestor */
456 typedef enum {
457     WIFI_MOTION_NOT_EXPECTED = 0, // Not expected to change location
458     WIFI_MOTION_EXPECTED = 1,     // Expected to change location
459     WIFI_MOTION_UNKNOWN  = 2,     // Movement pattern unknown
460 } wifi_motion_pattern;
461 
462 typedef struct {
463     long latitude;              // latitude in degrees * 2^25 , 2's complement
464     long longitude;             // latitude in degrees * 2^25 , 2's complement
465     int  altitude;              // Altitude in units of 1/256 m
466     byte latitude_unc;          // As defined in Section 2.3.2 of IETF RFC 6225
467     byte longitude_unc;         // As defined in Section 2.3.2 of IETF RFC 6225
468     byte altitude_unc;          // As defined in Section 2.4.5 from IETF RFC 6225:
469 
470     //Following element for configuring the Z subelement
471     wifi_motion_pattern motion_pattern;
472     int  floor;                 // floor in units of 1/16th of floor. 0x80000000 if unknown.
473     int  height_above_floor;    // in units of 1/64 m
474     int  height_unc;            // in units of 1/64 m. 0 if unknown
475 } wifi_lci_information;
476 
477 typedef struct {
478     char country_code[2];       // country code
479     int  length;                // length of the info field
480     char civic_info[256];       // Civic info to be copied in FTM frame
481 } wifi_lcr_information;
482 
483 // API to configure the LCI. Used in RTT Responder mode only
484 wifi_error wifi_set_lci(wifi_request_id id, wifi_interface_handle iface,
485                         wifi_lci_information *lci);
486 
487 // API to configure the LCR. Used in RTT Responder mode only.
488 wifi_error wifi_set_lcr(wifi_request_id id, wifi_interface_handle iface,
489                         wifi_lcr_information *lcr);
490 
491 /**
492  * RTT Responder information
493  */
494 typedef struct {
495     wifi_channel_info channel;
496     wifi_rtt_preamble preamble;
497 } wifi_rtt_responder;
498 
499 /**
500  * Get RTT responder information e.g. WiFi channel to enable responder on.
501  */
502 wifi_error wifi_rtt_get_responder_info(wifi_interface_handle iface,
503                                        wifi_rtt_responder *responder_info);
504 
505 /**
506  * Enable RTT responder mode.
507  * channel_hint - hint of the channel information where RTT responder should be enabled on.
508  * max_duration_seconds - timeout of responder mode.
509  * channel_used - channel used for RTT responder, NULL if responder is not enabled.
510  */
511 wifi_error wifi_enable_responder(wifi_request_id id, wifi_interface_handle iface,
512                                  wifi_channel_info channel_hint, unsigned max_duration_seconds,
513                                  wifi_rtt_responder *responder_info);
514 
515 /**
516  * Disable RTT responder mode.
517  */
518 wifi_error wifi_disable_responder(wifi_request_id id, wifi_interface_handle iface);
519 
520 #endif
521