1. Signal Strength Algorithm
Wifimanager. Java
/** Anything worse than or equal to this will show 0 bars. */ private static final int MIN_RSSI = -100; /** Anything better than or equal to this will show the max bars. */ private static final int MAX_RSSI = -55; /** * Calculates the level of the signal. This should be used any time a signal * is being shown. * * @param rssi The power of the signal measured in RSSI. * @param numLevels The number of levels to consider in the calculated * level. * @return A level of the signal, given in the range of 0 to numLevels-1 * (both inclusive). */ public static int calculateSignalLevel(int rssi, int numLevels) { /* in general, numLevels is 4 */ if (rssi <= MIN_RSSI) { return 0; } else if (rssi >= MAX_RSSI) { return numLevels - 1; } else { float inputRange = (MAX_RSSI - MIN_RSSI); float outputRange = (numLevels - 1); return (int)((float)(rssi - MIN_RSSI) * outputRange / inputRange); } }
2. WiFi command process
3. wpa_supplicant Startup Process
4. wifiservice Startup Process
5. signal_poll call Process
Eloop_run-> .. response-> // receive and process responses from framework-> (signal_poll) response-> construct (struct wpa_supplicant * wpa_s, struct wpa_signal_info * si)-> receive (void * priv, struct wpa_signal_info * si)-> evaluate (priv, rssi_cmd, Buf, sizeof (BUF) or // driver_cmd_wext.c evaluate (priv, linkspeed_cmd, Buf, sizeof (BUF )) -> struct iwreq IWR; IWR. u. data. pointer = Buf; IWR. u. data. length = buf_len; IOCTL (DRV-> ioctl_sock, siocsiwpriv, & IWR); function in the kernel: Listen 80211_wext_setpriv (wext-compat.c) rssi_cmd: 201780211_wireless_stats (obtain the signal strength and other information of the currently connected AP) for the above linkspeed_cmd, if IOCTL fails, call IOCTL (DRV-> ioctl_sock, siocgiwrate, & WRQ) function in kernel: 201780211_wext_giwrate (get the sending speed of the currently connected AP) // information of each AP struct station_info {u32 filled; u32 connected_time; u32 inactive_time; u32 rx_bytes; u32 tx_bytes; b2llid; b2plid; u8 plink_state; S8 signal; // signal strength S8 platinum; struct rate_info txrate; // sending speed struct rate_info rxrate; u32 rx_packets; u32 tx_packets; u32 tx_retries; u32 tx_failed; u32 rx_dropped_misc; struct sta_bss_parameters bss_param; int generation ;};