9

I'm interested in knowing how to set the first wifi on android things (not android phone) without access to a network cable, for a fresh install.

There certainly must be a way to put the information in the SD card right after copying the OS image. If that can't be done directly, worst case scenario I would expect it should be possible to write a script and copy it somewhere into some of the partitions and have it automatically run at boot (which can be handy for other things). Unless the image is signed?

I would also be ok by writing an app that could be copied to SD card before first boot that would be auto-installed and do that thing for me. I would know how to write the app, but so far I don't know how to do the copy/autoinstall/autorun thing.

I would also be ok having one device connect to network and configure wifi, then clone its SD card into another one.

What really gets in my way is having to get a network cable every time I prepare a new SD card.

Fabio
  • 2,654
  • 16
  • 31
  • Alternatively, it is possible to connect to serial debug console as described [here under the **What if I have neither display nor Ethernet cable?** section](https://stackoverflow.com/a/41988431/3290339) – Onik Jul 26 '17 at 19:58
  • as for now, you can create your own Android Things image with your own bundle (your main apk, any other apk that will be accessible from your main apk, bootanimation.zip) from [Android Things Console](https://partner.android.com/things/console/). There so it will be easier if your main apk containing connect to available wifi network functionality. – adadion Aug 21 '17 at 05:38
  • I plan to make a library that sets up a BLE connection and waits for a companion app on a phone to send wifi credentials. Put that library in either the IoT app or start it as a service, and bundle the app in the image in the console. That will make it useful to set up other things like language and timezone. – Fabio Aug 23 '17 at 04:29

2 Answers2

9

You should be able to add your wifi configuration at the end of /data/misc/wifi/wpa_supplicant.conf.

network={
    ssid="SSID"
    key_mgmt=WPA-PSK
    psk="PASSPHRASE"
}

This should be located on the data (ext4) partition of the sdcard (for me /dev/sdb15)

proppy
  • 10,495
  • 5
  • 37
  • 66
  • I could mount /dev/disk3s15 (equivalent to /dev/sdb15) as ext4 but only could find `benchmarktest lost+found nativetest`. I'll try later creating the folders there, I must go to something else now. Although I could find what appears to be the root partition at disk3s16 (sdb6), which also looks very promising. Thanks for mentioning ext4, that's what I needed to get the partitions mounted in first place. – Fabio Jan 19 '17 at 02:59
  • while accessing the wifi folder it says permission denied... – Leons May 27 '17 at 19:12
  • Has anyone had luck modifying the config files, such as this one, from an os x machine? I don't have any luck mounting the Android Things img for editing. – JTE Jul 03 '17 at 12:28
  • OS X can't do it on itself, you'd either need a VM to boot a linux (painfull, I tried, you need extra instructions for writing to a partition from real sd card) or a paid tool that has experimental support for writing ext4. – Fabio Aug 06 '17 at 09:14
1

You can use:

adb connect Android.local

to connect to Android Things PC (Raspberry PI3) and then just set up your WiFi like described in Android Things tutorial:

$ adb shell am startservice \
    -n com.google.wifisetup/.WifiSetupService \
    -a WifiSetupService.Connect \
    -e ssid <Network_SSID> \
    -e passphrase <Network_Passcode>

https://developer.android.com/things/hardware/raspberrypi.html

Mat
  • 27
  • 1
  • 2