/* * Copyright (C) 2008 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef _WIFI_H #define _WIFI_H #if __cplusplus extern "C" { #endif /** * Load the Wi-Fi driver. * * @return 0 on success, < 0 on failure. */ int wifi_load_driver(); /** * Unload the Wi-Fi driver. * * @return 0 on success, < 0 on failure. */ int wifi_unload_driver(); /** * Start supplicant. * * @return 0 on success, < 0 on failure. */ int wifi_start_supplicant(); /** * Stop supplicant. * * @return 0 on success, < 0 on failure. */ int wifi_stop_supplicant(); /** * Open a connection to supplicant. * * @return 0 on success, < 0 on failure. */ int wifi_connect_to_supplicant(); /** * Close connection supplicant. * * @return 0 on success, < 0 on failure. */ void wifi_close_supplicant_connection(); /** * wifi_wait_for_event() performs a blocking call to * get a Wi-Fi event and returns a string representing * a Wi-Fi event when it occurs. * * @param buf is the buffer that receives the event * @param len is the maximum length of the buffer * * @returns number of bytes in buffer, 0 if no * event (for instance, no connection), and less than 0 * if there is an error. */ int wifi_wait_for_event(char *buf, size_t len); /** * wifi_command() issues a command to the Wi-Fi driver. * * Android extends the standard commands listed at * /link http://hostap.epitest.fi/wpa_supplicant/devel/ctrl_iface_page.html * to include support for sending commands to the driver: * *
Command / Command summary | *Form of Response | *Processing | *
DRIVER START Turn on Wi-Fi Hardware |
* OK if successful | *OK ? true : false | *
DRIVER STOP Turn off Wi-Fi hardware |
* OK if successful | *OK ? true : false | *
DRIVER RSSI Return received signal strength indicator in -db for current AP |
* <ssid> Rssi xx | *%*s %*s %d", &rssi | *
DRIVER LINKSPEED Return link speed in MBPS |
* LinkSpeed xx | *%*s %d", &linkspd | *
DRIVER MACADDR Return mac address of the station |
* Macaddr = xx.xx.xx.xx.xx.xx | *"%*s = %s", &macadr | *
DRIVER SCAN-ACTIVE Set scan type to active |
* "OK" if successful | *"OK" ? true : false | *
DRIVER SCAN-PASSIVE Set scan type to passive |
* "OK" if successful | *"OK" ? true : false | *