11

Newer iPhones will broadcast an SSID in hotspot mode as such:

My Name\342\\\200\\\231\\s iPhone

I observed this SSID in the GUI.

When I grab the SSID via the command line:

$ sudo iwlist wlan0 scan | grep ESSID
> My Name\xE52\x80\x99s iPhone

In the iPhone it shows up as:

My Name's iPhone

If, in wpa_supplicant.conf, I enter:

network={
    ssid="My Name's iPhone"
    psk="my_passcode"
}

The Raspberry Pi will not connect to the iPhone hotspot.

However, if, in wpa_supplicant.conf, I enter:

network={
    ssid="My Name\342\\\200\\\231\s iPhone"
    psk="my_passcode"
}

I get an error in the command line.

$ sudo ifdown wlan0
$ sudo ifup wlan0
> wpa_supplicant: /sbin/wpa_supplicant daemon failed to start
> run-parts: /etc/network/if-pre-up/wpasupplicant exited with return code 1
> Failed to bring up wlan0

Via GUI, I get the error "Invalid argument".

If, in wpa_supplicant.conf I enter:

network={
    ssid="My Name\xE52\x80\x99s iPhone"
    psk="my_passcode"
}

Then raspbian will not connect to it, and will connect to a lower priority network (assume I have the priorities set correctly, which I have tested).

11
  • Why don't you just set the SSID on the iPhone? I don't want everyone to see "Joe Bloggs iPhone" anyway and set a sensible SSID.
    – Milliways
    Commented Jan 13, 2016 at 22:28
  • That requires changing my colleague's iPhone name, which I would prefer not to do. The purpose is to get internet in a field site where we're collecting data with the raspberry Pis, so that it can set time correctly.
    – ericmjl
    Commented Jan 13, 2016 at 22:31
  • @Milliways: by no means do I mean to disagree with your suggestion as a potential solution; if this were my own device, I would totally do what you suggested :).
    – ericmjl
    Commented Jan 13, 2016 at 22:39
  • How did you determine the SSID? The '\' is a normal 'NIX escape character. I guess this derived from Unicode (maybe U+2019)
    – Milliways
    Commented Jan 13, 2016 at 22:51
  • @Milliways: I updated my post with details on how I grabbed the SSIDs. From the GUI, I get the ones with triple slashes. From the terminal, I get the version with \xE52\x80\x99.
    – ericmjl
    Commented Jan 13, 2016 at 22:52

4 Answers 4

3

The iPhone prompt includes the Unicode character U+2019 "single right quotation mark". This is valid (if very inconvenient).

It is easy enough to include Unicode characters in strings. The following would echo this at the bash command prompt.

echo $'My Name\u2019s iPhone'
echo $'My Name\xE2\x80\x99s iPhone'

The (very sketchy) documentation of man wpa_supplicant.conf does not seem to specify how the ssid parameter is interpreted. You could try the form above $'My Name\u2019s iPhone' and see if that helps.

NOTE The string "My Name\xE52\x80\x99s iPhone" in your question is not valid Unicode (there is an excess character 5) but this MAY work if you correct it.

1
  • I was having this same problem, but changing the iphone SSID fixed everything. Thanks Milliways
    – user43452
    Commented Mar 19, 2016 at 23:39
3

I had a look into how wpa_supplicant parses the configuration file, and it seems like it extracts the exact bytes between ssid=" and the last ". Escaped unicode (\u) and escaped non-ascii characters (\x) will not work.

In your case, you would have to specify your SSID like this:

    ssid="My Name’s iPhone"

Which would look like this in a hex editor:

09 73 73 69 64 3D 22 4D 79 20 4E 61 6D 65 E2 80 99 73 20 69 50 68 6F 6E 65 22

If you're using the output from iw (which escapes non-ascii characters), you can use Python to interpret and write the exact bytes to a file:

$ python
>>> ssid = 'My Name\xE5\x80\x99s iPhone'
>>> file = open('ssid', 'w')
>>> file.write(ssid)
>>> file.close()

Note that if you want to connect to an access point with the SSID A so called "SSID" it will work to enter it like this: ssid="A so called "SSID"". This is because wpa_supplicant will look for the bytes between the first and the last quote on a line.

One limitiation I found is that wpa_supplicant.conf will not accept newline characters (0x0A) in the SSID, even though it technically is possible.

1
  • 1
    I confirm this works. I wrote the text in unicode python string, though: ssid="\U0001F4A9" and then I wrote it with file.write(ssid.encode("UTF-8")). Read ssid file with xxd and copied the bytes without spaces. The line in my config now reads ssid=f09f92a9. Commented Aug 26, 2017 at 14:18
2

You have to rename you iPhone to remove any spaces... this can be done in Settings>General>About.

Once you have chosen a name without spaces you will be able to connect to a hot spot not issues.

2

You can take the ssid, in this case "My Name’s iPhone" (without the quotes), and convert to hex using https://www.browserling.com/tools/text-to-hex.

Take the result, in this case 4d 79 20 4e 61 6d 65 e2 80 99 73 20 69 50 68 6f 6e 65 and remove the spaces.

Or in bash

    $ echo -n $'My Name\xE2\x80\x99s iPhone' | od -t x1 -A n -w100000 | tr -d ' '
    4d79204e616d65e2809973206950686f6e65

Update /etc/wpa_supplicant/wpa_supplicant.conf:

network = {
    # Hex encoded 'My Name\xE2\x80\x99s iPhone', NO quotes in ssid=...
    ssid=4d79204e616d65e2809973206950686f6e65
    psk="your passphrase"
    key_mgmt=WPA-PSK
}

Then exit the editor, and in the terminal:

$ sudo ifdown wlan0
$ sudo ifup wlan0

If you have no errors, try to connect. Should work. Just make sure your ssid hex value is NOT in quotations, and doesn't contain spaces.

Cheers!

0

Your Answer

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

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