A new way to distribute an ESP solution without requiring from the user to compile...
Posted: Fri Jul 05, 2024 4:00 pm
Following problem was to solve:
Distributing an ESP32 or ESP8266 solution without requiring the user to compile a version with his own credentials.
I don't want use the usual way of a temporary website to enter the credentials.
That is a very clumsy solution requiring a lot of code and program space (all the HTML code must be in program space)
Event for the user it is not straigt forward...
SmartConfig is a nice solution, but only provides SSID and Password.
I need at least: SSID, WiFiPassword, Device Name, Cloud Account, Device Credentials.
(the rest of the options and parameters can then be gathered from the cloud)
The solution is quite simple, elegant and requires practically no additional ESP code, no library and nothing to install on the user's side.
(excepted Python, which he needs anyway to upload the binary).
In your ESP code, you define placeholders for your credentials and make them long enough to potentially fit any user's content.
Here:
The placeholders MUST match exactly those defined in the provided PythonPatcher.py Python script.
You then compile your code and distribute the raw binary together with PythonPatcher.py
The user places the two files on his desktop and runs the PythonPatcher.py.
The script will ask for the file to patch, and the credentials and patch the binary accordingly, saving the patched file on the destop too:
You then upload the patched file to the ESP and you are online !
Soo easy...
Caveats:
This solution is not suitable to distribute an ESP device including code, the user must patch and upload.
You must take care to use the credentials only at one place of your code (if you need it a several places, copy it to a String-variable).
In my example, the placeholders are 16 chars long, the placeholder for WiFI password is 24 chars long
You might use longer strings in your code and match them in the PythonPacher.
You might adapt the python code for more/less credentials
The python Script is on Github:
https://github.com/rin67630/ESP_Binary_ ... Patcher.py
Credit for the idea to patch the binary: inq720.
Thank you for that brilliant idea!
Next step will be to include the upload from esptool.py in the patcher, so it gets even easier...
Distributing an ESP32 or ESP8266 solution without requiring the user to compile a version with his own credentials.
I don't want use the usual way of a temporary website to enter the credentials.
That is a very clumsy solution requiring a lot of code and program space (all the HTML code must be in program space)
Event for the user it is not straigt forward...
SmartConfig is a nice solution, but only provides SSID and Password.
I need at least: SSID, WiFiPassword, Device Name, Cloud Account, Device Credentials.
(the rest of the options and parameters can then be gathered from the cloud)
The solution is quite simple, elegant and requires practically no additional ESP code, no library and nothing to install on the user's side.
(excepted Python, which he needs anyway to upload the binary).
In your ESP code, you define placeholders for your credentials and make them long enough to potentially fit any user's content.
Here:
- #define DEVICE_NAME "DEVCNAME "
- #define WIFI_SSID "WIFISSID "
- #define WIFI_PASS "WIFIPASS "
- #define THINGER_USERNAME "CLOUDNAM "
- #define DEVICE_CREDENTIALS "DEVCCRED "
You then compile your code and distribute the raw binary together with PythonPatcher.py
The user places the two files on his desktop and runs the PythonPatcher.py.
The script will ask for the file to patch, and the credentials and patch the binary accordingly, saving the patched file on the destop too:
- %Run PythonPatcher.py
- Enter binfile to patch:PythonTest.bin
- Enter SSID:GW-****
- Enter Password:*******
- Enter Device Name:Steroids
- Enter Cloud User Name:Thing4
- Enter Device Credentials:*******
- File PythonTest_patched.bin saved
Soo easy...
Caveats:
This solution is not suitable to distribute an ESP device including code, the user must patch and upload.
You must take care to use the credentials only at one place of your code (if you need it a several places, copy it to a String-variable).
In my example, the placeholders are 16 chars long, the placeholder for WiFI password is 24 chars long
You might use longer strings in your code and match them in the PythonPacher.
You might adapt the python code for more/less credentials
The python Script is on Github:
https://github.com/rin67630/ESP_Binary_ ... Patcher.py
Credit for the idea to patch the binary: inq720.
Thank you for that brilliant idea!
Next step will be to include the upload from esptool.py in the patcher, so it gets even easier...