Configuring Wi-Fi using the script

We already mentioned that you can only deploy your code to a Raspberry Pi using adb over a network connection, so configuring Wi-Fi is quite important. I do use an Ethernet cable most of the time when testing on a Pi, but configuring Wi-Fi comes in handy quite often.

In the case of the iMX7D, this step is even less important, since we can use the board for debugging via the USB type C cable.

In any case, there are several ways to configure Wi-Fi: you can use the script any time to perform just this step, you can do it with the adb command (for which the script is a wrapper) or you can use the system UI for that.

Let's take a quick look at the message from the script:

Would you like to set up Wi-Fi on this device? (y/n)
Please plug your Raspberry Pi to your router with an Ethernet cable, then press [Enter].

So, to be able to configure Wi-Fi on a Raspberry Pi, you need to connect it via Ethernet first; then, the script will connect to it using adb and configure Wi-Fi.

You need an Ethernet cable to configure Wi-Fi on the Raspberry Pi with the setup script.

In the case of the iMX7D, the message is slightly different:

Please ensure antenna is already attached. If it is not, disconnect your board, attach the antenna and reconnect your board to your computer.

When ready, press [Enter]...

This board will not be able to connect to Wi-Fi unless the antenna is connected, but the configuration is done via the USB type C cable:

The Wi-Fi on iMX7D will not work unless the antenna is connected.
Attempting to connect to your Raspberry Pi at Android.local...
Connected to device through Ethernet.
Enter the Wi-Fi network name: PlattySoftHQ
Enter the Wi-Fi network password (leave empty if no password):
Connecting to Wi-Fi network PlattySoftHQ...
Looking for device... This can take up to 3 minutes.
Device found.
Waiting...

What the script does is to connect adb to the device using the name Android.local and then send an adb command to set up the Wi-Fi. If you want to do that by hand, you just have to type the following:

$ adb connect Android.local
connected to Android.local:5555
$ adb shell am startservice
-n com.google.wifisetup/.WifiSetupService
-a WifiSetupService.Connect
-e ssid <Network_SSID>
-e passphrase <Network_Passcode>

You can see the complete list of parameters in the official documentation at https://developer.android.com/things/hardware/wifi-adb.

The Wi-Fi setup may fail if you have several Android devices on the LAN.

Since the script relies on the device identifying itself as Android.local on the local network, this only works if it is the only device doing that. If you already have another device on the network that uses that name (such as another Android Things or an Android TV) this may fail, so let's look at a back-up plan.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.222.67.251