Change Photon SSID

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.

I have following the instructions:

I have installed the DFU driver (windows x64)

The prompt, etc.

When I write:

#echo -e -n "\x03Rad" > ssid_prefix (It's OK)

When I try to upload in the dfu:

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

I receive the following:

Copyright 2005-2008 Weston Schmidt, Harald Welte and OpenMoko Inc.
Copyright 2010-2012 Tormod Volden and Stefan Schmidt
This program is Free Software and has ABSOLUTELY NO WARRANTY
Please report bugs to dfu-util@lists.gnumonks.org

Filter on vendor = 0x2b04 product = 0xd006
Opening DFU capable USB device... ID 2b04:d006
Run-time device DFU version 011a
Found DFU: [2b04:d006] devnum=0, cfg=1, intf=0, alt=1, name="@DCT Flash   /0x000
00000/01*016Kg"
Claiming USB DFU Interface...
Setting Alternate Setting #1 ...
Determining device status: state = dfuIDLE, status = 0
dfuIDLE, continuing
DFU mode device DFU version 011a
Device returned transfer size 4096
No valid DFU suffix signature
#Warning: File has no DFU suffix
DfuSe interface name: "DCT Flash   "
Downloading to address = 0x00000722, size = 18
.
File downloaded successfully

When I reset the device and set it on listening mode it continues appearing the standard name.

I have tried with the lib… driver for photon dfu and with the windows… driver which Zadig propose. Both options generates the same. I think it is not related with it.

I have also tried to modify the serial following your example and the name of the serial has been modified to:

Photon--n "

So, it seems the name has been (-n "), the four characters (instead of 6) before “ABCDEF”. I have modified the echo serial line from:

echo -n "ABCDEF" > serial

to:

echo ABCDEF > serial

And when I try with:
dfu-util -d 2b04:d006 -a 1 -s 1852:6 -D serial

The SSID has changed to: Photon-ABCD

In the serial it seems that the maximum is 4 letters (unless in firmware 0.4.7). It is not a problem for me.

I do not know if something related with the SSID Prefix has changed @mdma

We are ending a product development and this is possible the last step. Any help will be hardly appreciated.

Thank you very much


@Moors7: in the future, PLEASE use some formatting in your posts. This one was really hard to read.

I have just achieved in a Ubuntu 14.04 machine without problems :smiley:

It would be great if you could complete @mdma instructions for Windows User.

Thanks

@mdma could you share the ETA when it will be available via code? We are planning to ship a 1000 particle based products to our customers and it’s going to be painful for us to rename each of them via DFU mode. I have the same scenario as @henkep

I just did this today with the code below.

System.set(SYSTEM_CONFIG_SOFTAP_PREFIX, "Gizmo");

Edit: removed the code to check the value was already set since @mdma mentioned that System.set does it by itself.

2 Likes

Do you need the check? System.set() checks if the data to be written is the same as what is already present, so it’s not causing flash wear.

I updated my post. Thanks.

I see that I can set the prefix and suffix manually right now with:

System.set(SYSTEM_CONFIG_SOFTAP_PREFIX, "hello");
System.set(SYSTEM_CONFIG_SOFTAP_SUFFIX, "hello");

However I was wondering how the factory suffix from the Photon was generated? Is this a part of the DeviceID (which is a lot more characters) that I can get with System.deviceID();?

I’d like to use mDNS / Bonjour to discover my Photon and was thinking to use the preconfigured suffix. However there is no System.get command in the firmware I think, since it seems commented out in the code: https://github.com/spark/firmware/blob/27dec24644c58935af728b00adb742f7d18a5b86/user/tests/wiring/api/system.cpp

The suffix is generated using the RNG build into the device.

So the best way to use a suffix which I can use in the mDNS name and the SSID name is to generate a new one myself? There is no getter function? I found the location in Flash, however that might be not so smart (I don’t know if that will change in future firmware releases).

I suppose this is the code you use to generate the number isn’t?

void random_code(uint8_t* dest, unsigned len) {
    unsigned value = HAL_RNG_GetRandomNumber();
    bytesToCode(value, (char*)dest, len);
}

That’s it - https://github.com/spark/firmware/blob/develop/hal/src/photon/softap.cpp#L757-L760

1 Like

@kasper Hi! I’ve been bumping into the same trick, wanting to save the SSID suffix to the phone client so after softap setup I could use that in mdns.

What did you end up doing? Reading ala ‘fetch_or_generate_device_code’ and using that in your setup? Would you mind sharing your solution?

@mterrill I didn’t implement it yet. It’s not my top priority and I decided to wait for an API implementation. However that is now already postponed to version 0.8.

@mdma any ETA on System.get ? Ideally would read back the SSID prefix/suffix in code for display on an OLED and would rather not hard-code it.