2

I have installed a fresh copy of the latest Android Things rom into my pi 3 and now I wish to connect it to my tethered smartphones wifi connection.

How do I do that?

All examples I have seen has shown that it only works if you attach an ethernet connection from the pi 3 to a router?

Can't this done without ethernet cable and able to somehow type in commands on the actual pi 3 device to connect to a wifi?

I have my pi 3 attached to a external monitor with keyboard and mouse

1

1 Answer 1

2

This can be done via ADB if you have access to to a shell:

adb shell su 0 service call wifi 11

This will invoke WifiManager.startScan()

or you could try the following:

Once you can access a shell prompt, follow these steps:

  1. Send an intent to the Wi-Fi service that includes the SSID of your local network. Your board must support the network protocol and frequency band of the wireless network in order to establish a connection.
     $ am startservice \
         -n com.google.wifisetup/.WifiSetupService \
         -a WifiSetupService.Connect

I looked up the documentation and you can get access to a shell can be done with a serial cable:

enter image description here

Alternatively, you could try writing an app to help you out (in the onCreate()) have not tested in Android things though:

Intent intent = new Intent(Intent.ACTION_MAIN, null);
    intent.addCategory(Intent.CATEGORY_LAUNCHER);
    ComponentName cn = new ComponentName("com.android.settings", "com.android.settings.wifi.WifiSettings");
    intent.setComponent(cn);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    startActivity(intent);

EDIT

If you REALLY want to avoid the use of extra cables, you could mount the SD card to your normal pc (assuming linux I show how to mount here) and add the following to /data/misc/wifi/wpa_supplicant.conf:

network={
    ssid="[WIFI NAME]"
    key_mgmt=WPA-PSK
    psk="[PASSWORD]"
}

If you don't want your password stored in plain test you can generate the hash on the command line (and assuming you have the SD card mounted (I stole this from a script I wrote):

wpa_passphrase $1 $2 | awk '(NR != 3)' | sudo tee -a /data/misc/wifi/wpa_supplicant.conf > /dev/null

Where $1 is the name of the wifi and $2 is the password.

4
  • Can i access adb console from directly on the PI 3?
    – Jono
    Oct 20, 2017 at 10:54
  • Well remember the adb is your bridge to the pi - we need access to the shell (usually done via adb). It seems to me (from my limited knowledge) that there is going to have to be SOME physical connection from the Pi to a PC (either ethernet or serial cable) as I think all the Android Things Pi displays at startup is the I.P. address. I'll add an extra suggestion to my answer that may be sneaky enough to work Oct 20, 2017 at 11:01
  • Hi i just bought one of those usb cables and tried to connect it to my windows laptop and all i get from the putty console is a blank screen. no logs, nothing
    – Jono
    Oct 23, 2017 at 13:37
  • When I follow the steps after mounting the sd card, I don't see that data/misc/wifi folder. Is it something I would just create myself?
    – AdamMc331
    Dec 20, 2018 at 1:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.