Add command ``WebGetConfig <url>``

Add command ``WebGetConfig <url>`` if ``#define USE_WEBGETCONFIG`` is enabled to restore/init configuration from external webserver (#13034)
This commit is contained in:
Theo Arends 2021-09-02 10:46:29 +02:00
parent 4e835a63da
commit 1c4bca8a8c
4 changed files with 9 additions and 3 deletions

View File

@ -4,6 +4,9 @@ All notable changes to this project will be documented in this file.
## [Unreleased] - Development
## [9.5.0.8]
### Added
- Command ``WebGetConfig <url>`` if ``#define USE_WEBGETCONFIG`` is enabled to restore/init configuration from external webserver (#13034)
### Fixed
- ESP32 crash when PSRAM is absent and ``BOARD_HAS_PSRAM`` set (#13037)
- MQTT TLS related connection timing errors (#13033)

View File

@ -105,6 +105,7 @@ The latter links can be used for OTA upgrades too like ``OtaUrl http://ota.tasmo
- Command ``SetOption127 1`` to force Wi-Fi in no-sleep mode even if ``Sleep 0`` is not enabled
- Command ``SetOption128 0|1`` web referer check disabling HTTP API commands if set to 0. Default set to 1 for backward compatibility [#12828](https://github.com/arendst/Tasmota/issues/12828)
- Command ``SetSensor1..127 0|1`` to globally disable individual sensor driver
- Command ``WebGetConfig <url>`` if ``#define USE_WEBGETCONFIG`` is enabled to restore/init configuration from external webserver [#13034](https://github.com/arendst/Tasmota/issues/13034)
- Neopool commands ``NPPHRes``, ``NPCLRes`` and ``NPIonRes`` [#12813](https://github.com/arendst/Tasmota/issues/12813)
- Support for second DNS server
- Support for (Yeelight) Mi Desk Pro using binary tasmota32solo1.bin

View File

@ -461,6 +461,7 @@
// #define USE_JAVASCRIPT_ES6 // Enable ECMAScript6 syntax using less JavaScript code bytes (fails on IE11)
#define USE_ENHANCED_GUI_WIFI_SCAN // Enable Wi-Fi scan output with BSSID (+0k5 code)
// #define USE_WEBSEND_RESPONSE // Enable command WebSend response message (+1k code)
// #define USE_WEBGETCONFIG // Enable restoring config from external webserver (+0k6)
#define USE_EMULATION_HUE // Enable Hue Bridge emulation for Alexa (+14k code, +2k mem common)
#define USE_EMULATION_WEMO // Enable Belkin WeMo emulation for Alexa (+6k code, +2k mem common)
// #define USE_CCLOADER // Enable CCLoader FW upgrade tool (for CC25xx devices)

View File

@ -3124,7 +3124,7 @@ int WebGetConfig(char *buffer)
RemoveSpace(buffer); // host = |[192.168.178.86:80,admin:joker|
String url = ResolveToken(buffer);
DEBUG_CORE_LOG(PSTR("WEB: Config Uri |%s|"), url.c_str());
DEBUG_CORE_LOG(PSTR("WEB: Config Uri '%s'"), url.c_str());
WiFiClient http_client;
HTTPClient http;
@ -3137,7 +3137,7 @@ int WebGetConfig(char *buffer)
int len = http.getSize();
if ((len <= sizeof(TSettings)) && SettingsBufferAlloc()) {
uint8_t *buff = settings_buffer;
if (len==-1) len = sizeof(TSettings);
if (len == -1) { len = sizeof(TSettings); }
while (http.connected() && (len > 0)) {
size_t size = stream->available();
if (size) {
@ -3177,7 +3177,6 @@ int WebGetConfig(char *buffer)
}
#endif // USE_WEBGETCONFIG
bool JsonWebColor(const char* dataBuf)
{
// Default (Dark theme)
@ -3337,6 +3336,8 @@ void CmndWebSend(void)
#ifdef USE_WEBGETCONFIG
void CmndWebGetConfig(void)
{
// WebGetConfig http://myserver:8000/tasmota/conf/%id%.dmp where %id% is expanded to device mac address
// WebGetConfig http://myserver:8000/tasmota/conf/Config_demo_9.5.0.8.dmp
if (XdrvMailbox.data_len > 0) {
uint32_t result = WebGetConfig(XdrvMailbox.data);
char stemp1[20];