Unable to open connection to supplicant on "wlan0": No such file or directory

2,073 views
Skip to first unread message

Elvis Dowson

unread,
Jun 29, 2009, 6:11:04 PM6/29/09
to android-porting
Hi,
I am getting the following error, while trying to port my
Ralink RT2571WF wifi module to android-2.6.29.

E/WifiHW ( 918): Unable to open connection to supplicant on "wlan0":
No such file or directory
I/WifiHW ( 918): wifi_connect_to_supplicant called

How can I resolve this?

Some people who have enable wifi have set ctrl_interface to wlan0 in
their wpa_supplicant.conf file:

ctrl_interface=wlan0

Other have specified a directory:

ctrl_interface=DIR=/data/system/wpa_supplicant/ GROUP=system

This also gives me an error :-)

E/WifiHW ( 912): Unable to open connection to supplicant on "/data/
system/wpa_supplicant/wlan0": No such file or directory
I/WifiHW ( 912): wifi_connect_to_supplicant called

So, I'm not sure what I should be doing!! :-)

This is what my init.rc file looks like at the moment:

# create wifi filesystem structure
mkdir /data/misc/wifi 0770 system system
mkdir /data/misc/wifi/sockets 0770 system system
mkdir /data/system/wpa_supplicant 0770 system system
mkdir /data/misc/dhcp 0770 dhcp dhcp
chown dhcp dhcp /data/misc/dhcp

on boot
# basic network init
ifup lo
ifup wlan0
hostname localhost
domainname localdomain

## Daemon processes to be run by init.
##
service console /system/bin/sh
console

# adbd is controlled by the persist.service.adb.enable system property
service adbd /sbin/adbd
disabled

# adbd on at boot in emulator
on property:ro.kernel.qemu=1
start adbd

on property:persist.service.adb.enable=1
start adbd

on property:persist.service.adb.enable=0
stop adbd

service servicemanager /system/bin/servicemanager
user system
critical
onrestart restart zygote
onrestart restart media

service vold /system/bin/vold
socket vold stream 0660 root mount

service mountd /system/bin/mountd
socket mountd stream 0660 root mount

service debuggerd /system/bin/debuggerd

#service ril-daemon /system/bin/rild
# socket rild stream 660 root radio
# socket rild-debug stream 660 radio system
# user root
# group radio cache inet misc

service zygote /system/bin/app_process -Xzygote /system/bin --zygote --
start-system-server
socket zygote stream 666
onrestart write /sys/android_power/request_state wake
onrestart write /sys/power/state on

service media /system/bin/mediaserver
user media
group system audio camera graphics inet net_bt net_bt_admin

#service bootsound /system/bin/playmp3
# user media
# group audio
# oneshot

#service dbus /system/bin/dbus-daemon --system --nofork
# socket dbus stream 660 bluetooth bluetooth
# user bluetooth
# group bluetooth net_bt_admin

#service hcid /system/bin/hcid -s -n -f /etc/bluez/hcid.conf
# socket bluetooth stream 660 bluetooth bluetooth
# socket dbus_bluetooth stream 660 bluetooth bluetooth
# init.rc does not yet support applying capabilities, so run as
root and
# let hcid drop uid to bluetooth with the right linux capabilities
# group bluetooth net_bt_admin misc
# disabled

#service hfag /system/bin/sdptool add --channel=10 HFAG
# user bluetooth
# group bluetooth net_bt_admin
# disabled
# oneshot

#service hsag /system/bin/sdptool add --channel=11 HSAG
# user bluetooth
# group bluetooth net_bt_admin
# disabled
# oneshot

service wlan_loader /system/bin/wlan_loader
disabled
oneshot

service ifcfg_ralink /system/bin/ifconfig wlan0 up
disabled
oneshot

service wpa_supplicant /system/bin/logwrapper /system/bin/
wpa_supplicant -Dwext -iwlan0 -c /system/etc/wifi/wpa_supplicant.conf -
dd
disabled
group system

service dhcpcd /system/bin/logwrapper /system/bin/dhcpcd -d wlan0 -dd
disabled
#group system dhcp

#on property:init.svc.wpa_supplicant=stopped
# stop dhcpcd

service installd /system/bin/installd
socket installd stream 600 system system

#service flash_recovery /system/bin/flash_image recovery /system/
recovery.img
# oneshot

Best regards,

Elvis

阿虚

unread,
Jun 29, 2009, 9:31:21 PM6/29/09
to android...@googlegroups.com
I think that ralink wifi driver use the name of rausb0
 
You can try it!

2009/6/30 Elvis Dowson <elvis....@gmail.com>

Elvis Dowson

unread,
Jun 29, 2009, 10:33:54 PM6/29/09
to android...@googlegroups.com
Hi,
     For the moment, I managed to get the driver to work using the linux kernel supplied rt2x00 driver for the kernel. It creates wlan0.

I think the problem might be the name of the ctrl_interface defined in wpa_supplicant.conf file, 

ctrl_interface=DIR=/data/system/wpa_supplicant GROUP=system


and the code that uses of the interface name in wifi.c 

property_get("wifi.interface", iface, "wlan0"); 

this is where it is failing. What have you entered here?

In the board system.prop file, I also have the following entry:

wifi.interface = wlan0

So what do you think the correct entries are in my case? The rtx2000 ralink kernel drivers create a wlan0 interface connection which I can access if I normaly boot in using the linux init process. 

Best regards,

Elvis

int wifi_connect_to_supplicant()
{
    char ifname[256];
    char supp_status[PROPERTY_VALUE_MAX] = {'\0'};

    LOGI("%s called",__func__);
    /* Make sure supplicant is running */
    if (!property_get(SUPP_PROP_NAME, supp_status, NULL)
            || strcmp(supp_status, "running") != 0) {
        LOGE("Supplicant not running, cannot connect");
        return -1;
    }

    property_get("wifi.interface", iface, "wlan0");

    if (access(IFACE_DIR, F_OK) == 0) {
        snprintf(ifname, sizeof(ifname), "%s/%s", IFACE_DIR, iface);
    } else {
        strlcpy(ifname, iface, sizeof(ifname));
    }
    LOGI("Interface directory = %s", IFACE_DIR);
    LOGI("Interface name = %s", ifname);
    ctrl_conn = wpa_ctrl_open(ifname);
    if (ctrl_conn == NULL) {
        LOGE("Unable to open connection to supplicant on \"%s\": %s",
             ifname, strerror(errno));
        return -1;
    }


Elvis Dowson

unread,
Jun 30, 2009, 12:20:53 PM6/30/09
to android-porting
Hi,
You can find the full list of modifications that I have made to
android-1.5 so far below.

I am at a loss to figure out why I get the "/data/system/
wpa_supplicant/wlan0": No such file or directory error.

I/WifiHW ( 913): wifi_command called, cmd:LIST_NETWORKS
I/WifiHW ( 913): wifi_send_command, cmd = LIST_NETWORKS
I/WifiHW ( 913): wifi_connect_to_supplicant called
I/WifiHW ( 913): Interface directory = /data/system/wpa_supplicant
I/WifiHW ( 913): Interface name = /data/system/wpa_supplicant/wlan0
E/WifiHW ( 913): Unable to open connection to supplicant on "/data/
system/wpa_supplicant/wlan0": No such file or directory

What could the reason be?

In my wpa_supplicant.conf, I have

update_config=1
ctrl_interface=/data/system/wpa_supplicant/
eapol_version=1
ap_scan=1
fast_reauth=1



Best regards,

Elvis

diff --git a/target/board/generic/BoardConfig.mk b/target/board/
generic/BoardConfig.mk
index a874742..deaa84d 100644
--- a/target/board/generic/BoardConfig.mk
+++ b/target/board/generic/BoardConfig.mk
@@ -9,3 +9,5 @@ TARGET_NO_KERNEL := true
TARGET_NO_RADIOIMAGE := true
HAVE_HTC_AUDIO_DRIVER := true
BOARD_USES_GENERIC_AUDIO := true
+HAVE_CUSTOM_WIFI_DRIVER_2 := true
+
diff --git a/target/board/generic/system.prop b/target/board/generic/
system.prop
index f2424c9..21b1710 100644
--- a/target/board/generic/system.prop
+++ b/target/board/generic/system.prop
@@ -2,5 +2,10 @@
# system.prop for generic sdk
#

-rild.libpath=/system/lib/libreference-ril.so
-rild.libargs=-d /dev/ttyS0
+# RILD settings
+#rild.libpath=/system/lib/libreference-ril.so
+#rild.libargs=-d /dev/ttyS0
+
+# WiFi settings
+wifi.interface = wlan0
+



project external/wpa_supplicant/
diff --git a/.config b/.config
index 93ba434..6b71f9c 100644
--- a/.config
+++ b/.config
@@ -19,13 +19,13 @@ CONFIG_EAP_LEAP=y
CONFIG_PKCS12=y
# CONFIG_PCSC=y
CONFIG_SMARTCARD=y
-# CONFIG_WIRELESS_EXTENSION=y
+CONFIG_WIRELESS_EXTENSION=y
CONFIG_CTRL_IFACE=y
# CONFIG_DRIVER_HOSTAP=y
# CONFIG_DRIVER_HERMES=y
# CONFIG_DRIVER_MADWIFI=y
# CONFIG_DRIVER_ATMEL=y
-# CONFIG_DRIVER_WEXT=y
+CONFIG_DRIVER_WEXT=y


diff --git a/Android.mk b/Android.mk
index c11329d..fa1a54c 100644
--- a/Android.mk
+++ b/Android.mk
@@ -15,7 +15,7 @@
#
LOCAL_PATH := $(call my-dir)

-WPA_BUILD_SUPPLICANT := false
+WPA_BUILD_SUPPLICANT := true
ifneq ($(TARGET_SIMULATOR),true)
ifneq ($(BOARD_WPA_SUPPLICANT_DRIVER),)
WPA_BUILD_SUPPLICANT := true
diff --git a/wpa_supplicant.conf b/wpa_supplicant.conf
index 7476f0e..7ad4c65 100644
--- a/wpa_supplicant.conf
+++ b/wpa_supplicant.conf
@@ -72,7 +72,8 @@ update_config=1
# DACL (which will reject all connections). See README-Windows.txt
for more
# information about SDDL string format.
#
-ctrl_interface=tiwlan0
+#ctrl_interface=wlan0
+ctrl_interface=DIR=/data/system/wpa_supplicant GROUP=system


diff --git a/services/java/com/android/server/WifiService.java b/
services/java/com/android/server/WifiService.java
index 54e77f0..ce5fe42 100644
--- a/services/java/com/android/server/WifiService.java
+++ b/services/java/com/android/server/WifiService.java
@@ -75,7 +75,7 @@ import com.android.server.am.BatteryStatsService;
*/
public class WifiService extends IWifiManager.Stub {
private static final String TAG = "WifiService";
- private static final boolean DBG = false;
+ private static final boolean DBG = true;
private static final Pattern scanResultPattern = Pattern.compile
("\t+");
private final WifiStateTracker mWifiStateTracker;

@@ -1219,53 +1219,18 @@ public class WifiService extends
IWifiManager.Stub {
}
int lineLen = lineEnd - lineBeg;
if (0 < lineLen && lineLen <=
SCAN_RESULT_BUFFER_SIZE) {
- int scanResultLevel = 0;
/*
* At most one thread should have access to the
buffer at a time!
*/
synchronized(mScanResultBuffer) {
- boolean parsingScanResultLevel = false;
for (int i = lineBeg; i < lineEnd; ++i) {
- char ch = reply.charAt(i);
- /*
- * Assume that the signal level starts
with a '-'
- */
- if (ch == '-') {
- /*
- * Skip whatever instances of '-' we
may have
- * after we parse the signal level
- */
- parsingScanResultLevel =
(scanResultLevel == 0);
- } else if (parsingScanResultLevel) {
- int digit = Character.digit(ch, 10);
- if (0 <= digit) {
- scanResultLevel =
- 10 * scanResultLevel + digit;
- /*
- * Replace the signal level
number in
- * the string with 0's for
caching
- */
- ch = '0';
- } else {
- /*
- * Reset the flag if we meet a
non-digit
- * character
- */
- parsingScanResultLevel = false;
- }
- }
- mScanResultBuffer[i - lineBeg] = ch;
+ mScanResultBuffer[i - lineBeg] =
reply.charAt(i);
}
- if (scanResultLevel != 0) {
- ScanResult scanResult = parseScanResult(
- new String(mScanResultBuffer, 0,
lineLen));
- if (scanResult != null) {
- scanResult.level = -scanResultLevel;
- scanList.add(scanResult);
- }
- } else if (DBG) {
- Log.w(TAG,
- "ScanResult.level=0: misformatted
scan result?");
+ ScanResult scanResult = parseScanResult(
+ new String(mScanResultBuffer,0,lineLen));
+ if (scanResult != null) {
+ scanList.add(scanResult);
+ if (DBG) Log.d(TAG, "ScanResult: " +
scanResult);
}
}
} else if (0 < lineLen) {

diff --git a/wifi/java/android/net/wifi/WifiStateTracker.java b/wifi/
java/android/net/wifi/WifiStateTracker.java
index 6ea35f5..481855d 100644
--- a/wifi/java/android/net/wifi/WifiStateTracker.java
+++ b/wifi/java/android/net/wifi/WifiStateTracker.java
@@ -59,7 +59,7 @@ import java.net.UnknownHostException;
*/
public class WifiStateTracker extends NetworkStateTracker {

- private static final boolean LOCAL_LOGD = Config.LOGD || false;
+ private static final boolean LOCAL_LOGD = Config.LOGD || true;

private static final String TAG = "WifiStateTracker";

@@ -321,7 +321,7 @@ public class WifiStateTracker extends
NetworkStateTracker {

mSettingsObserver = new SettingsObserver(new Handler());

- mInterfaceName = SystemProperties.get("wifi.interface",
"tiwlan0");
+ mInterfaceName = SystemProperties.get("wifi.interface",
"wlan0");
sDnsPropNames = new String[] {
"dhcp." + mInterfaceName + ".dns1",
"dhcp." + mInterfaceName + ".dns2"

project hardware/libhardware_legacy/
diff --git a/wifi/wifi.c b/wifi/wifi.c
index 0778e77..70aa552 100644
--- a/wifi/wifi.c
+++ b/wifi/wifi.c
@@ -48,10 +48,19 @@ static char iface[PROPERTY_VALUE_MAX];
// TODO: use new ANDROID_SOCKET mechanism, once support for multiple
// sockets is in

-static const char IFACE_DIR[] = "/data/system/
wpa_supplicant";
-static const char DRIVER_MODULE_NAME[] = "wlan";
-static const char DRIVER_MODULE_TAG[] = "wlan ";
-static const char DRIVER_MODULE_PATH[] = "/system/lib/modules/
wlan.ko";
+static const char IFACE_DIR[] = "/data/system/
wpa_supplicant";
+static const char DRIVER_MODULE_NAME[] = "rt73usb";
+static const char DRIVER_MODULE_TAG[] = "rt73usb ";
+static const char DRIVER_MODULE_PATH[] = "/system/lib/modules/
rt73usb.ko";
+static const char RT2570_DRIVER_MODULE_NAME[] = "rt2500usb";
+static const char RT2570_DRIVER_MODULE_TAG[] = "rt2500usb ";
+static const char RT2570_DRIVER_MODULE_PATH[] = "/system/lib/
modules/rt2500usb.ko";
+static const char RT2X00_LIB_DRIVER_MODULE_NAME[] = "rt2x00lib";
+static const char RT2X00_LIB_DRIVER_MODULE_TAG[] = "rt2x00lib ";
+static const char RT2X00_LIB_DRIVER_MODULE_PATH[] = "/system/lib/
modules/rt2x00lib.ko";
+static const char RT2X00_LIB_USB_DRIVER_MODULE_NAME[] =
"rt2x00usb";
+static const char RT2X00_LIB_USB_DRIVER_MODULE_TAG[] = "rt2x00usb
";
+static const char RT2X00_LIB_USB_DRIVER_MODULE_PATH[] = "/system/
lib/modules/rt2x00usb.ko";
static const char FIRMWARE_LOADER[] = "wlan_loader";
static const char DRIVER_PROP_NAME[] = "wlan.driver.status";
static const char SUPPLICANT_NAME[] = "wpa_supplicant";
@@ -66,6 +75,7 @@ static int insmod(const char *filename)
unsigned int size;
int ret;

+ LOGI("%s\n", __FUNCTION__);
module = load_file(filename, &size);
if (!module)
return -1;
@@ -82,6 +92,7 @@ static int rmmod(const char *modname)
int ret = -1;
int maxtry = 10;

+ LOGI("%s\n", __FUNCTION__);
while (maxtry-- > 0) {
ret = delete_module(modname, O_NONBLOCK | O_EXCL);
if (ret < 0 && errno == EAGAIN)
@@ -91,30 +102,35 @@ static int rmmod(const char *modname)
}

if (ret != 0)
- LOGD("Unable to unload driver module \"%s\": %s\n",
+ LOGE("Unable to unload driver module \"%s\": %s\n",
modname, strerror(errno));
return ret;
}

int do_dhcp_request(int *ipaddr, int *gateway, int *mask,
int *dns1, int *dns2, int *server, int *lease) {
+ LOGI("1. inside %s\n", __FUNCTION__);
/* For test driver, always report success */
- if (strcmp(iface, "sta") == 0)
+ if (strcmp(iface, "wlan0") == 0)
return 0;

+ LOGI("2. inside %s\n", __FUNCTION__);
if (ifc_init() < 0)
return -1;

+ LOGI("3. inside %s\n", __FUNCTION__);
if (do_dhcp(iface) < 0) {
ifc_close();
return -1;
}
ifc_close();
get_dhcp_info(ipaddr, gateway, mask, dns1, dns2, server, lease);
+ LOGI("4. inside %s\n", __FUNCTION__);
return 0;
}

const char *get_dhcp_error_string() {
+ LOGI("Inside %s\n", __FUNCTION__);
return dhcp_lasterror();
}

@@ -123,8 +139,10 @@ static int check_driver_loaded() {
FILE *proc;
char line[sizeof(DRIVER_MODULE_TAG)+10];

+ LOGI("%s\n", __FUNCTION__);
if (!property_get(DRIVER_PROP_NAME, driver_status, NULL)
|| strcmp(driver_status, "ok") != 0) {
+ LOGE("driver %s has NOT been installed",DRIVER_MODULE_TAG);
return 0; /* driver not loaded */
}
/*
@@ -135,15 +153,17 @@ static int check_driver_loaded() {
*/
if ((proc = fopen(MODULE_FILE, "r")) == NULL) {
LOGW("Could not open %s: %s", MODULE_FILE, strerror(errno));
- property_set(DRIVER_PROP_NAME, "unloaded");
+ property_set(DRIVER_PROP_NAME, "unloaded");
return 0;
}
while ((fgets(line, sizeof(line), proc)) != NULL) {
if (strncmp(line, DRIVER_MODULE_TAG, strlen
(DRIVER_MODULE_TAG)) == 0) {
+ LOGI("driver %s has been installed\n",DRIVER_MODULE_TAG);
fclose(proc);
return 1;
}
}
+ LOGE("Cannot find driver %s in proc",DRIVER_MODULE_TAG);
fclose(proc);
property_set(DRIVER_PROP_NAME, "unloaded");
return 0;
@@ -154,23 +174,35 @@ int wifi_load_driver()
char driver_status[PROPERTY_VALUE_MAX];
int count = 100; /* wait at most 20 seconds for completion */

+ LOGI("Loading WiFi Modules\n");
+ sleep(1);
+
+ // Hack taken from EEPC WiFi path. We have statically linked the
WiFi driver
+ // into the kernel, so we simply return and don't attempt to load
the driver.
+ // So we set the driver property to ok, since we have already
installed it.
+ property_set(DRIVER_PROP_NAME, "ok");
if (check_driver_loaded()) {
return 0;
}
-
- if (insmod(DRIVER_MODULE_PATH) < 0)
- return -1;
-
+ insmod(RT2X00_LIB_DRIVER_MODULE_PATH);
+ insmod(RT2X00_LIB_USB_DRIVER_MODULE_PATH);
+ insmod(RT2570_DRIVER_MODULE_PATH);
+ insmod(DRIVER_MODULE_PATH);
property_set("ctl.start", FIRMWARE_LOADER);
sched_yield();
while (count-- > 0) {
+ usleep(500000);
if (property_get(DRIVER_PROP_NAME, driver_status, NULL)) {
- if (strcmp(driver_status, "ok") == 0)
+ if (strcmp(driver_status, "ok") == 0) {
+ property_set("ctl.start", "ifcfg_ralink");
+ usleep(1000000);
+ //property_set("ctl.start", "dhcpcd");
return 0;
- else if (strcmp(DRIVER_PROP_NAME, "failed") == 0)
+ }
+ else if (strcmp(DRIVER_PROP_NAME, "failed") == 0) {
return -1;
+ }
}
- usleep(200000);
}
property_set(DRIVER_PROP_NAME, "timeout");
return -1;
@@ -178,20 +210,33 @@ int wifi_load_driver()

int wifi_unload_driver()
{
- int count = 20; /* wait at most 10 seconds for completion */
-
+ LOGI("Unloading WiFi Modules\n");
+ sleep(1);
if (rmmod(DRIVER_MODULE_NAME) == 0) {
- while (count-- > 0) {
- if (!check_driver_loaded())
- break;
- usleep(500000);
- }
- if (count) {
- return 0;
+ usleep(1000000);
+ } else {
+ LOGE("Unloading Ralink RT73USB WLAN Module Failed\n");
+ return -1;
}
- return -1;
- } else
+ if (rmmod(RT2570_DRIVER_MODULE_NAME) == 0) {
+ usleep(1000000);
+ } else {
+ LOGE("Unloading RT2570 Module Failed\n");
return -1;
+ }
+ if (rmmod(RT2X00_LIB_USB_DRIVER_MODULE_NAME) == 0) {
+ usleep(1000000);
+ } else {
+ LOGE("Unloading RT2X00_LIB_USB Module Failed\n");
+ return -1;
+ }
+ if (rmmod(RT2X00_LIB_DRIVER_MODULE_NAME) == 0) {
+ usleep(1000000);
+ } else {
+ LOGE("Unloading RT2X00_LIB Module Failed\n");
+ return -1;
+ }
+ return 0;
}

int ensure_config_file_exists()
@@ -200,6 +245,7 @@ int ensure_config_file_exists()
int srcfd, destfd;
int nread;

+ LOGE("%s\n", __FUNCTION__);
if (access(SUPP_CONFIG_FILE, R_OK|W_OK) == 0) {
return 0;
} else if (errno != ENOENT) {
@@ -252,6 +298,7 @@ int wifi_start_supplicant()
unsigned serial = 0;
#endif

+ LOGI("start %s",__FUNCTION__);
/* Check whether already running */
if (property_get(SUPP_PROP_NAME, supp_status, NULL)
&& strcmp(supp_status, "running") == 0) {
@@ -260,7 +307,7 @@ int wifi_start_supplicant()

/* Before starting the daemon, make sure its config file exists
*/
if (ensure_config_file_exists() < 0) {
- LOGE("Wi-Fi will not be enabled");
+ LOGE("Configuration file does not exis. Wi-Fi will not be
enabled");
return -1;
}

@@ -291,9 +338,11 @@ int wifi_start_supplicant()
if (pi != NULL) {
__system_property_read(pi, NULL, supp_status);
if (strcmp(supp_status, "running") == 0) {
+ LOGI("Wi-Fi is running\n");
return 0;
} else if (pi->serial != serial &&
strcmp(supp_status, "stopped") == 0) {
+ LOGI("Wi-Fi has been stopped");
return -1;
}
}
@@ -313,6 +362,7 @@ int wifi_stop_supplicant()
char supp_status[PROPERTY_VALUE_MAX] = {'\0'};
int count = 50; /* wait at most 5 seconds for completion */

+ LOGI("%s called",__func__);
/* Check whether supplicant already stopped */
if (property_get(SUPP_PROP_NAME, supp_status, NULL)
&& strcmp(supp_status, "stopped") == 0) {
@@ -337,6 +387,7 @@ int wifi_connect_to_supplicant()
char ifname[256];
char supp_status[PROPERTY_VALUE_MAX] = {'\0'};

+ LOGI("%s called",__func__);
/* Make sure supplicant is running */
if (!property_get(SUPP_PROP_NAME, supp_status, NULL)
|| strcmp(supp_status, "running") != 0) {
@@ -344,14 +395,15 @@ int wifi_connect_to_supplicant()
return -1;
}

- property_get("wifi.interface", iface, "sta");
+ property_get("wifi.interface", iface, "wlan0");

if (access(IFACE_DIR, F_OK) == 0) {
snprintf(ifname, sizeof(ifname), "%s/%s", IFACE_DIR, iface);
} else {
strlcpy(ifname, iface, sizeof(ifname));
}
-
+ LOGI("Interface directory = %s", IFACE_DIR);
+ LOGI("Interface name = %s", ifname);
ctrl_conn = wpa_ctrl_open(ifname);
if (ctrl_conn == NULL) {
LOGE("Unable to open connection to supplicant on \"%s\": %s",
@@ -370,6 +422,7 @@ int wifi_connect_to_supplicant()
ctrl_conn = monitor_conn = NULL;
return -1;
}
+ LOGI("Connect to Supplicant done\n");
return 0;
}

@@ -377,20 +430,26 @@ int wifi_send_command(struct wpa_ctrl *ctrl,
const char *cmd, char *reply, size_
{
int ret;

+ LOGI("%s, cmd = %s\n", __FUNCTION__, cmd);
if (ctrl_conn == NULL) {
LOGV("Not connected to wpa_supplicant - \"%s\" command
dropped.\n", cmd);
return -1;
}
+
+ memset(reply, 0, *reply_len);
ret = wpa_ctrl_request(ctrl, cmd, strlen(cmd), reply, reply_len,
NULL);
if (ret == -2) {
LOGD("'%s' command timed out.\n", cmd);
return -2;
} else if (ret < 0 || strncmp(reply, "FAIL", 4) == 0) {
+ LOGI("reply:%s\n",reply);
return -1;
}
if (strncmp(cmd, "PING", 4) == 0) {
reply[*reply_len] = '\0';
}
+
+ LOGI("returning reply %s for cmd %s\n", reply, cmd);
return 0;
}

@@ -402,17 +461,20 @@ int wifi_wait_for_event(char *buf, size_t
buflen)
int result;
struct timeval tval;
struct timeval *tptr;
-
+
+ LOGI("%s called",__func__);
+ LOGI("monitor_conn checking \n");
if (monitor_conn == NULL)
return 0;

+ LOGI("calling wpa_ctrl_recv\n");
result = wpa_ctrl_recv(monitor_conn, buf, &nread);
if (result < 0) {
LOGD("wpa_ctrl_recv failed: %s\n", strerror(errno));
return -1;
}
buf[nread] = '\0';
- /* LOGD("wait_for_event: result=%d nread=%d string=\"%s\"\n",
result, nread, buf); */
+ LOGI("wait_for_event: result=%d nread=%d string=\"%s\"\n",
result, nread, buf);
/* Check for EOF on the socket */
if (result == 0 && nread == 0) {
/* Fabricate an event to pass up */
@@ -424,7 +486,7 @@ int wifi_wait_for_event(char *buf, size_t buflen)
/*
* Events strings are in the format
*
- * <N>CTRL-EVENT-XXX
+ * <N>CTRL-EVENT-XXX
*
* where N is the message level in numerical form (0=VERBOSE,
1=DEBUG,
* etc.) and XXX is the event name. The level information is not
useful
@@ -437,11 +499,13 @@ int wifi_wait_for_event(char *buf, size_t
buflen)
memmove(buf, match+1, nread+1);
}
}
+ LOGI("returning nread\n");
return nread;
}

void wifi_close_supplicant_connection()
{
+ LOGI("%s called",__func__);
if (ctrl_conn != NULL) {
wpa_ctrl_close(ctrl_conn);
ctrl_conn = NULL;
@@ -454,5 +518,6 @@ void wifi_close_supplicant_connection()

int wifi_command(const char *command, char *reply, size_t *reply_len)
{
+ LOGI("%s called, cmd:%s",__func__,command);
return wifi_send_command(ctrl_conn, command, reply, reply_len);
}
Reply all
Reply to author
Forward
0 new messages