4 #ifndef __WIFI_HAL_GSCAN_H__
5 #define __WIFI_HAL_GSCAN_H__
10 WIFI_BAND_UNSPECIFIED,
11 WIFI_BAND_BG = 1, // 2.4 GHz
12 WIFI_BAND_A = 2, // 5 GHz without DFS
13 WIFI_BAND_A_DFS = 4, // 5 GHz DFS only
14 WIFI_BAND_A_WITH_DFS = 6, // 5 GHz with DFS
15 WIFI_BAND_ABG = 3, // 2.4 GHz + 5 GHz; no DFS
16 WIFI_BAND_ABG_WITH_DFS = 7, // 2.4 GHz + 5 GHz with DFS
19 const unsigned MAX_CHANNELS = 16;
20 const unsigned MAX_BUCKETS = 16;
21 const unsigned MAX_HOTLIST_APS = 128;
22 const unsigned MAX_SIGNIFICANT_CHANGE_APS = 64;
24 wifi_error wifi_get_valid_channels(wifi_interface_handle handle,
25 int band, int max_channels, wifi_channel *channels, int *num_channels);
28 int max_scan_cache_size; // total space allocated for scan (in bytes)
29 int max_scan_buckets; // maximum number of channel buckets
30 int max_ap_cache_per_scan; // maximum number of APs that can be stored per scan
31 int max_rssi_sample_size; // number of RSSI samples used for averaging RSSI
32 int max_scan_reporting_threshold; // max possible report_threshold as described
33 // in wifi_scan_cmd_params
34 int max_hotlist_aps; // maximum number of entries for hotlist APs
35 int max_significant_wifi_change_aps; // maximum number of entries for
36 // significant wifi change APs
37 int max_bssid_history_entries; // number of BSSID/RSSI entries that device can hold
38 } wifi_gscan_capabilities;
40 wifi_error wifi_get_gscan_capabilities(wifi_interface_handle handle,
41 wifi_gscan_capabilities *capabilities);
44 WIFI_SCAN_BUFFER_FULL,
49 /* Format of information elements found in the beacon */
51 byte id; // element identifier
52 byte len; // number of bytes to follow
54 } wifi_information_element;
57 wifi_timestamp ts; // time since boot (in microsecond) when the result was
59 char ssid[32+1]; // null terminated
61 wifi_channel channel; // channel frequency in MHz
62 wifi_rssi rssi; // in db
63 wifi_timespan rtt; // in nanoseconds
64 wifi_timespan rtt_sd; // standard deviation in rtt
65 unsigned short beacon_period; // period advertised in the beacon
66 unsigned short capability; // capabilities advertised in the beacon
67 unsigned int ie_length; // size of the ie_data blob
68 char ie_data[1]; // blob of all the information elements found in the
69 // beacon; this data should be a packed list of
70 // wifi_information_element objects, one after the other.
75 /* reported when report_threshold is reached in scan cache */
76 void (*on_scan_results_available) (wifi_request_id id, unsigned num_results_available);
78 /* reported when each probe response is received, if report_events
79 * enabled in wifi_scan_cmd_params */
80 void (*on_full_scan_result) (wifi_request_id id, wifi_scan_result *result);
82 /* optional event - indicates progress of scanning statemachine */
83 void (*on_scan_event) (wifi_scan_event event, unsigned status);
85 } wifi_scan_result_handler;
88 wifi_channel channel; // frequency
89 int dwellTimeMs; // dwell time hint
90 int passive; // 0 => active, 1 => passive scan; ignored for DFS
91 /* Add channel class */
92 } wifi_scan_channel_spec;
96 int bucket; // bucket index, 0 based
97 wifi_band band; // when UNSPECIFIED, use channel list
98 int period; // desired period, in millisecond; if this is too
99 // low, the firmware should choose to generate results as
100 // fast as it can instead of failing the command
101 /* report_events semantics -
102 * 0 => report only when scan history is % full
103 * 1 => same as 0 + report a scan completion event after scanning this bucket
104 * 2 => same as 1 + forward scan results (beacons/probe responses + IEs) in real time to HAL
105 * 3 => same as 2 + forward scan results (beacons/probe responses + IEs) in real time to
106 supplicant as well (optional) . */
110 wifi_scan_channel_spec channels[MAX_CHANNELS]; // channels to scan; these may include DFS channels
111 } wifi_scan_bucket_spec;
114 int base_period; // base timer period in ms
115 int max_ap_per_scan; // number of APs to store in each scan in the
116 // BSSID/RSSI history buffer (keep the highest RSSI APs)
117 int report_threshold; // in %, when scan buffer is this much full, wake up AP
119 wifi_scan_bucket_spec buckets[MAX_BUCKETS];
120 } wifi_scan_cmd_params;
122 /* Start periodic GSCAN */
123 wifi_error wifi_start_gscan(wifi_request_id id, wifi_interface_handle iface,
124 wifi_scan_cmd_params params, wifi_scan_result_handler handler);
126 /* Stop periodic GSCAN */
127 wifi_error wifi_stop_gscan(wifi_request_id id, wifi_interface_handle iface);
129 /* Get the GSCAN cached scan results */
130 wifi_error wifi_get_cached_gscan_results(wifi_interface_handle iface, byte flush,
131 int max, wifi_scan_result *results, int *num);
135 void (*on_hotlist_ap_found)(wifi_request_id id,
136 unsigned num_results, wifi_scan_result *results);
137 } wifi_hotlist_ap_found_handler;
140 mac_addr bssid; // AP BSSID
141 wifi_rssi low; // low threshold
142 wifi_rssi high; // high threshold
143 wifi_channel channel; // channel hint
144 } ap_threshold_param;
147 int num_ap; // number of hotlist APs
148 ap_threshold_param ap[MAX_HOTLIST_APS]; // hotlist APs
149 } wifi_bssid_hotlist_params;
151 /* Set the BSSID Hotlist */
152 wifi_error wifi_set_bssid_hotlist(wifi_request_id id, wifi_interface_handle iface,
153 wifi_bssid_hotlist_params params, wifi_hotlist_ap_found_handler handler);
155 /* Clear the BSSID Hotlist */
156 wifi_error wifi_reset_bssid_hotlist(wifi_request_id id, wifi_interface_handle iface);
158 /* Significant wifi change*/
160 mac_addr bssid; // BSSID
161 wifi_channel channel; // channel frequency in MHz
162 int num_rssi; // number of rssi samples
163 wifi_rssi rssi[]; // RSSI history in db
164 } wifi_significant_change_result;
167 void (*on_significant_change)(wifi_request_id id,
168 unsigned num_results, wifi_significant_change_result **results);
169 } wifi_significant_change_handler;
172 int rssi_sample_size; // number of samples for averaging RSSI
173 int lost_ap_sample_size; // number of samples to confirm AP loss
174 int min_breaching; // number of APs breaching threshold
175 int num_ap; // max 64
176 ap_threshold_param ap[MAX_SIGNIFICANT_CHANGE_APS];
177 } wifi_significant_change_params;
179 /* Set the Signifcant AP change list */
180 wifi_error wifi_set_significant_change_handler(wifi_request_id id, wifi_interface_handle iface,
181 wifi_significant_change_params params, wifi_significant_change_handler handler);
183 /* Clear the Signifcant AP change list */
184 wifi_error wifi_reset_significant_change_handler(wifi_request_id id, wifi_interface_handle iface);