How to flash specific device out of multiple device network using single hex

Thread Starter

zazas321

Joined Nov 29, 2015
936
Hello. I have multiple ESP32 devices and I am using MQTT to communicate between the remote devices and the server. Each device has unique ID such as:
Code:
char DEVICE_ID[10] = "device1/";
Device ID can be device1, device2, device3 and etc.

After assigning a unique ID to specific device, I then assign topics to this particular device as following:
device1/sensor
device1/temperature
and etc..

This works but is not an ideal.. I use OTA to flash my remote devices and I have stored all my hexes on my Raspberry PI server.

The problem is that when I have multiple devices ( lets say 30), I need to save 30 hexes ( all the same except Unique ID ). That is very annoying since every time I modify a code I need resave all the hex files again and again and again!.

The solution I want to make is implement some sort of encoder or increment 4 switches. Based on their state, I know which ID I want to assign for this particular device.

Instead of assigning a unique device id like that:
Code:
char DEVICE_ID[10] = "device1/";
I could do something like:
Code:
char DEVICE_ID[10] = "device";
id_number = read button states here
strcat(DEVICE_ID,id_number);
strcat(DEVICE_ID,"/")
So once the devices are programmed atleast once, I can use a single hex and then modify what number they are assigned by using some sort of hardware method..

Could someone with a little bit more expertise share their knowledge with me? Is that a good idea to implement/use?
 
Top