Setting wifi ssid with a space in it
Asked Answered
P

2

6

I am trying to setup the wifi on my android things raspberry pi following the documentation.

My Ssid contains a space in the name let's say "my ssid".

I tried to put quotes around it like this:

$ adb shell am startservice \
    -n com.google.wifisetup/.WifiSetupService \
    -a WifiSetupService.Connect \
    -e ssid "my ssid" \
    -e passphrase secretpassword

When looking at the logcat for the wifi connection I see:

WifiNetworkHistory: saving network history: "my"NONE gw: null Network Selection-status: NETWORK_SELECTION_ENABLED ephemeral=false choice:null link:0 status:2 nid:0 hasEverConnected: false
WifiConfigurator: Wifi failed to connect in 30000 ms

How can I set my wifi correctly?

Pivoting answered 25/12, 2016 at 2:38 Comment(1)
Did you try -e ssid "my\ ssid" ? Basically escaping the space character itselfBabirusa
R
12

To enter characters like "(double quotes),*(asterisk), (space), we need to use escape sequences( i.e a backslash before the character) to tell the compiler to read the character as a part of the string instead of a command (for example double quotes is usually interpreted as the start/end of a string, to interpret it as a character in the string we use \").

The solution

$ adb shell am startservice \
-n com.google.wifisetup/.WifiSetupService \
-a WifiSetupService.Connect \
-e ssid "my\ ssid" \
-e passphrase secretpassword
Regimen answered 25/12, 2016 at 4:58 Comment(2)
were you able to connect with wifi or ethernet cable is required all the time?Pulcheria
You need an ethernet cable to setup the wifi. Once your wifi is setup, you don't need the ethernet anymore.Pivoting
T
0

I had the same problem. Repowering (unplugging & replugging) the ESP board did the trick for me without the need to escape any characters etc.

Triaxial answered 6/5 at 19:17 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.