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 code for 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...
That will be a bit tougher: It needs to find the serial and must be cross-platform:
You cannot expect that the end-user is on Linux.
(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:
Code:
#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:
Code:
%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 code for 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...
That will be a bit tougher: It needs to find the serial and must be cross-platform:
You cannot expect that the end-user is on Linux.
Statistics: Posted by rin67630 — Fri Jul 05, 2024 6:26 pm