Search code examples
network-programmingraspberry-pi3android-wifiandroid-thingswifi

Android Things: connect to WiFi without cables


How to connect to WiFi my Raspberry Pi 3 with Android Things version 0.5.1. I've mounted SD card and current the /misc/wifi directory is

wifi> ls
drwxrwx--- 2  1010  1010 4096 1970-01-01  hostapd
drwxrwx--- 2  1010  1010 4096 1970-01-01  sockets
-rw------- 1 jacek jacek   46 2009-01-01  softap.conf
-rw------- 1 jacek jacek  236 2009-01-01  WifiConfigStore.xml
drwxrwx--- 2  1010  1010 4096 10-29 15:09 wpa_supplicant

where the wpa_supplicant, hostapd, sockets directories are empty.

According to this answer https://stackoverflow.com/a/41732035 there should be a file wpa_supplicant.conf.

I dont't have any cables so this is my last chance to get it working.

I think WiFi configuration is stored in WifiConfigStore.xml, but I dont't know what fields I should add.

Contents of WifiConfigStoreData.xml is:

<?xml version='1.0' encoding='utf-8' standalone='yes' ?>
<WifiConfigStoreData>
<int name="Version" value="1" />
<NetworkList />
<PasspointConfigData>
<long name="ProviderIndex" value="0" />
</PasspointConfigData>
</WifiConfigStoreData>

Solution

  • If you've never executed adb shell am startservice -n com.google.wifisetup... within your RPi3's shell then the /misc/wifi/wpa_supplicant directory is empty.

    Simply creating a wpa_supplicant.conf file in the mounted on your host machine SD card isn't enough as the file, similar to the /misc/wifi/wpa_supplicant directory, should be owned and grouped by the system service's process which is 1010 in your ls command result:

    drwxrwx--- 2  1010  1010 4096 10-29 15:09 wpa_supplicant
    

    Yet I recommend to connect your RPi3 either over Ethernet or USB-to-TTL cable.