Change Photon SSID

Hi

Is there any way of changing the SSID of the Photons soft AP?

We are doing a demo and would very much like it to show our product name instead of Photon-XXX

//Henrik

1 Like

@henkep, I’m guessing that if you build locally, you can change these 2 lines.

I’m not sure if this is linked anywhere else or what implications would be by changing it.

There was a similar question before, maybe you can bump that one :wink:

1 Like

Photon memory map - https://github.com/spark/docs/issues/82 - shows where to change the SSID prefix, but doesn’t tell the format except it’s in softap.cpp. This must be FAQ and described somewhere but I couldn’t find it. So, this is how to do it.

$ echo “My Cool Prefix Here” | perl -ne ‘chop; printf("%c%s", length, $_)’ > ssid_prefix
$ dfu-util -d 1d50:607f -a 1 -s 1826 -D ssid_prefix

Note that the maximum length of the prefix is 25, and you need to match [SparkSetupCustomization sharedInstance].networkNamePrefix as well.

If you change the SSID, the mobile apps and the particle CLI won’t find the device, which would seem to reduce the usefulness of SoftAP mode.

Please tell me more about your use case for making the SoftAP mode name configurable.

Cheers,
mat.

How do you figure that?

If a Photon ever should be used commercially I don´t think many companies would like to use the Particle app or Particle-CLI for claiming devices. That is why Particle have released the libraries for iOS development and so on.

We are developing a commercial product and of course want our product name as the SSID, we also have our own iOS client that will do the claiming.

//Henrik

2 Likes

Hi @henkep, that makes perfect sense, sorry wasn’t thinking clearly, and thinking back to how things were for very early versions of the mobile SDK.

The format of the SSID in memory is

1-byte for the length of the SSID prefix
N-bytes for the SSID prefix.

This is something that we’ll add to firmware so the SSID prefix can be set from code.

1 Like

No worries. :smile:

Any ETA on when that firmware change can be in effect?

//Henrik

1 Like

Any news wrt this matter? This is something that is critical for the application I am currently working on as well.

There is a way to set the SSID using DFU on each photon - does that help as an interim solution until we add this to firmware?

@mdma Yes! :smile:

Ok, here’s the deets on setting the SSID. The SSID is made of two parts - a prefix and the device serial.

Setting the SSID Prefix

The SSID prefix can be set by writing the prefix value to the device.

First, create a file that contains the length of the prefix, followed by the prefix itself. In bash, this is done like this:

echo -e -n "\x03Rad" > ssid_prefix

The \x03 writes a literal value 3 (not the ASCII character ‘3’) to the file - 3 being the length of our prefix “Rad”. The value is specified on the command line as hex, so values over 10 start ‘A’, ‘B’ etc… The maximum allowed length of the prefix is 24.

(There’s no need to add a trailing ‘-’ to the prefix, the device automatically adds a ‘-’ between the prefix and the 6-digit serial.)

Then flash this to the device like this:

dfu-util -d 2b04:d006 -a 1 -s 1826 -D ssid_prefix

Next time the device enters softAP mode it will use the given prefix.

Setting the Device Serial

The Device Serial can be set by writing the 6-digit serial to the device.

First, create a file that contains the 6-digit device serial. In bash, this is done like this:

echo -n "ABCDEF" > serial

Then flash the serial to the device:

dfu-util -d 2b04:d006 -a 1 -s 1852:6 -D serial

Next time the device enters softAP mode, it will use the given serial.

5 Likes

Ok, so I’ve just done this on a Photon running 0.4.4.

Both flash operations completed correctly. But:

  1. The SSID change works, using your example ("\x3Rad"). But then I tried "\x7Example", and it reverts back to “Photon.”
  2. The device serial does update, but the broadcast AP only includes the first 4 characters of the 6-char serial.

In fact, perplexingly, nothing except "\x3Rad" works. I tried "\x3Exa", and it just comes out as “Photon”.

Not sure what to suggest. I just tried it here with a 12-character SSID and it worked. Double check the contents of the ssid_prefix file that’s produced with a hex editor (or use xxd to dump to binary) to be sure nothing spooky has crept in there.

Mine is a 13 byte file that looks like this:

0000000: 0c4d 6174 7468 6577 2d4d 444d 41         .Matthew-MDMA

Here you see the first byte is 0x0c - 12 - for the length of the prefix followed by the 12 prefix name characters.

1 Like

Yes! Ok, it seems the problem was integers < 10 in hex representation need to be specified using a leading 0 when saved to the SSID prefix file.

So, for example, "\x7Example" was getting saved as 7e78 616d ... instead of 0745 7861 .... The fix was saving the file as "\x07Example".

Which OS are you using? For me the single char was working on OSX…but so does 0 padded, so let’s stick to that. I’ll edit the original post.

Ubuntu 15.04

The problem was probably that the ‘E’ in ‘Example’ is a valid hex digit. Whereas the ‘M’ in ‘Matthew-MDMA’ is not.

So, \x7Example was getting interpreted as \x7E + xample, but since ‘M’ isn’t a hex digit (and likewise for ‘R’ in the ‘Rad’ example), the shell was stopping with the last valid hex character, to give \xb + Matthew-MMDA.

This only seems to interpolate the first 1 or 2 hex digits, so \xdeadbeef results in \xde + adbeef, and not the 32 bit value of 3,735,928,559.

4 Likes

You’re absolutely right! It did bother me that \x3Rad had worked (which was all I had to go on initially) but not others. I guess it really just means you definitely got pad those 0’s to make sure the integers get parsed correctly.