OSDN Git Service

Moving Wifi HAL to hardware
[android-x86/hardware-libhardware_legacy.git] / include / hardware_legacy / gscan.h
1
2 #include "wifi_hal.h"
3
4 #ifndef __WIFI_HAL_GSCAN_H__
5 #define __WIFI_HAL_GSCAN_H__
6
7 /* AP Scans */
8
9 typedef enum {
10     WIFI_BAND_UNSPECIFIED,
11     WIFI_BAND_BG,                       // 2.4 GHz
12     WIFI_BAND_A,                        // 5 GHz without DFS
13     WIFI_BAND_A_WITH_DFS,               // 5 GHz with DFS
14     WIFI_BAND_ABG,                      // 2.4 GHz + 5 GHz; no DFS
15     WIFI_BAND_ABG_WITH_DFS,             // 2.4 GHz + 5 GHz with DFS
16 } wifi_band;
17
18 wifi_error wifi_get_valid_channels(wifi_interface_handle handle,
19         int band, int size, wifi_channel *channels, int *num);
20
21 typedef struct {
22     int max_scan_cache_size;                 // in number of scan results??
23     int max_scan_buckets;
24     int max_ap_cache_per_scan;
25     int max_rssi_sample_size;
26     int max_scan_reporting_threshold;        // in number of scan results??
27     int max_hotlist_aps;
28     int max_significant_wifi_change_aps;
29 } wifi_gscan_capabilities;
30
31 wifi_error wifi_get_gscan_capabilities(wifi_interface_handle handle,
32         wifi_gscan_capabilities *capabilities);
33
34 typedef struct {
35     wifi_timestamp ts;                  // Time of discovery
36     char ssid[32+1];                    // null terminated
37     mac_addr bssid;
38     wifi_channel channel;               // channel frequency in MHz
39     wifi_rssi rssi;                     // in db
40     wifi_timespan rtt;                  // in nanoseconds
41     wifi_timespan rtt_sd;               // standard deviation in rtt
42
43     // other fields
44 } wifi_scan_result;
45
46 typedef struct {
47     void (*on_scan_results_available) (wifi_request_id id, unsigned num_results_available);
48 } wifi_scan_result_handler;
49
50 typedef struct {
51     wifi_channel channel;               // frequency
52     int dwellTimeMs;                    // dwell time hint
53     int passive;                        // 0 => active, 1 => passive scan; ignored for DFS
54     /* Add channel class */
55 } wifi_scan_channel_spec;
56
57 typedef struct {
58     int bucket;                         // bucket index, 0 based
59     wifi_band band;                     // when UNSPECIFIED, use channel list
60     int period;                         // desired period, in millisecond; if this is too
61                                         // low, the firmware should choose to generate results as
62                                         // fast as it can instead of failing the command
63     byte report_events;                 // 1 => report events after each scan
64     int num_channels;
65     wifi_scan_channel_spec channels[8]; // channels to scan; these may include DFS channels
66 } wifi_scan_bucket_spec;
67
68 typedef struct {
69     int base_period;                    // base timer period in ms
70     int max_ap_per_scan;
71     int report_threshold;               // in %, when buffer is this much full, wake up AP
72     int num_buckets;                    // maximum 8
73     wifi_scan_bucket_spec buckets[8];
74 } wifi_scan_cmd_params;
75
76 wifi_error wifi_start_gscan(wifi_request_id id, wifi_interface_handle iface,
77         wifi_scan_cmd_params params, wifi_scan_result_handler handler);
78 wifi_error wifi_stop_gscan(wifi_request_id id, wifi_interface_handle iface);
79
80 wifi_error wifi_get_cached_gscan_results(wifi_interface_handle iface, byte flush,
81         wifi_scan_result *results, int *num);
82
83
84 /* BSSID Hotlist */
85 typedef struct {
86     void (*on_hotlist_ap_found)(wifi_request_id id,
87             unsigned num_results, wifi_scan_result *results);
88 } wifi_hotlist_ap_found_handler;
89
90 typedef struct {
91     mac_addr  bssid;                    // AP BSSID
92     wifi_rssi low;                      // low threshold
93     wifi_rssi high;                     // high threshold
94 } ap_threshold_param;
95
96 typedef struct {
97     int num;                            // max??
98     ap_threshold_param bssids[64];
99 } wifi_bssid_hotlist_params;
100
101 wifi_error wifi_set_bssid_hotlist(wifi_request_id id, wifi_interface_handle iface,
102         wifi_bssid_hotlist_params params, wifi_hotlist_ap_found_handler handler);
103 wifi_error wifi_reset_bssid_hotlist(wifi_request_id id, wifi_interface_handle iface);
104
105 /* Significant wifi change*/
106
107 typedef struct {
108     void (*on_significant_change)(wifi_request_id id,
109             unsigned num_results, wifi_scan_result *results);
110 } wifi_significant_change_handler;
111
112 typedef struct {
113     int rssi_sample_size;               // number of samples for averaging RSSI
114     int lost_ap_sample_size;            // number of samples to confirm AP loss
115     int min_breaching;                  // number of APs breaching threshold
116     int num;                            // max 64
117     ap_threshold_param bssids[64];
118 } wifi_significant_change_params;
119
120 wifi_error wifi_set_significant_change_handler(wifi_request_id id, wifi_interface_handle iface,
121         wifi_significant_change_params params, wifi_significant_change_handler handler);
122 wifi_error wifi_reset_significant_change_handler(wifi_request_id id, wifi_interface_handle iface);
123
124 #endif
125