Change Photon SSID

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.

I resorted to pulling a few of the more entropic parts of the device ID to generate a consistently-different 6-character suffix. Not perfect, but sufficient for my small fleet of photons:

String prefix = "Custom"
String suffix = "";

void setup() {
  System.set(SYSTEM_CONFIG_SOFTAP_PREFIX, prefix);
  String id = System.deviceID();
  suffix = id.substring(0,2) + id.substring(4,6) + id.substring(8,10);
  System.set(SYSTEM_CONFIG_SOFTAP_SUFFIX, suffix);
}

String getSSID() {
  return prefix + "-" + suffix;
}