Merge remote-tracking branch 'origin/development' into armtronix

This commit is contained in:
wvdv2002 2018-11-16 09:31:58 +01:00
commit 7b6553d116
86 changed files with 2550 additions and 1636 deletions

View File

@ -1,5 +1,17 @@
/* 6.3.0.6 20181110 /* 6.3.0.8 20181115
* Stop enforcing flashmode dout. Still mandatory but this a chk for possible future flash corruption
*
* 6.3.0.7 20181111
* Fix wifi connection errors using wifi disconnect and ESP.reset instead of ESP.restart
* Fix Sonoff Pow R2 and Sonoff S31 Serial interface hang caused by Sonoff Basic R2 driver delay implementation (and possibly core bug)
* Change command WebSend Host header field from IP address to hostname (#4331)
* Add to command WebSend option to send a direct path when command starts with a slash (#4329)
* Consolidate LTrim into Trim
* Increase log buffer size from 512 to 520 to accommodate http sensor data (#4354)
*
* 6.3.0.6 20181110
* Change GUI Configure Module by using AJAX for data fetch to cut page size (and memory use) by 40% * Change GUI Configure Module by using AJAX for data fetch to cut page size (and memory use) by 40%
* In case of web page errors clear your browser cache or do Page Reload (F5 or Ctrl+R)
* *
* 6.3.0.5 20181107 * 6.3.0.5 20181107
* Add code image and optional commit number to version * Add code image and optional commit number to version

View File

@ -46,7 +46,7 @@ void ICACHE_RAM_ATTR timer1_isr_handler(void *para){
} }
} }
void ICACHE_RAM_ATTR timer1_isr_init(){ void ICACHE_RAM_ATTR timer1_isr_init(void){
ETS_FRC_TIMER1_INTR_ATTACH(timer1_isr_handler, NULL); ETS_FRC_TIMER1_INTR_ATTACH(timer1_isr_handler, NULL);
} }
@ -55,7 +55,7 @@ void timer1_attachInterrupt(timercallback userFunc) {
ETS_FRC1_INTR_ENABLE(); ETS_FRC1_INTR_ENABLE();
} }
void ICACHE_RAM_ATTR timer1_detachInterrupt() { void ICACHE_RAM_ATTR timer1_detachInterrupt(void) {
timer1_user_cb = 0; timer1_user_cb = 0;
TEIE &= ~TEIE1;//edge int disable TEIE &= ~TEIE1;//edge int disable
ETS_FRC1_INTR_DISABLE(); ETS_FRC1_INTR_DISABLE();
@ -71,7 +71,7 @@ void ICACHE_RAM_ATTR timer1_write(uint32_t ticks){
if ((T1C & (1 << TCIT)) == 0) TEIE |= TEIE1;//edge int enable if ((T1C & (1 << TCIT)) == 0) TEIE |= TEIE1;//edge int enable
} }
void ICACHE_RAM_ATTR timer1_disable(){ void ICACHE_RAM_ATTR timer1_disable(void){
T1C = 0; T1C = 0;
T1I = 0; T1I = 0;
} }
@ -92,7 +92,7 @@ void ICACHE_RAM_ATTR timer0_isr_handler(void* para){
} }
} }
void timer0_isr_init(){ void timer0_isr_init(void){
ETS_CCOMPARE0_INTR_ATTACH(timer0_isr_handler, NULL); ETS_CCOMPARE0_INTR_ATTACH(timer0_isr_handler, NULL);
} }
@ -101,7 +101,7 @@ void timer0_attachInterrupt(timercallback userFunc) {
ETS_CCOMPARE0_ENABLE(); ETS_CCOMPARE0_ENABLE();
} }
void ICACHE_RAM_ATTR timer0_detachInterrupt() { void ICACHE_RAM_ATTR timer0_detachInterrupt(void) {
timer0_user_cb = NULL; timer0_user_cb = NULL;
ETS_CCOMPARE0_DISABLE(); ETS_CCOMPARE0_DISABLE();
} }

View File

@ -188,7 +188,7 @@ extern void ICACHE_RAM_ATTR __detachInterrupt(uint8_t pin) {
} }
} }
void initPins() { void initPins(void) {
//Disable UART interrupts //Disable UART interrupts
system_set_os_print(0); system_set_os_print(0);
U0IE = 0; U0IE = 0;

View File

@ -84,7 +84,7 @@ uint32_t pwm_get_mask(uint16_t value)
return mask; return mask;
} }
void prep_pwm_steps() void prep_pwm_steps(void)
{ {
if(pwm_mask == 0) { if(pwm_mask == 0) {
return; return;
@ -123,7 +123,7 @@ void prep_pwm_steps()
pwm_steps_changed = 1; pwm_steps_changed = 1;
} }
void ICACHE_RAM_ATTR pwm_timer_isr() //103-138 void ICACHE_RAM_ATTR pwm_timer_isr(void) //103-138
{ {
struct pwm_isr_table *table = &(_pwm_isr_data.tables[_pwm_isr_data.active]); struct pwm_isr_table *table = &(_pwm_isr_data.tables[_pwm_isr_data.active]);
static uint8_t current_step = 0; static uint8_t current_step = 0;
@ -160,7 +160,7 @@ void ICACHE_RAM_ATTR pwm_timer_isr() //103-138
TEIE |= TEIE1;//13 TEIE |= TEIE1;//13
} }
void pwm_start_timer() void pwm_start_timer(void)
{ {
timer1_disable(); timer1_disable();
ETS_FRC_TIMER1_INTR_ATTACH(NULL, NULL); ETS_FRC_TIMER1_INTR_ATTACH(NULL, NULL);

View File

@ -68,7 +68,7 @@ typedef union { // Restricted by MISRA-C Rule 18.4 bu
uint32_t time_append_timezone : 1; // bit 2 (v6.2.1.2) uint32_t time_append_timezone : 1; // bit 2 (v6.2.1.2)
uint32_t gui_hostname_ip : 1; // bit 3 (v6.2.1.20) uint32_t gui_hostname_ip : 1; // bit 3 (v6.2.1.20)
uint32_t tuya_apply_o20 : 1; // bit 4 (v6.3.0.4) uint32_t tuya_apply_o20 : 1; // bit 4 (v6.3.0.4)
uint32_t spare05 : 1; uint32_t hass_short_discovery_msg : 1; // bit 5 (vTBD)
uint32_t spare06 : 1; uint32_t spare06 : 1;
uint32_t spare07 : 1; uint32_t spare07 : 1;
uint32_t spare08 : 1; uint32_t spare08 : 1;

View File

@ -69,7 +69,7 @@
uint32_t rtc_settings_crc = 0; uint32_t rtc_settings_crc = 0;
uint32_t GetRtcSettingsCrc() uint32_t GetRtcSettingsCrc(void)
{ {
uint32_t crc = 0; uint32_t crc = 0;
uint8_t *bytes = (uint8_t*)&RtcSettings; uint8_t *bytes = (uint8_t*)&RtcSettings;
@ -80,7 +80,7 @@ uint32_t GetRtcSettingsCrc()
return crc; return crc;
} }
void RtcSettingsSave() void RtcSettingsSave(void)
{ {
if (GetRtcSettingsCrc() != rtc_settings_crc) { if (GetRtcSettingsCrc() != rtc_settings_crc) {
RtcSettings.valid = RTC_MEM_VALID; RtcSettings.valid = RTC_MEM_VALID;
@ -89,7 +89,7 @@ void RtcSettingsSave()
} }
} }
void RtcSettingsLoad() void RtcSettingsLoad(void)
{ {
ESP.rtcUserMemoryRead(100, (uint32_t*)&RtcSettings, sizeof(RTCMEM)); // 0x290 ESP.rtcUserMemoryRead(100, (uint32_t*)&RtcSettings, sizeof(RTCMEM)); // 0x290
if (RtcSettings.valid != RTC_MEM_VALID) { if (RtcSettings.valid != RTC_MEM_VALID) {
@ -106,7 +106,7 @@ void RtcSettingsLoad()
rtc_settings_crc = GetRtcSettingsCrc(); rtc_settings_crc = GetRtcSettingsCrc();
} }
boolean RtcSettingsValid() boolean RtcSettingsValid(void)
{ {
return (RTC_MEM_VALID == RtcSettings.valid); return (RTC_MEM_VALID == RtcSettings.valid);
} }
@ -115,7 +115,7 @@ boolean RtcSettingsValid()
uint32_t rtc_reboot_crc = 0; uint32_t rtc_reboot_crc = 0;
uint32_t GetRtcRebootCrc() uint32_t GetRtcRebootCrc(void)
{ {
uint32_t crc = 0; uint32_t crc = 0;
uint8_t *bytes = (uint8_t*)&RtcReboot; uint8_t *bytes = (uint8_t*)&RtcReboot;
@ -126,7 +126,7 @@ uint32_t GetRtcRebootCrc()
return crc; return crc;
} }
void RtcRebootSave() void RtcRebootSave(void)
{ {
if (GetRtcRebootCrc() != rtc_reboot_crc) { if (GetRtcRebootCrc() != rtc_reboot_crc) {
RtcReboot.valid = RTC_MEM_VALID; RtcReboot.valid = RTC_MEM_VALID;
@ -135,7 +135,7 @@ void RtcRebootSave()
} }
} }
void RtcRebootLoad() void RtcRebootLoad(void)
{ {
ESP.rtcUserMemoryRead(100 - sizeof(RTCRBT), (uint32_t*)&RtcReboot, sizeof(RTCRBT)); // 0x280 ESP.rtcUserMemoryRead(100 - sizeof(RTCRBT), (uint32_t*)&RtcReboot, sizeof(RTCRBT)); // 0x280
if (RtcReboot.valid != RTC_MEM_VALID) { if (RtcReboot.valid != RTC_MEM_VALID) {
@ -147,7 +147,7 @@ void RtcRebootLoad()
rtc_reboot_crc = GetRtcRebootCrc(); rtc_reboot_crc = GetRtcRebootCrc();
} }
boolean RtcRebootValid() boolean RtcRebootValid(void)
{ {
return (RTC_MEM_VALID == RtcReboot.valid); return (RTC_MEM_VALID == RtcReboot.valid);
} }
@ -179,7 +179,7 @@ uint8_t *settings_buffer = NULL;
/* /*
* Based on cores/esp8266/Updater.cpp * Based on cores/esp8266/Updater.cpp
*/ */
void SetFlashModeDout() void SetFlashModeDout(void)
{ {
uint8_t *_buffer; uint8_t *_buffer;
uint32_t address; uint32_t address;
@ -198,7 +198,7 @@ void SetFlashModeDout()
delete[] _buffer; delete[] _buffer;
} }
void SettingsBufferFree() void SettingsBufferFree(void)
{ {
if (settings_buffer != NULL) { if (settings_buffer != NULL) {
free(settings_buffer); free(settings_buffer);
@ -206,7 +206,7 @@ void SettingsBufferFree()
} }
} }
bool SettingsBufferAlloc() bool SettingsBufferAlloc(void)
{ {
SettingsBufferFree(); SettingsBufferFree();
if (!(settings_buffer = (uint8_t *)malloc(sizeof(Settings)))) { if (!(settings_buffer = (uint8_t *)malloc(sizeof(Settings)))) {
@ -216,7 +216,7 @@ bool SettingsBufferAlloc()
return true; return true;
} }
uint16_t GetSettingsCrc() uint16_t GetSettingsCrc(void)
{ {
uint16_t crc = 0; uint16_t crc = 0;
uint8_t *bytes = (uint8_t*)&Settings; uint8_t *bytes = (uint8_t*)&Settings;
@ -227,7 +227,7 @@ uint16_t GetSettingsCrc()
return crc; return crc;
} }
void SettingsSaveAll() void SettingsSaveAll(void)
{ {
if (Settings.flag.save_state) { if (Settings.flag.save_state) {
Settings.power = power; Settings.power = power;
@ -242,7 +242,7 @@ void SettingsSaveAll()
* Config Save - Save parameters to Flash ONLY if any parameter has changed * Config Save - Save parameters to Flash ONLY if any parameter has changed
\*********************************************************************************************/ \*********************************************************************************************/
uint32_t GetSettingsAddress() uint32_t GetSettingsAddress(void)
{ {
return settings_location * SPI_FLASH_SEC_SIZE; return settings_location * SPI_FLASH_SEC_SIZE;
} }
@ -294,7 +294,7 @@ void SettingsSave(byte rotate)
RtcSettingsSave(); RtcSettingsSave();
} }
void SettingsLoad() void SettingsLoad(void)
{ {
/* Load configuration from eeprom or one of 7 slots below if first load does not stop_flash_rotate /* Load configuration from eeprom or one of 7 slots below if first load does not stop_flash_rotate
*/ */
@ -377,7 +377,7 @@ bool SettingsEraseConfig(void) {
return true; return true;
} }
void SettingsSdkErase() void SettingsSdkErase(void)
{ {
WiFi.disconnect(true); // Delete SDK wifi config WiFi.disconnect(true); // Delete SDK wifi config
SettingsErase(1); SettingsErase(1);
@ -387,7 +387,7 @@ void SettingsSdkErase()
/********************************************************************************************/ /********************************************************************************************/
void SettingsDefault() void SettingsDefault(void)
{ {
AddLog_P(LOG_LEVEL_NONE, PSTR(D_LOG_CONFIG D_USE_DEFAULTS)); AddLog_P(LOG_LEVEL_NONE, PSTR(D_LOG_CONFIG D_USE_DEFAULTS));
SettingsDefaultSet1(); SettingsDefaultSet1();
@ -395,7 +395,7 @@ void SettingsDefault()
SettingsSave(2); SettingsSave(2);
} }
void SettingsDefaultSet1() void SettingsDefaultSet1(void)
{ {
memset(&Settings, 0x00, sizeof(SYSCFG)); memset(&Settings, 0x00, sizeof(SYSCFG));
@ -407,7 +407,7 @@ void SettingsDefaultSet1()
// Settings.cfg_crc = 0; // Settings.cfg_crc = 0;
} }
void SettingsDefaultSet2() void SettingsDefaultSet2(void)
{ {
memset((char*)&Settings +16, 0x00, sizeof(SYSCFG) -16); memset((char*)&Settings +16, 0x00, sizeof(SYSCFG) -16);
@ -641,7 +641,7 @@ void SettingsDefaultSet2()
/********************************************************************************************/ /********************************************************************************************/
void SettingsDefaultSet_5_8_1() void SettingsDefaultSet_5_8_1(void)
{ {
// Settings.flag.ws_clock_reverse = 0; // Settings.flag.ws_clock_reverse = 0;
Settings.ws_width[WS_SECOND] = 1; Settings.ws_width[WS_SECOND] = 1;
@ -658,7 +658,7 @@ void SettingsDefaultSet_5_8_1()
Settings.ws_color[WS_HOUR][WS_BLUE] = 0; Settings.ws_color[WS_HOUR][WS_BLUE] = 0;
} }
void SettingsDefaultSet_5_10_1() void SettingsDefaultSet_5_10_1(void)
{ {
Settings.display_model = 0; Settings.display_model = 0;
Settings.display_mode = 1; Settings.display_mode = 1;
@ -680,7 +680,7 @@ void SettingsDefaultSet_5_10_1()
Settings.display_address[7] = MTX_ADDRESS8; Settings.display_address[7] = MTX_ADDRESS8;
} }
void SettingsResetStd() void SettingsResetStd(void)
{ {
Settings.tflag[0].hemis = TIME_STD_HEMISPHERE; Settings.tflag[0].hemis = TIME_STD_HEMISPHERE;
Settings.tflag[0].week = TIME_STD_WEEK; Settings.tflag[0].week = TIME_STD_WEEK;
@ -690,7 +690,7 @@ void SettingsResetStd()
Settings.toffset[0] = TIME_STD_OFFSET; Settings.toffset[0] = TIME_STD_OFFSET;
} }
void SettingsResetDst() void SettingsResetDst(void)
{ {
Settings.tflag[1].hemis = TIME_DST_HEMISPHERE; Settings.tflag[1].hemis = TIME_DST_HEMISPHERE;
Settings.tflag[1].week = TIME_DST_WEEK; Settings.tflag[1].week = TIME_DST_WEEK;
@ -700,7 +700,7 @@ void SettingsResetDst()
Settings.toffset[1] = TIME_DST_OFFSET; Settings.toffset[1] = TIME_DST_OFFSET;
} }
void SettingsDefaultSet_5_13_1c() void SettingsDefaultSet_5_13_1c(void)
{ {
SettingsResetStd(); SettingsResetStd();
SettingsResetDst(); SettingsResetDst();
@ -708,7 +708,7 @@ void SettingsDefaultSet_5_13_1c()
/********************************************************************************************/ /********************************************************************************************/
void SettingsDelta() void SettingsDelta(void)
{ {
if (Settings.version != VERSION) { // Fix version dependent changes if (Settings.version != VERSION) { // Fix version dependent changes

View File

@ -119,7 +119,7 @@ typedef unsigned long power_t; // Power (Relay) type
#define INPUT_BUFFER_SIZE 520 // Max number of characters in (serial and http) command buffer #define INPUT_BUFFER_SIZE 520 // Max number of characters in (serial and http) command buffer
#define CMDSZ 24 // Max number of characters in command #define CMDSZ 24 // Max number of characters in command
#define TOPSZ 100 // Max number of characters in topic string #define TOPSZ 100 // Max number of characters in topic string
#define LOGSZ 512 // Max number of characters in log #define LOGSZ 520 // Max number of characters in log
#define MIN_MESSZ 893 // Min number of characters in MQTT message #define MIN_MESSZ 893 // Min number of characters in MQTT message
#define SENSOR_MAX_MISS 5 // Max number of missed sensor reads before deciding it's offline #define SENSOR_MAX_MISS 5 // Max number of missed sensor reads before deciding it's offline

View File

@ -378,7 +378,7 @@ void SetLedPower(uint8_t state)
digitalWrite(pin[GPIO_LED1], (bitRead(led_inverted, 0)) ? !state : state); digitalWrite(pin[GPIO_LED1], (bitRead(led_inverted, 0)) ? !state : state);
} }
uint8_t GetFanspeed() uint8_t GetFanspeed(void)
{ {
uint8_t fanspeed = 0; uint8_t fanspeed = 0;
@ -531,7 +531,7 @@ void MqttDataHandler(char* topic, byte* data, unsigned int data_len)
char *blcommand = strtok(dataBuf, ";"); char *blcommand = strtok(dataBuf, ";");
while ((blcommand != NULL) && (backlog_index != bl_pointer)) { while ((blcommand != NULL) && (backlog_index != bl_pointer)) {
while(true) { while(true) {
blcommand = LTrim(blcommand); blcommand = Trim(blcommand);
if (!strncasecmp_P(blcommand, PSTR(D_CMND_BACKLOG), strlen(D_CMND_BACKLOG))) { if (!strncasecmp_P(blcommand, PSTR(D_CMND_BACKLOG), strlen(D_CMND_BACKLOG))) {
blcommand += strlen(D_CMND_BACKLOG); // Skip unnecessary command Backlog blcommand += strlen(D_CMND_BACKLOG); // Skip unnecessary command Backlog
} else { } else {
@ -1224,9 +1224,9 @@ void MqttDataHandler(char* topic, byte* data, unsigned int data_len)
if (5 == tpos) { Settings.tflag[ts].hour = (value < 0) ? 0 : (value > 23) ? 23 : value; } if (5 == tpos) { Settings.tflag[ts].hour = (value < 0) ? 0 : (value > 23) ? 23 : value; }
if (6 == tpos) { Settings.toffset[ts] = (value < -900) ? -900 : (value > 900) ? 900 : value; } if (6 == tpos) { Settings.toffset[ts] = (value < -900) ? -900 : (value > 900) ? 900 : value; }
} }
p = LTrim(p); // Skip spaces p = Trim(p); // Skip spaces
if (tpos && (*p == ',')) { p++; } // Skip separator if (tpos && (*p == ',')) { p++; } // Skip separator
p = LTrim(p); // Skip spaces p = Trim(p); // Skip spaces
q = p; // Reset any value entered flag q = p; // Reset any value entered flag
value = strtol(p, &p, 10); value = strtol(p, &p, 10);
tpos++; // Next parameter tpos++; // Next parameter
@ -1426,7 +1426,7 @@ void ExecuteCommandPower(byte device, byte state, int source)
if (publish_power) MqttPublishPowerState(device); if (publish_power) MqttPublishPowerState(device);
} }
void StopAllPowerBlink() void StopAllPowerBlink(void)
{ {
power_t mask; power_t mask;
@ -1571,7 +1571,7 @@ void PublishStatus(uint8_t payload)
} }
void MqttShowPWMState() void MqttShowPWMState(void)
{ {
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s\"" D_CMND_PWM "\":{"), mqtt_data); snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s\"" D_CMND_PWM "\":{"), mqtt_data);
bool first = true; bool first = true;
@ -1584,7 +1584,7 @@ void MqttShowPWMState()
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s}"), mqtt_data); snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s}"), mqtt_data);
} }
void MqttShowState() void MqttShowState(void)
{ {
char stemp1[33]; char stemp1[33];
@ -1615,7 +1615,7 @@ void MqttShowState()
mqtt_data, Settings.sta_active +1, Settings.sta_ssid[Settings.sta_active], WiFi.BSSIDstr().c_str(), WiFi.channel(), WifiGetRssiAsQuality(WiFi.RSSI())); mqtt_data, Settings.sta_active +1, Settings.sta_ssid[Settings.sta_active], WiFi.BSSIDstr().c_str(), WiFi.channel(), WifiGetRssiAsQuality(WiFi.RSSI()));
} }
boolean MqttShowSensor() boolean MqttShowSensor(void)
{ {
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s{\"" D_JSON_TIME "\":\"%s\""), mqtt_data, GetDateAndTime(DT_LOCAL).c_str()); snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s{\"" D_JSON_TIME "\":\"%s\""), mqtt_data, GetDateAndTime(DT_LOCAL).c_str());
int json_data_start = strlen(mqtt_data); int json_data_start = strlen(mqtt_data);
@ -1645,7 +1645,7 @@ boolean MqttShowSensor()
/********************************************************************************************/ /********************************************************************************************/
void PerformEverySecond() void PerformEverySecond(void)
{ {
uptime++; uptime++;
@ -1718,7 +1718,7 @@ void PerformEverySecond()
* Button handler with single press only or multi-press and hold on all buttons * Button handler with single press only or multi-press and hold on all buttons
\*********************************************************************************************/ \*********************************************************************************************/
void ButtonHandler() void ButtonHandler(void)
{ {
uint8_t button = NOT_PRESSED; uint8_t button = NOT_PRESSED;
uint8_t button_present = 0; uint8_t button_present = 0;
@ -1956,7 +1956,7 @@ void SwitchHandler(byte mode)
* Every 0.1 second * Every 0.1 second
\*-------------------------------------------------------------------------------------------*/ \*-------------------------------------------------------------------------------------------*/
void Every100mSeconds() void Every100mSeconds(void)
{ {
// As the max amount of sleep = 250 mSec this loop will shift in time... // As the max amount of sleep = 250 mSec this loop will shift in time...
power_t power_now; power_t power_now;
@ -2005,7 +2005,7 @@ void Every100mSeconds()
* Every 0.25 second * Every 0.25 second
\*-------------------------------------------------------------------------------------------*/ \*-------------------------------------------------------------------------------------------*/
void Every250mSeconds() void Every250mSeconds(void)
{ {
// As the max amount of sleep = 250 mSec this loop should always be taken... // As the max amount of sleep = 250 mSec this loop should always be taken...
@ -2117,7 +2117,7 @@ void Every250mSeconds()
if (90 == ota_state_flag) { // Allow MQTT to reconnect if (90 == ota_state_flag) { // Allow MQTT to reconnect
ota_state_flag = 0; ota_state_flag = 0;
if (ota_result) { if (ota_result) {
SetFlashModeDout(); // Force DOUT for both ESP8266 and ESP8285 // SetFlashModeDout(); // Force DOUT for both ESP8266 and ESP8285
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR(D_JSON_SUCCESSFUL ". " D_JSON_RESTARTING)); snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR(D_JSON_SUCCESSFUL ". " D_JSON_RESTARTING));
} else { } else {
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR(D_JSON_FAILED " %s"), ESPhttpUpdate.getLastErrorString().c_str()); snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR(D_JSON_FAILED " %s"), ESPhttpUpdate.getLastErrorString().c_str());
@ -2201,7 +2201,7 @@ void Every250mSeconds()
bool arduino_ota_triggered = false; bool arduino_ota_triggered = false;
uint16_t arduino_ota_progress_dot_count = 0; uint16_t arduino_ota_progress_dot_count = 0;
void ArduinoOTAInit() void ArduinoOTAInit(void)
{ {
ArduinoOTA.setPort(8266); ArduinoOTA.setPort(8266);
ArduinoOTA.setHostname(Settings.hostname); ArduinoOTA.setHostname(Settings.hostname);
@ -2270,7 +2270,7 @@ void ArduinoOTAInit()
/********************************************************************************************/ /********************************************************************************************/
void SerialInput() void SerialInput(void)
{ {
while (Serial.available()) { while (Serial.available()) {
yield(); yield();
@ -2398,7 +2398,7 @@ void GpioSwitchPinMode(uint8_t index)
} }
} }
void GpioInit() void GpioInit(void)
{ {
uint8_t mpin; uint8_t mpin;
uint8_t key_no_pullup = 0; uint8_t key_no_pullup = 0;
@ -2599,7 +2599,7 @@ extern "C" {
extern struct rst_info resetInfo; extern struct rst_info resetInfo;
} }
void setup() void setup(void)
{ {
byte idx; byte idx;
@ -2751,7 +2751,7 @@ void setup()
XsnsCall(FUNC_INIT); XsnsCall(FUNC_INIT);
} }
void loop() void loop(void)
{ {
XdrvCall(FUNC_LOOP); XdrvCall(FUNC_LOOP);

View File

@ -20,7 +20,7 @@
#ifndef _SONOFF_VERSION_H_ #ifndef _SONOFF_VERSION_H_
#define _SONOFF_VERSION_H_ #define _SONOFF_VERSION_H_
#define VERSION 0x06030006 #define VERSION 0x06030008
#define D_PROGRAMNAME "Sonoff-Tasmota" #define D_PROGRAMNAME "Sonoff-Tasmota"
#define D_AUTHOR "Theo Arends" #define D_AUTHOR "Theo Arends"

View File

@ -39,7 +39,7 @@ byte oswatch_blocked_loop = 0;
bool knx_started = false; bool knx_started = false;
#endif // USE_KNX #endif // USE_KNX
void OsWatchTicker() void OsWatchTicker(void)
{ {
unsigned long t = millis(); unsigned long t = millis();
unsigned long last_run = abs(t - oswatch_last_loop_time); unsigned long last_run = abs(t - oswatch_last_loop_time);
@ -57,7 +57,7 @@ void OsWatchTicker()
} }
} }
void OsWatchInit() void OsWatchInit(void)
{ {
oswatch_blocked_loop = RtcSettings.oswatch_blocked_loop; oswatch_blocked_loop = RtcSettings.oswatch_blocked_loop;
RtcSettings.oswatch_blocked_loop = 0; RtcSettings.oswatch_blocked_loop = 0;
@ -65,13 +65,13 @@ void OsWatchInit()
tickerOSWatch.attach_ms(((OSWATCH_RESET_TIME / 3) * 1000), OsWatchTicker); tickerOSWatch.attach_ms(((OSWATCH_RESET_TIME / 3) * 1000), OsWatchTicker);
} }
void OsWatchLoop() void OsWatchLoop(void)
{ {
oswatch_last_loop_time = millis(); oswatch_last_loop_time = millis();
// while(1) delay(1000); // this will trigger the os watch // while(1) delay(1000); // this will trigger the os watch
} }
String GetResetReason() String GetResetReason(void)
{ {
char buff[32]; char buff[32];
if (oswatch_blocked_loop) { if (oswatch_blocked_loop) {
@ -82,7 +82,7 @@ String GetResetReason()
} }
} }
boolean OsWatchBlockedLoop() boolean OsWatchBlockedLoop(void)
{ {
return oswatch_blocked_loop; return oswatch_blocked_loop;
} }
@ -290,6 +290,7 @@ char* UpperCase_P(char* dest, const char* source)
return dest; return dest;
} }
/*
char* LTrim(char* p) char* LTrim(char* p)
{ {
while ((*p != '\0') && (isblank(*p))) { while ((*p != '\0') && (isblank(*p))) {
@ -308,14 +309,13 @@ char* RTrim(char* p)
*q = '\0'; *q = '\0';
return p; return p;
} }
*/
char* Trim(char* p) char* Trim(char* p)
{ {
if (*p == '\0') { return p; } while ((*p != '\0') && isblank(*p)) { p++; } // Trim leading spaces
while (isspace(*p)) { p++; } // Trim leading spaces
if (*p == '\0') { return p; }
char* q = p + strlen(p) -1; char* q = p + strlen(p) -1;
while (isspace(*q) && q >= p) { q--; } // Trim trailing spaces while ((q >= p) && isblank(*q)) { q--; } // Trim trailing spaces
q++; q++;
*q = '\0'; *q = '\0';
return p; return p;
@ -470,7 +470,7 @@ float ConvertTemp(float c)
return result; return result;
} }
char TempUnit() char TempUnit(void)
{ {
return (Settings.flag.temperature_conversion) ? 'F' : 'C'; return (Settings.flag.temperature_conversion) ? 'F' : 'C';
} }
@ -485,7 +485,7 @@ float ConvertPressure(float p)
return result; return result;
} }
String PressureUnit() String PressureUnit(void)
{ {
return (Settings.flag.pressure_conversion) ? String(D_UNIT_MILLIMETER_MERCURY) : String(D_UNIT_PRESSURE); return (Settings.flag.pressure_conversion) ? String(D_UNIT_MILLIMETER_MERCURY) : String(D_UNIT_PRESSURE);
} }
@ -497,7 +497,7 @@ void SetGlobalValues(float temperature, float humidity)
global_humidity = humidity; global_humidity = humidity;
} }
void ResetGlobalValues() void ResetGlobalValues(void)
{ {
if ((uptime - global_update) > GLOBAL_VALUES_VALID) { // Reset after 5 minutes if ((uptime - global_update) > GLOBAL_VALUES_VALID) { // Reset after 5 minutes
global_update = 0; global_update = 0;
@ -712,7 +712,7 @@ void SetSerialBaudrate(int baudrate)
} }
} }
void ClaimSerial() void ClaimSerial(void)
{ {
serial_local = 1; serial_local = 1;
AddLog_P(LOG_LEVEL_INFO, PSTR("SNS: Hardware Serial")); AddLog_P(LOG_LEVEL_INFO, PSTR("SNS: Hardware Serial"));
@ -765,6 +765,15 @@ uint8_t ValidGPIO(uint8_t pin, uint8_t gpio)
return result; return result;
} }
void AppDelay(void)
{
if (APP_BAUDRATE == baudrate) { // When baudrate too low it will fail on Sonoff Pow R2 and S31 serial interface initialization
if (global_state.wifi_down) {
delay(DRIVER_BOOT_DELAY);
}
}
}
/*********************************************************************************************\ /*********************************************************************************************\
* Sleep aware time scheduler functions borrowed from ESPEasy * Sleep aware time scheduler functions borrowed from ESPEasy
\*********************************************************************************************/ \*********************************************************************************************/
@ -832,7 +841,7 @@ void SetNextTimeInterval(unsigned long& timer, const unsigned long step)
* Fill feature list * Fill feature list
\*********************************************************************************************/ \*********************************************************************************************/
void GetFeatures() void GetFeatures(void)
{ {
feature_drv1 = 0x00000000; // xdrv_01_mqtt.ino, xdrv_01_light.ino, xdrv_04_snfbridge.ino feature_drv1 = 0x00000000; // xdrv_01_mqtt.ino, xdrv_01_light.ino, xdrv_04_snfbridge.ino
@ -1199,7 +1208,7 @@ int WifiGetRssiAsQuality(int rssi)
return quality; return quality;
} }
boolean WifiConfigCounter() boolean WifiConfigCounter(void)
{ {
if (wifi_config_counter) { if (wifi_config_counter) {
wifi_config_counter = WIFI_CONFIG_SEC; wifi_config_counter = WIFI_CONFIG_SEC;
@ -1303,7 +1312,7 @@ void WifiConfig(uint8_t type)
} }
} }
void WiFiSetSleepMode() void WiFiSetSleepMode(void)
{ {
/* Excerpt from the esp8266 non os sdk api reference (v2.2.1): /* Excerpt from the esp8266 non os sdk api reference (v2.2.1):
* Sets sleep type for power saving. Set WIFI_NONE_SLEEP to disable power saving. * Sets sleep type for power saving. Set WIFI_NONE_SLEEP to disable power saving.
@ -1380,7 +1389,7 @@ void WifiSetState(uint8_t state)
global_state.wifi_down = state ^1; global_state.wifi_down = state ^1;
} }
void WifiCheckIp() void WifiCheckIp(void)
{ {
if ((WL_CONNECTED == WiFi.status()) && (static_cast<uint32_t>(WiFi.localIP()) != 0)) { if ((WL_CONNECTED == WiFi.status()) && (static_cast<uint32_t>(WiFi.localIP()) != 0)) {
WifiSetState(1); WifiSetState(1);
@ -1567,7 +1576,7 @@ void WifiCheck(uint8_t param)
} }
} }
int WifiState() int WifiState(void)
{ {
int state = -1; int state = -1;
@ -1576,19 +1585,19 @@ int WifiState()
return state; return state;
} }
void WifiConnect() void WifiConnect(void)
{ {
WifiSetState(0); WifiSetState(0);
WiFi.persistent(false); // Solve possible wifi init errors WiFi.persistent(false); // Solve possible wifi init errors
wifi_status = 0; wifi_status = 0;
wifi_retry_init = WIFI_RETRY_OFFSET_SEC + ((ESP.getChipId() & 0xF) * 2); wifi_retry_init = WIFI_RETRY_OFFSET_SEC + ((ESP.getChipId() & 0xF) * 2);
wifi_retry = wifi_retry_init; wifi_retry = wifi_retry_init;
wifi_counter = 1; wifi_counter = 1;
} }
/*
// Enable from 6.0.0a until 6.1.0a - disabled due to possible cause of bad wifi connect on core 2.3.0 // Enable from 6.0.0a until 6.1.0a - disabled due to possible cause of bad wifi connect on core 2.3.0
void WifiDisconnect() // Re-enabled from 6.3.0.7 with ESP.restart replaced by ESP.reset
void WifiDisconnect(void)
{ {
// Courtesy of EspEasy // Courtesy of EspEasy
WiFi.persistent(true); // use SDK storage of SSID/WPA parameters WiFi.persistent(true); // use SDK storage of SSID/WPA parameters
@ -1598,20 +1607,21 @@ void WifiDisconnect()
WiFi.persistent(false); // Do not use SDK storage of SSID/WPA parameters WiFi.persistent(false); // Do not use SDK storage of SSID/WPA parameters
} }
void EspRestart() void EspRestart(void)
{ {
// This results in exception 3 on restarts
delay(100); // Allow time for message xfer - disabled v6.1.0b delay(100); // Allow time for message xfer - disabled v6.1.0b
WifiDisconnect(); WifiDisconnect();
// ESP.restart(); // This results in exception 3 on restarts on core 2.3.0
ESP.reset();
}
/*
void EspRestart(void)
{
ESP.restart(); ESP.restart();
} }
*/ */
void EspRestart()
{
ESP.restart();
}
/*********************************************************************************************\ /*********************************************************************************************\
* Basic I2C routines * Basic I2C routines
\*********************************************************************************************/ \*********************************************************************************************/
@ -1855,7 +1865,7 @@ int32_t time_timezone = 0;
uint8_t midnight_now = 0; uint8_t midnight_now = 0;
uint8_t ntp_sync_minute = 0; uint8_t ntp_sync_minute = 0;
String GetBuildDateAndTime() String GetBuildDateAndTime(void)
{ {
// "2017-03-07T11:08:02" - ISO8601:2004 // "2017-03-07T11:08:02" - ISO8601:2004
char bdt[21]; char bdt[21];
@ -1884,7 +1894,7 @@ String GetBuildDateAndTime()
return String(bdt); // 2017-03-07T11:08:02 return String(bdt); // 2017-03-07T11:08:02
} }
String GetTimeZone() String GetTimeZone(void)
{ {
char tz[7]; char tz[7];
@ -1958,7 +1968,7 @@ String GetTime(int type)
return String(stime); // Thu Nov 01 11:41:02 2018 return String(stime); // Thu Nov 01 11:41:02 2018
} }
String GetUptime() String GetUptime(void)
{ {
char dt[16]; char dt[16];
@ -1980,7 +1990,7 @@ String GetUptime()
return String(dt); // 128T14:35:44 return String(dt); // 128T14:35:44
} }
uint32_t GetMinutesUptime() uint32_t GetMinutesUptime(void)
{ {
TIME_T ut; TIME_T ut;
@ -1993,7 +2003,7 @@ uint32_t GetMinutesUptime()
return (ut.days *1440) + (ut.hour *60) + ut.minute; return (ut.days *1440) + (ut.hour *60) + ut.minute;
} }
uint32_t GetMinutesPastMidnight() uint32_t GetMinutesPastMidnight(void)
{ {
uint32_t minutes = 0; uint32_t minutes = 0;
@ -2125,24 +2135,24 @@ uint32_t RuleToTime(TimeRule r, int yr)
return t; return t;
} }
uint32_t LocalTime() uint32_t LocalTime(void)
{ {
return local_time; return local_time;
} }
uint32_t Midnight() uint32_t Midnight(void)
{ {
return midnight; return midnight;
} }
boolean MidnightNow() boolean MidnightNow(void)
{ {
boolean mnflg = midnight_now; boolean mnflg = midnight_now;
if (mnflg) midnight_now = 0; if (mnflg) midnight_now = 0;
return mnflg; return mnflg;
} }
void RtcSecond() void RtcSecond(void)
{ {
TIME_T tmpTime; TIME_T tmpTime;
@ -2210,7 +2220,7 @@ void RtcSecond()
RtcTime.year += 1970; RtcTime.year += 1970;
} }
void RtcInit() void RtcInit(void)
{ {
sntp_setservername(0, Settings.ntp_server[0]); sntp_setservername(0, Settings.ntp_server[0]);
sntp_setservername(1, Settings.ntp_server[1]); sntp_setservername(1, Settings.ntp_server[1]);
@ -2265,7 +2275,7 @@ void GetLog(byte idx, char** entry_pp, size_t* len_p)
} }
#endif // USE_WEBSERVER #endif // USE_WEBSERVER
void Syslog() void Syslog(void)
{ {
// Destroys log_data // Destroys log_data
char syslog_preamble[64]; // Hostname + Id char syslog_preamble[64]; // Hostname + Id

View File

@ -43,12 +43,13 @@ const char HTTP_HEAD[] PROGMEM =
"<title>{h} - {v}</title>" "<title>{h} - {v}</title>"
"<script>" "<script>"
"var cn,x,lt,to,tp,pc='';" "var x=null,lt,to,tp,pc='';" // x=null allow for abortion
"cn=180;"
"x=null;" // Allow for abortion
"function eb(s){" "function eb(s){"
"return document.getElementById(s);" // Save code space "return document.getElementById(s);" // Save code space
"}" "}";
const char HTTP_SCRIPT_COUNTER[] PROGMEM =
"var cn=180;" // seconds
"function u(){" "function u(){"
"if(cn>=0){" "if(cn>=0){"
"eb('t').innerHTML='" D_RESTART_IN " '+cn+' " D_SECONDS "';" "eb('t').innerHTML='" D_RESTART_IN " '+cn+' " D_SECONDS "';"
@ -56,10 +57,9 @@ const char HTTP_HEAD[] PROGMEM =
"setTimeout(u,1000);" "setTimeout(u,1000);"
"}" "}"
"}" "}"
"function c(l){" "</script>";
"eb('s1').value=l.innerText||l.textContent;"
"eb('p1').focus();" const char HTTP_SCRIPT_ROOT[] PROGMEM =
"}"
"function la(p){" "function la(p){"
"var a='';" "var a='';"
"if(la.arguments.length==1){" "if(la.arguments.length==1){"
@ -84,44 +84,17 @@ const char HTTP_HEAD[] PROGMEM =
"function lc(p){" "function lc(p){"
"la('?t='+p);" // ?t related to WebGetArg("t", tmp, sizeof(tmp)); "la('?t='+p);" // ?t related to WebGetArg("t", tmp, sizeof(tmp));
"}"; "}";
const char HTTP_HEAD_RELOAD[] PROGMEM =
"setTimeout(function(){location.href='.';},4000);";
const char HTTP_HEAD_STYLE[] PROGMEM = const char HTTP_SCRIPT_WIFI[] PROGMEM =
"</script>" "function c(l){"
"eb('s1').value=l.innerText||l.textContent;"
"eb('p1').focus();"
"}";
"<style>" const char HTTP_SCRIPT_RELOAD[] PROGMEM =
"div,fieldset,input,select{padding:5px;font-size:1em;}" "setTimeout(function(){location.href='.';},5000);"
"input{width:100%;box-sizing:border-box;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;}" "</script>";
"select{width:100%;}"
"textarea{resize:none;width:98%;height:318px;padding:5px;overflow:auto;}"
"body{text-align:center;font-family:verdana;}"
"td{padding:0px;}"
"button{border:0;border-radius:0.3rem;background-color:#1fa3ec;color:#fff;line-height:2.4rem;font-size:1.2rem;width:100%;-webkit-transition-duration:0.4s;transition-duration:0.4s;cursor:pointer;}"
"button:hover{background-color:#0e70a4;}"
".bred{background-color:#d43535;}"
".bred:hover{background-color:#931f1f;}"
".bgrn{background-color:#47c266;}"
".bgrn:hover{background-color:#5aaf6f;}"
"a{text-decoration:none;}"
".p{float:left;text-align:left;}"
".q{float:right;text-align:right;}"
"</style>"
"</head>"
"<body>"
"<div style='text-align:left;display:inline-block;min-width:340px;'>"
#ifdef BE_MINIMAL
"<div style='text-align:center;color:red;'><h3>" D_MINIMAL_FIRMWARE_PLEASE_UPGRADE "</h3></div>"
#endif
"<div style='text-align:center;'><noscript>" D_NOSCRIPT "<br/></noscript>"
#ifdef LANGUAGE_MODULE_NAME
"<h3>" D_MODULE " {ha</h3>"
#else
"<h3>{ha " D_MODULE "</h3>"
#endif
"<h2>{h}</h2>{j}</div>";
const char HTTP_SCRIPT_CONSOL[] PROGMEM = const char HTTP_SCRIPT_CONSOL[] PROGMEM =
"var sn=0;" // Scroll position "var sn=0;" // Scroll position
"var id=0;" // Get most of weblog initially "var id=0;" // Get most of weblog initially
@ -158,21 +131,22 @@ const char HTTP_SCRIPT_CONSOL[] PROGMEM =
"return false;" "return false;"
"}" "}"
"</script>"; "</script>";
const char HTTP_SCRIPT_MODULE1[] PROGMEM = const char HTTP_SCRIPT_MODULE1[] PROGMEM =
"var os;" "var os;"
"function sk(s,g){" // s = value, g = id and name "function sk(s,g){" // s = value, g = id and name
"var o=os.replace(\"value='\"+s+\"'\",\"selected value='\"+s+\"'\");" "var o=os.replace(\"value='\"+s+\"'\",\"selected value='\"+s+\"'\");"
"eb('g'+g).innerHTML=o;" "eb('g'+g).innerHTML=o;"
"}" "}"
"function sl(){" "function sl(){"
"if(x!=null){x.abort();}" // Abort any request pending "if(x!=null){x.abort();}" // Abort any request pending
"x=new XMLHttpRequest();" "x=new XMLHttpRequest();"
"x.onreadystatechange=function(){" "x.onreadystatechange=function(){"
"if(x.readyState==4&&x.status==200){" "if(x.readyState==4&&x.status==200){"
"var i,o=x.responseText.replace(/}1/g,\"<option value=\").replace(/}2/g,\"</option>\");" "var i,o=x.responseText.replace(/}1/g,\"<option value=\").replace(/}2/g,\"</option>\");"
"i=o.indexOf(\"}3\");" // String separator means do not use "}3" in Module name and Sensor name "i=o.indexOf(\"}3\");" // String separator means do not use "}3" in Module name and Sensor name
"os=o.substring(0,i);" "os=o.substring(0,i);"
"sk(17,99);" "sk(}4,99);"
"os=o.substring(i+2);"; // +2 is length "}3" "os=o.substring(i+2);"; // +2 is length "}3"
const char HTTP_SCRIPT_MODULE2[] PROGMEM = const char HTTP_SCRIPT_MODULE2[] PROGMEM =
"}" "}"
@ -181,16 +155,52 @@ const char HTTP_SCRIPT_MODULE2[] PROGMEM =
"x.send();" "x.send();"
"}"; "}";
const char HTTP_SCRIPT_MODULE3[] PROGMEM = const char HTTP_SCRIPT_MODULE3[] PROGMEM =
"}1'%d'>%02d %s}2"; // "}1" and "}2" means do not use "}x" in Module name and Sensor name "}1'%d'>%02d %s}2"; // "}1" and "}2" means do not use "}x" in Module name and Sensor name
const char HTTP_SCRIPT_INFO_BEGIN[] PROGMEM = const char HTTP_SCRIPT_INFO_BEGIN[] PROGMEM =
"function i(){" "function i(){"
"var s,o=\""; "var s,o=\"";
const char HTTP_SCRIPT_INFO_END[] PROGMEM = const char HTTP_SCRIPT_INFO_END[] PROGMEM =
"\";" // "}1" and "}2" means do not use "}x" in Information text "\";" // "}1" and "}2" means do not use "}x" in Information text
"s=o.replace(/}1/g,\"</td></tr><tr><th>\").replace(/}2/g,\"</th><td>\");" "s=o.replace(/}1/g,\"</td></tr><tr><th>\").replace(/}2/g,\"</th><td>\");"
"eb('i').innerHTML=s;" "eb('i').innerHTML=s;"
"}" "}"
"</script>"; "</script>";
const char HTTP_HEAD_STYLE[] PROGMEM =
"</script>"
"<style>"
"div,fieldset,input,select{padding:5px;font-size:1em;}"
"input{width:100%;box-sizing:border-box;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;}"
"select{width:100%;}"
"textarea{resize:none;width:98%;height:318px;padding:5px;overflow:auto;}"
"body{text-align:center;font-family:verdana;}"
"td{padding:0px;}"
"button{border:0;border-radius:0.3rem;background-color:#1fa3ec;color:#fff;line-height:2.4rem;font-size:1.2rem;width:100%;-webkit-transition-duration:0.4s;transition-duration:0.4s;cursor:pointer;}"
"button:hover{background-color:#0e70a4;}"
".bred{background-color:#d43535;}"
".bred:hover{background-color:#931f1f;}"
".bgrn{background-color:#47c266;}"
".bgrn:hover{background-color:#5aaf6f;}"
"a{text-decoration:none;}"
".p{float:left;text-align:left;}"
".q{float:right;text-align:right;}"
"</style>"
"</head>"
"<body>"
"<div style='text-align:left;display:inline-block;min-width:340px;'>"
#ifdef BE_MINIMAL
"<div style='text-align:center;color:red;'><h3>" D_MINIMAL_FIRMWARE_PLEASE_UPGRADE "</h3></div>"
#endif
"<div style='text-align:center;'><noscript>" D_NOSCRIPT "<br/></noscript>"
#ifdef LANGUAGE_MODULE_NAME
"<h3>" D_MODULE " {ha</h3>"
#else
"<h3>{ha " D_MODULE "</h3>"
#endif
"<h2>{h}</h2>{j}</div>";
const char HTTP_MSG_SLIDER1[] PROGMEM = const char HTTP_MSG_SLIDER1[] PROGMEM =
"<div><span class='p'>" D_COLDLIGHT "</span><span class='q'>" D_WARMLIGHT "</span></div>" "<div><span class='p'>" D_COLDLIGHT "</span><span class='q'>" D_WARMLIGHT "</span></div>"
"<div><input type='range' min='153' max='500' value='%d' onchange='lc(value)'></div>"; "<div><input type='range' min='153' max='500' value='%d' onchange='lc(value)'></div>";
@ -398,7 +408,7 @@ void StartWebserver(int type, IPAddress ipweb)
if (type) { webserver_state = type; } if (type) { webserver_state = type; }
} }
void StopWebserver() void StopWebserver(void)
{ {
if (webserver_state) { if (webserver_state) {
WebServer->close(); WebServer->close();
@ -407,7 +417,7 @@ void StopWebserver()
} }
} }
void WifiManagerBegin() void WifiManagerBegin(void)
{ {
// setup AP // setup AP
if (!global_state.wifi_down) { if (!global_state.wifi_down) {
@ -430,7 +440,7 @@ void WifiManagerBegin()
StartWebserver(HTTP_MANAGER, WiFi.softAPIP()); StartWebserver(HTTP_MANAGER, WiFi.softAPIP());
} }
void PollDnsWebserver() void PollDnsWebserver(void)
{ {
if (DnsServer) { DnsServer->processNextRequest(); } if (DnsServer) { DnsServer->processNextRequest(); }
if (WebServer) { WebServer->handleClient(); } if (WebServer) { WebServer->handleClient(); }
@ -438,7 +448,7 @@ void PollDnsWebserver()
/*********************************************************************************************/ /*********************************************************************************************/
void SetHeader() void SetHeader(void)
{ {
WebServer->sendHeader(F("Cache-Control"), F("no-cache, no-store, must-revalidate")); WebServer->sendHeader(F("Cache-Control"), F("no-cache, no-store, must-revalidate"));
WebServer->sendHeader(F("Pragma"), F("no-cache")); WebServer->sendHeader(F("Pragma"), F("no-cache"));
@ -487,6 +497,7 @@ void ShowPage(String &page, bool auth)
if (HTTP_MANAGER == webserver_state) { if (HTTP_MANAGER == webserver_state) {
if (WifiConfigCounter()) { if (WifiConfigCounter()) {
page.replace(F("</script>"), FPSTR(HTTP_SCRIPT_COUNTER));
page.replace(F("<body>"), F("<body onload='u()'>")); page.replace(F("<body>"), F("<body onload='u()'>"));
page += FPSTR(HTTP_COUNTER); page += FPSTR(HTTP_COUNTER);
} }
@ -515,7 +526,6 @@ void WebRestart(uint8_t type)
AddLog_P(LOG_LEVEL_DEBUG, S_LOG_HTTP, S_RESTART); AddLog_P(LOG_LEVEL_DEBUG, S_LOG_HTTP, S_RESTART);
String page = FPSTR(HTTP_HEAD); String page = FPSTR(HTTP_HEAD);
page += FPSTR(HTTP_HEAD_RELOAD);
page += FPSTR(HTTP_HEAD_STYLE); page += FPSTR(HTTP_HEAD_STYLE);
if (type) { if (type) {
@ -536,6 +546,7 @@ void WebRestart(uint8_t type)
} else { } else {
page += FPSTR(HTTP_BTN_MAIN); page += FPSTR(HTTP_BTN_MAIN);
} }
page.replace(F("</script>"), FPSTR(HTTP_SCRIPT_RELOAD));
ShowPage(page); ShowPage(page);
ShowWebSource(SRC_WEBGUI); ShowWebSource(SRC_WEBGUI);
@ -544,7 +555,7 @@ void WebRestart(uint8_t type)
/*********************************************************************************************/ /*********************************************************************************************/
void HandleWifiLogin() void HandleWifiLogin(void)
{ {
String page = FPSTR(HTTP_HEAD); String page = FPSTR(HTTP_HEAD);
page.replace(F("{v}"), FPSTR( D_CONFIGURE_WIFI )); page.replace(F("{v}"), FPSTR( D_CONFIGURE_WIFI ));
@ -553,7 +564,7 @@ void HandleWifiLogin()
ShowPage(page, false); // false means show page no matter if the client has or has not credentials ShowPage(page, false); // false means show page no matter if the client has or has not credentials
} }
void HandleRoot() void HandleRoot(void)
{ {
AddLog_P(LOG_LEVEL_DEBUG, S_LOG_HTTP, S_MAIN_MENU); AddLog_P(LOG_LEVEL_DEBUG, S_LOG_HTTP, S_MAIN_MENU);
@ -588,6 +599,7 @@ void HandleRoot()
char stemp[10]; char stemp[10];
String page = FPSTR(HTTP_HEAD); String page = FPSTR(HTTP_HEAD);
page.replace(F("{v}"), FPSTR(S_MAIN_MENU)); page.replace(F("{v}"), FPSTR(S_MAIN_MENU));
page += FPSTR(HTTP_SCRIPT_ROOT);
page += FPSTR(HTTP_HEAD_STYLE); page += FPSTR(HTTP_HEAD_STYLE);
page.replace(F("<body>"), F("<body onload='la()'>")); page.replace(F("<body>"), F("<body onload='la()'>"));
@ -651,7 +663,7 @@ void HandleRoot()
} }
} }
void HandleAjaxStatusRefresh() void HandleAjaxStatusRefresh(void)
{ {
if (!WebAuthenticate()) { return WebServer->requestAuthentication(); } if (!WebAuthenticate()) { return WebServer->requestAuthentication(); }
@ -721,7 +733,7 @@ void HandleAjaxStatusRefresh()
WebServer->send(200, FPSTR(HDR_CTYPE_HTML), mqtt_data); WebServer->send(200, FPSTR(HDR_CTYPE_HTML), mqtt_data);
} }
boolean HttpUser() boolean HttpUser(void)
{ {
boolean status = (HTTP_USER == webserver_state); boolean status = (HTTP_USER == webserver_state);
if (status) { HandleRoot(); } if (status) { HandleRoot(); }
@ -732,7 +744,7 @@ boolean HttpUser()
#ifndef BE_MINIMAL #ifndef BE_MINIMAL
void HandleConfiguration() void HandleConfiguration(void)
{ {
if (HttpUser()) { return; } if (HttpUser()) { return; }
if (!WebAuthenticate()) { return WebServer->requestAuthentication(); } if (!WebAuthenticate()) { return WebServer->requestAuthentication(); }
@ -755,7 +767,7 @@ void HandleConfiguration()
/*-------------------------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------------------------*/
void HandleModuleConfiguration() void HandleModuleConfiguration(void)
{ {
if (HttpUser()) { return; } if (HttpUser()) { return; }
if (!WebAuthenticate()) { return WebServer->requestAuthentication(); } if (!WebAuthenticate()) { return WebServer->requestAuthentication(); }
@ -796,6 +808,7 @@ void HandleModuleConfiguration()
String page = FPSTR(HTTP_HEAD); String page = FPSTR(HTTP_HEAD);
page.replace(F("{v}"), FPSTR(S_CONFIGURE_MODULE)); page.replace(F("{v}"), FPSTR(S_CONFIGURE_MODULE));
page += FPSTR(HTTP_SCRIPT_MODULE1); page += FPSTR(HTTP_SCRIPT_MODULE1);
page.replace(F("}4"), String(Settings.module));
for (byte i = 0; i < MAX_GPIO_PIN; i++) { for (byte i = 0; i < MAX_GPIO_PIN; i++) {
if (GPIO_USER == ValidGPIO(i, cmodule.gp.io[i])) { if (GPIO_USER == ValidGPIO(i, cmodule.gp.io[i])) {
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("sk(%d,%d);"), my_module.gp.io[i], i); // g0 - g16 snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("sk(%d,%d);"), my_module.gp.io[i], i); // g0 - g16
@ -823,7 +836,7 @@ void HandleModuleConfiguration()
ShowPage(page); ShowPage(page);
} }
void ModuleSaveSettings() void ModuleSaveSettings(void)
{ {
char tmp[100]; char tmp[100];
char stemp[TOPSZ]; char stemp[TOPSZ];
@ -865,7 +878,7 @@ String htmlEscape(String s)
return s; return s;
} }
void HandleWifiConfiguration() void HandleWifiConfiguration(void)
{ {
if (HttpUser()) { return; } if (HttpUser()) { return; }
if (!WebAuthenticate()) { return WebServer->requestAuthentication(); } if (!WebAuthenticate()) { return WebServer->requestAuthentication(); }
@ -880,6 +893,7 @@ void HandleWifiConfiguration()
String page = FPSTR(HTTP_HEAD); String page = FPSTR(HTTP_HEAD);
page.replace(F("{v}"), FPSTR(S_CONFIGURE_WIFI)); page.replace(F("{v}"), FPSTR(S_CONFIGURE_WIFI));
page += FPSTR(HTTP_SCRIPT_WIFI);
page += FPSTR(HTTP_HEAD_STYLE); page += FPSTR(HTTP_HEAD_STYLE);
if (WebServer->hasArg("scan")) { if (WebServer->hasArg("scan")) {
@ -968,7 +982,7 @@ void HandleWifiConfiguration()
ShowPage(page, !(HTTP_MANAGER == webserver_state)); ShowPage(page, !(HTTP_MANAGER == webserver_state));
} }
void WifiSaveSettings() void WifiSaveSettings(void)
{ {
char tmp[100]; char tmp[100];
@ -992,7 +1006,7 @@ void WifiSaveSettings()
/*-------------------------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------------------------*/
void HandleLoggingConfiguration() void HandleLoggingConfiguration(void)
{ {
if (HttpUser()) { return; } if (HttpUser()) { return; }
if (!WebAuthenticate()) { return WebServer->requestAuthentication(); } if (!WebAuthenticate()) { return WebServer->requestAuthentication(); }
@ -1047,7 +1061,7 @@ void HandleLoggingConfiguration()
ShowPage(page); ShowPage(page);
} }
void LoggingSaveSettings() void LoggingSaveSettings(void)
{ {
char tmp[100]; char tmp[100];
@ -1075,7 +1089,7 @@ void LoggingSaveSettings()
/*-------------------------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------------------------*/
void HandleOtherConfiguration() void HandleOtherConfiguration(void)
{ {
if (HttpUser()) { return; } if (HttpUser()) { return; }
if (!WebAuthenticate()) { return WebServer->requestAuthentication(); } if (!WebAuthenticate()) { return WebServer->requestAuthentication(); }
@ -1120,7 +1134,7 @@ void HandleOtherConfiguration()
ShowPage(page); ShowPage(page);
} }
void OtherSaveSettings() void OtherSaveSettings(void)
{ {
char tmp[100]; char tmp[100];
char stemp[TOPSZ]; char stemp[TOPSZ];
@ -1146,7 +1160,7 @@ void OtherSaveSettings()
/*-------------------------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------------------------*/
void HandleBackupConfiguration() void HandleBackupConfiguration(void)
{ {
if (HttpUser()) { return; } if (HttpUser()) { return; }
if (!WebAuthenticate()) { return WebServer->requestAuthentication(); } if (!WebAuthenticate()) { return WebServer->requestAuthentication(); }
@ -1190,7 +1204,7 @@ void HandleBackupConfiguration()
/*-------------------------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------------------------*/
void HandleResetConfiguration() void HandleResetConfiguration(void)
{ {
if (HttpUser()) { return; } if (HttpUser()) { return; }
if (!WebAuthenticate()) { return WebServer->requestAuthentication(); } if (!WebAuthenticate()) { return WebServer->requestAuthentication(); }
@ -1211,7 +1225,7 @@ void HandleResetConfiguration()
ExecuteWebCommand(svalue, SRC_WEBGUI); ExecuteWebCommand(svalue, SRC_WEBGUI);
} }
void HandleRestoreConfiguration() void HandleRestoreConfiguration(void)
{ {
if (HttpUser()) { return; } if (HttpUser()) { return; }
if (!WebAuthenticate()) { return WebServer->requestAuthentication(); } if (!WebAuthenticate()) { return WebServer->requestAuthentication(); }
@ -1232,7 +1246,7 @@ void HandleRestoreConfiguration()
/*-------------------------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------------------------*/
void HandleInformation() void HandleInformation(void)
{ {
if (HttpUser()) { return; } if (HttpUser()) { return; }
if (!WebAuthenticate()) { return WebServer->requestAuthentication(); } if (!WebAuthenticate()) { return WebServer->requestAuthentication(); }
@ -1353,7 +1367,7 @@ void HandleInformation()
/*-------------------------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------------------------*/
void HandleUpgradeFirmware() void HandleUpgradeFirmware(void)
{ {
if (HttpUser()) { return; } if (HttpUser()) { return; }
if (!WebAuthenticate()) { return WebServer->requestAuthentication(); } if (!WebAuthenticate()) { return WebServer->requestAuthentication(); }
@ -1373,7 +1387,7 @@ void HandleUpgradeFirmware()
upload_file_type = UPL_TASMOTA; upload_file_type = UPL_TASMOTA;
} }
void HandleUpgradeFirmwareStart() void HandleUpgradeFirmwareStart(void)
{ {
if (HttpUser()) { return; } if (HttpUser()) { return; }
if (!WebAuthenticate()) { return WebServer->requestAuthentication(); } if (!WebAuthenticate()) { return WebServer->requestAuthentication(); }
@ -1395,13 +1409,14 @@ void HandleUpgradeFirmwareStart()
page += F("<div style='text-align:center;'><b>" D_UPGRADE_STARTED " ...</b></div>"); page += F("<div style='text-align:center;'><b>" D_UPGRADE_STARTED " ...</b></div>");
page += FPSTR(HTTP_MSG_RSTRT); page += FPSTR(HTTP_MSG_RSTRT);
page += FPSTR(HTTP_BTN_MAIN); page += FPSTR(HTTP_BTN_MAIN);
// page.replace(F("</script>"), FPSTR(HTTP_SCRIPT_RELOAD));
ShowPage(page); ShowPage(page);
snprintf_P(svalue, sizeof(svalue), PSTR(D_CMND_UPGRADE " 1")); snprintf_P(svalue, sizeof(svalue), PSTR(D_CMND_UPGRADE " 1"));
ExecuteWebCommand(svalue, SRC_WEBGUI); ExecuteWebCommand(svalue, SRC_WEBGUI);
} }
void HandleUploadDone() void HandleUploadDone(void)
{ {
if (HttpUser()) { return; } if (HttpUser()) { return; }
if (!WebAuthenticate()) { return WebServer->requestAuthentication(); } if (!WebAuthenticate()) { return WebServer->requestAuthentication(); }
@ -1445,6 +1460,7 @@ void HandleUploadDone()
} else { } else {
page += F("green'>" D_SUCCESSFUL "</font></b><br/>"); page += F("green'>" D_SUCCESSFUL "</font></b><br/>");
page += FPSTR(HTTP_MSG_RSTRT); page += FPSTR(HTTP_MSG_RSTRT);
page.replace(F("</script>"), FPSTR(HTTP_SCRIPT_RELOAD));
ShowWebSource(SRC_WEBGUI); ShowWebSource(SRC_WEBGUI);
restart_flag = 2; // Always restart to re-enable disabled features during update restart_flag = 2; // Always restart to re-enable disabled features during update
} }
@ -1454,7 +1470,7 @@ void HandleUploadDone()
ShowPage(page); ShowPage(page);
} }
void HandleUploadLoop() void HandleUploadLoop(void)
{ {
// Based on ESP8266HTTPUpdateServer.cpp uses ESP8266WebServer Parsing.cpp and Cores Updater.cpp (Update) // Based on ESP8266HTTPUpdateServer.cpp uses ESP8266WebServer Parsing.cpp and Cores Updater.cpp (Update)
boolean _serialoutput = (LOG_LEVEL_DEBUG <= seriallog_level); boolean _serialoutput = (LOG_LEVEL_DEBUG <= seriallog_level);
@ -1528,7 +1544,7 @@ void HandleUploadLoop()
upload_error = 4; // Program flash size is larger than real flash size upload_error = 4; // Program flash size is larger than real flash size
return; return;
} }
upload.buf[2] = 3; // Force DOUT - ESP8285 // upload.buf[2] = 3; // Force DOUT - ESP8285
} }
} }
} }
@ -1648,7 +1664,7 @@ void HandleUploadLoop()
/*-------------------------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------------------------*/
void HandlePreflightRequest() void HandlePreflightRequest(void)
{ {
WebServer->sendHeader(F("Access-Control-Allow-Origin"), F("*")); WebServer->sendHeader(F("Access-Control-Allow-Origin"), F("*"));
WebServer->sendHeader(F("Access-Control-Allow-Methods"), F("GET, POST")); WebServer->sendHeader(F("Access-Control-Allow-Methods"), F("GET, POST"));
@ -1658,7 +1674,7 @@ void HandlePreflightRequest()
/*-------------------------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------------------------*/
void HandleHttpCommand() void HandleHttpCommand(void)
{ {
if (HttpUser()) { return; } if (HttpUser()) { return; }
// if (!WebAuthenticate()) { return WebServer->requestAuthentication(); } // if (!WebAuthenticate()) { return WebServer->requestAuthentication(); }
@ -1718,7 +1734,7 @@ void HandleHttpCommand()
/*-------------------------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------------------------*/
void HandleConsole() void HandleConsole(void)
{ {
if (HttpUser()) { return; } if (HttpUser()) { return; }
if (!WebAuthenticate()) { return WebServer->requestAuthentication(); } if (!WebAuthenticate()) { return WebServer->requestAuthentication(); }
@ -1734,7 +1750,7 @@ void HandleConsole()
ShowPage(page); ShowPage(page);
} }
void HandleAjaxConsoleRefresh() void HandleAjaxConsoleRefresh(void)
{ {
if (HttpUser()) { return; } if (HttpUser()) { return; }
if (!WebAuthenticate()) { return WebServer->requestAuthentication(); } if (!WebAuthenticate()) { return WebServer->requestAuthentication(); }
@ -1793,7 +1809,7 @@ void HandleAjaxConsoleRefresh()
/********************************************************************************************/ /********************************************************************************************/
void HandleNotFound() void HandleNotFound(void)
{ {
// snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_HTTP "Not fount (%s)"), WebServer->uri().c_str()); // snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_HTTP "Not fount (%s)"), WebServer->uri().c_str());
// AddLog(LOG_LEVEL_DEBUG); // AddLog(LOG_LEVEL_DEBUG);
@ -1818,7 +1834,7 @@ void HandleNotFound()
} }
/* Redirect to captive portal if we got a request for another domain. Return true in that case so the page handler do not try to handle the request again. */ /* Redirect to captive portal if we got a request for another domain. Return true in that case so the page handler do not try to handle the request again. */
boolean CaptivePortal() boolean CaptivePortal(void)
{ {
if ((HTTP_MANAGER == webserver_state) && !ValidIpAddress(WebServer->hostHeader())) { if ((HTTP_MANAGER == webserver_state) && !ValidIpAddress(WebServer->hostHeader())) {
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_REDIRECTED)); AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_REDIRECTED));
@ -1879,9 +1895,11 @@ String UrlEncode(const String& text)
int WebSend(char *buffer) int WebSend(char *buffer)
{ {
// http://192.168.178.86:80/cm?user=admin&password=joker&cmnd=POWER1 ON /* [sonoff] POWER1 ON --> Sends http://sonoff/cm?cmnd=POWER1 ON
// http://192.168.178.86:80/cm?cmnd=POWER1 ON * [192.168.178.86:80,admin:joker] POWER1 ON --> Sends http://hostname:80/cm?user=admin&password=joker&cmnd=POWER1 ON
// [192.168.178.86:80,admin:joker] POWER1 ON * [sonoff] /any/link/starting/with/a/slash.php?log=123 --> Sends http://sonoff/any/link/starting/with/a/slash.php?log=123
* [sonoff,admin:joker] /any/link/starting/with/a/slash.php?log=123 --> Sends http://sonoff/any/link/starting/with/a/slash.php?log=123
*/
char *host; char *host;
char *port; char *port;
@ -1891,31 +1909,38 @@ int WebSend(char *buffer)
uint16_t nport = 80; uint16_t nport = 80;
int status = 1; // Wrong parameters int status = 1; // Wrong parameters
host = strtok_r(buffer, "]", &command); // buffer = [192.168.178.86:80,admin:joker] POWER1 ON // buffer = | [ 192.168.178.86 : 80 , admin : joker ] POWER1 ON |
host = strtok_r(buffer, "]", &command); // host = | [ 192.168.178.86 : 80 , admin : joker |, command = | POWER1 ON |
if (host && command) { if (host && command) {
host = LTrim(host); host = Trim(host); // host = |[ 192.168.178.86 : 80 , admin : joker|
host++; // Skip [ host++; // host = | 192.168.178.86 : 80 , admin : joker| - Skip [
host = strtok_r(host, ",", &user); // host = 192.168.178.86:80,admin:joker > 192.168.178.86:80 host = strtok_r(host, ",", &user); // host = | 192.168.178.86 : 80 |, user = | admin : joker|
host = strtok_r(host, ":", &port); // host = 192.168.178.86:80 > 192.168.178.86 host = strtok_r(host, ":", &port); // host = | 192.168.178.86 |, port = | 80 |
if (user) { host = Trim(host); // host = |192.168.178.86|
user = strtok_r(user, ":", &password); // user = admin:joker > admin if (port) {
port = Trim(port); // port = |80|
nport = atoi(port);
} }
if (user) {
//snprintf_P(log_data, sizeof(log_data), PSTR("DBG: Buffer |%X|, Host |%X|, Port |%X|, User |%X|, Password |%X|, Command |%X|"), buffer, host, port, user, password, command); user = strtok_r(user, ":", &password); // user = | admin |, password = | joker|
//AddLog(LOG_LEVEL_DEBUG); user = Trim(user); // user = |admin|
if (password) { password = Trim(password); } // password = |joker|
if (port) { nport = atoi(port); } }
command = Trim(command); // command = |POWER1 ON| or |/any/link/starting/with/a/slash.php?log=123|
String nuri = ""; String nuri = "";
if (user && password) { if (command[0] != '/') {
nuri += F("user="); nuri = "/cm?";
nuri += user; if (user && password) {
nuri += F("&password="); nuri += F("user=");
nuri += password; nuri += user;
nuri += F("&"); nuri += F("&password=");
nuri += password;
nuri += F("&");
}
nuri += F("cmnd=");
} }
nuri += F("cmnd="); nuri += command;
nuri += LTrim(command);
String uri = UrlEncode(nuri); String uri = UrlEncode(nuri);
IPAddress host_ip; IPAddress host_ip;
@ -1931,15 +1956,16 @@ int WebSend(char *buffer)
} }
if (connected) { if (connected) {
String url = F("GET /cm?"); String url = F("GET ");
url += uri; url += uri;
url += F(" HTTP/1.1\r\n Host: "); url += F(" HTTP/1.1\r\nHost: ");
url += IPAddress(host_ip).toString(); // url += IPAddress(host_ip).toString();
url += host; // https://tools.ietf.org/html/rfc7230#section-5.4 (#4331)
if (port) { if (port) {
url += F(" \r\n Port: "); url += F(":");
url += port; url += port;
} }
url += F(" \r\n Connection: close\r\n\r\n"); url += F("\r\nConnection: close\r\n\r\n");
//snprintf_P(log_data, sizeof(log_data), PSTR("DBG: Url |%s|"), url.c_str()); //snprintf_P(log_data, sizeof(log_data), PSTR("DBG: Url |%s|"), url.c_str());
//AddLog(LOG_LEVEL_DEBUG); //AddLog(LOG_LEVEL_DEBUG);
@ -1964,7 +1990,7 @@ enum WebCommands { CMND_WEBSERVER, CMND_WEBPASSWORD, CMND_WEBLOG, CMND_WEBREFRES
const char kWebCommands[] PROGMEM = D_CMND_WEBSERVER "|" D_CMND_WEBPASSWORD "|" D_CMND_WEBLOG "|" D_CMND_WEBREFRESH "|" D_CMND_WEBSEND "|" D_CMND_EMULATION ; const char kWebCommands[] PROGMEM = D_CMND_WEBSERVER "|" D_CMND_WEBPASSWORD "|" D_CMND_WEBLOG "|" D_CMND_WEBREFRESH "|" D_CMND_WEBSEND "|" D_CMND_EMULATION ;
const char kWebSendStatus[] PROGMEM = D_JSON_DONE "|" D_JSON_WRONG_PARAMETERS "|" D_JSON_CONNECT_FAILED "|" D_JSON_HOST_NOT_FOUND ; const char kWebSendStatus[] PROGMEM = D_JSON_DONE "|" D_JSON_WRONG_PARAMETERS "|" D_JSON_CONNECT_FAILED "|" D_JSON_HOST_NOT_FOUND ;
bool WebCommand() bool WebCommand(void)
{ {
char command[CMDSZ]; char command[CMDSZ];
bool serviced = true; bool serviced = true;

View File

@ -89,12 +89,12 @@ bool mqtt_connected = false; // MQTT virtual connection status
PubSubClient MqttClient(EspClient); PubSubClient MqttClient(EspClient);
bool MqttIsConnected() bool MqttIsConnected(void)
{ {
return MqttClient.connected(); return MqttClient.connected();
} }
void MqttDisconnect() void MqttDisconnect(void)
{ {
MqttClient.disconnect(); MqttClient.disconnect();
} }
@ -112,7 +112,7 @@ bool MqttPublishLib(const char* topic, boolean retained)
return result; return result;
} }
void MqttLoop() void MqttLoop(void)
{ {
MqttClient.loop(); MqttClient.loop();
} }
@ -122,17 +122,17 @@ void MqttLoop()
#include <TasmotaMqtt.h> #include <TasmotaMqtt.h>
TasmotaMqtt MqttClient; TasmotaMqtt MqttClient;
bool MqttIsConnected() bool MqttIsConnected(void)
{ {
return MqttClient.Connected(); return MqttClient.Connected();
} }
void MqttDisconnect() void MqttDisconnect(void)
{ {
MqttClient.Disconnect(); MqttClient.Disconnect();
} }
void MqttDisconnectedCb() void MqttDisconnectedCb(void)
{ {
MqttDisconnected(MqttClient.State()); // status codes are documented in file mqtt.h as tConnState MqttDisconnected(MqttClient.State()); // status codes are documented in file mqtt.h as tConnState
} }
@ -147,7 +147,7 @@ bool MqttPublishLib(const char* topic, boolean retained)
return MqttClient.Publish(topic, mqtt_data, strlen(mqtt_data), 0, retained); return MqttClient.Publish(topic, mqtt_data, strlen(mqtt_data), 0, retained);
} }
void MqttLoop() void MqttLoop(void)
{ {
} }
@ -156,12 +156,12 @@ void MqttLoop()
#include <MQTTClient.h> #include <MQTTClient.h>
MQTTClient MqttClient(MQTT_MAX_PACKET_SIZE); MQTTClient MqttClient(MQTT_MAX_PACKET_SIZE);
bool MqttIsConnected() bool MqttIsConnected(void)
{ {
return MqttClient.connected(); return MqttClient.connected();
} }
void MqttDisconnect() void MqttDisconnect(void)
{ {
MqttClient.disconnect(); MqttClient.disconnect();
} }
@ -189,7 +189,7 @@ bool MqttPublishLib(const char* topic, boolean retained)
return MqttClient.publish(topic, mqtt_data, strlen(mqtt_data), retained, 0); return MqttClient.publish(topic, mqtt_data, strlen(mqtt_data), retained, 0);
} }
void MqttLoop() void MqttLoop(void)
{ {
MqttClient.loop(); MqttClient.loop();
// delay(10); // delay(10);
@ -201,7 +201,7 @@ void MqttLoop()
#ifdef USE_DISCOVERY #ifdef USE_DISCOVERY
#ifdef MQTT_HOST_DISCOVERY #ifdef MQTT_HOST_DISCOVERY
boolean MqttDiscoverServer() boolean MqttDiscoverServer(void)
{ {
if (!mdns_begun) { return false; } if (!mdns_begun) { return false; }
@ -225,7 +225,7 @@ boolean MqttDiscoverServer()
#endif // MQTT_HOST_DISCOVERY #endif // MQTT_HOST_DISCOVERY
#endif // USE_DISCOVERY #endif // USE_DISCOVERY
int MqttLibraryType() int MqttLibraryType(void)
{ {
return (int)MQTT_LIBRARY_TYPE; return (int)MQTT_LIBRARY_TYPE;
} }
@ -372,7 +372,7 @@ void MqttDisconnected(int state)
rules_flag.mqtt_disconnected = 1; rules_flag.mqtt_disconnected = 1;
} }
void MqttConnected() void MqttConnected(void)
{ {
char stopic[TOPSZ]; char stopic[TOPSZ];
@ -434,7 +434,7 @@ void MqttConnected()
} }
#ifdef USE_MQTT_TLS #ifdef USE_MQTT_TLS
boolean MqttCheckTls() boolean MqttCheckTls(void)
{ {
char fingerprint1[60]; char fingerprint1[60];
char fingerprint2[60]; char fingerprint2[60];
@ -474,7 +474,7 @@ boolean MqttCheckTls()
} }
#endif // USE_MQTT_TLS #endif // USE_MQTT_TLS
void MqttReconnect() void MqttReconnect(void)
{ {
char stopic[TOPSZ]; char stopic[TOPSZ];
@ -559,7 +559,7 @@ void MqttReconnect()
#endif // MQTT_LIBRARY_TYPE #endif // MQTT_LIBRARY_TYPE
} }
void MqttCheck() void MqttCheck(void)
{ {
if (Settings.flag.mqtt_enabled) { if (Settings.flag.mqtt_enabled) {
if (!MqttIsConnected()) { if (!MqttIsConnected()) {
@ -587,7 +587,7 @@ void MqttCheck()
/*********************************************************************************************/ /*********************************************************************************************/
bool MqttCommand() bool MqttCommand(void)
{ {
char command [CMDSZ]; char command [CMDSZ];
bool serviced = true; bool serviced = true;
@ -841,7 +841,7 @@ const char HTTP_FORM_MQTT[] PROGMEM =
"<br/><b>" D_TOPIC "</b> = %topic% (" MQTT_TOPIC ")<br/><input id='mt' name='mt' placeholder='" MQTT_TOPIC" ' value='{m6'><br/>" "<br/><b>" D_TOPIC "</b> = %topic% (" MQTT_TOPIC ")<br/><input id='mt' name='mt' placeholder='" MQTT_TOPIC" ' value='{m6'><br/>"
"<br/><b>" D_FULL_TOPIC "</b> (" MQTT_FULLTOPIC ")<br/><input id='mf' name='mf' placeholder='" MQTT_FULLTOPIC" ' value='{m7'><br/>"; "<br/><b>" D_FULL_TOPIC "</b> (" MQTT_FULLTOPIC ")<br/><input id='mf' name='mf' placeholder='" MQTT_FULLTOPIC" ' value='{m7'><br/>";
void HandleMqttConfiguration() void HandleMqttConfiguration(void)
{ {
if (HttpUser()) { return; } if (HttpUser()) { return; }
if (!WebAuthenticate()) { return WebServer->requestAuthentication(); } if (!WebAuthenticate()) { return WebServer->requestAuthentication(); }
@ -873,7 +873,7 @@ void HandleMqttConfiguration()
ShowPage(page); ShowPage(page);
} }
void MqttSaveSettings() void MqttSaveSettings(void)
{ {
char tmp[100]; char tmp[100];
char stemp[TOPSZ]; char stemp[TOPSZ];

View File

@ -87,7 +87,7 @@ Ticker ticker_energy;
int energy_command_code = 0; int energy_command_code = 0;
/********************************************************************************************/ /********************************************************************************************/
void EnergyUpdateToday() void EnergyUpdateToday(void)
{ {
if (energy_kWhtoday_delta > 1000) { if (energy_kWhtoday_delta > 1000) {
unsigned long delta = energy_kWhtoday_delta / 1000; unsigned long delta = energy_kWhtoday_delta / 1000;
@ -101,7 +101,7 @@ void EnergyUpdateToday()
/*********************************************************************************************/ /*********************************************************************************************/
void Energy200ms() void Energy200ms(void)
{ {
energy_power_on = (power != 0) | Settings.flag.no_power_on_check; energy_power_on = (power != 0) | Settings.flag.no_power_on_check;
@ -131,7 +131,7 @@ void Energy200ms()
XnrgCall(FUNC_EVERY_200_MSECOND); XnrgCall(FUNC_EVERY_200_MSECOND);
} }
void EnergySaveState() void EnergySaveState(void)
{ {
Settings.energy_kWhdoy = (RtcTime.valid) ? RtcTime.day_of_year : 0; Settings.energy_kWhdoy = (RtcTime.valid) ? RtcTime.day_of_year : 0;
Settings.energy_kWhtoday = energy_kWhtoday; Settings.energy_kWhtoday = energy_kWhtoday;
@ -154,12 +154,12 @@ boolean EnergyMargin(byte type, uint16_t margin, uint16_t value, byte &flag, byt
return (change != save_flag); return (change != save_flag);
} }
void EnergySetPowerSteadyCounter() void EnergySetPowerSteadyCounter(void)
{ {
energy_power_steady_cntr = 2; energy_power_steady_cntr = 2;
} }
void EnergyMarginCheck() void EnergyMarginCheck(void)
{ {
uint16_t energy_daily_u = 0; uint16_t energy_daily_u = 0;
uint16_t energy_power_u = 0; uint16_t energy_power_u = 0;
@ -296,7 +296,7 @@ void EnergyMarginCheck()
if (energy_power_delta) EnergyMqttShow(); if (energy_power_delta) EnergyMqttShow();
} }
void EnergyMqttShow() void EnergyMqttShow(void)
{ {
// {"Time":"2017-12-16T11:48:55","ENERGY":{"Total":0.212,"Yesterday":0.000,"Today":0.014,"Period":2.0,"Power":22.0,"Factor":1.00,"Voltage":213.6,"Current":0.100}} // {"Time":"2017-12-16T11:48:55","ENERGY":{"Total":0.212,"Yesterday":0.000,"Today":0.014,"Period":2.0,"Power":22.0,"Factor":1.00,"Voltage":213.6,"Current":0.100}}
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("{\"" D_JSON_TIME "\":\"%s\""), GetDateAndTime(DT_LOCAL).c_str()); snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("{\"" D_JSON_TIME "\":\"%s\""), GetDateAndTime(DT_LOCAL).c_str());
@ -313,7 +313,7 @@ void EnergyMqttShow()
* Commands * Commands
\*********************************************************************************************/ \*********************************************************************************************/
boolean EnergyCommand() boolean EnergyCommand(void)
{ {
char command [CMDSZ]; char command [CMDSZ];
char sunit[CMDSZ]; char sunit[CMDSZ];
@ -506,13 +506,13 @@ boolean EnergyCommand()
return serviced; return serviced;
} }
void EnergyDrvInit() void EnergyDrvInit(void)
{ {
energy_flg = ENERGY_NONE; energy_flg = ENERGY_NONE;
XnrgCall(FUNC_PRE_INIT); XnrgCall(FUNC_PRE_INIT);
} }
void EnergySnsInit() void EnergySnsInit(void)
{ {
XnrgCall(FUNC_INIT); XnrgCall(FUNC_INIT);

View File

@ -146,11 +146,11 @@ uint8_t arilux_rf_toggle = 0;
#ifndef ARDUINO_ESP8266_RELEASE_2_3_0 #ifndef ARDUINO_ESP8266_RELEASE_2_3_0
#ifndef USE_WS2812_DMA // Collides with Neopixelbus but solves RF misses #ifndef USE_WS2812_DMA // Collides with Neopixelbus but solves RF misses
void AriluxRfInterrupt() ICACHE_RAM_ATTR; // As iram is tight and it works this way too void AriluxRfInterrupt(void) ICACHE_RAM_ATTR; // As iram is tight and it works this way too
#endif // USE_WS2812_DMA #endif // USE_WS2812_DMA
#endif // ARDUINO_ESP8266_RELEASE_2_3_0 #endif // ARDUINO_ESP8266_RELEASE_2_3_0
void AriluxRfInterrupt() void AriluxRfInterrupt(void)
{ {
unsigned long time = micros(); unsigned long time = micros();
unsigned int duration = time - arilux_rf_lasttime; unsigned int duration = time - arilux_rf_lasttime;
@ -184,7 +184,7 @@ void AriluxRfInterrupt()
arilux_rf_lasttime = time; arilux_rf_lasttime = time;
} }
void AriluxRfHandler() void AriluxRfHandler(void)
{ {
unsigned long now = millis(); unsigned long now = millis();
if (arilux_rf_received_value && !((arilux_rf_received_value == arilux_rf_last_received_value) && (now - arilux_rf_last_time < ARILUX_RF_TIME_AVOID_DUPLICATE))) { if (arilux_rf_received_value && !((arilux_rf_received_value == arilux_rf_last_received_value) && (now - arilux_rf_last_time < ARILUX_RF_TIME_AVOID_DUPLICATE))) {
@ -245,7 +245,7 @@ void AriluxRfHandler()
arilux_rf_received_value = 0; arilux_rf_received_value = 0;
} }
void AriluxRfInit() void AriluxRfInit(void)
{ {
if ((pin[GPIO_ARIRFRCV] < 99) && (pin[GPIO_LED2] < 99)) { if ((pin[GPIO_ARIRFRCV] < 99) && (pin[GPIO_LED2] < 99)) {
if (Settings.last_module != Settings.module) { if (Settings.last_module != Settings.module) {
@ -259,7 +259,7 @@ void AriluxRfInit()
} }
} }
void AriluxRfDisable() void AriluxRfDisable(void)
{ {
if ((pin[GPIO_ARIRFRCV] < 99) && (pin[GPIO_LED2] < 99)) { if ((pin[GPIO_ARIRFRCV] < 99) && (pin[GPIO_LED2] < 99)) {
detachInterrupt(pin[GPIO_ARIRFRCV]); detachInterrupt(pin[GPIO_ARIRFRCV]);
@ -309,7 +309,7 @@ void LightMy92x1Write(uint8_t data)
} }
} }
void LightMy92x1Init() void LightMy92x1Init(void)
{ {
uint8_t chips = light_type -11; // 1 (AiLight) or 2 (Sonoff B1) uint8_t chips = light_type -11; // 1 (AiLight) or 2 (Sonoff B1)
@ -347,7 +347,7 @@ void LightMy92x1Duty(uint8_t duty_r, uint8_t duty_g, uint8_t duty_b, uint8_t dut
/********************************************************************************************/ /********************************************************************************************/
void LightInit() void LightInit(void)
{ {
uint8_t max_scheme = LS_MAX -1; uint8_t max_scheme = LS_MAX -1;
@ -452,7 +452,7 @@ void LightSetColorTemp(uint16_t ct)
} }
} }
uint16_t LightGetColorTemp() uint16_t LightGetColorTemp(void)
{ {
uint8_t ct_idx = 0; uint8_t ct_idx = 0;
if (LST_RGBWC == light_subtype) { if (LST_RGBWC == light_subtype) {
@ -494,7 +494,7 @@ void LightSetDimmer(uint8_t myDimmer)
} }
} }
void LightSetColor() void LightSetColor(void)
{ {
uint8_t highest = 0; uint8_t highest = 0;
@ -554,7 +554,7 @@ char* LightGetColor(uint8_t type, char* scolor)
return scolor; return scolor;
} }
void LightPowerOn() void LightPowerOn(void)
{ {
if (Settings.light_dimmer && !(light_power)) { if (Settings.light_dimmer && !(light_power)) {
ExecuteCommandPower(light_device, POWER_ON, SRC_LIGHT); ExecuteCommandPower(light_device, POWER_ON, SRC_LIGHT);
@ -609,7 +609,7 @@ void LightState(uint8_t append)
} }
} }
void LightPreparePower() void LightPreparePower(void)
{ {
if (Settings.light_dimmer && !(light_power)) { if (Settings.light_dimmer && !(light_power)) {
if (!Settings.flag.not_power_linked) { if (!Settings.flag.not_power_linked) {
@ -626,7 +626,7 @@ void LightPreparePower()
LightState(0); LightState(0);
} }
void LightFade() void LightFade(void)
{ {
if (0 == Settings.light_fade) { if (0 == Settings.light_fade) {
for (byte i = 0; i < light_subtype; i++) { for (byte i = 0; i < light_subtype; i++) {
@ -689,7 +689,7 @@ void LightCycleColor(int8_t direction)
memcpy(light_new_color, light_entry_color, sizeof(light_new_color)); memcpy(light_new_color, light_entry_color, sizeof(light_new_color));
} }
void LightRandomColor() void LightRandomColor(void)
{ {
uint8_t light_update = 0; uint8_t light_update = 0;
for (byte i = 0; i < LST_RGB; i++) { for (byte i = 0; i < LST_RGB; i++) {
@ -705,7 +705,7 @@ void LightRandomColor()
LightFade(); LightFade();
} }
void LightSetPower() void LightSetPower(void)
{ {
// light_power = XdrvMailbox.index; // light_power = XdrvMailbox.index;
light_power = bitRead(XdrvMailbox.index, light_device -1); light_power = bitRead(XdrvMailbox.index, light_device -1);
@ -718,7 +718,7 @@ void LightSetPower()
LightAnimate(); LightAnimate();
} }
void LightAnimate() void LightAnimate(void)
{ {
uint8_t cur_col[5]; uint8_t cur_col[5];
uint16_t light_still_on = 0; uint16_t light_still_on = 0;
@ -852,7 +852,7 @@ float light_hue = 0.0;
float light_saturation = 0.0; float light_saturation = 0.0;
float light_brightness = 0.0; float light_brightness = 0.0;
void LightRgbToHsb() void LightRgbToHsb(void)
{ {
LightSetDimmer(Settings.light_dimmer); LightSetDimmer(Settings.light_dimmer);
@ -883,7 +883,7 @@ void LightRgbToHsb()
} }
} }
void LightHsbToRgb() void LightHsbToRgb(void)
{ {
float r; float r;
float g; float g;
@ -1073,7 +1073,7 @@ boolean LightColorEntry(char *buffer, uint8_t buffer_length)
/********************************************************************************************/ /********************************************************************************************/
//boolean LightCommand(char *type, uint16_t index, char *dataBuf, uint16_t XdrvMailbox.data_len, int16_t XdrvMailbox.payload) //boolean LightCommand(char *type, uint16_t index, char *dataBuf, uint16_t XdrvMailbox.data_len, int16_t XdrvMailbox.payload)
boolean LightCommand() boolean LightCommand(void)
{ {
char command [CMDSZ]; char command [CMDSZ];
boolean serviced = true; boolean serviced = true;

View File

@ -88,7 +88,7 @@ void IrReceiveInit(void)
// AddLog_P(LOG_LEVEL_DEBUG, PSTR("IrReceive initialized")); // AddLog_P(LOG_LEVEL_DEBUG, PSTR("IrReceive initialized"));
} }
void IrReceiveCheck() void IrReceiveCheck(void)
{ {
char sirtype[14]; // Max is AIWA_RC_T501 char sirtype[14]; // Max is AIWA_RC_T501
char stemp[16]; char stemp[16];
@ -285,7 +285,7 @@ boolean IrHvacMitsubishi(const char *HVAC_Mode, const char *HVAC_FanMode, boolea
*/ */
//boolean IrSendCommand(char *type, uint16_t index, char *dataBuf, uint16_t data_len, int16_t payload) //boolean IrSendCommand(char *type, uint16_t index, char *dataBuf, uint16_t data_len, int16_t payload)
boolean IrSendCommand() boolean IrSendCommand(void)
{ {
boolean serviced = true; boolean serviced = true;
boolean error = false; boolean error = false;

View File

@ -167,7 +167,7 @@ ssize_t rf_search_and_write(uint8_t *buf, size_t size)
return 0; return 0;
} }
uint8_t rf_erase_flash() uint8_t rf_erase_flash(void)
{ {
uint8_t err; uint8_t err;
@ -190,7 +190,7 @@ uint8_t rf_erase_flash()
return 0; return 0;
} }
uint8_t SnfBrUpdateInit() uint8_t SnfBrUpdateInit(void)
{ {
pinMode(PIN_C2CK, OUTPUT); pinMode(PIN_C2CK, OUTPUT);
pinMode(PIN_C2D, INPUT); pinMode(PIN_C2D, INPUT);
@ -201,7 +201,7 @@ uint8_t SnfBrUpdateInit()
/********************************************************************************************/ /********************************************************************************************/
void SonoffBridgeReceivedRaw() void SonoffBridgeReceivedRaw(void)
{ {
// Decoding according to https://github.com/Portisch/RF-Bridge-EFM8BB1 // Decoding according to https://github.com/Portisch/RF-Bridge-EFM8BB1
uint8_t buckets = 0; uint8_t buckets = 0;
@ -225,14 +225,14 @@ void SonoffBridgeReceivedRaw()
/********************************************************************************************/ /********************************************************************************************/
void SonoffBridgeLearnFailed() void SonoffBridgeLearnFailed(void)
{ {
sonoff_bridge_learn_active = 0; sonoff_bridge_learn_active = 0;
snprintf_P(mqtt_data, sizeof(mqtt_data), S_JSON_COMMAND_INDEX_SVALUE, D_CMND_RFKEY, sonoff_bridge_learn_key, D_JSON_LEARN_FAILED); snprintf_P(mqtt_data, sizeof(mqtt_data), S_JSON_COMMAND_INDEX_SVALUE, D_CMND_RFKEY, sonoff_bridge_learn_key, D_JSON_LEARN_FAILED);
MqttPublishPrefixTopic_P(RESULT_OR_STAT, PSTR(D_CMND_RFKEY)); MqttPublishPrefixTopic_P(RESULT_OR_STAT, PSTR(D_CMND_RFKEY));
} }
void SonoffBridgeReceived() void SonoffBridgeReceived(void)
{ {
uint16_t sync_time = 0; uint16_t sync_time = 0;
uint16_t low_time = 0; uint16_t low_time = 0;
@ -300,7 +300,7 @@ void SonoffBridgeReceived()
} }
} }
boolean SonoffBridgeSerialInput() boolean SonoffBridgeSerialInput(void)
{ {
// iTead Rf Universal Transceiver Module Serial Protocol Version 1.0 (20170420) // iTead Rf Universal Transceiver Module Serial Protocol Version 1.0 (20170420)
static int8_t receive_len = 0; static int8_t receive_len = 0;
@ -359,7 +359,7 @@ void SonoffBridgeSendCommand(byte code)
Serial.write(0x55); // End of Text Serial.write(0x55); // End of Text
} }
void SonoffBridgeSendAck() void SonoffBridgeSendAck(void)
{ {
Serial.write(0xAA); // Start of Text Serial.write(0xAA); // Start of Text
Serial.write(0xA0); // Acknowledge Serial.write(0xA0); // Acknowledge
@ -418,7 +418,7 @@ void SonoffBridgeLearn(uint8_t key)
* Commands * Commands
\*********************************************************************************************/ \*********************************************************************************************/
boolean SonoffBridgeCommand() boolean SonoffBridgeCommand(void)
{ {
char command [CMDSZ]; char command [CMDSZ];
boolean serviced = true; boolean serviced = true;
@ -556,7 +556,7 @@ boolean SonoffBridgeCommand()
/*********************************************************************************************/ /*********************************************************************************************/
void SonoffBridgeInit() void SonoffBridgeInit(void)
{ {
sonoff_bridge_receive_raw_flag = 0; sonoff_bridge_receive_raw_flag = 0;
SonoffBridgeSendCommand(0xA7); // Stop reading RF signals enabling iTead default RF handling SonoffBridgeSendCommand(0xA7); // Stop reading RF signals enabling iTead default RF handling

View File

@ -45,7 +45,7 @@ boolean domoticz_subscribe = false;
int domoticz_update_timer = 0; int domoticz_update_timer = 0;
byte domoticz_update_flag = 1; byte domoticz_update_flag = 1;
int DomoticzBatteryQuality() int DomoticzBatteryQuality(void)
{ {
// Battery 0%: ESP 2.6V (minimum operating voltage is 2.5) // Battery 0%: ESP 2.6V (minimum operating voltage is 2.5)
// Battery 100%: ESP 3.6V (maximum operating voltage is 3.6) // Battery 100%: ESP 3.6V (maximum operating voltage is 3.6)
@ -64,7 +64,7 @@ int DomoticzBatteryQuality()
return quality; return quality;
} }
int DomoticzRssiQuality() int DomoticzRssiQuality(void)
{ {
// RSSI range: 0% to 10% (12 means disable RSSI in Domoticz) // RSSI range: 0% to 10% (12 means disable RSSI in Domoticz)
@ -94,7 +94,7 @@ void DomoticzUpdatePowerState(byte device)
domoticz_update_flag = 1; domoticz_update_flag = 1;
} }
void DomoticzMqttUpdate() void DomoticzMqttUpdate(void)
{ {
if (domoticz_subscribe && (Settings.domoticz_update_timer || domoticz_update_timer)) { if (domoticz_subscribe && (Settings.domoticz_update_timer || domoticz_update_timer)) {
domoticz_update_timer--; domoticz_update_timer--;
@ -107,7 +107,7 @@ void DomoticzMqttUpdate()
} }
} }
void DomoticzMqttSubscribe() void DomoticzMqttSubscribe(void)
{ {
uint8_t maxdev = (devices_present > MAX_DOMOTICZ_IDX) ? MAX_DOMOTICZ_IDX : devices_present; uint8_t maxdev = (devices_present > MAX_DOMOTICZ_IDX) ? MAX_DOMOTICZ_IDX : devices_present;
for (byte i = 0; i < maxdev; i++) { for (byte i = 0; i < maxdev; i++) {
@ -148,7 +148,7 @@ void DomoticzMqttSubscribe()
} }
*/ */
boolean DomoticzMqttData() boolean DomoticzMqttData(void)
{ {
char stemp1[10]; char stemp1[10];
unsigned long idx = 0; unsigned long idx = 0;
@ -234,7 +234,7 @@ boolean DomoticzMqttData()
* Commands * Commands
\*********************************************************************************************/ \*********************************************************************************************/
boolean DomoticzCommand() boolean DomoticzCommand(void)
{ {
char command [CMDSZ]; char command [CMDSZ];
boolean serviced = true; boolean serviced = true;
@ -393,7 +393,7 @@ const char HTTP_FORM_DOMOTICZ_SENSOR[] PROGMEM =
const char HTTP_FORM_DOMOTICZ_TIMER[] PROGMEM = const char HTTP_FORM_DOMOTICZ_TIMER[] PROGMEM =
"<tr><td style='width:260px'><b>" D_DOMOTICZ_UPDATE_TIMER "</b> (" STR(DOMOTICZ_UPDATE_TIMER) ")</td><td style='width:70px'><input id='ut' name='ut' placeholder='" STR(DOMOTICZ_UPDATE_TIMER) "' value='{6'</td></tr>"; "<tr><td style='width:260px'><b>" D_DOMOTICZ_UPDATE_TIMER "</b> (" STR(DOMOTICZ_UPDATE_TIMER) ")</td><td style='width:70px'><input id='ut' name='ut' placeholder='" STR(DOMOTICZ_UPDATE_TIMER) "' value='{6'</td></tr>";
void HandleDomoticzConfiguration() void HandleDomoticzConfiguration(void)
{ {
if (HttpUser()) { return; } if (HttpUser()) { return; }
if (!WebAuthenticate()) { return WebServer->requestAuthentication(); } if (!WebAuthenticate()) { return WebServer->requestAuthentication(); }
@ -437,7 +437,7 @@ void HandleDomoticzConfiguration()
ShowPage(page); ShowPage(page);
} }
void DomoticzSaveSettings() void DomoticzSaveSettings(void)
{ {
char stemp[20]; char stemp[20];
char ssensor_indices[6 * MAX_DOMOTICZ_SNS_IDX]; char ssensor_indices[6 * MAX_DOMOTICZ_SNS_IDX];

View File

@ -38,7 +38,7 @@ uint8_t serial_bridge_in_byte_counter = 0;
unsigned long serial_bridge_polling_window = 0; unsigned long serial_bridge_polling_window = 0;
char serial_bridge_buffer[SERIAL_BRIDGE_BUFFER_SIZE]; char serial_bridge_buffer[SERIAL_BRIDGE_BUFFER_SIZE];
void SerialBridgeInput() void SerialBridgeInput(void)
{ {
while (SerialBridgeSerial->available()) { while (SerialBridgeSerial->available()) {
yield(); yield();
@ -87,7 +87,7 @@ void SerialBridgeInit(void)
* Commands * Commands
\*********************************************************************************************/ \*********************************************************************************************/
boolean SerialBridgeCommand() boolean SerialBridgeCommand(void)
{ {
char command [CMDSZ]; char command [CMDSZ];
boolean serviced = true; boolean serviced = true;

View File

@ -64,7 +64,7 @@ const double pi2 = TWO_PI;
const double pi = PI; const double pi = PI;
const double RAD = DEG_TO_RAD; const double RAD = DEG_TO_RAD;
double JulianischesDatum() double JulianischesDatum(void)
{ {
// Gregorianischer Kalender // Gregorianischer Kalender
int Gregor; int Gregor;
@ -255,12 +255,12 @@ void TimerSetRandomWindow(byte index)
} }
} }
void TimerSetRandomWindows() void TimerSetRandomWindows(void)
{ {
for (byte i = 0; i < MAX_TIMERS; i++) { TimerSetRandomWindow(i); } for (byte i = 0; i < MAX_TIMERS; i++) { TimerSetRandomWindow(i); }
} }
void TimerEverySecond() void TimerEverySecond(void)
{ {
if (RtcTime.valid) { if (RtcTime.valid) {
if (!RtcTime.hour && !RtcTime.minute && !RtcTime.second) { TimerSetRandomWindows(); } // Midnight if (!RtcTime.hour && !RtcTime.minute && !RtcTime.second) { TimerSetRandomWindows(); } // Midnight
@ -338,7 +338,7 @@ void PrepShowTimer(uint8_t index)
* Commands * Commands
\*********************************************************************************************/ \*********************************************************************************************/
boolean TimerCommand() boolean TimerCommand(void)
{ {
char command[CMDSZ]; char command[CMDSZ];
char dataBufUc[XdrvMailbox.data_len]; char dataBufUc[XdrvMailbox.data_len];
@ -681,7 +681,7 @@ const char HTTP_FORM_TIMER1[] PROGMEM =
"</div><br/>" "</div><br/>"
"<div id='ds' name='ds'></div>"; "<div id='ds' name='ds'></div>";
void HandleTimerConfiguration() void HandleTimerConfiguration(void)
{ {
if (HttpUser()) { return; } if (HttpUser()) { return; }
if (!WebAuthenticate()) { return WebServer->requestAuthentication(); } if (!WebAuthenticate()) { return WebServer->requestAuthentication(); }
@ -717,7 +717,7 @@ void HandleTimerConfiguration()
ShowPage(page); ShowPage(page);
} }
void TimerSaveSettings() void TimerSaveSettings(void)
{ {
char tmp[MAX_TIMERS *12]; // Need space for MAX_TIMERS x 10 digit numbers separated by a comma char tmp[MAX_TIMERS *12]; // Need space for MAX_TIMERS x 10 digit numbers separated by a comma
Timer timer; Timer timer;

View File

@ -347,12 +347,12 @@ bool RulesProcessEvent(char *json_event)
return serviced; return serviced;
} }
bool RulesProcess() bool RulesProcess(void)
{ {
return RulesProcessEvent(mqtt_data); return RulesProcessEvent(mqtt_data);
} }
void RulesInit() void RulesInit(void)
{ {
rules_flag.data = 0; rules_flag.data = 0;
for (byte i = 0; i < MAX_RULE_SETS; i++) { for (byte i = 0; i < MAX_RULE_SETS; i++) {
@ -364,7 +364,7 @@ void RulesInit()
rules_teleperiod = 0; rules_teleperiod = 0;
} }
void RulesEvery50ms() void RulesEvery50ms(void)
{ {
if (Settings.rule_enabled) { // Any rule enabled if (Settings.rule_enabled) { // Any rule enabled
char json_event[120]; char json_event[120];
@ -455,7 +455,7 @@ void RulesEvery50ms()
} }
} }
void RulesEvery100ms() void RulesEvery100ms(void)
{ {
if (Settings.rule_enabled && (uptime > 4)) { // Any rule enabled and allow 4 seconds start-up time for sensors (#3811) if (Settings.rule_enabled && (uptime > 4)) { // Any rule enabled and allow 4 seconds start-up time for sensors (#3811)
mqtt_data[0] = '\0'; mqtt_data[0] = '\0';
@ -471,7 +471,7 @@ void RulesEvery100ms()
} }
} }
void RulesEverySecond() void RulesEverySecond(void)
{ {
if (Settings.rule_enabled) { // Any rule enabled if (Settings.rule_enabled) { // Any rule enabled
char json_event[120]; char json_event[120];
@ -495,19 +495,19 @@ void RulesEverySecond()
} }
} }
void RulesSetPower() void RulesSetPower(void)
{ {
rules_new_power = XdrvMailbox.index; rules_new_power = XdrvMailbox.index;
} }
void RulesTeleperiod() void RulesTeleperiod(void)
{ {
rules_teleperiod = 1; rules_teleperiod = 1;
RulesProcess(); RulesProcess();
rules_teleperiod = 0; rules_teleperiod = 0;
} }
boolean RulesCommand() boolean RulesCommand(void)
{ {
char command[CMDSZ]; char command[CMDSZ];
boolean serviced = true; boolean serviced = true;

View File

@ -392,7 +392,7 @@ void KNX_DEL_CB( byte CBnum )
} }
bool KNX_CONFIG_NOT_MATCH() bool KNX_CONFIG_NOT_MATCH(void)
{ {
// Check for configured parameters that the device does not have (module changed) // Check for configured parameters that the device does not have (module changed)
for (byte i = 0; i < KNX_MAX_device_param; ++i) for (byte i = 0; i < KNX_MAX_device_param; ++i)
@ -442,7 +442,7 @@ bool KNX_CONFIG_NOT_MATCH()
} }
void KNXStart() void KNXStart(void)
{ {
knx.start(nullptr); knx.start(nullptr);
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_KNX D_START)); snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_KNX D_START));
@ -450,7 +450,7 @@ void KNXStart()
} }
void KNX_INIT() void KNX_INIT(void)
{ {
// Check for incompatible config // Check for incompatible config
if (Settings.knx_GA_registered > MAX_KNX_GA) { Settings.knx_GA_registered = MAX_KNX_GA; } if (Settings.knx_GA_registered > MAX_KNX_GA) { Settings.knx_GA_registered = MAX_KNX_GA; }
@ -795,7 +795,7 @@ const char HTTP_FORM_KNX_ADD_TABLE_ROW2[] PROGMEM =
"<tr><td><b>GAfnum / GAarea / GAfdef -> {optex}</b></td>" "<tr><td><b>GAfnum / GAarea / GAfdef -> {optex}</b></td>"
"<td><button type='submit' name='btn_del_cb' value='{opval}' class='button bred'> " D_DELETE " </button></td></tr>"; "<td><button type='submit' name='btn_del_cb' value='{opval}' class='button bred'> " D_DELETE " </button></td></tr>";
void HandleKNXConfiguration() void HandleKNXConfiguration(void)
{ {
if (HttpUser()) { return; } if (HttpUser()) { return; }
if (!WebAuthenticate()) { return WebServer->requestAuthentication(); } if (!WebAuthenticate()) { return WebServer->requestAuthentication(); }
@ -994,7 +994,7 @@ void HandleKNXConfiguration()
} }
void KNX_Save_Settings() void KNX_Save_Settings(void)
{ {
String stmp; String stmp;
address_t KNX_addr; address_t KNX_addr;
@ -1047,7 +1047,7 @@ void KNX_Save_Settings()
#endif // USE_WEBSERVER #endif // USE_WEBSERVER
boolean KnxCommand() boolean KnxCommand(void)
{ {
char command[CMDSZ]; char command[CMDSZ];
uint8_t index = XdrvMailbox.index; uint8_t index = XdrvMailbox.index;

View File

@ -61,6 +61,47 @@ const char HASS_DISCOVER_LIGHT_CT[] PROGMEM =
"%s,\"color_temp_command_topic\":\"%s\"," // cmnd/led2/CT "%s,\"color_temp_command_topic\":\"%s\"," // cmnd/led2/CT
"\"color_temp_state_topic\":\"%s\"," // stat/led2/RESULT "\"color_temp_state_topic\":\"%s\"," // stat/led2/RESULT
"\"color_temp_value_template\":\"{{value_json." D_CMND_COLORTEMPERATURE "}}\""; "\"color_temp_value_template\":\"{{value_json." D_CMND_COLORTEMPERATURE "}}\"";
const char HASS_DISCOVER_RELAY_SHORT[] PROGMEM =
"{\"name\":\"%s\"," // dualr2 1
"\"cmd_t\":\"%s\"," // cmnd/dualr2/POWER2
"\"stat_t\":\"%s\"," // stat/dualr2/RESULT (implies "\"optimistic\":\"false\",")
"\"val_tpl\":\"{{value_json.%s}}\"," // POWER2
"\"pl_off\":\"%s\"," // OFF
"\"pl_on\":\"%s\"," // ON
// "\"optimistic\":\"false\"," // false is Hass default when state_topic is set
"\"avty_t\":\"%s\"," // tele/dualr2/LWT
"\"pl_avail\":\"" D_ONLINE "\"," // Online
"\"pl_not_avail\":\"" D_OFFLINE "\""; // Offline
const char HASS_DISCOVER_BUTTON_SHORT[] PROGMEM =
"{\"name\":\"%s\"," // dualr2 1 BTN
"\"stat_t\":\"%s\"," // cmnd/dualr2/POWER (implies "\"optimistic\":\"false\",")
// "\"value_template\":\"{{value_json.%s}}\"," // POWER2
"\"pl_on\":\"%s\"," // TOGGLE
// "\"optimistic\":\"false\"," // false is Hass default when state_topic is set
"\"avty_t\":\"%s\"," // tele/dualr2/LWT
"\"pl_avail\":\"" D_ONLINE "\"," // Online
"\"pl_not_avail\":\"" D_OFFLINE "\"," // Offline
"\"frc_upd\":true";
const char HASS_DISCOVER_LIGHT_DIMMER_SHORT[] PROGMEM =
"%s,\"bri_cmd_t\":\"%s\"," // cmnd/led2/Dimmer
"\"bri_stat_t\":\"%s\"," // stat/led2/RESULT
"\"bri_scl\":100," // 100%
"\"on_cmd_type\":\"brightness\"," // power on (first), power on (last), no power on (brightness)
"\"bri_val_tpl\":\"{{value_json." D_CMND_DIMMER "}}\"";
const char HASS_DISCOVER_LIGHT_COLOR_SHORT[] PROGMEM =
"%s,\"rgb_cmd_t\":\"%s2\"," // cmnd/led2/Color2
"\"rgb_stat_t\":\"%s\"," // stat/led2/RESULT
"\"rgb_val_tpl\":\"{{value_json." D_CMND_COLOR ".split(',')[0:3]|join(',')}}\"";
// "\"rgb_val_tpl\":\"{{value_json." D_CMND_COLOR " | join(',')}}\"";
const char HASS_DISCOVER_LIGHT_CT_SHORT[] PROGMEM =
"%s,\"clr_temp_cmd_t\":\"%s\"," // cmnd/led2/CT
"\"clr_temp_stat_t\":\"%s\"," // stat/led2/RESULT
"\"clr_temp_val_tpl\":\"{{value_json." D_CMND_COLORTEMPERATURE "}}\"";
/* /*
const char HASS_DISCOVER_LIGHT_SCHEME[] PROGMEM = const char HASS_DISCOVER_LIGHT_SCHEME[] PROGMEM =
"%s,\"effect_command_topic\":\"%s\"," // cmnd/led2/Scheme "%s,\"effect_command_topic\":\"%s\"," // cmnd/led2/Scheme
@ -68,8 +109,30 @@ const char HASS_DISCOVER_LIGHT_SCHEME[] PROGMEM =
"\"effect_value_template\":\"{{value_json." D_CMND_SCHEME "}}\"," "\"effect_value_template\":\"{{value_json." D_CMND_SCHEME "}}\","
"\"effect_list\":[\"0\",\"1\",\"2\",\"3\",\"4\"]"; // string list with reference to scheme parameter. Currently only supports numbers 0 to 11 as it make the mqtt string too long "\"effect_list\":[\"0\",\"1\",\"2\",\"3\",\"4\"]"; // string list with reference to scheme parameter. Currently only supports numbers 0 to 11 as it make the mqtt string too long
*/ */
const char HASS_DISCOVER_TOPIC_PREFIX[] PROGMEM =
"%s, \"~\":\"%s\"";
void HAssDiscoverRelay() static void FindPrefix(char* s1, char* s2, char* out)
{
int prefixlen = 0;
while (s1[prefixlen] != '\0' && s2[prefixlen] != '\0' && s1[prefixlen] == s2[prefixlen]) {
prefixlen++;
}
strlcpy(out, s1, prefixlen+1);
}
static void Shorten(char** s, char *prefix)
{
size_t len = strlen(*s);
size_t prefixlen = strlen(prefix);
if (len > prefixlen && !strncmp(*s, prefix, prefixlen)) {
*s += prefixlen-1;
*s[0] = '~';
}
}
void HAssDiscoverRelay(void)
{ {
char sidx[8]; char sidx[8];
char stopic[TOPSZ]; char stopic[TOPSZ];
@ -92,9 +155,13 @@ void HAssDiscoverRelay()
if (Settings.flag.hass_discovery && (i <= devices_present)) { if (Settings.flag.hass_discovery && (i <= devices_present)) {
char name[33]; char name[33];
char value_template[33]; char value_template[33];
char command_topic[TOPSZ]; char _command_topic[TOPSZ];
char state_topic[TOPSZ]; char _state_topic[TOPSZ];
char availability_topic[TOPSZ]; char _availability_topic[TOPSZ];
char prefix[TOPSZ];
char *command_topic = _command_topic;
char *state_topic = _state_topic;
char *availability_topic = _availability_topic;
if (i > MAX_FRIENDLYNAMES) { if (i > MAX_FRIENDLYNAMES) {
snprintf_P(name, sizeof(name), PSTR("%s %d"), Settings.friendlyname[0], i); snprintf_P(name, sizeof(name), PSTR("%s %d"), Settings.friendlyname[0], i);
@ -105,19 +172,34 @@ void HAssDiscoverRelay()
GetTopic_P(command_topic, CMND, mqtt_topic, value_template); GetTopic_P(command_topic, CMND, mqtt_topic, value_template);
GetTopic_P(state_topic, STAT, mqtt_topic, S_RSLT_RESULT); GetTopic_P(state_topic, STAT, mqtt_topic, S_RSLT_RESULT);
GetTopic_P(availability_topic, TELE, mqtt_topic, S_LWT); GetTopic_P(availability_topic, TELE, mqtt_topic, S_LWT);
snprintf_P(mqtt_data, sizeof(mqtt_data), HASS_DISCOVER_RELAY, name, command_topic, state_topic, value_template, Settings.state_text[0], Settings.state_text[1], availability_topic); FindPrefix(command_topic, state_topic, prefix);
if (Settings.flag3.hass_short_discovery_msg) {
Shorten(&command_topic, prefix);
Shorten(&state_topic, prefix);
Shorten(&availability_topic, prefix);
}
snprintf_P(mqtt_data, sizeof(mqtt_data), Settings.flag3.hass_short_discovery_msg?HASS_DISCOVER_RELAY_SHORT:HASS_DISCOVER_RELAY,
name, command_topic, state_topic, value_template, Settings.state_text[0], Settings.state_text[1], availability_topic);
if (is_light) { if (is_light) {
char brightness_command_topic[TOPSZ]; char _brightness_command_topic[TOPSZ];
char *brightness_command_topic = _brightness_command_topic;
GetTopic_P(brightness_command_topic, CMND, mqtt_topic, D_CMND_DIMMER); GetTopic_P(brightness_command_topic, CMND, mqtt_topic, D_CMND_DIMMER);
snprintf_P(mqtt_data, sizeof(mqtt_data), HASS_DISCOVER_LIGHT_DIMMER, mqtt_data, brightness_command_topic, state_topic); if (Settings.flag3.hass_short_discovery_msg)
Shorten(&brightness_command_topic, prefix);
snprintf_P(mqtt_data, sizeof(mqtt_data), Settings.flag3.hass_short_discovery_msg?HASS_DISCOVER_LIGHT_DIMMER_SHORT:HASS_DISCOVER_LIGHT_DIMMER,
mqtt_data, brightness_command_topic, state_topic);
if (light_subtype >= LST_RGB) { if (light_subtype >= LST_RGB) {
char rgb_command_topic[TOPSZ]; char _rgb_command_topic[TOPSZ];
char *rgb_command_topic = _rgb_command_topic;
GetTopic_P(rgb_command_topic, CMND, mqtt_topic, D_CMND_COLOR); GetTopic_P(rgb_command_topic, CMND, mqtt_topic, D_CMND_COLOR);
snprintf_P(mqtt_data, sizeof(mqtt_data), HASS_DISCOVER_LIGHT_COLOR, mqtt_data, rgb_command_topic, state_topic); if (Settings.flag3.hass_short_discovery_msg)
Shorten(&rgb_command_topic, prefix);
snprintf_P(mqtt_data, sizeof(mqtt_data), Settings.flag3.hass_short_discovery_msg?HASS_DISCOVER_LIGHT_COLOR_SHORT:HASS_DISCOVER_LIGHT_COLOR,
mqtt_data, rgb_command_topic, state_topic);
/* /*
char effect_command_topic[TOPSZ]; char effect_command_topic[TOPSZ];
@ -126,19 +208,25 @@ void HAssDiscoverRelay()
*/ */
} }
if ((LST_COLDWARM == light_subtype) || (LST_RGBWC == light_subtype)) { if ((LST_COLDWARM == light_subtype) || (LST_RGBWC == light_subtype)) {
char color_temp_command_topic[TOPSZ]; char _color_temp_command_topic[TOPSZ];
char *color_temp_command_topic = _color_temp_command_topic;
GetTopic_P(color_temp_command_topic, CMND, mqtt_topic, D_CMND_COLORTEMPERATURE); GetTopic_P(color_temp_command_topic, CMND, mqtt_topic, D_CMND_COLORTEMPERATURE);
snprintf_P(mqtt_data, sizeof(mqtt_data), HASS_DISCOVER_LIGHT_CT, mqtt_data, color_temp_command_topic, state_topic); if (Settings.flag3.hass_short_discovery_msg)
Shorten(&color_temp_command_topic, prefix);
snprintf_P(mqtt_data, sizeof(mqtt_data), Settings.flag3.hass_short_discovery_msg?HASS_DISCOVER_LIGHT_CT_SHORT:HASS_DISCOVER_LIGHT_CT,
mqtt_data, color_temp_command_topic, state_topic);
} }
} }
if (Settings.flag3.hass_short_discovery_msg)
snprintf_P(mqtt_data, sizeof(mqtt_data), HASS_DISCOVER_TOPIC_PREFIX, mqtt_data, prefix);
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s}"), mqtt_data); snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s}"), mqtt_data);
} }
MqttPublish(stopic, true); MqttPublish(stopic, true);
} }
} }
void HAssDiscoverButton() void HAssDiscoverButton(void)
{ {
char sidx[8]; char sidx[8];
char stopic[TOPSZ]; char stopic[TOPSZ];
@ -168,8 +256,11 @@ void HAssDiscoverButton()
if (Settings.flag.hass_discovery && button_present) { if (Settings.flag.hass_discovery && button_present) {
char name[33]; char name[33];
char value_template[33]; char value_template[33];
char state_topic[TOPSZ]; char _state_topic[TOPSZ];
char availability_topic[TOPSZ]; char _availability_topic[TOPSZ];
char prefix[TOPSZ];
char *state_topic = _state_topic;
char *availability_topic = _availability_topic;
if (button_index+1 > MAX_FRIENDLYNAMES) { if (button_index+1 > MAX_FRIENDLYNAMES) {
snprintf_P(name, sizeof(name), PSTR("%s %d BTN"), Settings.friendlyname[0], button_index+1); snprintf_P(name, sizeof(name), PSTR("%s %d BTN"), Settings.friendlyname[0], button_index+1);
@ -179,8 +270,16 @@ void HAssDiscoverButton()
GetPowerDevice(value_template, button_index+1, sizeof(value_template), Settings.flag.device_index_enable); GetPowerDevice(value_template, button_index+1, sizeof(value_template), Settings.flag.device_index_enable);
GetTopic_P(state_topic, CMND, key_topic, value_template); // State of button is sent as CMND TOGGLE GetTopic_P(state_topic, CMND, key_topic, value_template); // State of button is sent as CMND TOGGLE
GetTopic_P(availability_topic, TELE, mqtt_topic, S_LWT); GetTopic_P(availability_topic, TELE, mqtt_topic, S_LWT);
snprintf_P(mqtt_data, sizeof(mqtt_data), HASS_DISCOVER_BUTTON, name, state_topic, Settings.state_text[2], availability_topic); FindPrefix(state_topic, availability_topic, prefix);
if (Settings.flag3.hass_short_discovery_msg) {
Shorten(&state_topic, prefix);
Shorten(&availability_topic, prefix);
}
snprintf_P(mqtt_data, sizeof(mqtt_data), Settings.flag3.hass_short_discovery_msg?HASS_DISCOVER_BUTTON_SHORT:HASS_DISCOVER_BUTTON,
name, state_topic, Settings.state_text[2], availability_topic);
if (Settings.flag3.hass_short_discovery_msg)
snprintf_P(mqtt_data, sizeof(mqtt_data), HASS_DISCOVER_TOPIC_PREFIX, mqtt_data, prefix);
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s}"), mqtt_data); snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s}"), mqtt_data);
} }
MqttPublish(stopic, true); MqttPublish(stopic, true);
@ -188,6 +287,14 @@ void HAssDiscoverButton()
} }
} }
static int string_ends_with(const char * str, const char * suffix)
{
int str_len = strlen(str);
int suffix_len = strlen(suffix);
return (str_len >= suffix_len) && (0 == strcmp(str + (str_len-suffix_len), suffix));
}
void HAssDiscovery(uint8_t mode) void HAssDiscovery(uint8_t mode)
{ {
// Configure Tasmota for default Home Assistant parameters to keep discovery message as short as possible // Configure Tasmota for default Home Assistant parameters to keep discovery message as short as possible
@ -195,7 +302,8 @@ void HAssDiscovery(uint8_t mode)
Settings.flag.mqtt_response = 0; // Response always as RESULT and not as uppercase command Settings.flag.mqtt_response = 0; // Response always as RESULT and not as uppercase command
Settings.flag.decimal_text = 1; // Respond with decimal color values Settings.flag.decimal_text = 1; // Respond with decimal color values
// Settings.light_scheme = 0; // To just control color it needs to be Scheme 0 // Settings.light_scheme = 0; // To just control color it needs to be Scheme 0
// strncpy_P(Settings.mqtt_fulltopic, PSTR("%prefix%/%topic%/"), sizeof(Settings.mqtt_fulltopic)); // Make MQTT topic as short as possible to make this process posible within MQTT_MAX_PACKET_SIZE if (!string_ends_with(Settings.mqtt_fulltopic, "%prefix%/"))
strncpy_P(Settings.mqtt_fulltopic, PSTR("%topic%/%prefix%/"), sizeof(Settings.mqtt_fulltopic));
} }
if (Settings.flag.hass_discovery || (1 == mode)) { if (Settings.flag.hass_discovery || (1 == mode)) {
@ -215,7 +323,7 @@ void HAssDiscovery(uint8_t mode)
enum HassCommands { CMND_HASSDISCOVER }; enum HassCommands { CMND_HASSDISCOVER };
const char kHassCommands[] PROGMEM = D_CMND_HASSDISCOVER ; const char kHassCommands[] PROGMEM = D_CMND_HASSDISCOVER ;
boolean HassCommand() boolean HassCommand(void)
{ {
char command[CMDSZ]; char command[CMDSZ];
boolean serviced = true; boolean serviced = true;

View File

@ -106,7 +106,7 @@ void DisplayInit(uint8_t mode)
XdspCall(FUNC_DISPLAY_INIT); XdspCall(FUNC_DISPLAY_INIT);
} }
void DisplayClear() void DisplayClear(void)
{ {
XdspCall(FUNC_DISPLAY_CLEAR); XdspCall(FUNC_DISPLAY_CLEAR);
} }
@ -177,7 +177,7 @@ void DisplayDrawFilledRectangle(uint16_t x, uint16_t y, uint16_t x2, uint16_t y2
XdspCall(FUNC_DISPLAY_FILL_RECTANGLE); XdspCall(FUNC_DISPLAY_FILL_RECTANGLE);
} }
void DisplayDrawFrame() void DisplayDrawFrame(void)
{ {
XdspCall(FUNC_DISPLAY_DRAW_FRAME); XdspCall(FUNC_DISPLAY_DRAW_FRAME);
} }
@ -254,7 +254,7 @@ uint8_t atoiV(char *cp, uint16_t *res)
#define DISPLAY_BUFFER_COLS 128 // Max number of characters in linebuf #define DISPLAY_BUFFER_COLS 128 // Max number of characters in linebuf
void DisplayText() void DisplayText(void)
{ {
uint8_t lpos; uint8_t lpos;
uint8_t escape = 0; uint8_t escape = 0;
@ -487,7 +487,7 @@ void DisplayText()
#ifdef USE_DISPLAY_MODES1TO5 #ifdef USE_DISPLAY_MODES1TO5
void DisplayClearScreenBuffer() void DisplayClearScreenBuffer(void)
{ {
if (disp_screen_buffer_cols) { if (disp_screen_buffer_cols) {
for (byte i = 0; i < disp_screen_buffer_rows; i++) { for (byte i = 0; i < disp_screen_buffer_rows; i++) {
@ -496,7 +496,7 @@ void DisplayClearScreenBuffer()
} }
} }
void DisplayFreeScreenBuffer() void DisplayFreeScreenBuffer(void)
{ {
if (disp_screen_buffer != NULL) { if (disp_screen_buffer != NULL) {
for (byte i = 0; i < disp_screen_buffer_rows; i++) { for (byte i = 0; i < disp_screen_buffer_rows; i++) {
@ -508,7 +508,7 @@ void DisplayFreeScreenBuffer()
} }
} }
void DisplayAllocScreenBuffer() void DisplayAllocScreenBuffer(void)
{ {
if (!disp_screen_buffer_cols) { if (!disp_screen_buffer_cols) {
disp_screen_buffer_rows = Settings.display_rows; disp_screen_buffer_rows = Settings.display_rows;
@ -529,7 +529,7 @@ void DisplayAllocScreenBuffer()
} }
} }
void DisplayReAllocScreenBuffer() void DisplayReAllocScreenBuffer(void)
{ {
DisplayFreeScreenBuffer(); DisplayFreeScreenBuffer();
DisplayAllocScreenBuffer(); DisplayAllocScreenBuffer();
@ -546,7 +546,7 @@ void DisplayFillScreen(uint8_t line)
/*-------------------------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------------------------*/
void DisplayClearLogBuffer() void DisplayClearLogBuffer(void)
{ {
if (disp_log_buffer_cols) { if (disp_log_buffer_cols) {
for (byte i = 0; i < DISPLAY_LOG_ROWS; i++) { for (byte i = 0; i < DISPLAY_LOG_ROWS; i++) {
@ -555,7 +555,7 @@ void DisplayClearLogBuffer()
} }
} }
void DisplayFreeLogBuffer() void DisplayFreeLogBuffer(void)
{ {
if (disp_log_buffer != NULL) { if (disp_log_buffer != NULL) {
for (byte i = 0; i < DISPLAY_LOG_ROWS; i++) { for (byte i = 0; i < DISPLAY_LOG_ROWS; i++) {
@ -566,7 +566,7 @@ void DisplayFreeLogBuffer()
} }
} }
void DisplayAllocLogBuffer() void DisplayAllocLogBuffer(void)
{ {
if (!disp_log_buffer_cols) { if (!disp_log_buffer_cols) {
disp_log_buffer = (char**)malloc(sizeof(*disp_log_buffer) * DISPLAY_LOG_ROWS); disp_log_buffer = (char**)malloc(sizeof(*disp_log_buffer) * DISPLAY_LOG_ROWS);
@ -586,7 +586,7 @@ void DisplayAllocLogBuffer()
} }
} }
void DisplayReAllocLogBuffer() void DisplayReAllocLogBuffer(void)
{ {
DisplayFreeLogBuffer(); DisplayFreeLogBuffer();
DisplayAllocLogBuffer(); DisplayAllocLogBuffer();
@ -617,7 +617,7 @@ char* DisplayLogBuffer(char temp_code)
return result; return result;
} }
void DisplayLogBufferInit() void DisplayLogBufferInit(void)
{ {
if (Settings.display_mode) { if (Settings.display_mode) {
disp_log_buffer_idx = 0; disp_log_buffer_idx = 0;
@ -798,7 +798,7 @@ void DisplayAnalyzeJson(char *topic, char *json)
} }
} }
void DisplayMqttSubscribe() void DisplayMqttSubscribe(void)
{ {
/* Subscribe to tele messages only /* Subscribe to tele messages only
* Supports the following FullTopic formats * Supports the following FullTopic formats
@ -831,7 +831,7 @@ void DisplayMqttSubscribe()
} }
} }
boolean DisplayMqttData() boolean DisplayMqttData(void)
{ {
if (disp_subscribed) { if (disp_subscribed) {
char stopic[TOPSZ]; char stopic[TOPSZ];
@ -850,7 +850,7 @@ boolean DisplayMqttData()
return false; return false;
} }
void DisplayLocalSensor() void DisplayLocalSensor(void)
{ {
if ((Settings.display_mode &0x02) && (0 == tele_period)) { if ((Settings.display_mode &0x02) && (0 == tele_period)) {
DisplayAnalyzeJson(mqtt_topic, mqtt_data); DisplayAnalyzeJson(mqtt_topic, mqtt_data);
@ -863,7 +863,7 @@ void DisplayLocalSensor()
* Public * Public
\*********************************************************************************************/ \*********************************************************************************************/
void DisplayInitDriver() void DisplayInitDriver(void)
{ {
XdspCall(FUNC_DISPLAY_INIT_DRIVER); XdspCall(FUNC_DISPLAY_INIT_DRIVER);
@ -882,7 +882,7 @@ void DisplayInitDriver()
} }
} }
void DisplaySetPower() void DisplaySetPower(void)
{ {
disp_power = bitRead(XdrvMailbox.index, disp_device -1); disp_power = bitRead(XdrvMailbox.index, disp_device -1);
if (Settings.display_model) { if (Settings.display_model) {
@ -894,7 +894,7 @@ void DisplaySetPower()
* Commands * Commands
\*********************************************************************************************/ \*********************************************************************************************/
boolean DisplayCommand() boolean DisplayCommand(void)
{ {
char command [CMDSZ]; char command [CMDSZ];
boolean serviced = true; boolean serviced = true;

View File

@ -33,7 +33,7 @@
tested - works by MP3Device 1 = USB STick, or MP3Device 2 = SD-Card tested - works by MP3Device 1 = USB STick, or MP3Device 2 = SD-Card
- after power and/or reset the SD-Card(2) is the default device - after power and/or reset the SD-Card(2) is the default device
--- ---
1.0.0.2 20180912 added - again some if-commands to switch() because of new commands 1.0.0.2 20180912 added - again some if-commands to switch() because of new commands
--- ---
1.0.0.1 20180911 added - command eq (equalizer 0..5) 1.0.0.1 20180911 added - command eq (equalizer 0..5)
tested - works in console with MP3EQ 1, the value can be 0..5 tested - works in console with MP3EQ 1, the value can be 0..5
@ -42,13 +42,13 @@
erased - code for USB device about some errors, will be added in a next release erased - code for USB device about some errors, will be added in a next release
--- ---
1.0.0.1 20180910 changed - command real MP3Stop in place of pause/stop used in the original version 1.0.0.1 20180910 changed - command real MP3Stop in place of pause/stop used in the original version
changed - the command MP3Play e.g. 001 to MP3Track e.g. 001, changed - the command MP3Play e.g. 001 to MP3Track e.g. 001,
added - new normal command MP3Play and MP3Pause added - new normal command MP3Play and MP3Pause
--- ---
1.0.0.0 20180907 merged - by arendst 1.0.0.0 20180907 merged - by arendst
changed - the driver name from xdrv_91_mp3.ino to xdrv_14_mp3.ino changed - the driver name from xdrv_91_mp3.ino to xdrv_14_mp3.ino
--- ---
0.9.0.3 20180906 request - Pull Request 0.9.0.3 20180906 request - Pull Request
changed - if-commands to switch() for faster response changed - if-commands to switch() for faster response
--- ---
0.9.0.2 20180906 cleaned - source code for faster reading 0.9.0.2 20180906 cleaned - source code for faster reading
@ -98,7 +98,7 @@ enum MP3_Commands { // commands useable in conso
CMND_MP3_RESET, // MP3Reset, a fresh and default restart CMND_MP3_RESET, // MP3Reset, a fresh and default restart
CMND_MP3_DAC }; // set dac, 1=off, 0=on, DAC is turned on (0) by default CMND_MP3_DAC }; // set dac, 1=off, 0=on, DAC is turned on (0) by default
/*********************************************************************************************\ /*********************************************************************************************\
* command defines * command defines
\*********************************************************************************************/ \*********************************************************************************************/
@ -107,7 +107,7 @@ enum MP3_Commands { // commands useable in conso
// player commands // player commands
#define MP3_CMD_TRACK 0x03 // specify playback of a track, e.g. MP3Track 003 #define MP3_CMD_TRACK 0x03 // specify playback of a track, e.g. MP3Track 003
#define MP3_CMD_PLAY 0x0d // Play, works as a normal play on a real MP3 Player, starts at 001.mp3 file on the selected device #define MP3_CMD_PLAY 0x0d // Play, works as a normal play on a real MP3 Player, starts at 001.mp3 file on the selected device
#define MP3_CMD_PAUSE 0x0e // Pause, was original designed as stop, see data sheet #define MP3_CMD_PAUSE 0x0e // Pause, was original designed as stop, see data sheet
#define MP3_CMD_STOP 0x16 // Stop, it's a real stop now, in the original version it was a pause command #define MP3_CMD_STOP 0x16 // Stop, it's a real stop now, in the original version it was a pause command
#define MP3_CMD_VOLUME 0x06 // specifies the volume and means a console input as 0..100 #define MP3_CMD_VOLUME 0x06 // specifies the volume and means a console input as 0..100
#define MP3_CMD_EQ 0x07 // specify EQ(0/1/2/3/4/5), 0:Normal, 1:Pop, 2:Rock, 3:Jazz, 4:Classic, 5:Bass #define MP3_CMD_EQ 0x07 // specify EQ(0/1/2/3/4/5), 0:Normal, 1:Pop, 2:Rock, 3:Jazz, 4:Classic, 5:Bass
@ -138,7 +138,7 @@ uint16_t MP3_Checksum(uint8_t *array)
void MP3PlayerInit(void) { void MP3PlayerInit(void) {
MP3Player = new TasmotaSerial(-1, pin[GPIO_MP3_DFR562]); MP3Player = new TasmotaSerial(-1, pin[GPIO_MP3_DFR562]);
// start serial communication fixed to 9600 baud // start serial communication fixed to 9600 baud
if (MP3Player->begin(9600)) { if (MP3Player->begin(9600)) {
MP3Player->flush(); MP3Player->flush();
delay(1000); delay(1000);
MP3_CMD(MP3_CMD_RESET, MP3_CMD_RESET_VALUE); // reset the player to defaults MP3_CMD(MP3_CMD_RESET, MP3_CMD_RESET_VALUE); // reset the player to defaults
@ -185,7 +185,7 @@ boolean MP3PlayerCmd(void) {
if (!strncasecmp_P(XdrvMailbox.topic, PSTR(D_CMND_MP3), disp_len)) { // prefix if (!strncasecmp_P(XdrvMailbox.topic, PSTR(D_CMND_MP3), disp_len)) { // prefix
int command_code = GetCommandCode(command, sizeof(command), XdrvMailbox.topic + disp_len, kMP3_Commands); int command_code = GetCommandCode(command, sizeof(command), XdrvMailbox.topic + disp_len, kMP3_Commands);
switch (command_code) { switch (command_code) {
case CMND_MP3_TRACK: case CMND_MP3_TRACK:
case CMND_MP3_VOLUME: case CMND_MP3_VOLUME:
@ -206,7 +206,7 @@ boolean MP3PlayerCmd(void) {
case CMND_MP3_PAUSE: case CMND_MP3_PAUSE:
case CMND_MP3_STOP: case CMND_MP3_STOP:
case CMND_MP3_RESET: case CMND_MP3_RESET:
// play or re-play after pause, pause, stop, // play or re-play after pause, pause, stop,
if (command_code == CMND_MP3_PLAY) { MP3_CMD(MP3_CMD_PLAY, 0); } if (command_code == CMND_MP3_PLAY) { MP3_CMD(MP3_CMD_PLAY, 0); }
if (command_code == CMND_MP3_PAUSE) { MP3_CMD(MP3_CMD_PAUSE, 0); } if (command_code == CMND_MP3_PAUSE) { MP3_CMD(MP3_CMD_PAUSE, 0); }
if (command_code == CMND_MP3_STOP) { MP3_CMD(MP3_CMD_STOP, 0); } if (command_code == CMND_MP3_STOP) { MP3_CMD(MP3_CMD_STOP, 0); }
@ -230,13 +230,15 @@ boolean Xdrv14(byte function)
{ {
boolean result = false; boolean result = false;
switch (function) { if (pin[GPIO_MP3_DFR562] < 99) {
case FUNC_PRE_INIT: switch (function) {
MP3PlayerInit(); // init and start communication case FUNC_PRE_INIT:
break; MP3PlayerInit(); // init and start communication
case FUNC_COMMAND: break;
result = MP3PlayerCmd(); // return result from mp3 player command case FUNC_COMMAND:
break; result = MP3PlayerCmd(); // return result from mp3 player command
break;
}
} }
return result; return result;
} }

View File

@ -68,7 +68,7 @@ void TuyaSendCmd(uint8_t cmd, uint8_t payload[] = nullptr, uint16_t payload_len
TuyaSerial->write(cmd); // Tuya command TuyaSerial->write(cmd); // Tuya command
TuyaSerial->write(payload_len >> 8); // following data length (Hi) TuyaSerial->write(payload_len >> 8); // following data length (Hi)
TuyaSerial->write(payload_len & 0xFF); // following data length (Lo) TuyaSerial->write(payload_len & 0xFF); // following data length (Lo)
snprintf_P(log_data, sizeof(log_data), PSTR("TYA: Sent Packet: \"55aa00%02x%02x%02x"), cmd, payload_len >> 8, payload_len & 0xFF); snprintf_P(log_data, sizeof(log_data), PSTR("TYA: TX Packet: \"55aa00%02x%02x%02x"), cmd, payload_len >> 8, payload_len & 0xFF);
for(int i = 0; i < payload_len; ++i) { for(int i = 0; i < payload_len; ++i) {
TuyaSerial->write(payload[i]); TuyaSerial->write(payload[i]);
checksum += payload[i]; checksum += payload[i];
@ -114,7 +114,7 @@ void TuyaSendValue(uint8_t id, uint32_t value){
TuyaSendState(id, TUYA_TYPE_VALUE, (uint8_t*)(&value)); TuyaSendState(id, TUYA_TYPE_VALUE, (uint8_t*)(&value));
} }
boolean TuyaSetPower() boolean TuyaSetPower(void)
{ {
boolean status = false; boolean status = false;
@ -140,11 +140,11 @@ void LightSerialDuty(uint8_t duty)
duty = 25; // dimming acts odd below 25(10%) - this mirrors the threshold set on the faceplate itself duty = 25; // dimming acts odd below 25(10%) - this mirrors the threshold set on the faceplate itself
} }
TuyaSendValue(Settings.param[P_TUYA_DIMMER_ID], duty);
snprintf_P(log_data, sizeof(log_data), PSTR( "TYA: Send Serial Packet Dim Value=%d (id=%d)"), duty, Settings.param[P_TUYA_DIMMER_ID]); snprintf_P(log_data, sizeof(log_data), PSTR( "TYA: Send Serial Packet Dim Value=%d (id=%d)"), duty, Settings.param[P_TUYA_DIMMER_ID]);
AddLog(LOG_LEVEL_DEBUG); AddLog(LOG_LEVEL_DEBUG);
TuyaSendValue(Settings.param[P_TUYA_DIMMER_ID], duty);
} else { } else {
tuya_ignore_dim = false; // reset flag tuya_ignore_dim = false; // reset flag
@ -154,8 +154,9 @@ void LightSerialDuty(uint8_t duty)
} }
} }
void TuyaRequestState(){ void TuyaRequestState(void){
if(TuyaSerial) { if(TuyaSerial) {
// Get current status of MCU // Get current status of MCU
snprintf_P(log_data, sizeof(log_data), "TYA: Request MCU state"); snprintf_P(log_data, sizeof(log_data), "TYA: Request MCU state");
AddLog(LOG_LEVEL_DEBUG); AddLog(LOG_LEVEL_DEBUG);
@ -164,7 +165,7 @@ void TuyaRequestState(){
} }
} }
void TuyaResetWifi() void TuyaResetWifi(void)
{ {
if (!Settings.flag.button_restrict) { if (!Settings.flag.button_restrict) {
char scmnd[20]; char scmnd[20];
@ -173,7 +174,7 @@ void TuyaResetWifi()
} }
} }
void TuyaPacketProcess() void TuyaPacketProcess(void)
{ {
char scmnd[20]; char scmnd[20];
@ -190,7 +191,7 @@ void TuyaPacketProcess()
case TUYA_CMD_STATE: case TUYA_CMD_STATE:
if (tuya_buffer[5] == 5) { // on/off packet if (tuya_buffer[5] == 5) { // on/off packet
snprintf_P(log_data, sizeof(log_data),PSTR("TYA: Rcvd - %s State"),tuya_buffer[10]?"On":"Off"); snprintf_P(log_data, sizeof(log_data),PSTR("TYA: RX - %s State"),tuya_buffer[10]?"On":"Off");
AddLog(LOG_LEVEL_DEBUG); AddLog(LOG_LEVEL_DEBUG);
if((power || Settings.light_dimmer > 0) && (power != tuya_buffer[10])) { if((power || Settings.light_dimmer > 0) && (power != tuya_buffer[10])) {
@ -199,7 +200,7 @@ void TuyaPacketProcess()
} }
else if (tuya_buffer[5] == 8) { // dim packet else if (tuya_buffer[5] == 8) { // dim packet
snprintf_P(log_data, sizeof(log_data), PSTR("TYA: Rcvd Dim State=%d"), tuya_buffer[13]); snprintf_P(log_data, sizeof(log_data), PSTR("TYA: RX Dim State=%d"), tuya_buffer[13]);
AddLog(LOG_LEVEL_DEBUG); AddLog(LOG_LEVEL_DEBUG);
if (!Settings.param[P_TUYA_DIMMER_ID]) { if (!Settings.param[P_TUYA_DIMMER_ID]) {
@ -224,17 +225,17 @@ void TuyaPacketProcess()
case TUYA_CMD_WIFI_RESET: case TUYA_CMD_WIFI_RESET:
case TUYA_CMD_WIFI_SELECT: case TUYA_CMD_WIFI_SELECT:
AddLog_P(LOG_LEVEL_DEBUG, PSTR("TYA: Rcvd WiFi Reset")); AddLog_P(LOG_LEVEL_DEBUG, PSTR("TYA: RX WiFi Reset"));
TuyaResetWifi(); TuyaResetWifi();
break; break;
case TUYA_CMD_WIFI_STATE: case TUYA_CMD_WIFI_STATE:
AddLog_P(LOG_LEVEL_DEBUG, PSTR("TYA: Rcvd WiFi LED set ACK")); AddLog_P(LOG_LEVEL_DEBUG, PSTR("TYA: RX WiFi LED set ACK"));
tuya_wifi_state = WifiState(); tuya_wifi_state = WifiState();
break; break;
case TUYA_CMD_MCU_CONF: case TUYA_CMD_MCU_CONF:
AddLog_P(LOG_LEVEL_DEBUG, PSTR("TYA: Rcvd MCU configuration")); AddLog_P(LOG_LEVEL_DEBUG, PSTR("TYA: RX MCU configuration"));
if (tuya_buffer[5] == 2) { if (tuya_buffer[5] == 2) {
uint8_t led1_gpio = tuya_buffer[6]; uint8_t led1_gpio = tuya_buffer[6];
@ -258,7 +259,7 @@ void TuyaPacketProcess()
break; break;
default: default:
AddLog_P(LOG_LEVEL_DEBUG, PSTR("TYA: Rcvd unknown command")); AddLog_P(LOG_LEVEL_DEBUG, PSTR("TYA: RX unknown command"));
} }
} }
@ -266,7 +267,7 @@ void TuyaPacketProcess()
* API Functions * API Functions
\*********************************************************************************************/ \*********************************************************************************************/
boolean TuyaModuleSelected() boolean TuyaModuleSelected(void)
{ {
if (!(pin[GPIO_TUYA_RX] < 99) || !(pin[GPIO_TUYA_TX] < 99)) { // fallback to hardware-serial if not explicitly selected if (!(pin[GPIO_TUYA_RX] < 99) || !(pin[GPIO_TUYA_TX] < 99)) { // fallback to hardware-serial if not explicitly selected
pin[GPIO_TUYA_TX] = 1; pin[GPIO_TUYA_TX] = 1;
@ -279,7 +280,7 @@ boolean TuyaModuleSelected()
return true; return true;
} }
void TuyaInit() void TuyaInit(void)
{ {
if (!Settings.param[P_TUYA_DIMMER_ID]) { if (!Settings.param[P_TUYA_DIMMER_ID]) {
Settings.param[P_TUYA_DIMMER_ID] = TUYA_DIMMER_ID; Settings.param[P_TUYA_DIMMER_ID] = TUYA_DIMMER_ID;
@ -295,7 +296,7 @@ void TuyaInit()
} }
} }
void TuyaSerialInput() void TuyaSerialInput(void)
{ {
while (TuyaSerial->available()) { while (TuyaSerial->available()) {
yield(); yield();
@ -325,7 +326,7 @@ void TuyaSerialInput()
else if ((tuya_cmd_status == 3) && (tuya_byte_counter == (6 + tuya_data_len)) && (tuya_cmd_checksum == serial_in_byte)){ // Compare checksum and process packet else if ((tuya_cmd_status == 3) && (tuya_byte_counter == (6 + tuya_data_len)) && (tuya_cmd_checksum == serial_in_byte)){ // Compare checksum and process packet
tuya_buffer[tuya_byte_counter++] = serial_in_byte; tuya_buffer[tuya_byte_counter++] = serial_in_byte;
snprintf_P(log_data, sizeof(log_data), PSTR("TYA: Received Packet: \"")); snprintf_P(log_data, sizeof(log_data), PSTR("TYA: RX Packet: \""));
for (int i = 0; i < tuya_byte_counter; i++) { for (int i = 0; i < tuya_byte_counter; i++) {
snprintf_P(log_data, sizeof(log_data), PSTR("%s%02x"), log_data, tuya_buffer[i]); snprintf_P(log_data, sizeof(log_data), PSTR("%s%02x"), log_data, tuya_buffer[i]);
} }
@ -351,7 +352,7 @@ void TuyaSerialInput()
} }
boolean TuyaButtonPressed() boolean TuyaButtonPressed(void)
{ {
if (!XdrvMailbox.index && ((PRESSED == XdrvMailbox.payload) && (NOT_PRESSED == lastbutton[XdrvMailbox.index]))) { if (!XdrvMailbox.index && ((PRESSED == XdrvMailbox.payload) && (NOT_PRESSED == lastbutton[XdrvMailbox.index]))) {
snprintf_P(log_data, sizeof(log_data), PSTR("TYA: Reset GPIO triggered")); snprintf_P(log_data, sizeof(log_data), PSTR("TYA: Reset GPIO triggered"));
@ -362,7 +363,7 @@ boolean TuyaButtonPressed()
return false; // Don't serve other buttons return false; // Don't serve other buttons
} }
void TuyaSetWifiLed(){ void TuyaSetWifiLed(void){
uint8_t wifi_state = 0x02; uint8_t wifi_state = 0x02;
switch(WifiState()){ switch(WifiState()){
case WIFI_SMARTCONFIG: case WIFI_SMARTCONFIG:

View File

@ -36,11 +36,11 @@
RCSwitch mySwitch = RCSwitch(); RCSwitch mySwitch = RCSwitch();
#define RF_TIME_AVOID_DUPLICATE 1000 // Milliseconds #define RF_TIME_AVOID_DUPLICATE 1000 // Milliseconds
uint32_t rf_lasttime = 0; uint32_t rf_lasttime = 0;
void RfReceiveCheck() void RfReceiveCheck(void)
{ {
if (mySwitch.available()) { if (mySwitch.available()) {
@ -62,8 +62,8 @@ void RfReceiveCheck()
} else { } else {
snprintf_P(stemp, sizeof(stemp), PSTR("\"%lX\""), (uint32_t)data); snprintf_P(stemp, sizeof(stemp), PSTR("\"%lX\""), (uint32_t)data);
} }
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("{\"" D_JSON_RFRECEIVED "\":{\"" D_JSON_RF_DATA "\":%s,\"" D_JSON_RF_BITS "\":%d,\"" D_JSON_RF_PROTOCOL "\":%d}}"), snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("{\"" D_JSON_RFRECEIVED "\":{\"" D_JSON_RF_DATA "\":%s,\"" D_JSON_RF_BITS "\":%d,\"" D_JSON_RF_PROTOCOL "\":%d,\"" D_JSON_RF_PULSE "\":%d}}"),
stemp, bits, protocol); stemp, bits, protocol, delay);
MqttPublishPrefixTopic_P(RESULT_OR_TELE, PSTR(D_JSON_RFRECEIVED)); MqttPublishPrefixTopic_P(RESULT_OR_TELE, PSTR(D_JSON_RFRECEIVED));
XdrvRulesProcess(); XdrvRulesProcess();
#ifdef USE_DOMOTICZ #ifdef USE_DOMOTICZ
@ -74,7 +74,7 @@ void RfReceiveCheck()
} }
} }
void RfInit() void RfInit(void)
{ {
if (pin[GPIO_RFSEND] < 99) { if (pin[GPIO_RFSEND] < 99) {
mySwitch.enableTransmit(pin[GPIO_RFSEND]); mySwitch.enableTransmit(pin[GPIO_RFSEND]);
@ -88,7 +88,7 @@ void RfInit()
* Commands * Commands
\*********************************************************************************************/ \*********************************************************************************************/
boolean RfSendCommand() boolean RfSendCommand(void)
{ {
boolean serviced = true; boolean serviced = true;
boolean error = false; boolean error = false;

View File

@ -131,7 +131,7 @@ Decoding 14 results
/*******************************************************************************************/ /*******************************************************************************************/
void CpuLoadLoop() void CpuLoadLoop(void)
{ {
CPU_last_loop_time = millis(); CPU_last_loop_time = millis();
if (CPU_load_check && CPU_last_millis) { if (CPU_load_check && CPU_last_millis) {
@ -164,7 +164,7 @@ extern "C" {
extern cont_t g_cont; extern cont_t g_cont;
} }
void DebugFreeMem() void DebugFreeMem(void)
{ {
register uint32_t *sp asm("a1"); register uint32_t *sp asm("a1");
@ -186,7 +186,7 @@ extern "C" {
extern cont_t* g_pcont; extern cont_t* g_pcont;
} }
void DebugFreeMem() void DebugFreeMem(void)
{ {
register uint32_t *sp asm("a1"); register uint32_t *sp asm("a1");
@ -408,7 +408,7 @@ void DebugCfgShow(uint8_t more)
/*******************************************************************************************/ /*******************************************************************************************/
boolean DebugCommand() boolean DebugCommand(void)
{ {
char command[CMDSZ]; char command[CMDSZ];
boolean serviced = true; boolean serviced = true;

View File

@ -216,7 +216,7 @@ boolean XdrvMqttData(char *topicBuf, uint16_t stopicBuf, char *dataBuf, uint16_t
return XdrvCall(FUNC_MQTT_DATA); return XdrvCall(FUNC_MQTT_DATA);
} }
boolean XdrvRulesProcess() boolean XdrvRulesProcess(void)
{ {
return XdrvCall(FUNC_RULES_PROCESS); return XdrvCall(FUNC_RULES_PROCESS);
} }
@ -238,7 +238,7 @@ boolean XdrvCall(byte Function)
boolean result = false; boolean result = false;
for (byte x = 0; x < xdrv_present; x++) { for (byte x = 0; x < xdrv_present; x++) {
if (global_state.wifi_down) { delay(DRIVER_BOOT_DELAY); } AppDelay();
result = xdrv_func_ptr[x](Function); result = xdrv_func_ptr[x](Function);
if (result) break; if (result) break;
} }

View File

@ -33,7 +33,7 @@ LiquidCrystal_I2C *lcd;
/*********************************************************************************************/ /*********************************************************************************************/
void LcdInitMode() void LcdInitMode(void)
{ {
lcd->init(); lcd->init();
lcd->clear(); lcd->clear();
@ -54,7 +54,7 @@ void LcdInit(uint8_t mode)
} }
} }
void LcdInitDriver() void LcdInitDriver(void)
{ {
if (!Settings.display_model) { if (!Settings.display_model) {
if (I2cDevice(LCD_ADDRESS1)) { if (I2cDevice(LCD_ADDRESS1)) {
@ -78,7 +78,7 @@ void LcdInitDriver()
} }
} }
void LcdDrawStringAt() void LcdDrawStringAt(void)
{ {
lcd->setCursor(dsp_x, dsp_y); lcd->setCursor(dsp_x, dsp_y);
lcd->print(dsp_str); lcd->print(dsp_str);
@ -112,7 +112,7 @@ void LcdCenter(byte row, char* txt)
lcd->print(line); lcd->print(line);
} }
boolean LcdPrintLog() boolean LcdPrintLog(void)
{ {
boolean result = false; boolean result = false;
@ -145,7 +145,7 @@ boolean LcdPrintLog()
return result; return result;
} }
void LcdTime() void LcdTime(void)
{ {
char line[Settings.display_cols[0] +1]; char line[Settings.display_cols[0] +1];
@ -155,7 +155,7 @@ void LcdTime()
LcdCenter(1, line); LcdCenter(1, line);
} }
void LcdRefresh() // Every second void LcdRefresh(void) // Every second
{ {
if (Settings.display_mode) { // Mode 0 is User text if (Settings.display_mode) { // Mode 0 is User text
switch (Settings.display_mode) { switch (Settings.display_mode) {

View File

@ -43,7 +43,7 @@ uint8_t ssd1306_font_y = OLED_FONT_HEIGTH;
/*********************************************************************************************/ /*********************************************************************************************/
void Ssd1306InitMode() void Ssd1306InitMode(void)
{ {
oled->setRotation(Settings.display_rotate); // 0 oled->setRotation(Settings.display_rotate); // 0
oled->invertDisplay(false); oled->invertDisplay(false);
@ -72,7 +72,7 @@ void Ssd1306Init(uint8_t mode)
} }
} }
void Ssd1306InitDriver() void Ssd1306InitDriver(void)
{ {
if (!Settings.display_model) { if (!Settings.display_model) {
if (I2cDevice(OLED_ADDRESS1)) { if (I2cDevice(OLED_ADDRESS1)) {
@ -97,7 +97,7 @@ void Ssd1306InitDriver()
} }
} }
void Ssd1306Clear() void Ssd1306Clear(void)
{ {
oled->clearDisplay(); oled->clearDisplay();
oled->setCursor(0, 0); oled->setCursor(0, 0);
@ -123,7 +123,7 @@ void Ssd1306DisplayOnOff(uint8_t on)
} }
} }
void Ssd1306OnOff() void Ssd1306OnOff(void)
{ {
Ssd1306DisplayOnOff(disp_power); Ssd1306DisplayOnOff(disp_power);
oled->display(); oled->display();
@ -133,7 +133,7 @@ void Ssd1306OnOff()
#ifdef USE_DISPLAY_MODES1TO5 #ifdef USE_DISPLAY_MODES1TO5
void Ssd1306PrintLog() void Ssd1306PrintLog(void)
{ {
disp_refresh--; disp_refresh--;
if (!disp_refresh) { if (!disp_refresh) {
@ -163,7 +163,7 @@ void Ssd1306PrintLog()
} }
} }
void Ssd1306Time() void Ssd1306Time(void)
{ {
char line[12]; char line[12];
@ -177,7 +177,7 @@ void Ssd1306Time()
oled->display(); oled->display();
} }
void Ssd1306Refresh() // Every second void Ssd1306Refresh(void) // Every second
{ {
if (Settings.display_mode) { // Mode 0 is User text if (Settings.display_mode) { // Mode 0 is User text
switch (Settings.display_mode) { switch (Settings.display_mode) {

View File

@ -43,14 +43,14 @@ uint8_t mtx_done = 0;
/*********************************************************************************************/ /*********************************************************************************************/
void MatrixWrite() void MatrixWrite(void)
{ {
for (byte i = 0; i < mtx_matrices; i++) { for (byte i = 0; i < mtx_matrices; i++) {
matrix[i]->writeDisplay(); matrix[i]->writeDisplay();
} }
} }
void MatrixClear() void MatrixClear(void)
{ {
for (byte i = 0; i < mtx_matrices; i++) { for (byte i = 0; i < mtx_matrices; i++) {
matrix[i]->clear(); matrix[i]->clear();
@ -166,7 +166,7 @@ void MatrixScrollUp(char* txt, int loop)
/*********************************************************************************************/ /*********************************************************************************************/
void MatrixInitMode() void MatrixInitMode(void)
{ {
for (byte i = 0; i < mtx_matrices; i++) { for (byte i = 0; i < mtx_matrices; i++) {
matrix[i]->setRotation(Settings.display_rotate); // 1 matrix[i]->setRotation(Settings.display_rotate); // 1
@ -192,7 +192,7 @@ void MatrixInit(uint8_t mode)
} }
} }
void MatrixInitDriver() void MatrixInitDriver(void)
{ {
if (!Settings.display_model) { if (!Settings.display_model) {
if (I2cDevice(Settings.display_address[1])) { if (I2cDevice(Settings.display_address[1])) {
@ -215,7 +215,7 @@ void MatrixInitDriver()
} }
} }
void MatrixOnOff() void MatrixOnOff(void)
{ {
if (!disp_power) { MatrixClear(); } if (!disp_power) { MatrixClear(); }
} }
@ -278,7 +278,7 @@ void MatrixPrintLog(uint8_t direction)
#endif // USE_DISPLAY_MODES1TO5 #endif // USE_DISPLAY_MODES1TO5
void MatrixRefresh() // Every second void MatrixRefresh(void) // Every second
{ {
if (disp_power) { if (disp_power) {
switch (Settings.display_mode) { switch (Settings.display_mode) {

View File

@ -38,7 +38,7 @@ uint16_t tft_scroll;
/*********************************************************************************************/ /*********************************************************************************************/
void Ili9341InitMode() void Ili9341InitMode(void)
{ {
tft->setRotation(Settings.display_rotate); // 0 tft->setRotation(Settings.display_rotate); // 0
tft->invertDisplay(0); tft->invertDisplay(0);
@ -77,7 +77,7 @@ void Ili9341Init(uint8_t mode)
} }
} }
void Ili9341InitDriver() void Ili9341InitDriver(void)
{ {
if (!Settings.display_model) { if (!Settings.display_model) {
Settings.display_model = XDSP_04; Settings.display_model = XDSP_04;
@ -97,7 +97,7 @@ void Ili9341InitDriver()
} }
} }
void Ili9341Clear() void Ili9341Clear(void)
{ {
tft->fillScreen(ILI9341_BLACK); tft->fillScreen(ILI9341_BLACK);
tft->setCursor(0, 0); tft->setCursor(0, 0);
@ -128,7 +128,7 @@ void Ili9341DisplayOnOff(uint8_t on)
} }
} }
void Ili9341OnOff() void Ili9341OnOff(void)
{ {
Ili9341DisplayOnOff(disp_power); Ili9341DisplayOnOff(disp_power);
} }
@ -137,7 +137,7 @@ void Ili9341OnOff()
#ifdef USE_DISPLAY_MODES1TO5 #ifdef USE_DISPLAY_MODES1TO5
void Ili9341PrintLog() void Ili9341PrintLog(void)
{ {
disp_refresh--; disp_refresh--;
if (!disp_refresh) { if (!disp_refresh) {
@ -184,7 +184,7 @@ void Ili9341PrintLog()
} }
} }
void Ili9341Refresh() // Every second void Ili9341Refresh(void) // Every second
{ {
if (Settings.display_mode) { // Mode 0 is User text if (Settings.display_mode) { // Mode 0 is User text
char tftdt[Settings.display_cols[0] +1]; char tftdt[Settings.display_cols[0] +1];

View File

@ -41,7 +41,7 @@ sFONT *selected_font;
/*********************************************************************************************/ /*********************************************************************************************/
void EpdInitMode() void EpdInitMode(void)
{ {
// whiten display with full update // whiten display with full update
epd.Init(lut_full_update); epd.Init(lut_full_update);
@ -72,7 +72,7 @@ void EpdInitMode()
paint.Clear(UNCOLORED); paint.Clear(UNCOLORED);
} }
void EpdInitPartial() void EpdInitPartial(void)
{ {
epd.Init(lut_partial_update); epd.Init(lut_partial_update);
//paint.Clear(UNCOLORED); //paint.Clear(UNCOLORED);
@ -80,7 +80,7 @@ void EpdInitPartial()
delay(500); delay(500);
} }
void EpdInitFull() void EpdInitFull(void)
{ {
epd.Init(lut_full_update); epd.Init(lut_full_update);
//paint.Clear(UNCOLORED); //paint.Clear(UNCOLORED);
@ -104,7 +104,7 @@ void EpdInit(uint8_t mode)
} }
} }
void EpdInitDriver() void EpdInitDriver(void)
{ {
if (!Settings.display_model) { if (!Settings.display_model) {
Settings.display_model = XDSP_05; Settings.display_model = XDSP_05;
@ -121,7 +121,7 @@ void EpdInitDriver()
/*********************************************************************************************/ /*********************************************************************************************/
void EpdClear() void EpdClear(void)
{ {
paint.Clear(UNCOLORED); paint.Clear(UNCOLORED);
} }
@ -158,7 +158,7 @@ void EpdDisplayOnOff(uint8_t on)
} }
void EpdOnOff() void EpdOnOff(void)
{ {
EpdDisplayOnOff(disp_power); EpdDisplayOnOff(disp_power);
} }
@ -167,7 +167,7 @@ void EpdOnOff()
#ifdef USE_DISPLAY_MODES1TO5 #ifdef USE_DISPLAY_MODES1TO5
void EpdRefresh() // Every second void EpdRefresh(void) // Every second
{ {
if (Settings.display_mode) { // Mode 0 is User text if (Settings.display_mode) { // Mode 0 is User text

View File

@ -112,7 +112,7 @@ const uint8_t xdsp_present = sizeof(xdsp_func_ptr) / sizeof(xdsp_func_ptr[0]);
* FUNC_DISPLAY_ONOFF * FUNC_DISPLAY_ONOFF
\*********************************************************************************************/ \*********************************************************************************************/
uint8_t XdspPresent() uint8_t XdspPresent(void)
{ {
return xdsp_present; return xdsp_present;
} }

View File

@ -62,11 +62,11 @@ unsigned long hlw_cf1_voltage_max_pulse_counter;
unsigned long hlw_cf1_current_max_pulse_counter; unsigned long hlw_cf1_current_max_pulse_counter;
#ifndef USE_WS2812_DMA // Collides with Neopixelbus but solves exception #ifndef USE_WS2812_DMA // Collides with Neopixelbus but solves exception
void HlwCfInterrupt() ICACHE_RAM_ATTR; void HlwCfInterrupt(void) ICACHE_RAM_ATTR;
void HlwCf1Interrupt() ICACHE_RAM_ATTR; void HlwCf1Interrupt(void) ICACHE_RAM_ATTR;
#endif // USE_WS2812_DMA #endif // USE_WS2812_DMA
void HlwCfInterrupt() // Service Power void HlwCfInterrupt(void) // Service Power
{ {
unsigned long us = micros(); unsigned long us = micros();
@ -80,7 +80,7 @@ void HlwCfInterrupt() // Service Power
} }
} }
void HlwCf1Interrupt() // Service Voltage and Current void HlwCf1Interrupt(void) // Service Voltage and Current
{ {
unsigned long us = micros(); unsigned long us = micros();
@ -97,7 +97,7 @@ void HlwCf1Interrupt() // Service Voltage and Current
/********************************************************************************************/ /********************************************************************************************/
void HlwEvery200ms() void HlwEvery200ms(void)
{ {
unsigned long hlw_w = 0; unsigned long hlw_w = 0;
unsigned long hlw_u = 0; unsigned long hlw_u = 0;
@ -154,7 +154,7 @@ void HlwEvery200ms()
} }
} }
void HlwEverySecond() void HlwEverySecond(void)
{ {
unsigned long hlw_len; unsigned long hlw_len;
@ -168,7 +168,7 @@ void HlwEverySecond()
} }
} }
void HlwSnsInit() void HlwSnsInit(void)
{ {
if (!Settings.energy_power_calibration || (4975 == Settings.energy_power_calibration)) { if (!Settings.energy_power_calibration || (4975 == Settings.energy_power_calibration)) {
Settings.energy_power_calibration = HLW_PREF_PULSE; Settings.energy_power_calibration = HLW_PREF_PULSE;
@ -210,7 +210,7 @@ void HlwSnsInit()
hlw_cf1_timer = 0; hlw_cf1_timer = 0;
} }
void HlwDrvInit() void HlwDrvInit(void)
{ {
if (!energy_flg) { if (!energy_flg) {
hlw_model_type = 0; hlw_model_type = 0;
@ -233,7 +233,7 @@ void HlwDrvInit()
} }
} }
boolean HlwCommand() boolean HlwCommand(void)
{ {
boolean serviced = true; boolean serviced = true;

View File

@ -46,7 +46,7 @@ long cf_pulses = 0;
long cf_pulses_last_time = CSE_PULSES_NOT_INITIALIZED; long cf_pulses_last_time = CSE_PULSES_NOT_INITIALIZED;
uint8_t cse_power_invalid = CSE_MAX_INVALID_POWER; uint8_t cse_power_invalid = CSE_MAX_INVALID_POWER;
void CseReceived() void CseReceived(void)
{ {
// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
// 55 5A 02 F7 60 00 03 5A 00 40 10 04 8B 9F 51 A6 58 18 72 75 61 AC A1 30 - Power not valid (load below 5W) // 55 5A 02 F7 60 00 03 5A 00 40 10 04 8B 9F 51 A6 58 18 72 75 61 AC A1 30 - Power not valid (load below 5W)
@ -128,7 +128,7 @@ void CseReceived()
} }
} }
bool CseSerialInput() bool CseSerialInput(void)
{ {
if (cse_receive_flag) { if (cse_receive_flag) {
serial_in_buffer[serial_in_byte_counter++] = serial_in_byte; serial_in_buffer[serial_in_byte_counter++] = serial_in_byte;
@ -168,7 +168,7 @@ bool CseSerialInput()
/********************************************************************************************/ /********************************************************************************************/
void CseEverySecond() void CseEverySecond(void)
{ {
long cf_frequency = 0; long cf_frequency = 0;
@ -188,7 +188,7 @@ void CseEverySecond()
} }
} }
void CseDrvInit() void CseDrvInit(void)
{ {
if (!energy_flg) { if (!energy_flg) {
if ((SONOFF_S31 == Settings.module) || (SONOFF_POW_R2 == Settings.module)) { // Sonoff S31 or Sonoff Pow R2 if ((SONOFF_S31 == Settings.module) || (SONOFF_POW_R2 == Settings.module)) { // Sonoff S31 or Sonoff Pow R2
@ -199,7 +199,7 @@ void CseDrvInit()
} }
} }
boolean CseCommand() boolean CseCommand(void)
{ {
boolean serviced = true; boolean serviced = true;

View File

@ -87,7 +87,7 @@ void PzemSend(uint8_t cmd)
PzemSerial->write(bytes, sizeof(pzem)); PzemSerial->write(bytes, sizeof(pzem));
} }
bool PzemReceiveReady() bool PzemReceiveReady(void)
{ {
return PzemSerial->available() >= (int)sizeof(PZEMCommand); return PzemSerial->available() >= (int)sizeof(PZEMCommand);
} }
@ -162,7 +162,7 @@ const uint8_t pzem_responses[] { RESP_SET_ADDRESS, RESP_VOLTAGE, RESP_CURRENT, R
uint8_t pzem_read_state = 0; uint8_t pzem_read_state = 0;
uint8_t pzem_sendRetry = 0; uint8_t pzem_sendRetry = 0;
void PzemEvery200ms() void PzemEvery200ms(void)
{ {
bool data_ready = PzemReceiveReady(); bool data_ready = PzemReceiveReady();
@ -200,7 +200,7 @@ void PzemEvery200ms()
} }
} }
void PzemSnsInit() void PzemSnsInit(void)
{ {
// Software serial init needs to be done here as earlier (serial) interrupts may lead to Exceptions // Software serial init needs to be done here as earlier (serial) interrupts may lead to Exceptions
PzemSerial = new TasmotaSerial(pin[GPIO_PZEM004_RX], pin[GPIO_PZEM0XX_TX], 1); PzemSerial = new TasmotaSerial(pin[GPIO_PZEM004_RX], pin[GPIO_PZEM0XX_TX], 1);
@ -211,7 +211,7 @@ void PzemSnsInit()
} }
} }
void PzemDrvInit() void PzemDrvInit(void)
{ {
if (!energy_flg) { if (!energy_flg) {
if ((pin[GPIO_PZEM004_RX] < 99) && (pin[GPIO_PZEM0XX_TX] < 99)) { // Any device with a Pzem004T if ((pin[GPIO_PZEM004_RX] < 99) && (pin[GPIO_PZEM0XX_TX] < 99)) { // Any device with a Pzem004T

View File

@ -36,7 +36,7 @@
#include <TasmotaModbus.h> #include <TasmotaModbus.h>
TasmotaModbus *PzemAcModbus; TasmotaModbus *PzemAcModbus;
void PzemAcEverySecond() void PzemAcEverySecond(void)
{ {
static uint8_t send_retry = 0; static uint8_t send_retry = 0;
@ -78,7 +78,7 @@ void PzemAcEverySecond()
} }
} }
void PzemAcSnsInit() void PzemAcSnsInit(void)
{ {
PzemAcModbus = new TasmotaModbus(pin[GPIO_PZEM016_RX], pin[GPIO_PZEM0XX_TX]); PzemAcModbus = new TasmotaModbus(pin[GPIO_PZEM016_RX], pin[GPIO_PZEM0XX_TX]);
uint8_t result = PzemAcModbus->Begin(9600); uint8_t result = PzemAcModbus->Begin(9600);
@ -89,7 +89,7 @@ void PzemAcSnsInit()
} }
} }
void PzemAcDrvInit() void PzemAcDrvInit(void)
{ {
if (!energy_flg) { if (!energy_flg) {
if ((pin[GPIO_PZEM016_RX] < 99) && (pin[GPIO_PZEM0XX_TX] < 99)) { if ((pin[GPIO_PZEM016_RX] < 99) && (pin[GPIO_PZEM0XX_TX] < 99)) {

View File

@ -36,7 +36,7 @@
#include <TasmotaModbus.h> #include <TasmotaModbus.h>
TasmotaModbus *PzemDcModbus; TasmotaModbus *PzemDcModbus;
void PzemDcEverySecond() void PzemDcEverySecond(void)
{ {
static uint8_t send_retry = 0; static uint8_t send_retry = 0;
@ -76,7 +76,7 @@ void PzemDcEverySecond()
} }
} }
void PzemDcSnsInit() void PzemDcSnsInit(void)
{ {
PzemDcModbus = new TasmotaModbus(pin[GPIO_PZEM017_RX], pin[GPIO_PZEM0XX_TX]); PzemDcModbus = new TasmotaModbus(pin[GPIO_PZEM017_RX], pin[GPIO_PZEM0XX_TX]);
uint8_t result = PzemDcModbus->Begin(9600, 2); // Uses two stop bits!! uint8_t result = PzemDcModbus->Begin(9600, 2); // Uses two stop bits!!
@ -88,7 +88,7 @@ void PzemDcSnsInit()
} }
} }
void PzemDcDrvInit() void PzemDcDrvInit(void)
{ {
if (!energy_flg) { if (!energy_flg) {
if ((pin[GPIO_PZEM017_RX] < 99) && (pin[GPIO_PZEM0XX_TX] < 99)) { if ((pin[GPIO_PZEM017_RX] < 99) && (pin[GPIO_PZEM0XX_TX] < 99)) {

View File

@ -59,7 +59,7 @@ const char WEMO_MSEARCH[] PROGMEM =
"X-User-Agent: redsonic\r\n" "X-User-Agent: redsonic\r\n"
"\r\n"; "\r\n";
String WemoSerialnumber() String WemoSerialnumber(void)
{ {
char serial[16]; char serial[16];
@ -67,7 +67,7 @@ String WemoSerialnumber()
return String(serial); return String(serial);
} }
String WemoUuid() String WemoUuid(void)
{ {
char uuid[27]; char uuid[27];
@ -131,7 +131,7 @@ const char HUE_ST3[] PROGMEM =
"USN: uuid:{r3\r\n" "USN: uuid:{r3\r\n"
"\r\n"; "\r\n";
String HueBridgeId() String HueBridgeId(void)
{ {
String temp = WiFi.macAddress(); String temp = WiFi.macAddress();
temp.replace(":", ""); temp.replace(":", "");
@ -139,7 +139,7 @@ String HueBridgeId()
return bridgeid; // 5CCF7FFFFE139F3D return bridgeid; // 5CCF7FFFFE139F3D
} }
String HueSerialnumber() String HueSerialnumber(void)
{ {
String serial = WiFi.macAddress(); String serial = WiFi.macAddress();
serial.replace(":", ""); serial.replace(":", "");
@ -147,14 +147,14 @@ String HueSerialnumber()
return serial; // 5ccf7f139f3d return serial; // 5ccf7f139f3d
} }
String HueUuid() String HueUuid(void)
{ {
String uuid = F("f6543a06-da50-11ba-8d8f-"); String uuid = F("f6543a06-da50-11ba-8d8f-");
uuid += HueSerialnumber(); uuid += HueSerialnumber();
return uuid; // f6543a06-da50-11ba-8d8f-5ccf7f139f3d return uuid; // f6543a06-da50-11ba-8d8f-5ccf7f139f3d
} }
void HueRespondToMSearch() void HueRespondToMSearch(void)
{ {
char message[TOPSZ]; char message[TOPSZ];
@ -197,7 +197,7 @@ void HueRespondToMSearch()
* Belkin WeMo and Philips Hue bridge UDP multicast support * Belkin WeMo and Philips Hue bridge UDP multicast support
\*********************************************************************************************/ \*********************************************************************************************/
boolean UdpDisconnect() boolean UdpDisconnect(void)
{ {
if (udp_connected) { if (udp_connected) {
WiFiUDP::stopAll(); WiFiUDP::stopAll();
@ -207,7 +207,7 @@ boolean UdpDisconnect()
return udp_connected; return udp_connected;
} }
boolean UdpConnect() boolean UdpConnect(void)
{ {
if (!udp_connected) { if (!udp_connected) {
if (PortUdp.beginMulticast(WiFi.localIP(), ipMulticast, port_multicast)) { if (PortUdp.beginMulticast(WiFi.localIP(), ipMulticast, port_multicast)) {
@ -222,7 +222,7 @@ boolean UdpConnect()
return udp_connected; return udp_connected;
} }
void PollUdp() void PollUdp(void)
{ {
if (udp_connected && !udp_response_mutex) { if (udp_connected && !udp_response_mutex) {
if (PortUdp.parsePacket()) { if (PortUdp.parsePacket()) {
@ -381,7 +381,7 @@ const char WEMO_SETUP_XML[] PROGMEM =
/********************************************************************************************/ /********************************************************************************************/
void HandleUpnpEvent() void HandleUpnpEvent(void)
{ {
AddLog_P(LOG_LEVEL_DEBUG, S_LOG_HTTP, PSTR(D_WEMO_BASIC_EVENT)); AddLog_P(LOG_LEVEL_DEBUG, S_LOG_HTTP, PSTR(D_WEMO_BASIC_EVENT));
@ -408,21 +408,21 @@ void HandleUpnpEvent()
WebServer->send(200, FPSTR(HDR_CTYPE_XML), state_xml); WebServer->send(200, FPSTR(HDR_CTYPE_XML), state_xml);
} }
void HandleUpnpService() void HandleUpnpService(void)
{ {
AddLog_P(LOG_LEVEL_DEBUG, S_LOG_HTTP, PSTR(D_WEMO_EVENT_SERVICE)); AddLog_P(LOG_LEVEL_DEBUG, S_LOG_HTTP, PSTR(D_WEMO_EVENT_SERVICE));
WebServer->send(200, FPSTR(HDR_CTYPE_PLAIN), FPSTR(WEMO_EVENTSERVICE_XML)); WebServer->send(200, FPSTR(HDR_CTYPE_PLAIN), FPSTR(WEMO_EVENTSERVICE_XML));
} }
void HandleUpnpMetaService() void HandleUpnpMetaService(void)
{ {
AddLog_P(LOG_LEVEL_DEBUG, S_LOG_HTTP, PSTR(D_WEMO_META_SERVICE)); AddLog_P(LOG_LEVEL_DEBUG, S_LOG_HTTP, PSTR(D_WEMO_META_SERVICE));
WebServer->send(200, FPSTR(HDR_CTYPE_PLAIN), FPSTR(WEMO_METASERVICE_XML)); WebServer->send(200, FPSTR(HDR_CTYPE_PLAIN), FPSTR(WEMO_METASERVICE_XML));
} }
void HandleUpnpSetupWemo() void HandleUpnpSetupWemo(void)
{ {
AddLog_P(LOG_LEVEL_DEBUG, S_LOG_HTTP, PSTR(D_WEMO_SETUP)); AddLog_P(LOG_LEVEL_DEBUG, S_LOG_HTTP, PSTR(D_WEMO_SETUP));
@ -517,7 +517,7 @@ String GetHueDeviceId(uint8_t id)
return deviceid; // 5c:cf:7f:13:9f:3d:00:11-1 return deviceid; // 5c:cf:7f:13:9f:3d:00:11-1
} }
String GetHueUserId() String GetHueUserId(void)
{ {
char userid[7]; char userid[7];
@ -525,7 +525,7 @@ String GetHueUserId()
return String(userid); return String(userid);
} }
void HandleUpnpSetupHue() void HandleUpnpSetupHue(void)
{ {
AddLog_P(LOG_LEVEL_DEBUG, S_LOG_HTTP, PSTR(D_HUE_BRIDGE_SETUP)); AddLog_P(LOG_LEVEL_DEBUG, S_LOG_HTTP, PSTR(D_HUE_BRIDGE_SETUP));
String description_xml = FPSTR(HUE_DESCRIPTION_XML); String description_xml = FPSTR(HUE_DESCRIPTION_XML);
@ -841,7 +841,7 @@ void HandleHueApi(String *path)
else HueGlobalConfig(path); else HueGlobalConfig(path);
} }
void HueWemoAddHandlers() void HueWemoAddHandlers(void)
{ {
if (EMUL_WEMO == Settings.flag2.emulation) { if (EMUL_WEMO == Settings.flag2.emulation) {
WebServer->on("/upnp/control/basicevent1", HTTP_POST, HandleUpnpEvent); WebServer->on("/upnp/control/basicevent1", HTTP_POST, HandleUpnpEvent);

View File

@ -96,7 +96,7 @@ uint8_t ws_show_next = 1;
bool ws_suspend_update = false; bool ws_suspend_update = false;
/********************************************************************************************/ /********************************************************************************************/
void Ws2812StripShow() void Ws2812StripShow(void)
{ {
#if (USE_WS2812_CTYPE > NEO_3LED) #if (USE_WS2812_CTYPE > NEO_3LED)
RgbwColor c; RgbwColor c;
@ -163,7 +163,7 @@ void Ws2812UpdateHand(int position, uint8_t index)
} }
} }
void Ws2812Clock() void Ws2812Clock(void)
{ {
strip->ClearTo(0); // Reset strip strip->ClearTo(0); // Reset strip
int clksize = 60000 / (int)Settings.light_pixels; int clksize = 60000 / (int)Settings.light_pixels;
@ -302,7 +302,7 @@ void Ws2812Bars(uint8_t schemenr)
* Public * Public
\*********************************************************************************************/ \*********************************************************************************************/
void Ws2812Init() void Ws2812Init(void)
{ {
#ifdef USE_WS2812_DMA #ifdef USE_WS2812_DMA
#if (USE_WS2812_CTYPE == NEO_GRB) #if (USE_WS2812_CTYPE == NEO_GRB)
@ -337,7 +337,7 @@ void Ws2812Init()
Ws2812Clear(); Ws2812Clear();
} }
void Ws2812Clear() void Ws2812Clear(void)
{ {
strip->ClearTo(0); strip->ClearTo(0);
strip->Show(); strip->Show();
@ -371,11 +371,11 @@ void Ws2812SetColor(uint16_t led, uint8_t red, uint8_t green, uint8_t blue, uint
} }
} }
void Ws2812ForceSuspend () { void Ws2812ForceSuspend (void) {
ws_suspend_update = true; ws_suspend_update = true;
} }
void Ws2812ForceUpdate () { void Ws2812ForceUpdate (void) {
ws_suspend_update = false; ws_suspend_update = false;
strip->Show(); strip->Show();
ws_show_next = 1; ws_show_next = 1;

View File

@ -41,29 +41,29 @@ void CounterUpdate(byte index)
} }
} }
void CounterUpdate1() void CounterUpdate1(void)
{ {
CounterUpdate(1); CounterUpdate(1);
} }
void CounterUpdate2() void CounterUpdate2(void)
{ {
CounterUpdate(2); CounterUpdate(2);
} }
void CounterUpdate3() void CounterUpdate3(void)
{ {
CounterUpdate(3); CounterUpdate(3);
} }
void CounterUpdate4() void CounterUpdate4(void)
{ {
CounterUpdate(4); CounterUpdate(4);
} }
/********************************************************************************************/ /********************************************************************************************/
void CounterSaveState() void CounterSaveState(void)
{ {
for (byte i = 0; i < MAX_COUNTERS; i++) { for (byte i = 0; i < MAX_COUNTERS; i++) {
if (pin[GPIO_CNTR1 +i] < 99) { if (pin[GPIO_CNTR1 +i] < 99) {
@ -72,7 +72,7 @@ void CounterSaveState()
} }
} }
void CounterInit() void CounterInit(void)
{ {
typedef void (*function) () ; typedef void (*function) () ;
function counter_callbacks[] = { CounterUpdate1, CounterUpdate2, CounterUpdate3, CounterUpdate4 }; function counter_callbacks[] = { CounterUpdate1, CounterUpdate2, CounterUpdate3, CounterUpdate4 };

View File

@ -26,7 +26,7 @@
uint16_t adc_last_value = 0; uint16_t adc_last_value = 0;
uint16_t AdcRead() uint16_t AdcRead(void)
{ {
uint16_t analog = 0; uint16_t analog = 0;
for (byte i = 0; i < 32; i++) { for (byte i = 0; i < 32; i++) {
@ -38,7 +38,7 @@ uint16_t AdcRead()
} }
#ifdef USE_RULES #ifdef USE_RULES
void AdcEvery250ms() void AdcEvery250ms(void)
{ {
uint16_t new_value = AdcRead(); uint16_t new_value = AdcRead();
if ((new_value < adc_last_value -10) || (new_value > adc_last_value +10)) { if ((new_value < adc_last_value -10) || (new_value > adc_last_value +10)) {

View File

@ -65,7 +65,7 @@ void SonoffScSend(const char *data)
AddLog(LOG_LEVEL_DEBUG); AddLog(LOG_LEVEL_DEBUG);
} }
void SonoffScInit() void SonoffScInit(void)
{ {
// SonoffScSend("AT+DEVCONFIG=\"uploadFreq\":1800"); // SonoffScSend("AT+DEVCONFIG=\"uploadFreq\":1800");
SonoffScSend("AT+START"); SonoffScSend("AT+START");

View File

@ -37,7 +37,7 @@ char ds18b20_types[] = "DS18B20";
* Embedded stripped and tuned OneWire library * Embedded stripped and tuned OneWire library
\*********************************************************************************************/ \*********************************************************************************************/
uint8_t OneWireReset() uint8_t OneWireReset(void)
{ {
uint8_t retries = 125; uint8_t retries = 125;
@ -75,7 +75,7 @@ void OneWireWriteBit(uint8_t v)
delayMicroseconds(delay_high[v]); delayMicroseconds(delay_high[v]);
} }
uint8_t OneWireReadBit() uint8_t OneWireReadBit(void)
{ {
//noInterrupts(); //noInterrupts();
pinMode(ds18x20_pin, OUTPUT); pinMode(ds18x20_pin, OUTPUT);
@ -96,7 +96,7 @@ void OneWireWrite(uint8_t v)
} }
} }
uint8_t OneWireRead() uint8_t OneWireRead(void)
{ {
uint8_t r = 0; uint8_t r = 0;
@ -129,7 +129,7 @@ boolean OneWireCrc8(uint8_t *addr)
/********************************************************************************************/ /********************************************************************************************/
void Ds18b20Convert() void Ds18b20Convert(void)
{ {
OneWireReset(); OneWireReset();
OneWireWrite(W1_SKIP_ROM); // Address all Sensors on Bus OneWireWrite(W1_SKIP_ROM); // Address all Sensors on Bus
@ -137,7 +137,7 @@ void Ds18b20Convert()
// delay(750); // 750ms should be enough for 12bit conv // delay(750); // 750ms should be enough for 12bit conv
} }
boolean Ds18b20Read() boolean Ds18b20Read(void)
{ {
uint8_t data[9]; uint8_t data[9];
int8_t sign = 1; int8_t sign = 1;
@ -173,7 +173,7 @@ boolean Ds18b20Read()
/********************************************************************************************/ /********************************************************************************************/
void Ds18b20EverySecond() void Ds18b20EverySecond(void)
{ {
ds18x20_pin = pin[GPIO_DSB]; ds18x20_pin = pin[GPIO_DSB];
if (uptime &1) { if (uptime &1) {

View File

@ -69,7 +69,7 @@ uint8_t onewire_last_family_discrepancy = 0;
bool onewire_last_device_flag = false; bool onewire_last_device_flag = false;
unsigned char onewire_rom_id[8] = { 0 }; unsigned char onewire_rom_id[8] = { 0 };
uint8_t OneWireReset() uint8_t OneWireReset(void)
{ {
uint8_t retries = 125; uint8_t retries = 125;
@ -107,7 +107,7 @@ void OneWireWriteBit(uint8_t v)
delayMicroseconds(delay_high[v]); delayMicroseconds(delay_high[v]);
} }
uint8_t OneWireReadBit() uint8_t OneWireReadBit(void)
{ {
//noInterrupts(); //noInterrupts();
pinMode(ds18x20_pin, OUTPUT); pinMode(ds18x20_pin, OUTPUT);
@ -128,7 +128,7 @@ void OneWireWrite(uint8_t v)
} }
} }
uint8_t OneWireRead() uint8_t OneWireRead(void)
{ {
uint8_t r = 0; uint8_t r = 0;
@ -148,7 +148,7 @@ void OneWireSelect(const uint8_t rom[8])
} }
} }
void OneWireResetSearch() void OneWireResetSearch(void)
{ {
onewire_last_discrepancy = 0; onewire_last_discrepancy = 0;
onewire_last_device_flag = false; onewire_last_device_flag = false;
@ -254,7 +254,7 @@ boolean OneWireCrc8(uint8_t *addr)
/********************************************************************************************/ /********************************************************************************************/
void Ds18x20Init() void Ds18x20Init(void)
{ {
uint64_t ids[DS18X20_MAX_SENSORS]; uint64_t ids[DS18X20_MAX_SENSORS];
@ -289,7 +289,7 @@ void Ds18x20Init()
AddLog(LOG_LEVEL_DEBUG); AddLog(LOG_LEVEL_DEBUG);
} }
void Ds18x20Convert() void Ds18x20Convert(void)
{ {
OneWireReset(); OneWireReset();
#ifdef W1_PARASITE_POWER #ifdef W1_PARASITE_POWER
@ -389,7 +389,7 @@ void Ds18x20Name(uint8_t sensor)
/********************************************************************************************/ /********************************************************************************************/
void Ds18x20EverySecond() void Ds18x20EverySecond(void)
{ {
#ifdef W1_PARASITE_POWER #ifdef W1_PARASITE_POWER
// skip access if there is still an eeprom write ongoing // skip access if there is still an eeprom write ongoing

View File

@ -43,12 +43,12 @@ uint8_t ds18x20_index[DS18X20_MAX_SENSORS];
uint8_t ds18x20_sensors = 0; uint8_t ds18x20_sensors = 0;
char ds18x20_types[9]; char ds18x20_types[9];
void Ds18x20Init() void Ds18x20Init(void)
{ {
ds = new OneWire(pin[GPIO_DSB]); ds = new OneWire(pin[GPIO_DSB]);
} }
void Ds18x20Search() void Ds18x20Search(void)
{ {
uint8_t num_sensors=0; uint8_t num_sensors=0;
uint8_t sensor = 0; uint8_t sensor = 0;
@ -78,7 +78,7 @@ void Ds18x20Search()
ds18x20_sensors = num_sensors; ds18x20_sensors = num_sensors;
} }
uint8_t Ds18x20Sensors() uint8_t Ds18x20Sensors(void)
{ {
return ds18x20_sensors; return ds18x20_sensors;
} }
@ -93,7 +93,7 @@ String Ds18x20Addresses(uint8_t sensor)
return String(address); return String(address);
} }
void Ds18x20Convert() void Ds18x20Convert(void)
{ {
ds->reset(); ds->reset();
ds->write(W1_SKIP_ROM); // Address all Sensors on Bus ds->write(W1_SKIP_ROM); // Address all Sensors on Bus

View File

@ -45,7 +45,7 @@ struct DHTSTRUCT {
float h = NAN; float h = NAN;
} Dht[DHT_MAX_SENSORS]; } Dht[DHT_MAX_SENSORS];
void DhtReadPrep() void DhtReadPrep(void)
{ {
for (byte i = 0; i < dht_sensors; i++) { for (byte i = 0; i < dht_sensors; i++) {
digitalWrite(Dht[i].pin, HIGH); digitalWrite(Dht[i].pin, HIGH);
@ -177,7 +177,7 @@ boolean DhtSetup(byte pin, byte type)
/********************************************************************************************/ /********************************************************************************************/
void DhtInit() void DhtInit(void)
{ {
dht_max_cycles = microsecondsToClockCycles(1000); // 1 millisecond timeout for reading pulses from DHT sensor. dht_max_cycles = microsecondsToClockCycles(1000); // 1 millisecond timeout for reading pulses from DHT sensor.
@ -192,7 +192,7 @@ void DhtInit()
} }
} }
void DhtEverySecond() void DhtEverySecond(void)
{ {
if (uptime &1) { if (uptime &1) {
// <1mS // <1mS

View File

@ -44,7 +44,7 @@ uint8_t sht_valid = 0;
float sht_temperature = 0; float sht_temperature = 0;
float sht_humidity = 0; float sht_humidity = 0;
boolean ShtReset() boolean ShtReset(void)
{ {
pinMode(sht_sda_pin, INPUT_PULLUP); pinMode(sht_sda_pin, INPUT_PULLUP);
pinMode(sht_scl_pin, OUTPUT); pinMode(sht_scl_pin, OUTPUT);
@ -90,7 +90,7 @@ boolean ShtSendCommand(const byte cmd)
return (!ackerror); return (!ackerror);
} }
boolean ShtAwaitResult() boolean ShtAwaitResult(void)
{ {
// Maximum 320ms for 14 bit measurement // Maximum 320ms for 14 bit measurement
for (byte i = 0; i < 16; i++) { for (byte i = 0; i < 16; i++) {
@ -104,7 +104,7 @@ boolean ShtAwaitResult()
return false; return false;
} }
int ShtReadData() int ShtReadData(void)
{ {
int val = 0; int val = 0;
@ -125,7 +125,7 @@ int ShtReadData()
return val; return val;
} }
boolean ShtRead() boolean ShtRead(void)
{ {
if (sht_valid) { sht_valid--; } if (sht_valid) { sht_valid--; }
if (!ShtReset()) { return false; } if (!ShtReset()) { return false; }
@ -157,7 +157,7 @@ boolean ShtRead()
/********************************************************************************************/ /********************************************************************************************/
void ShtDetect() void ShtDetect(void)
{ {
if (sht_type) { if (sht_type) {
return; return;
@ -174,7 +174,7 @@ void ShtDetect()
} }
} }
void ShtEverySecond() void ShtEverySecond(void)
{ {
if (sht_type && !(uptime %4)) { // Update every 4 seconds if (sht_type && !(uptime %4)) { // Update every 4 seconds
// 344mS // 344mS

View File

@ -133,14 +133,14 @@ void HtuHeater(uint8_t heater)
I2cWrite8(HTU21_ADDR, HTU21_WRITEREG, current); I2cWrite8(HTU21_ADDR, HTU21_WRITEREG, current);
} }
void HtuInit() void HtuInit(void)
{ {
HtuReset(); HtuReset();
HtuHeater(HTU21_HEATER_OFF); HtuHeater(HTU21_HEATER_OFF);
HtuSetResolution(HTU21_RES_RH12_T14); HtuSetResolution(HTU21_RES_RH12_T14);
} }
boolean HtuRead() boolean HtuRead(void)
{ {
uint8_t checksum = 0; uint8_t checksum = 0;
uint16_t sensorval = 0; uint16_t sensorval = 0;
@ -195,7 +195,7 @@ boolean HtuRead()
/********************************************************************************************/ /********************************************************************************************/
void HtuDetect() void HtuDetect(void)
{ {
if (htu_type) { return; } if (htu_type) { return; }
@ -229,7 +229,7 @@ void HtuDetect()
} }
} }
void HtuEverySecond() void HtuEverySecond(void)
{ {
if (92 == (uptime %100)) { if (92 == (uptime %100)) {
// 1mS // 1mS

View File

@ -417,7 +417,7 @@ void Bme680Read(uint8_t bmp_idx)
/********************************************************************************************/ /********************************************************************************************/
void BmpDetect() void BmpDetect(void)
{ {
if (bmp_count) return; if (bmp_count) return;
@ -456,7 +456,7 @@ void BmpDetect()
} }
} }
void BmpRead() void BmpRead(void)
{ {
for (byte bmp_idx = 0; bmp_idx < bmp_count; bmp_idx++) { for (byte bmp_idx = 0; bmp_idx < bmp_count; bmp_idx++) {
switch (bmp_sensors[bmp_idx].bmp_type) { switch (bmp_sensors[bmp_idx].bmp_type) {
@ -477,7 +477,7 @@ void BmpRead()
SetGlobalValues(ConvertTemp(bmp_sensors[0].bmp_temperature), bmp_sensors[0].bmp_humidity); SetGlobalValues(ConvertTemp(bmp_sensors[0].bmp_temperature), bmp_sensors[0].bmp_humidity);
} }
void BmpEverySecond() void BmpEverySecond(void)
{ {
if (91 == (uptime %100)) { if (91 == (uptime %100)) {
// 1mS // 1mS

View File

@ -39,7 +39,7 @@ uint8_t bh1750_valid = 0;
uint16_t bh1750_illuminance = 0; uint16_t bh1750_illuminance = 0;
char bh1750_types[] = "BH1750"; char bh1750_types[] = "BH1750";
bool Bh1750Read() bool Bh1750Read(void)
{ {
if (bh1750_valid) { bh1750_valid--; } if (bh1750_valid) { bh1750_valid--; }
@ -53,7 +53,7 @@ bool Bh1750Read()
/********************************************************************************************/ /********************************************************************************************/
void Bh1750Detect() void Bh1750Detect(void)
{ {
if (bh1750_type) { if (bh1750_type) {
return; return;
@ -72,7 +72,7 @@ void Bh1750Detect()
} }
} }
void Bh1750EverySecond() void Bh1750EverySecond(void)
{ {
if (90 == (uptime %100)) { if (90 == (uptime %100)) {
// 1mS // 1mS

View File

@ -157,7 +157,7 @@ int16_t Ads1115GetConversion(uint8_t channel)
/********************************************************************************************/ /********************************************************************************************/
void Ads1115Detect() void Ads1115Detect(void)
{ {
uint16_t buffer; uint16_t buffer;

View File

@ -75,7 +75,7 @@ int16_t Ads1115GetConversion(byte channel)
/********************************************************************************************/ /********************************************************************************************/
void Ads1115Detect() void Ads1115Detect(void)
{ {
if (ads1115_type) { if (ads1115_type) {
return; return;

View File

@ -128,7 +128,7 @@ bool Ina219SetCalibration(uint8_t mode)
return success; return success;
} }
float Ina219GetShuntVoltage_mV() float Ina219GetShuntVoltage_mV(void)
{ {
// raw shunt voltage (16-bit signed integer, so +-32767) // raw shunt voltage (16-bit signed integer, so +-32767)
int16_t value = I2cReadS16(ina219_address, INA219_REG_SHUNTVOLTAGE); int16_t value = I2cReadS16(ina219_address, INA219_REG_SHUNTVOLTAGE);
@ -136,7 +136,7 @@ float Ina219GetShuntVoltage_mV()
return value * 0.01; return value * 0.01;
} }
float Ina219GetBusVoltage_V() float Ina219GetBusVoltage_V(void)
{ {
// Shift to the right 3 to drop CNVR and OVF and multiply by LSB // Shift to the right 3 to drop CNVR and OVF and multiply by LSB
// raw bus voltage (16-bit signed integer, so +-32767) // raw bus voltage (16-bit signed integer, so +-32767)
@ -145,7 +145,7 @@ float Ina219GetBusVoltage_V()
return value * 0.001; return value * 0.001;
} }
float Ina219GetCurrent_mA() float Ina219GetCurrent_mA(void)
{ {
// Sometimes a sharp load will reset the INA219, which will reset the cal register, // Sometimes a sharp load will reset the INA219, which will reset the cal register,
// meaning CURRENT and POWER will not be available ... avoid this by always setting // meaning CURRENT and POWER will not be available ... avoid this by always setting
@ -159,7 +159,7 @@ float Ina219GetCurrent_mA()
return value; return value;
} }
bool Ina219Read() bool Ina219Read(void)
{ {
ina219_voltage = Ina219GetBusVoltage_V() + (Ina219GetShuntVoltage_mV() / 1000); ina219_voltage = Ina219GetBusVoltage_V() + (Ina219GetShuntVoltage_mV() / 1000);
ina219_current = Ina219GetCurrent_mA() / 1000; ina219_current = Ina219GetCurrent_mA() / 1000;
@ -175,7 +175,7 @@ bool Ina219Read()
* 2 - Max 16V 0.4A range * 2 - Max 16V 0.4A range
\*********************************************************************************************/ \*********************************************************************************************/
bool Ina219CommandSensor() bool Ina219CommandSensor(void)
{ {
boolean serviced = true; boolean serviced = true;
@ -190,7 +190,7 @@ bool Ina219CommandSensor()
/********************************************************************************************/ /********************************************************************************************/
void Ina219Detect() void Ina219Detect(void)
{ {
if (ina219_type) { return; } if (ina219_type) { return; }
@ -205,7 +205,7 @@ void Ina219Detect()
} }
} }
void Ina219EverySecond() void Ina219EverySecond(void)
{ {
if (87 == (uptime %100)) { if (87 == (uptime %100)) {
// 2mS // 2mS

View File

@ -76,7 +76,7 @@ bool Sht3xRead(float &t, float &h, uint8_t sht3x_address)
/********************************************************************************************/ /********************************************************************************************/
void Sht3xDetect() void Sht3xDetect(void)
{ {
if (sht3x_count) return; if (sht3x_count) return;

View File

@ -159,7 +159,7 @@ bool MhzCheckAndApplyFilter(uint16_t ppm, uint8_t s)
return true; return true;
} }
void MhzEverySecond() void MhzEverySecond(void)
{ {
mhz_state++; mhz_state++;
if (8 == mhz_state) { // Every 8 sec start a MH-Z19 measuring cycle (which takes 1005 +5% ms) if (8 == mhz_state) { // Every 8 sec start a MH-Z19 measuring cycle (which takes 1005 +5% ms)
@ -253,7 +253,7 @@ void MhzEverySecond()
* 9 - Reset * 9 - Reset
\*********************************************************************************************/ \*********************************************************************************************/
bool MhzCommandSensor() bool MhzCommandSensor(void)
{ {
boolean serviced = true; boolean serviced = true;
@ -275,7 +275,7 @@ bool MhzCommandSensor()
/*********************************************************************************************/ /*********************************************************************************************/
void MhzInit() void MhzInit(void)
{ {
mhz_type = 0; mhz_type = 0;
if ((pin[GPIO_MHZ_RXD] < 99) && (pin[GPIO_MHZ_TXD] < 99)) { if ((pin[GPIO_MHZ_RXD] < 99) && (pin[GPIO_MHZ_TXD] < 99)) {

View File

@ -38,7 +38,7 @@ uint8_t tsl2561_valid = 0;
uint32_t tsl2561_milliLux = 0; uint32_t tsl2561_milliLux = 0;
char tsl2561_types[] = "TSL2561"; char tsl2561_types[] = "TSL2561";
bool Tsl2561Read() bool Tsl2561Read(void)
{ {
if (tsl2561_valid) { tsl2561_valid--; } if (tsl2561_valid) { tsl2561_valid--; }
@ -63,7 +63,7 @@ bool Tsl2561Read()
return true; return true;
} }
void Tsl2561Detect() void Tsl2561Detect(void)
{ {
if (tsl2561_type) { return; } if (tsl2561_type) { return; }
@ -77,7 +77,7 @@ void Tsl2561Detect()
} }
} }
void Tsl2561EverySecond() void Tsl2561EverySecond(void)
{ {
if (90 == (uptime %100)) { if (90 == (uptime %100)) {
// 1mS // 1mS

View File

@ -58,7 +58,7 @@ const uint8_t start_addresses[] { 0x1A, 0x00, 0x03, 0x04, 0x05, 0x1C, 0x0A };
uint8_t senseair_read_state = 0; uint8_t senseair_read_state = 0;
uint8_t senseair_send_retry = 0; uint8_t senseair_send_retry = 0;
void Senseair250ms() // Every 250 mSec void Senseair250ms(void) // Every 250 mSec
{ {
// senseair_state++; // senseair_state++;
// if (6 == senseair_state) { // Every 300 mSec // if (6 == senseair_state) { // Every 300 mSec
@ -132,7 +132,7 @@ void Senseair250ms() // Every 250 mSec
/*********************************************************************************************/ /*********************************************************************************************/
void SenseairInit() void SenseairInit(void)
{ {
senseair_type = 0; senseair_type = 0;
if ((pin[GPIO_SAIR_RX] < 99) && (pin[GPIO_SAIR_TX] < 99)) { if ((pin[GPIO_SAIR_RX] < 99) && (pin[GPIO_SAIR_TX] < 99)) {

View File

@ -45,7 +45,7 @@ struct pms5003data {
/*********************************************************************************************/ /*********************************************************************************************/
boolean PmsReadData() boolean PmsReadData(void)
{ {
if (! PmsSerial->available()) { if (! PmsSerial->available()) {
return false; return false;
@ -87,7 +87,7 @@ boolean PmsReadData()
/*********************************************************************************************/ /*********************************************************************************************/
void PmsSecond() // Every second void PmsSecond(void) // Every second
{ {
if (PmsReadData()) { if (PmsReadData()) {
pms_valid = 10; pms_valid = 10;
@ -100,7 +100,7 @@ void PmsSecond() // Every second
/*********************************************************************************************/ /*********************************************************************************************/
void PmsInit() void PmsInit(void)
{ {
pms_type = 0; pms_type = 0;
if (pin[GPIO_PMS5003] < 99) { if (pin[GPIO_PMS5003] < 99) {

View File

@ -34,11 +34,11 @@
#include "MutichannelGasSensor.h" #include "MutichannelGasSensor.h"
void MGSInit() { void MGSInit(void) {
gas.begin(MGS_SENSOR_ADDR); gas.begin(MGS_SENSOR_ADDR);
} }
boolean MGSPrepare() boolean MGSPrepare(void)
{ {
gas.begin(MGS_SENSOR_ADDR); gas.begin(MGS_SENSOR_ADDR);
if (!gas.isError()) { if (!gas.isError()) {

View File

@ -48,7 +48,7 @@ struct sds011data {
uint16_t pm25; uint16_t pm25;
} novasds_data; } novasds_data;
void NovaSdsSetWorkPeriod() void NovaSdsSetWorkPeriod(void)
{ {
while (NovaSdsSerial->available() > 0) { while (NovaSdsSerial->available() > 0) {
@ -73,9 +73,7 @@ void NovaSdsSetWorkPeriod()
} }
} }
bool NovaSdsReadData(void)
bool NovaSdsReadData()
{ {
if (! NovaSdsSerial->available()) return false; if (! NovaSdsSerial->available()) return false;
@ -101,27 +99,31 @@ bool NovaSdsReadData()
return false; return false;
} }
novasds_valid = 10;
return true; return true;
} }
/*********************************************************************************************/ /*********************************************************************************************/
void NovaSdsSecond() // Every second void NovaSdsSecond(void) // Every second
{ {
if (NovaSdsReadData()) { if (XSNS_20 == (uptime % 100)) {
novasds_valid = 10; if (!novasds_valid) {
NovaSdsSetWorkPeriod();
}
} else { } else {
if (novasds_valid) { if (NovaSdsReadData()) {
novasds_valid--; novasds_valid = 10;
} else {
if (novasds_valid) {
novasds_valid--;
}
} }
} }
} }
/*********************************************************************************************/ /*********************************************************************************************/
void NovaSdsInit() void NovaSdsInit(void)
{ {
novasds_type = 0; novasds_type = 0;
if (pin[GPIO_SDS0X1_RX] < 99 && pin[GPIO_SDS0X1_TX] < 99) { if (pin[GPIO_SDS0X1_RX] < 99 && pin[GPIO_SDS0X1_TX] < 99) {

View File

@ -38,7 +38,7 @@ uint8_t sgp30_counter = 0;
/********************************************************************************************/ /********************************************************************************************/
void Sgp30Update() // Perform every second to ensure proper operation of the baseline compensation algorithm void Sgp30Update(void) // Perform every second to ensure proper operation of the baseline compensation algorithm
{ {
sgp30_ready = 0; sgp30_ready = 0;
if (!sgp30_type) { if (!sgp30_type) {

View File

@ -46,7 +46,7 @@ uint8_t sr04_trig_pin = 0;
/********************************************************************************************/ /********************************************************************************************/
void Sr04Init() void Sr04Init(void)
{ {
sr04_echo_pin = pin[GPIO_SR04_ECHO]; sr04_echo_pin = pin[GPIO_SR04_ECHO];
sr04_trig_pin = pin[GPIO_SR04_TRIG]; sr04_trig_pin = pin[GPIO_SR04_TRIG];
@ -136,6 +136,11 @@ void Sr04Show(boolean json)
if (Sr04Read(&distance)) { // Check if read failed if (Sr04Read(&distance)) { // Check if read failed
if(json) { if(json) {
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s,\"SR04\":{\"" D_JSON_DISTANCE "\":%d}"), mqtt_data, distance); snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s,\"SR04\":{\"" D_JSON_DISTANCE "\":%d}"), mqtt_data, distance);
#ifdef USE_DOMOTICZ
if (0 == tele_period) {
DomoticzSensor(DZ_COUNT, distance); // Send distance as Domoticz Counter value
}
#endif // USE_DOMOTICZ
#ifdef USE_WEBSERVER #ifdef USE_WEBSERVER
} else { } else {
snprintf_P(mqtt_data, sizeof(mqtt_data), HTTP_SNS_DISTANCE, mqtt_data, distance); snprintf_P(mqtt_data, sizeof(mqtt_data), HTTP_SNS_DISTANCE, mqtt_data, distance);

View File

@ -43,7 +43,7 @@ float sdm120_power_factor = 0;
float sdm120_frequency = 0; float sdm120_frequency = 0;
float sdm120_energy_total = 0; float sdm120_energy_total = 0;
bool SDM120_ModbusReceiveReady() bool SDM120_ModbusReceiveReady(void)
{ {
return (SDM120Serial->available() > 1); return (SDM120Serial->available() > 1);
} }
@ -137,7 +137,7 @@ const uint16_t sdm120_start_addresses[] {
uint8_t sdm120_read_state = 0; uint8_t sdm120_read_state = 0;
uint8_t sdm120_send_retry = 0; uint8_t sdm120_send_retry = 0;
void SDM120250ms() // Every 250 mSec void SDM120250ms(void) // Every 250 mSec
{ {
// sdm120_state++; // sdm120_state++;
// if (6 == sdm120_state) { // Every 300 mSec // if (6 == sdm120_state) { // Every 300 mSec
@ -203,7 +203,7 @@ void SDM120250ms() // Every 250 mSec
// } // end 300 ms // } // end 300 ms
} }
void SDM120Init() void SDM120Init(void)
{ {
sdm120_type = 0; sdm120_type = 0;
if ((pin[GPIO_SDM120_RX] < 99) && (pin[GPIO_SDM120_TX] < 99)) { if ((pin[GPIO_SDM120_RX] < 99) && (pin[GPIO_SDM120_TX] < 99)) {

View File

@ -210,12 +210,12 @@ uint8_t Si1145WriteParamData(uint8_t p, uint8_t v)
/********************************************************************************************/ /********************************************************************************************/
bool Si1145Present() bool Si1145Present(void)
{ {
return (Si1145ReadByte(SI114X_PART_ID) == 0X45); return (Si1145ReadByte(SI114X_PART_ID) == 0X45);
} }
void Si1145Reset() void Si1145Reset(void)
{ {
Si1145WriteByte(SI114X_MEAS_RATE0, 0); Si1145WriteByte(SI114X_MEAS_RATE0, 0);
Si1145WriteByte(SI114X_MEAS_RATE1, 0); Si1145WriteByte(SI114X_MEAS_RATE1, 0);
@ -231,7 +231,7 @@ void Si1145Reset()
delay(10); delay(10);
} }
void Si1145DeInit() void Si1145DeInit(void)
{ {
//ENABLE UV reading //ENABLE UV reading
//these reg must be set to the fixed value //these reg must be set to the fixed value
@ -276,7 +276,7 @@ void Si1145DeInit()
Si1145WriteByte(SI114X_COMMAND, SI114X_PSALS_AUTO); Si1145WriteByte(SI114X_COMMAND, SI114X_PSALS_AUTO);
} }
boolean Si1145Begin() boolean Si1145Begin(void)
{ {
if (!Si1145Present()) { return false; } if (!Si1145Present()) { return false; }
@ -286,26 +286,26 @@ boolean Si1145Begin()
} }
// returns the UV index * 100 (divide by 100 to get the index) // returns the UV index * 100 (divide by 100 to get the index)
uint16_t Si1145ReadUV() uint16_t Si1145ReadUV(void)
{ {
return Si1145ReadHalfWord(SI114X_AUX_DATA0_UVINDEX0); return Si1145ReadHalfWord(SI114X_AUX_DATA0_UVINDEX0);
} }
// returns visible+IR light levels // returns visible+IR light levels
uint16_t Si1145ReadVisible() uint16_t Si1145ReadVisible(void)
{ {
return Si1145ReadHalfWord(SI114X_ALS_VIS_DATA0); return Si1145ReadHalfWord(SI114X_ALS_VIS_DATA0);
} }
// returns IR light levels // returns IR light levels
uint16_t Si1145ReadIR() uint16_t Si1145ReadIR(void)
{ {
return Si1145ReadHalfWord(SI114X_ALS_IR_DATA0); return Si1145ReadHalfWord(SI114X_ALS_IR_DATA0);
} }
/********************************************************************************************/ /********************************************************************************************/
void Si1145Update() void Si1145Update(void)
{ {
if (!si1145_type) { if (!si1145_type) {
if (Si1145Begin()) { if (Si1145Begin()) {

View File

@ -41,7 +41,7 @@ float sdm630_reactive_power[] = {0,0,0};
float sdm630_power_factor[] = {0,0,0}; float sdm630_power_factor[] = {0,0,0};
float sdm630_energy_total = 0; float sdm630_energy_total = 0;
bool SDM630_ModbusReceiveReady() bool SDM630_ModbusReceiveReady(void)
{ {
return (SDM630Serial->available() > 1); return (SDM630Serial->available() > 1);
} }
@ -143,7 +143,7 @@ const uint16_t sdm630_start_addresses[] {
uint8_t sdm630_read_state = 0; uint8_t sdm630_read_state = 0;
uint8_t sdm630_send_retry = 0; uint8_t sdm630_send_retry = 0;
void SDM630250ms() // Every 250 mSec void SDM630250ms(void) // Every 250 mSec
{ {
// sdm630_state++; // sdm630_state++;
// if (6 == sdm630_state) { // Every 300 mSec // if (6 == sdm630_state) { // Every 300 mSec
@ -241,7 +241,7 @@ void SDM630250ms() // Every 250 mSec
// } // end 300 ms // } // end 300 ms
} }
void SDM630Init() void SDM630Init(void)
{ {
sdm630_type = 0; sdm630_type = 0;
if ((pin[GPIO_SDM630_RX] < 99) && (pin[GPIO_SDM630_TX] < 99)) { if ((pin[GPIO_SDM630_RX] < 99) && (pin[GPIO_SDM630_TX] < 99)) {

View File

@ -351,7 +351,7 @@ int8_t wireReadDataBlock( uint8_t reg,
* Kelvin * Kelvin
*/ */
void calculateColorTemperature() void calculateColorTemperature(void)
{ {
float X, Y, Z; /* RGB to XYZ correlation */ float X, Y, Z; /* RGB to XYZ correlation */
float xc, yc; /* Chromaticity co-ordinates */ float xc, yc; /* Chromaticity co-ordinates */
@ -398,7 +398,7 @@ float powf(const float x, const float y)
* *
* @return lower threshold * @return lower threshold
*/ */
uint8_t getProxIntLowThresh() uint8_t getProxIntLowThresh(void)
{ {
uint8_t val; uint8_t val;
@ -422,7 +422,7 @@ float powf(const float x, const float y)
* *
* @return high threshold * @return high threshold
*/ */
uint8_t getProxIntHighThresh() uint8_t getProxIntHighThresh(void)
{ {
uint8_t val; uint8_t val;
@ -454,7 +454,7 @@ float powf(const float x, const float y)
* *
* @return the value of the LED drive strength. 0xFF on failure. * @return the value of the LED drive strength. 0xFF on failure.
*/ */
uint8_t getLEDDrive() uint8_t getLEDDrive(void)
{ {
uint8_t val; uint8_t val;
@ -506,7 +506,7 @@ float powf(const float x, const float y)
* *
* @return the value of the proximity gain. 0xFF on failure. * @return the value of the proximity gain. 0xFF on failure.
*/ */
uint8_t getProximityGain() uint8_t getProximityGain(void)
{ {
uint8_t val; uint8_t val;
@ -597,7 +597,7 @@ float powf(const float x, const float y)
* *
* @return The LED boost value. 0xFF on failure. * @return The LED boost value. 0xFF on failure.
*/ */
uint8_t getLEDBoost() uint8_t getLEDBoost(void)
{ {
uint8_t val; uint8_t val;
@ -642,7 +642,7 @@ float powf(const float x, const float y)
* *
* @return 1 if compensation is enabled. 0 if not. 0xFF on error. * @return 1 if compensation is enabled. 0 if not. 0xFF on error.
*/ */
uint8_t getProxGainCompEnable() uint8_t getProxGainCompEnable(void)
{ {
uint8_t val; uint8_t val;
@ -689,7 +689,7 @@ float powf(const float x, const float y)
* *
* @return Current proximity mask for photodiodes. 0xFF on error. * @return Current proximity mask for photodiodes. 0xFF on error.
*/ */
uint8_t getProxPhotoMask() uint8_t getProxPhotoMask(void)
{ {
uint8_t val; uint8_t val;
@ -735,7 +735,7 @@ float powf(const float x, const float y)
* *
* @return Current entry proximity threshold. * @return Current entry proximity threshold.
*/ */
uint8_t getGestureEnterThresh() uint8_t getGestureEnterThresh(void)
{ {
uint8_t val; uint8_t val;
@ -761,7 +761,7 @@ float powf(const float x, const float y)
* *
* @return Current exit proximity threshold. * @return Current exit proximity threshold.
*/ */
uint8_t getGestureExitThresh() uint8_t getGestureExitThresh(void)
{ {
uint8_t val; uint8_t val;
@ -792,7 +792,7 @@ float powf(const float x, const float y)
* *
* @return the current photodiode gain. 0xFF on error. * @return the current photodiode gain. 0xFF on error.
*/ */
uint8_t getGestureGain() uint8_t getGestureGain(void)
{ {
uint8_t val; uint8_t val;
@ -844,7 +844,7 @@ float powf(const float x, const float y)
* *
* @return the LED drive current value. 0xFF on error. * @return the LED drive current value. 0xFF on error.
*/ */
uint8_t getGestureLEDDrive() uint8_t getGestureLEDDrive(void)
{ {
uint8_t val; uint8_t val;
@ -900,7 +900,7 @@ float powf(const float x, const float y)
* *
* @return the current wait time between gestures. 0xFF on error. * @return the current wait time between gestures. 0xFF on error.
*/ */
uint8_t getGestureWaitTime() uint8_t getGestureWaitTime(void)
{ {
uint8_t val; uint8_t val;
@ -1087,7 +1087,7 @@ float powf(const float x, const float y)
* *
* @return 1 if interrupts are enabled, 0 if not. 0xFF on error. * @return 1 if interrupts are enabled, 0 if not. 0xFF on error.
*/ */
uint8_t getAmbientLightIntEnable() uint8_t getAmbientLightIntEnable(void)
{ {
uint8_t val; uint8_t val;
@ -1127,7 +1127,7 @@ float powf(const float x, const float y)
* *
* @return 1 if interrupts are enabled, 0 if not. 0xFF on error. * @return 1 if interrupts are enabled, 0 if not. 0xFF on error.
*/ */
uint8_t getProximityIntEnable() uint8_t getProximityIntEnable(void)
{ {
uint8_t val; uint8_t val;
@ -1167,7 +1167,7 @@ float powf(const float x, const float y)
* *
* @return 1 if interrupts are enabled, 0 if not. 0xFF on error. * @return 1 if interrupts are enabled, 0 if not. 0xFF on error.
*/ */
uint8_t getGestureIntEnable() uint8_t getGestureIntEnable(void)
{ {
uint8_t val; uint8_t val;
@ -1206,7 +1206,7 @@ float powf(const float x, const float y)
* @brief Clears the ambient light interrupt * @brief Clears the ambient light interrupt
* *
*/ */
void clearAmbientLightInt() void clearAmbientLightInt(void)
{ {
uint8_t throwaway; uint8_t throwaway;
throwaway = I2cRead8(APDS9960_I2C_ADDR, APDS9960_AICLEAR); throwaway = I2cRead8(APDS9960_I2C_ADDR, APDS9960_AICLEAR);
@ -1216,7 +1216,7 @@ float powf(const float x, const float y)
* @brief Clears the proximity interrupt * @brief Clears the proximity interrupt
* *
*/ */
void clearProximityInt() void clearProximityInt(void)
{ {
uint8_t throwaway; uint8_t throwaway;
throwaway = I2cRead8(APDS9960_I2C_ADDR, APDS9960_PICLEAR) ; throwaway = I2cRead8(APDS9960_I2C_ADDR, APDS9960_PICLEAR) ;
@ -1228,7 +1228,7 @@ float powf(const float x, const float y)
* *
* @return 1 if gesture state machine is running, 0 if not. 0xFF on error. * @return 1 if gesture state machine is running, 0 if not. 0xFF on error.
*/ */
uint8_t getGestureMode() uint8_t getGestureMode(void)
{ {
uint8_t val; uint8_t val;
@ -1263,7 +1263,7 @@ float powf(const float x, const float y)
} }
bool APDS9960_init() bool APDS9960_init(void)
{ {
/* Set default values for ambient light and proximity registers */ /* Set default values for ambient light and proximity registers */
@ -1339,7 +1339,7 @@ bool APDS9960_init()
* *
* @return Contents of the ENABLE register. 0xFF if error. * @return Contents of the ENABLE register. 0xFF if error.
*/ */
uint8_t getMode() uint8_t getMode(void)
{ {
uint8_t enable_value; uint8_t enable_value;
@ -1388,7 +1388,7 @@ void setMode(uint8_t mode, uint8_t enable)
* *
* no interrupts * no interrupts
*/ */
void enableLightSensor() void enableLightSensor(void)
{ {
/* Set default gain, interrupts, enable power, and enable sensor */ /* Set default gain, interrupts, enable power, and enable sensor */
setAmbientLightGain(DEFAULT_AGAIN); setAmbientLightGain(DEFAULT_AGAIN);
@ -1401,7 +1401,7 @@ void enableLightSensor()
* @brief Ends the light sensor on the APDS-9960 * @brief Ends the light sensor on the APDS-9960
* *
*/ */
void disableLightSensor() void disableLightSensor(void)
{ {
setAmbientLightIntEnable(0) ; setAmbientLightIntEnable(0) ;
setMode(AMBIENT_LIGHT, 0) ; setMode(AMBIENT_LIGHT, 0) ;
@ -1412,7 +1412,7 @@ void disableLightSensor()
* *
* no interrupts * no interrupts
*/ */
void enableProximitySensor() void enableProximitySensor(void)
{ {
/* Set default gain, LED, interrupts, enable power, and enable sensor */ /* Set default gain, LED, interrupts, enable power, and enable sensor */
setProximityGain(DEFAULT_PGAIN); setProximityGain(DEFAULT_PGAIN);
@ -1426,7 +1426,7 @@ void enableProximitySensor()
* @brief Ends the proximity sensor on the APDS-9960 * @brief Ends the proximity sensor on the APDS-9960
* *
*/ */
void disableProximitySensor() void disableProximitySensor(void)
{ {
setProximityIntEnable(0) ; setProximityIntEnable(0) ;
setMode(PROXIMITY, 0) ; setMode(PROXIMITY, 0) ;
@ -1437,7 +1437,7 @@ void disableProximitySensor()
* *
* no interrupts * no interrupts
*/ */
void enableGestureSensor() void enableGestureSensor(void)
{ {
/* Enable gesture mode /* Enable gesture mode
Set ENABLE to 0 (power off) Set ENABLE to 0 (power off)
@ -1462,7 +1462,7 @@ void enableGestureSensor()
* @brief Ends the gesture recognition engine on the APDS-9960 * @brief Ends the gesture recognition engine on the APDS-9960
* *
*/ */
void disableGestureSensor() void disableGestureSensor(void)
{ {
resetGestureParameters(); resetGestureParameters();
setGestureIntEnable(0) ; setGestureIntEnable(0) ;
@ -1475,7 +1475,7 @@ void disableGestureSensor()
* *
* @return True if gesture available. False otherwise. * @return True if gesture available. False otherwise.
*/ */
bool isGestureAvailable() bool isGestureAvailable(void)
{ {
uint8_t val; uint8_t val;
@ -1498,7 +1498,7 @@ bool isGestureAvailable()
* *
* @return Number corresponding to gesture. -1 on error. * @return Number corresponding to gesture. -1 on error.
*/ */
int16_t readGesture() int16_t readGesture(void)
{ {
uint8_t fifo_level = 0; uint8_t fifo_level = 0;
uint8_t bytes_read = 0; uint8_t bytes_read = 0;
@ -1518,9 +1518,8 @@ int16_t readGesture()
if (gesture_loop_counter == APDS9960_MAX_GESTURE_CYCLES){ // We will escape after a few loops if (gesture_loop_counter == APDS9960_MAX_GESTURE_CYCLES){ // We will escape after a few loops
disableGestureSensor(); // stop the sensor to prevent problems with power consumption/blocking and return to the main loop disableGestureSensor(); // stop the sensor to prevent problems with power consumption/blocking and return to the main loop
APDS9960_overload = true; // we report this as "long"-gesture APDS9960_overload = true; // we report this as "long"-gesture
char log[LOGSZ]; snprintf_P(log_data, sizeof(log_data), PSTR("Sensor overload"));
snprintf_P(log, sizeof(log), PSTR("Sensor overload")); AddLog(LOG_LEVEL_DEBUG);
AddLog_P(LOG_LEVEL_DEBUG, log);
} }
gesture_loop_counter += 1; gesture_loop_counter += 1;
/* Wait some time to collect next batch of FIFO data */ /* Wait some time to collect next batch of FIFO data */
@ -1585,7 +1584,7 @@ int16_t readGesture()
* Turn the APDS-9960 on * Turn the APDS-9960 on
* *
*/ */
void enablePower() void enablePower(void)
{ {
setMode(POWER, 1) ; setMode(POWER, 1) ;
} }
@ -1594,7 +1593,7 @@ void enablePower()
* Turn the APDS-9960 off * Turn the APDS-9960 off
* *
*/ */
void disablePower() void disablePower(void)
{ {
setMode(POWER, 0) ; setMode(POWER, 0) ;
} }
@ -1608,7 +1607,7 @@ void disablePower()
* *
*/ */
void readAllColorAndProximityData() void readAllColorAndProximityData(void)
{ {
if (I2cReadBuffer(APDS9960_I2C_ADDR, APDS9960_CDATAL, (uint8_t *) &color_data, (uint16_t)9)) if (I2cReadBuffer(APDS9960_I2C_ADDR, APDS9960_CDATAL, (uint8_t *) &color_data, (uint16_t)9))
{ {
@ -1624,7 +1623,7 @@ void readAllColorAndProximityData()
/** /**
* @brief Resets all the parameters in the gesture data member * @brief Resets all the parameters in the gesture data member
*/ */
void resetGestureParameters() void resetGestureParameters(void)
{ {
gesture_data_.index = 0; gesture_data_.index = 0;
gesture_data_.total_gestures = 0; gesture_data_.total_gestures = 0;
@ -1644,7 +1643,7 @@ void resetGestureParameters()
* *
* @return True if near or far state seen. False otherwise. * @return True if near or far state seen. False otherwise.
*/ */
bool processGestureData() bool processGestureData(void)
{ {
uint8_t u_first = 0; uint8_t u_first = 0;
uint8_t d_first = 0; uint8_t d_first = 0;
@ -1748,7 +1747,7 @@ bool processGestureData()
* *
* @return True if near/far event. False otherwise. * @return True if near/far event. False otherwise.
*/ */
bool decodeGesture() bool decodeGesture(void)
{ {
/* Determine swipe direction */ /* Determine swipe direction */
@ -1791,38 +1790,37 @@ bool decodeGesture()
return true; return true;
} }
void handleGesture() { void handleGesture(void) {
if (isGestureAvailable() ) { if (isGestureAvailable() ) {
char log[LOGSZ];
switch (readGesture()) { switch (readGesture()) {
case DIR_UP: case DIR_UP:
snprintf_P(log, sizeof(log), PSTR("UP")); snprintf_P(log_data, sizeof(log_data), PSTR("UP"));
snprintf_P(currentGesture, sizeof(currentGesture), PSTR("Up")); snprintf_P(currentGesture, sizeof(currentGesture), PSTR("Up"));
break; break;
case DIR_DOWN: case DIR_DOWN:
snprintf_P(log, sizeof(log), PSTR("DOWN")); snprintf_P(log_data, sizeof(log_data), PSTR("DOWN"));
snprintf_P(currentGesture, sizeof(currentGesture), PSTR("Down")); snprintf_P(currentGesture, sizeof(currentGesture), PSTR("Down"));
break; break;
case DIR_LEFT: case DIR_LEFT:
snprintf_P(log, sizeof(log), PSTR("LEFT")); snprintf_P(log_data, sizeof(log_data), PSTR("LEFT"));
snprintf_P(currentGesture, sizeof(currentGesture), PSTR("Left")); snprintf_P(currentGesture, sizeof(currentGesture), PSTR("Left"));
break; break;
case DIR_RIGHT: case DIR_RIGHT:
snprintf_P(log, sizeof(log), PSTR("RIGHT")); snprintf_P(log_data, sizeof(log_data), PSTR("RIGHT"));
snprintf_P(currentGesture, sizeof(currentGesture), PSTR("Right")); snprintf_P(currentGesture, sizeof(currentGesture), PSTR("Right"));
break; break;
default: default:
if(APDS9960_overload) if(APDS9960_overload)
{ {
snprintf_P(log, sizeof(log), PSTR("LONG")); snprintf_P(log_data, sizeof(log_data), PSTR("LONG"));
snprintf_P(currentGesture, sizeof(currentGesture), PSTR("Long")); snprintf_P(currentGesture, sizeof(currentGesture), PSTR("Long"));
} }
else{ else{
snprintf_P(log, sizeof(log), PSTR("NONE")); snprintf_P(log_data, sizeof(log_data), PSTR("NONE"));
snprintf_P(currentGesture, sizeof(currentGesture), PSTR("None")); snprintf_P(currentGesture, sizeof(currentGesture), PSTR("None"));
} }
} }
AddLog_P(LOG_LEVEL_DEBUG, log); AddLog(LOG_LEVEL_DEBUG);
mqtt_data[0] = '\0'; mqtt_data[0] = '\0';
if (MqttShowSensor()) { if (MqttShowSensor()) {
@ -1834,7 +1832,7 @@ void handleGesture() {
} }
} }
void APDS9960_adjustATime(void) // not really used atm void APDS9960_adjustATime(void) // not really used atm
{ {
//readAllColorAndProximityData(); //readAllColorAndProximityData();
I2cValidRead16LE(&color_data.a, APDS9960_I2C_ADDR, APDS9960_CDATAL); I2cValidRead16LE(&color_data.a, APDS9960_I2C_ADDR, APDS9960_CDATAL);
@ -1870,7 +1868,7 @@ void APDS9960_adjustATime(void) // not really used atm
} }
void APDS9960_loop() void APDS9960_loop(void)
{ {
if (recovery_loop_counter > 0){ if (recovery_loop_counter > 0){
recovery_loop_counter -= 1; recovery_loop_counter -= 1;
@ -1993,7 +1991,7 @@ void APDS9960_show(boolean json)
* Sensor27 | 2 / On | Enable gesture mode with half gain * Sensor27 | 2 / On | Enable gesture mode with half gain
\*********************************************************************************************/ \*********************************************************************************************/
bool APDS9960CommandSensor() bool APDS9960CommandSensor(void)
{ {
boolean serviced = true; boolean serviced = true;

View File

@ -72,7 +72,7 @@ void TM16XXSendData(byte address, byte data)
digitalWrite(tm1638_strobe_pin, HIGH); digitalWrite(tm1638_strobe_pin, HIGH);
} }
byte Tm16XXReceive() byte Tm16XXReceive(void)
{ {
byte temp = 0; byte temp = 0;
@ -96,7 +96,7 @@ byte Tm16XXReceive()
/*********************************************************************************************/ /*********************************************************************************************/
void Tm16XXClearDisplay() void Tm16XXClearDisplay(void)
{ {
for (int i = 0; i < tm1638_displays; i++) { for (int i = 0; i < tm1638_displays; i++) {
TM16XXSendData(i << 1, 0); TM16XXSendData(i << 1, 0);
@ -125,7 +125,7 @@ void Tm1638SetLEDs(word leds)
} }
} }
byte Tm1638GetButtons() byte Tm1638GetButtons(void)
{ {
byte keys = 0; byte keys = 0;
@ -141,7 +141,7 @@ byte Tm1638GetButtons()
/*********************************************************************************************/ /*********************************************************************************************/
void TmInit() void TmInit(void)
{ {
tm1638_type = 0; tm1638_type = 0;
if ((pin[GPIO_TM16CLK] < 99) && (pin[GPIO_TM16DIO] < 99) && (pin[GPIO_TM16STB] < 99)) { if ((pin[GPIO_TM16CLK] < 99) && (pin[GPIO_TM16DIO] < 99) && (pin[GPIO_TM16STB] < 99)) {
@ -171,7 +171,7 @@ void TmInit()
} }
} }
void TmLoop() void TmLoop(void)
{ {
if (tm1638_state) { if (tm1638_state) {
byte buttons = Tm1638GetButtons(); byte buttons = Tm1638GetButtons();

View File

@ -42,7 +42,7 @@ uint8_t ecnt = 0;
/********************************************************************************************/ /********************************************************************************************/
#define EVERYNSECONDS 5 #define EVERYNSECONDS 5
void CCS811Update() // Perform every n second void CCS811Update(void) // Perform every n second
{ {
tcnt++; tcnt++;
if (tcnt >= EVERYNSECONDS) { if (tcnt >= EVERYNSECONDS) {

View File

@ -45,7 +45,7 @@ int16_t MPU_6050_temperature = 0;
#include <MPU6050.h> #include <MPU6050.h>
MPU6050 mpu6050; MPU6050 mpu6050;
void MPU_6050PerformReading() void MPU_6050PerformReading(void)
{ {
mpu6050.getMotion6( mpu6050.getMotion6(
&MPU_6050_ax, &MPU_6050_ax,
@ -75,7 +75,7 @@ void MPU_6050SetAccelOffsets(int x, int y, int z)
} }
*/ */
void MPU_6050Detect() void MPU_6050Detect(void)
{ {
if (MPU_6050_found) if (MPU_6050_found)
{ {

View File

@ -69,7 +69,7 @@ boolean DS3231chipDetected;
/*----------------------------------------------------------------------* /*----------------------------------------------------------------------*
Detect the DS3231 Chip Detect the DS3231 Chip
----------------------------------------------------------------------*/ ----------------------------------------------------------------------*/
boolean DS3231Detect() boolean DS3231Detect(void)
{ {
if (I2cValidRead(USE_RTC_ADDR, RTC_STATUS, 1)) if (I2cValidRead(USE_RTC_ADDR, RTC_STATUS, 1))
{ {
@ -104,7 +104,7 @@ uint8_t dec2bcd(uint8_t n)
/*----------------------------------------------------------------------* /*----------------------------------------------------------------------*
Read time from DS3231 and return the epoch time (second since 1-1-1970 00:00) Read time from DS3231 and return the epoch time (second since 1-1-1970 00:00)
----------------------------------------------------------------------*/ ----------------------------------------------------------------------*/
uint32_t ReadFromDS3231() uint32_t ReadFromDS3231(void)
{ {
TIME_T tm; TIME_T tm;
tm.second = bcd2dec(I2cRead8(USE_RTC_ADDR, RTC_SECONDS)); tm.second = bcd2dec(I2cRead8(USE_RTC_ADDR, RTC_SECONDS));

View File

@ -116,7 +116,7 @@ long HxRead()
/*********************************************************************************************/ /*********************************************************************************************/
void HxReset() void HxReset(void)
{ {
hx_tare_flg = 1; hx_tare_flg = 1;
hx_sum_weight = 0; hx_sum_weight = 0;
@ -149,7 +149,7 @@ void HxCalibrationStateTextJson(uint8_t msg_id)
* Sensor34 6 <weight in decigram> - Set item weight * Sensor34 6 <weight in decigram> - Set item weight
\*********************************************************************************************/ \*********************************************************************************************/
bool HxCommand() bool HxCommand(void)
{ {
bool serviced = true; bool serviced = true;
bool show_parms = false; bool show_parms = false;
@ -220,7 +220,7 @@ long HxWeight()
return (hx_calibrate_step < HX_CAL_FAIL) ? hx_weight : 0; return (hx_calibrate_step < HX_CAL_FAIL) ? hx_weight : 0;
} }
void HxInit() void HxInit(void)
{ {
hx_type = 0; hx_type = 0;
if ((pin[GPIO_HX711_DAT] < 99) && (pin[GPIO_HX711_SCK] < 99)) { if ((pin[GPIO_HX711_DAT] < 99) && (pin[GPIO_HX711_SCK] < 99)) {
@ -245,7 +245,7 @@ void HxInit()
} }
} }
void HxEvery100mSecond() void HxEvery100mSecond(void)
{ {
hx_sum_weight += HxRead(); hx_sum_weight += HxRead();
@ -391,7 +391,7 @@ const char HTTP_FORM_HX711[] PROGMEM =
"<form method='post' action='" WEB_HANDLE_HX711 "'>" "<form method='post' action='" WEB_HANDLE_HX711 "'>"
"<br/><b>" D_ITEM_WEIGHT "</b> (" D_UNIT_KILOGRAM ")<br/><input type='number' max='6.5535' step='0.0001' id='p2' name='p2' placeholder='0.0' value='{2'><br/>"; "<br/><b>" D_ITEM_WEIGHT "</b> (" D_UNIT_KILOGRAM ")<br/><input type='number' max='6.5535' step='0.0001' id='p2' name='p2' placeholder='0.0' value='{2'><br/>";
void HandleHxAction() void HandleHxAction(void)
{ {
if (HttpUser()) { return; } if (HttpUser()) { return; }
if (!WebAuthenticate()) { return WebServer->requestAuthentication(); } if (!WebAuthenticate()) { return WebServer->requestAuthentication(); }
@ -440,7 +440,7 @@ void HandleHxAction()
ShowPage(page); ShowPage(page);
} }
void HxSaveSettings() void HxSaveSettings(void)
{ {
char tmp[100]; char tmp[100];
@ -450,7 +450,7 @@ void HxSaveSettings()
HxLogUpdates(); HxLogUpdates();
} }
void HxLogUpdates() void HxLogUpdates(void)
{ {
char weigth_ref_chr[10]; char weigth_ref_chr[10];
char weigth_item_chr[10]; char weigth_item_chr[10];

View File

@ -80,7 +80,7 @@ uint8_t tx20_wind_direction = 0;
boolean tx20_available = false; boolean tx20_available = false;
void Tx20StartRead() void Tx20StartRead(void)
{ {
/* La Crosse TX20 Anemometer datagram every 2 seconds /* La Crosse TX20 Anemometer datagram every 2 seconds
* 0-0 11011 0011 111010101111 0101 1100 000101010000 0-0 - Received pin data at 1200 uSec per bit * 0-0 11011 0011 111010101111 0101 1100 000101010000 0-0 - Received pin data at 1200 uSec per bit
@ -146,7 +146,7 @@ void Tx20StartRead()
GPIO_REG_WRITE(GPIO_STATUS_W1TC_ADDRESS, 1 << pin[GPIO_TX20_TXD_BLACK]); GPIO_REG_WRITE(GPIO_STATUS_W1TC_ADDRESS, 1 << pin[GPIO_TX20_TXD_BLACK]);
} }
void Tx20Read() void Tx20Read(void)
{ {
if (!(uptime % TX20_RESET_VALUES)) { if (!(uptime % TX20_RESET_VALUES)) {
tx20_count = 0; tx20_count = 0;
@ -165,7 +165,7 @@ void Tx20Read()
} }
} }
void Tx20Init() { void Tx20Init(void) {
pinMode(pin[GPIO_TX20_TXD_BLACK], INPUT); pinMode(pin[GPIO_TX20_TXD_BLACK], INPUT);
attachInterrupt(pin[GPIO_TX20_TXD_BLACK], Tx20StartRead, RISING); attachInterrupt(pin[GPIO_TX20_TXD_BLACK], Tx20StartRead, RISING);
} }

View File

@ -542,7 +542,7 @@ boolean XsnsPresent(byte sns_index)
return false; return false;
} }
String XsnsGetSensors() String XsnsGetSensors(void)
{ {
char state[2] = { 0 }; char state[2] = { 0 };
@ -568,7 +568,7 @@ boolean XsnsNextCall(byte Function)
xsns_index++; xsns_index++;
if (xsns_index == xsns_present) { xsns_index = 0; } if (xsns_index == xsns_present) { xsns_index = 0; }
} }
if (global_state.wifi_down) { delay(DRIVER_BOOT_DELAY); } AppDelay();
return xsns_func_ptr[xsns_index](Function); return xsns_func_ptr[xsns_index](Function);
} }
@ -586,7 +586,7 @@ boolean XsnsCall(byte Function)
#ifdef PROFILE_XSNS_SENSOR_EVERY_SECOND #ifdef PROFILE_XSNS_SENSOR_EVERY_SECOND
uint32_t profile_start_millis = millis(); uint32_t profile_start_millis = millis();
#endif // PROFILE_XSNS_SENSOR_EVERY_SECOND #endif // PROFILE_XSNS_SENSOR_EVERY_SECOND
if (global_state.wifi_down) { delay(DRIVER_BOOT_DELAY); } AppDelay();
result = xsns_func_ptr[x](Function); result = xsns_func_ptr[x](Function);
#ifdef PROFILE_XSNS_SENSOR_EVERY_SECOND #ifdef PROFILE_XSNS_SENSOR_EVERY_SECOND

View File

@ -1,5 +1,11 @@
<h1 id="decode-config-py">decode-config.py</h1> <h1 id="decode-config-py">decode-config.py</h1>
<p><em>decode-config.py</em> backup and restore Sonoff-Tasmota configuration.</p> <p><em>decode-config.py</em> is able to backup and restore Sonoff-Tasmota configuration.</p>
<p>In contrast to the Tasmota build-in &quot;Backup/Restore Configuration&quot; function,</p>
<ul>
<li><em>decode-config.py</em> uses human readable and editable <a href="http://www.json.org/">JSON</a>-format for backup/restore,</li>
<li><em>decode-config.py</em> can restore previous backuped and changed <a href="http://www.json.org/">JSON</a>-format files,</li>
<li><em>decode-config.py</em> is able to create Tasmota commands based on given configuration</li>
</ul>
<p>Comparing backup files created by <em>decode-config.py</em> and *.dmp files created by Tasmota &quot;Backup/Restore Configuration&quot;: </p> <p>Comparing backup files created by <em>decode-config.py</em> and *.dmp files created by Tasmota &quot;Backup/Restore Configuration&quot;: </p>
<table> <table>
<thead> <thead>
@ -32,39 +38,51 @@
</tr> </tr>
</tbody> </tbody>
</table> </table>
<p><em>decode-config.py</em> handles Tasmota configurations for release version since 5.10.0 up to now.</p> <p><em>decode-config.py</em> is able to handle Tasmota configurations for release version starting from 5.10.0 up to now.</p>
<h1 id="content">Content</h1> <h1 id="content">Content</h1>
<ul> <ul>
<li><a href="decode-config.html#prerequisite">Prerequisite</a></li> <li><a href="decode-config.md#prerequisite">Prerequisite</a></li>
<li><a href="decode-config.html#file-types">File Types</a><ul> <li><a href="decode-config.md#file-types">File Types</a><ul>
<li><a href="decode-config.html#-dmp-file-format">.dmp File Format</a></li> <li><a href="decode-config.md#-dmp-format">.dmp File Format</a></li>
<li><a href="decode-config.html#-json-file-format">.json File Format</a></li> <li><a href="decode-config.md#-json-format">.json File Format</a></li>
<li><a href="decode-config.html#-bin-file-format">.bin File Format</a><ul> <li><a href="decode-config.md#-bin-format">.bin File Format</a><ul>
<li><a href="decode-config.html#file-extensions">File extensions</a></li> <li><a href="decode-config.md#file-extensions">File extensions</a></li>
</ul> </ul>
</li> </li>
</ul> </ul>
</li> </li>
<li><a href="decode-config.html#usage">Usage</a><ul> <li><a href="decode-config.md#usage">Usage</a><ul>
<li><a href="decode-config.html#basics">Basics</a></li> <li><a href="decode-config.md#basics">Basics</a></li>
<li><a href="decode-config.html#save-backup-file">Save backup file</a></li> <li><a href="decode-config.md#save-backup-file">Save backup file</a></li>
<li><a href="decode-config.html#restore-backup-file">Restore backup file</a></li> <li><a href="decode-config.md#restore-backup-file">Restore backup file</a></li>
<li><a href="decode-config.html#configuration-file">Configuration file</a></li> <li><a href="decode-config.md#output-to-screen">Output to screen</a><ul>
<li><a href="decode-config.html#more-program-arguments">More program arguments</a></li> <li><a href="decode-config.md#json-output">JSON output</a></li>
<li><a href="decode-config.html#examples">Examples</a><ul> <li><a href="decode-config.md#tasmota-command-output">Tasmota command output</a></li>
<li><a href="decode-config.html#config-file">Config file</a></li>
<li><a href="decode-config.html#using-tasmota-binary-configuration-files">Using Tasmota binary configuration files</a></li>
<li><a href="decode-config.html#use-batch-processing">Use batch processing</a></li>
</ul> </ul>
</li> </li>
<li><a href="decode-config.md#filter-data">Filter data</a></li>
<li><a href="decode-config.md#configuration-file">Configuration file</a></li>
<li><a href="decode-config.md#more-program-arguments">More program arguments</a></li>
<li><a href="decode-config.md#examples">Examples</a><ul>
<li><a href="decode-config.md#config-file">Config file</a></li>
<li><a href="decode-config.md#using-tasmota-binary-configuration-files">Using Tasmota binary configuration files</a></li>
<li><a href="decode-config.md#use-batch-processing">Use batch processing</a></li>
</ul>
</li>
<li><a href="decode-config.md#notes">Notes</a></li>
</ul> </ul>
</li> </li>
</ul> </ul>
<h2 id="prerequisite">Prerequisite</h2> <h2 id="prerequisite">Prerequisite</h2>
<ul> <ul>
<li><a href="https://en.wikipedia.org/wiki/Python_(programming_language">Python</a>)<br>This program is written in <a href="https://en.wikipedia.org/wiki/Python_(programming_language">Python</a>) so you need to install a python environment (for details see <a href="https://docs.python.org/2.7/using/index.html">Python Setup and Usage</a>)</li> <li><p><a href="https://en.wikipedia.org/wiki/Python_(programming_language">Python</a>)<br>This program is written in <a href="https://en.wikipedia.org/wiki/Python_(programming_language">Python</a>) so you need to install a python environment (for details see <a href="https://docs.python.org/2.7/using/index.html">Python Setup and Usage</a>)</p>
<li><a href="https://github.com/arendst/Sonoff-Tasmota">Sonoff-Tasmota</a> <a href="https://github.com/arendst/Sonoff-Tasmota/releases">Firmware</a> with enabled Web-Server<br>To backup or restore configurations from/to a Sonoff-Tasmota device you need a firmare with enabled web-server in admin mode (command <a href="https://github.com/arendst/Sonoff-Tasmota/wiki/Commands#wifi">WebServer 2</a>). </li>
<br />Only self compiled firmware may do not have a web-server sod if you use your own compiled firmware be aware to enable the web-server, otherwise you can only use the <code>--file</code> parameter as source.</li> <li><p><a href="https://github.com/arendst/Sonoff-Tasmota">Sonoff-Tasmota</a> <a href="https://github.com/arendst/Sonoff-Tasmota/releases">Firmware</a> with Web-Server enabled:</p>
<ul>
<li>To backup or restore configurations from/to a Sonoff-Tasmota device you need a firmare with enabled web-server in admin mode (command <a href="https://github.com/arendst/Sonoff-Tasmota/wiki/Commands#wifi">WebServer 2</a>).</li>
<li>If using your own compiled firmware be aware to enable the web-server (<code>#define USE_WEBSERVER</code> and <code>#define WEB_SERVER 2</code>).</li>
</ul>
</li>
</ul> </ul>
<h2 id="file-types">File Types</h2> <h2 id="file-types">File Types</h2>
<p><em>decode-config.py</em> can handle the following backup file types: </p> <p><em>decode-config.py</em> can handle the following backup file types: </p>
@ -83,7 +101,7 @@
<p>The source can be either </p> <p>The source can be either </p>
<ul> <ul>
<li>a Tasmota device hostname or IP by passing it using the <code>-d &lt;host&gt;</code> arg</li> <li>a Tasmota device hostname or IP by passing it using the <code>-d &lt;host&gt;</code> arg</li>
<li>or a previously stored Tasmota *.dmp<code>configuration file by passing the filename using</code>-f <filename>` arg</li> <li>or a previously stored Tasmota <code>*.dmp</code> configuration file by passing the filename using <code>-f &lt;filename&gt;</code> arg</li>
</ul> </ul>
<p>Example: </p> <p>Example: </p>
<pre><code>decode-config<span class="hljs-selector-class">.py</span> -d sonoff-<span class="hljs-number">4281</span> <pre><code>decode-config<span class="hljs-selector-class">.py</span> -d sonoff-<span class="hljs-number">4281</span>
@ -112,6 +130,72 @@
<pre><code><span class="hljs-selector-tag">decode-config</span><span class="hljs-selector-class">.py</span> <span class="hljs-selector-tag">-d</span> <span class="hljs-selector-tag">sonoff-4281</span> <span class="hljs-selector-tag">--restore-file</span> <span class="hljs-selector-tag">Config_Sonoff_6</span><span class="hljs-selector-class">.2</span><span class="hljs-selector-class">.1</span><span class="hljs-selector-class">.json</span> <pre><code><span class="hljs-selector-tag">decode-config</span><span class="hljs-selector-class">.py</span> <span class="hljs-selector-tag">-d</span> <span class="hljs-selector-tag">sonoff-4281</span> <span class="hljs-selector-tag">--restore-file</span> <span class="hljs-selector-tag">Config_Sonoff_6</span><span class="hljs-selector-class">.2</span><span class="hljs-selector-class">.1</span><span class="hljs-selector-class">.json</span>
</code></pre><p>with password set by WebPassword:</p> </code></pre><p>with password set by WebPassword:</p>
<pre><code><span class="hljs-selector-tag">decode-config</span><span class="hljs-selector-class">.py</span> <span class="hljs-selector-tag">-d</span> <span class="hljs-selector-tag">sonoff-4281</span> <span class="hljs-selector-tag">-p</span> &lt;<span class="hljs-selector-tag">yourpassword</span>&gt; <span class="hljs-selector-tag">--restore-file</span> <span class="hljs-selector-tag">Config_Sonoff_6</span><span class="hljs-selector-class">.2</span><span class="hljs-selector-class">.1</span><span class="hljs-selector-class">.json</span> <pre><code><span class="hljs-selector-tag">decode-config</span><span class="hljs-selector-class">.py</span> <span class="hljs-selector-tag">-d</span> <span class="hljs-selector-tag">sonoff-4281</span> <span class="hljs-selector-tag">-p</span> &lt;<span class="hljs-selector-tag">yourpassword</span>&gt; <span class="hljs-selector-tag">--restore-file</span> <span class="hljs-selector-tag">Config_Sonoff_6</span><span class="hljs-selector-class">.2</span><span class="hljs-selector-class">.1</span><span class="hljs-selector-class">.json</span>
</code></pre><h3 id="output-to-screen">Output to screen</h3>
<p>Output to screen is default enabled when calling the program with a source arg but without a backup or restore arg.</p>
<p><code>--output</code> arg will force screen output even if you use backup or restore arg.</p>
<h4 id="json-output">JSON output</h4>
<p>The default output format is JSON. You can force JSON output with <code>--output-format json</code> arg.</p>
<p>Example:</p>
<pre><code>decode-config.py -d sonoff<span class="hljs-number">-4281</span> -c my.conf -x <span class="hljs-symbol">Wifi</span> --output-format json
{
...
<span class="hljs-string">"hostname"</span>: <span class="hljs-string">"%s-%04d"</span>,
<span class="hljs-string">"ip_address"</span>: [
<span class="hljs-string">"0.0.0.0"</span>,
<span class="hljs-string">"192.168.12.1"</span>,
<span class="hljs-string">"255.255.255.0"</span>,
<span class="hljs-string">"192.168.12.1"</span>
],
<span class="hljs-string">"ntp_server"</span>: [
<span class="hljs-string">"ntp.localnet.home"</span>,
<span class="hljs-string">"ntp2.localnet.home"</span>,
<span class="hljs-string">"192.168.12.1"</span>
],
<span class="hljs-string">"sta_active"</span>: <span class="hljs-number">0</span>,
<span class="hljs-string">"sta_config"</span>: <span class="hljs-number">5</span>,
<span class="hljs-string">"sta_pwd"</span>: [
<span class="hljs-string">"myWlAnPaszxwo!z"</span>,
<span class="hljs-string">"myWlAnPaszxwo!z2"</span>
],
<span class="hljs-string">"sta_ssid"</span>: [
<span class="hljs-string">"wlan.1"</span>,
<span class="hljs-string">"my-wlan"</span>
],
<span class="hljs-string">"web_password"</span>: <span class="hljs-string">"myPaszxwo!z"</span>,
<span class="hljs-string">"webserver"</span>: <span class="hljs-number">2</span>
...
}
</code></pre><p>Note: JSON output always contains all configuration data like the backup file except you are using <code>--group</code> arg.</p>
<h4 id="tasmota-command-output">Tasmota command output</h4>
<p><em>decode-config.py</em> is able to translate the configuration data to (most all) Tasmota commands. To output your configuration as Tasmota commands use <code>--output-format cmnd</code> or <code>--output-format command</code>.</p>
<p>Example:</p>
<pre><code><span class="hljs-selector-tag">decode-config</span><span class="hljs-selector-class">.py</span> <span class="hljs-selector-tag">-d</span> <span class="hljs-selector-tag">sonoff-4281</span> <span class="hljs-selector-tag">-c</span> <span class="hljs-selector-tag">my</span><span class="hljs-selector-class">.conf</span> <span class="hljs-selector-tag">-g</span> <span class="hljs-selector-tag">Wifi</span> <span class="hljs-selector-tag">--output-format</span> <span class="hljs-selector-tag">cmnd</span>
# <span class="hljs-selector-tag">Wifi</span>:
<span class="hljs-selector-tag">AP</span> 0
<span class="hljs-selector-tag">Hostname</span> %<span class="hljs-selector-tag">s-</span>%04<span class="hljs-selector-tag">d</span>
<span class="hljs-selector-tag">IPAddress1</span> 0<span class="hljs-selector-class">.0</span><span class="hljs-selector-class">.0</span><span class="hljs-selector-class">.0</span>
<span class="hljs-selector-tag">IPAddress2</span> 192<span class="hljs-selector-class">.168</span><span class="hljs-selector-class">.12</span><span class="hljs-selector-class">.1</span>
<span class="hljs-selector-tag">IPAddress3</span> 255<span class="hljs-selector-class">.255</span><span class="hljs-selector-class">.255</span><span class="hljs-selector-class">.0</span>
<span class="hljs-selector-tag">IPAddress4</span> 192<span class="hljs-selector-class">.168</span><span class="hljs-selector-class">.12</span><span class="hljs-selector-class">.1</span>
<span class="hljs-selector-tag">NtpServer1</span> <span class="hljs-selector-tag">ntp</span><span class="hljs-selector-class">.localnet</span><span class="hljs-selector-class">.home</span>
<span class="hljs-selector-tag">NtpServer2</span> <span class="hljs-selector-tag">ntp2</span><span class="hljs-selector-class">.localnet</span><span class="hljs-selector-class">.home</span>
<span class="hljs-selector-tag">NtpServer3</span> 192<span class="hljs-selector-class">.168</span><span class="hljs-selector-class">.12</span><span class="hljs-selector-class">.1</span>
<span class="hljs-selector-tag">Password1</span> <span class="hljs-selector-tag">myWlAnPaszxwo</span>!<span class="hljs-selector-tag">z</span>
<span class="hljs-selector-tag">Password2</span> <span class="hljs-selector-tag">myWlAnPaszxwo</span>!<span class="hljs-selector-tag">z2</span>
<span class="hljs-selector-tag">SSId1</span> <span class="hljs-selector-tag">wlan</span><span class="hljs-selector-class">.1</span>
<span class="hljs-selector-tag">SSId2</span> <span class="hljs-selector-tag">wlan</span><span class="hljs-selector-class">.1</span>
<span class="hljs-selector-tag">WebPassword</span> <span class="hljs-selector-tag">myPaszxwo</span>!<span class="hljs-selector-tag">z</span>
<span class="hljs-selector-tag">WebServer</span> 2
<span class="hljs-selector-tag">WifiConfig</span> 5
</code></pre><p>Note: A few very specific module commands like MPC230xx, KNX and some Display commands are not supported. These are still available by JSON output.</p>
<h3 id="filter-data">Filter data</h3>
<p>The huge number of Tasmota configuration data can be overstrained and confusing, so the most of the configuration data are grouped into categories. </p>
<p>With <em>decode-config.py</em> the following categories are available: <code>Display</code>, <code>Domoticz</code>, <code>Internal</code>, <code>KNX</code>, <code>Led</code>, <code>Logging</code>, <code>MCP230xx</code>, <code>MQTT</code>, <code>Main</code>, <code>Management</code>, <code>Pow</code>, <code>Sensor</code>, <code>Serial</code>, <code>SetOption</code>, <code>SonoffRF</code>, <code>System</code>, <code>Timers</code>, <code>Wifi</code></p>
<p>These are similary to the categories on <a href="Tasmota Command Wiki">https://github.com/arendst/Sonoff-Tasmota/wiki/Commands</a>.</p>
<p>To filter outputs to a subset of groups use the <code>-g</code> or <code>--group</code> arg concatenating the grooup you want, e. g.</p>
<pre><code>decode-config<span class="hljs-selector-class">.py</span> -d sonoff-<span class="hljs-number">4281</span> -c my<span class="hljs-selector-class">.conf</span> --output-format cmnd --group Main MQTT Management Wifi
</code></pre><h3 id="configuration-file">Configuration file</h3> </code></pre><h3 id="configuration-file">Configuration file</h3>
<p>Each argument that start with <code>--</code> (eg. <code>--file</code>) can also be set in a config file (specified via -c). Config file syntax allows: key=value, flag=true, stuff=[a,b,c] (for details, see syntax at <a href="https://pypi.org/project/ConfigArgParse/">https://pypi.org/project/ConfigArgParse</a>).</p> <p>Each argument that start with <code>--</code> (eg. <code>--file</code>) can also be set in a config file (specified via -c). Config file syntax allows: key=value, flag=true, stuff=[a,b,c] (for details, see syntax at <a href="https://pypi.org/project/ConfigArgParse/">https://pypi.org/project/ConfigArgParse</a>).</p>
<p>If an argument is specified in more than one place, then commandline values override config file values which override defaults. This is usefull if you always use the same argument or a basic set of arguments.</p> <p>If an argument is specified in more than one place, then commandline values override config file values which override defaults. This is usefull if you always use the same argument or a basic set of arguments.</p>
@ -123,83 +207,115 @@
</code></pre><p>To make a backup file from example above you can now pass the config file instead using the password on command line:</p> </code></pre><p>To make a backup file from example above you can now pass the config file instead using the password on command line:</p>
<pre><code><span class="hljs-selector-tag">decode-config</span><span class="hljs-selector-class">.py</span> <span class="hljs-selector-tag">-d</span> <span class="hljs-selector-tag">sonoff-4281</span> <span class="hljs-selector-tag">-c</span> <span class="hljs-selector-tag">my</span><span class="hljs-selector-class">.conf</span> <span class="hljs-selector-tag">--backup-file</span> <span class="hljs-selector-tag">Config_</span>@<span class="hljs-keyword">f_</span>@<span class="hljs-keyword">v</span> <pre><code><span class="hljs-selector-tag">decode-config</span><span class="hljs-selector-class">.py</span> <span class="hljs-selector-tag">-d</span> <span class="hljs-selector-tag">sonoff-4281</span> <span class="hljs-selector-tag">-c</span> <span class="hljs-selector-tag">my</span><span class="hljs-selector-class">.conf</span> <span class="hljs-selector-tag">--backup-file</span> <span class="hljs-selector-tag">Config_</span>@<span class="hljs-keyword">f_</span>@<span class="hljs-keyword">v</span>
</code></pre><h3 id="more-program-arguments">More program arguments</h3> </code></pre><h3 id="more-program-arguments">More program arguments</h3>
<p>For better reading your porgram arguments each short written arg (minus sign <code>-</code>) has a corresponding readable long version (two minus signs <code>--</code>), eg. <code>--device</code> for <code>-d</code> or <code>--file</code> for <code>-f</code> (note: not even all <code>--</code> arg has a corresponding <code>-</code> one).</p> <p>For better reading each short written arg (minus sign <code>-</code>) has a corresponding long version (two minus signs <code>--</code>), eg. <code>--device</code> for <code>-d</code> or <code>--file</code> for <code>-f</code> (note: not even all <code>--</code> arg has a corresponding <code>-</code> one).</p>
<p>A short list of possible program args is displayed using <code>-h</code> or <code>--help</code>.</p> <p>A short list of possible program args is displayed using <code>-h</code> or <code>--help</code>.</p>
<p>For advanced help use <code>-H</code> or <code>--full-help</code>:</p> <p>For advanced help use <code>-H</code> or <code>--full-help</code>:</p>
<pre><code>usage: decode-config.py [-f &lt;filename&gt;] [-d &lt;host&gt;] [-P &lt;<span class="hljs-keyword">port</span>&gt;] <pre><code><span class="hljs-title">usage</span>: decode-config.py [-f &lt;filename&gt;] [-d &lt;host&gt;] [-<span class="hljs-type">P</span> &lt;port&gt;]
[-u &lt;username&gt;] [-p &lt;password&gt;] [-i &lt;filename&gt;] [-u &lt;username&gt;] [-p &lt;password&gt;] [-i &lt;filename&gt;]
[-o &lt;filename&gt;] [-F json|bin|dmp] [-E] [-e] [-o &lt;filename&gt;] [-t json|bin|dmp] [-<span class="hljs-type">E</span>] [-e] [-<span class="hljs-type">F</span>]
[<span class="hljs-comment">--json-indent &lt;indent&gt;] [--json-compact]</span> [<span class="hljs-comment">--json-indent &lt;indent&gt;] [--json-compact]</span>
[<span class="hljs-comment">--json-hide-pw] [--json-unhide-pw] [-h] [-H] [-v]</span> [<span class="hljs-comment">--json-hide-pw] [--json-show-pw]</span>
[-V] [-c &lt;filename&gt;] [<span class="hljs-comment">--ignore-warnings]</span> [<span class="hljs-comment">--cmnd-indent &lt;indent&gt;] [--cmnd-groups]</span>
[<span class="hljs-comment">--cmnd-nogroups] [--cmnd-sort] [--cmnd-unsort]</span>
[-c &lt;filename&gt;] [-<span class="hljs-type">S</span>] [-<span class="hljs-type">T</span> json|cmnd|command]
[-g {<span class="hljs-type">Display</span>,<span class="hljs-type">Domoticz</span>,<span class="hljs-type">Internal</span>,<span class="hljs-type">KNX</span>,<span class="hljs-type">Led</span>,<span class="hljs-type">Logging</span>,<span class="hljs-type">MCP230xx</span>,<span class="hljs-type">MQTT</span>,<span class="hljs-type">Main</span>,<span class="hljs-type">Management</span>,<span class="hljs-type">Pow</span>,<span class="hljs-type">Sensor</span>,<span class="hljs-type">Serial</span>,<span class="hljs-type">SetOption</span>,<span class="hljs-type">SonoffRF</span>,<span class="hljs-type">System</span>,<span class="hljs-type">Timers</span>,<span class="hljs-type">Wifi</span>} [{<span class="hljs-type">Display</span>,<span class="hljs-type">Domoticz</span>,<span class="hljs-type">Internal</span>,<span class="hljs-type">KNX</span>,<span class="hljs-type">Led</span>,<span class="hljs-type">Logging</span>,<span class="hljs-type">MCP230xx</span>,<span class="hljs-type">MQTT</span>,<span class="hljs-type">Main</span>,<span class="hljs-type">Management</span>,<span class="hljs-type">Pow</span>,<span class="hljs-type">Sensor</span>,<span class="hljs-type">Serial</span>,<span class="hljs-type">SetOption</span>,<span class="hljs-type">SonoffRF</span>,<span class="hljs-type">System</span>,<span class="hljs-type">Timers</span>,<span class="hljs-type">Wifi</span>} ...]]
[<span class="hljs-comment">--ignore-warnings] [-h] [-H] [-v] [-V]</span>
Backup/Restore Sonoff-Tasmota <span class="hljs-keyword">configuration</span> data. Args that start <span class="hljs-keyword">with</span> '<span class="hljs-comment">--'</span> <span class="hljs-type">Backup</span>/<span class="hljs-type">Restore</span> <span class="hljs-type">Sonoff</span>-<span class="hljs-type">Tasmota</span> configuration <span class="hljs-class"><span class="hljs-keyword">data</span>. <span class="hljs-type">Args</span> that start with '<span class="hljs-comment">--'</span></span>
(eg. -f) can also be set <span class="hljs-keyword">in</span> a config <span class="hljs-keyword">file</span> (specified via -c). Config <span class="hljs-keyword">file</span> (eg. -f) can also be set <span class="hljs-keyword">in</span> a config file (specified via -c). <span class="hljs-type">Config</span> file
syntax allows: key=value, flag=<span class="hljs-literal">true</span>, stuff=[a,b,c] (<span class="hljs-keyword">for</span> details, see syntax at <span class="hljs-title">syntax</span> allows: key=value, flag=true, stuff=[a,b,c] (for details, see syntax at
https://goo.gl/R74nmi). <span class="hljs-keyword">If</span> an arg <span class="hljs-keyword">is</span> specified <span class="hljs-keyword">in</span> more than one place, <span class="hljs-keyword">then</span> <span class="hljs-title">https</span>://goo.gl/<span class="hljs-type">R74nmi</span>). <span class="hljs-type">If</span> an arg is specified <span class="hljs-keyword">in</span> more than one place, <span class="hljs-keyword">then</span>
commandline values override config <span class="hljs-keyword">file</span> values which override defaults. <span class="hljs-title">commandline</span> values override config file values which override defaults.
<span class="hljs-type">Source</span>:
<span class="hljs-type">Read</span>/<span class="hljs-type">Write</span> <span class="hljs-type">Tasmota</span> configuration from/to
-f, <span class="hljs-comment">--file, --tasmota-file &lt;filename&gt;</span>
file to retrieve/write <span class="hljs-type">Tasmota</span> configuration from/to
(<span class="hljs-keyword">default</span>: <span class="hljs-type">None</span>)'
-d, <span class="hljs-comment">--device, --host &lt;host&gt;</span>
hostname or <span class="hljs-type">IP</span> address to retrieve/send <span class="hljs-type">Tasmota</span>
configuration from/to (<span class="hljs-keyword">default</span>: <span class="hljs-type">None</span>)
-<span class="hljs-type">P</span>, <span class="hljs-comment">--port &lt;port&gt; TCP/IP port number to use for the host connection</span>
(<span class="hljs-keyword">default</span>: 80)
-u, <span class="hljs-comment">--username &lt;username&gt;</span>
host <span class="hljs-type">HTTP</span> access username (<span class="hljs-keyword">default</span>: admin)
-p, <span class="hljs-comment">--password &lt;password&gt;</span>
host <span class="hljs-type">HTTP</span> access password (<span class="hljs-keyword">default</span>: <span class="hljs-type">None</span>)
<span class="hljs-type">Backup</span>/<span class="hljs-type">Restore</span>:
<span class="hljs-type">Backup</span> &amp; restore specification
-i, <span class="hljs-comment">--restore-file &lt;filename&gt;</span>
file to restore configuration from (<span class="hljs-keyword">default</span>: <span class="hljs-type">None</span>).
<span class="hljs-type">Replacements</span>: @v=firmware version from config,
@f=device friendly name from config, @h=device
hostname from config, @<span class="hljs-type">H</span>=device hostname from device
(-d arg only)
-o, <span class="hljs-comment">--backup-file &lt;filename&gt;</span>
file to backup configuration to (<span class="hljs-keyword">default</span>: <span class="hljs-type">None</span>).
<span class="hljs-type">Replacements</span>: @v=firmware version from config,
@f=device friendly name from config, @h=device
hostname from config, @<span class="hljs-type">H</span>=device hostname from device
(-d arg only)
-t, <span class="hljs-comment">--backup-type json|bin|dmp</span>
backup filetype (<span class="hljs-keyword">default</span>: 'json')
-<span class="hljs-type">E</span>, <span class="hljs-comment">--extension append filetype extension for -i and -o filename</span>
(<span class="hljs-keyword">default</span>)
-e, <span class="hljs-comment">--no-extension do not append filetype extension, use -i and -o</span>
filename <span class="hljs-keyword">as</span> passed
-<span class="hljs-type">F</span>, <span class="hljs-comment">--force-restore force restore even configuration is identical</span>
<span class="hljs-type">JSON</span> output:
<span class="hljs-type">JSON</span> format specification
<span class="hljs-comment">--json-indent &lt;indent&gt;</span>
pretty-printed <span class="hljs-type">JSON</span> output using indent level
(<span class="hljs-keyword">default</span>: '<span class="hljs-type">None'</span>). -1 disables indent.
<span class="hljs-comment">--json-compact compact JSON output by eliminate whitespace</span>
<span class="hljs-comment">--json-hide-pw hide passwords</span>
<span class="hljs-comment">--json-show-pw, --json-unhide-pw</span>
unhide passwords (<span class="hljs-keyword">default</span>)
<span class="hljs-type">Tasmota</span> command output:
<span class="hljs-type">Tasmota</span> command output format specification
<span class="hljs-comment">--cmnd-indent &lt;indent&gt;</span>
<span class="hljs-type">Tasmota</span> command grouping indent level (<span class="hljs-keyword">default</span>: '2').
<span class="hljs-number">0</span> disables indent
<span class="hljs-comment">--cmnd-groups group Tasmota commands (default)</span>
<span class="hljs-comment">--cmnd-nogroups leave Tasmota commands ungrouped</span>
<span class="hljs-comment">--cmnd-sort sort Tasmota commands (default)</span>
<span class="hljs-comment">--cmnd-unsort leave Tasmota commands unsorted</span>
<span class="hljs-type">Common</span>:
<span class="hljs-type">Optional</span> arguments
optional arguments:
-c, <span class="hljs-comment">--config &lt;filename&gt;</span> -c, <span class="hljs-comment">--config &lt;filename&gt;</span>
program config <span class="hljs-keyword">file</span> - can be used <span class="hljs-keyword">to</span> set <span class="hljs-keyword">default</span> program config file - can be used to set <span class="hljs-keyword">default</span>
command args (<span class="hljs-keyword">default</span>: None) command args (<span class="hljs-keyword">default</span>: <span class="hljs-type">None</span>)
-<span class="hljs-type">S</span>, <span class="hljs-comment">--output display output regardsless of backup/restore usage</span>
(<span class="hljs-keyword">default</span> do not output on backup or restore usage)
-<span class="hljs-type">T</span>, <span class="hljs-comment">--output-format json|cmnd|command</span>
display output format (<span class="hljs-keyword">default</span>: 'json')
-g, <span class="hljs-comment">--group {Display,Domoticz,Internal,KNX,Led,Logging,MCP230xx,MQTT,Main,Management,Pow,Sensor,Serial,SetOption,SonoffRF,System,Timers,Wifi}</span>
limit <span class="hljs-class"><span class="hljs-keyword">data</span> processing to command groups (<span class="hljs-title">default</span> <span class="hljs-title">no</span>
<span class="hljs-title">filter</span>)</span>
<span class="hljs-comment">--ignore-warnings do not exit on warnings. Not recommended, used by your</span> <span class="hljs-comment">--ignore-warnings do not exit on warnings. Not recommended, used by your</span>
own responsibility! own responsibility!
Source: <span class="hljs-type">Info</span>:
Read/Write Tasmota <span class="hljs-keyword">configuration</span> from/<span class="hljs-keyword">to</span> <span class="hljs-type">Extra</span> information
-f, <span class="hljs-comment">--file, --tasmota-file &lt;filename&gt;</span>
<span class="hljs-keyword">file</span> <span class="hljs-keyword">to</span> retrieve/write Tasmota <span class="hljs-keyword">configuration</span> from/<span class="hljs-keyword">to</span>
(<span class="hljs-keyword">default</span>: None)'
-d, <span class="hljs-comment">--device, --host &lt;host&gt;</span>
hostname <span class="hljs-keyword">or</span> IP address <span class="hljs-keyword">to</span> retrieve/send Tasmota
<span class="hljs-keyword">configuration</span> from/<span class="hljs-keyword">to</span> (<span class="hljs-keyword">default</span>: None)
-P, <span class="hljs-comment">--port &lt;port&gt; TCP/IP port number to use for the host connection</span>
(<span class="hljs-keyword">default</span>: <span class="hljs-number">80</span>)
-u, <span class="hljs-comment">--username &lt;username&gt;</span>
host HTTP <span class="hljs-keyword">access</span> username (<span class="hljs-keyword">default</span>: admin)
-p, <span class="hljs-comment">--password &lt;password&gt;</span>
host HTTP <span class="hljs-keyword">access</span> password (<span class="hljs-keyword">default</span>: None)
Backup/Restore:
Backup/Restore <span class="hljs-keyword">configuration</span> <span class="hljs-keyword">file</span> specification
-i, <span class="hljs-comment">--restore-file &lt;filename&gt;</span>
<span class="hljs-keyword">file</span> <span class="hljs-keyword">to</span> restore <span class="hljs-keyword">configuration</span> from (<span class="hljs-keyword">default</span>: None).
Replacements: @v=firmware version, @f=device friendly
name, @h=device hostname
-o, <span class="hljs-comment">--backup-file &lt;filename&gt;</span>
<span class="hljs-keyword">file</span> <span class="hljs-keyword">to</span> backup <span class="hljs-keyword">configuration</span> <span class="hljs-keyword">to</span> (<span class="hljs-keyword">default</span>: None).
Replacements: @v=firmware version, @f=device friendly
name, @h=device hostname
-F, <span class="hljs-comment">--backup-type json|bin|dmp</span>
backup filetype (<span class="hljs-keyword">default</span>: <span class="hljs-symbol">'json</span>')
-E, <span class="hljs-comment">--extension append filetype extension for -i and -o filename</span>
(<span class="hljs-keyword">default</span>)
-e, <span class="hljs-comment">--no-extension do not append filetype extension, use -i and -o</span>
filename as passed
JSON:
JSON backup format specification
<span class="hljs-comment">--json-indent &lt;indent&gt;</span>
pretty-printed JSON output using indent level
(<span class="hljs-keyword">default</span>: <span class="hljs-symbol">'None</span>'). -<span class="hljs-number">1</span> disables indent.
<span class="hljs-comment">--json-compact compact JSON output by eliminate whitespace</span>
<span class="hljs-comment">--json-hide-pw hide passwords (default)</span>
<span class="hljs-comment">--json-unhide-pw unhide passwords</span>
Info:
additional information
-h, <span class="hljs-comment">--help show usage help message and exit</span> -h, <span class="hljs-comment">--help show usage help message and exit</span>
-H, <span class="hljs-comment">--full-help show full help message and exit</span> -<span class="hljs-type">H</span>, <span class="hljs-comment">--full-help show full help message and exit</span>
-v, <span class="hljs-comment">--verbose produce more output about what the program does</span> -v, <span class="hljs-comment">--verbose produce more output about what the program does</span>
-V, <span class="hljs-comment">--version show program's version number and exit</span> -<span class="hljs-type">V</span>, <span class="hljs-comment">--version show program's version number and exit</span>
Either argument -d &lt;host&gt; <span class="hljs-keyword">or</span> -f &lt;filename&gt; must be given. <span class="hljs-type">Either</span> argument -d &lt;host&gt; or -f &lt;filename&gt; must be given.
</code></pre><h3 id="examples">Examples</h3> </code></pre><h3 id="program-parameter-notes">Program parameter notes</h3>
<p><em>decode-config.py</em></p>
<h3 id="examples">Examples</h3>
<p>The most of the examples are for linux command line. Under Windows call the program using <code>python decode-config.py ...</code>.</p> <p>The most of the examples are for linux command line. Under Windows call the program using <code>python decode-config.py ...</code>.</p>
<h4 id="config-file">Config file</h4> <h4 id="config-file">Config file</h4>
<p>Note: The example contains .ini style sections <code>[...]</code>. Sections are always treated as comment and serves as clarity only. <p>Note: The example contains .ini style sections <code>[...]</code>. Sections are always treated as comment and serves as clarity only.
@ -228,3 +344,12 @@ json-indent <span class="hljs-number">2</span>
</code></pre><p>or under windows</p> </code></pre><p>or under windows</p>
<pre><code><span class="hljs-keyword">for</span> device <span class="hljs-keyword">in</span> (sonoff1 sonoff2 sonoff3) <span class="hljs-keyword">do</span> <span class="hljs-keyword">python</span> decode-config.py -c my.conf -d %device -o Config_@f_@v <pre><code><span class="hljs-keyword">for</span> device <span class="hljs-keyword">in</span> (sonoff1 sonoff2 sonoff3) <span class="hljs-keyword">do</span> <span class="hljs-keyword">python</span> decode-config.py -c my.conf -d %device -o Config_@f_@v
</code></pre><p>will produce JSON configuration files for host sonoff1, sonoff2 and sonoff3 using friendly name and Tasmota firmware version for backup filenames.</p> </code></pre><p>will produce JSON configuration files for host sonoff1, sonoff2 and sonoff3 using friendly name and Tasmota firmware version for backup filenames.</p>
<h2 id="notes">Notes</h2>
<p>Some general notes:</p>
<ul>
<li>Filename replacement macros <strong>@h</strong> and <strong>@H</strong>:<ul>
<li><strong>@h</strong><br>The <strong>@h</strong> replacement macro uses the hostname configured with the Tasomta Wifi <code>Hostname &lt;host&gt;</code> command (defaults to <code>%s-%04d</code>). It will not use the network hostname of your device because this is not available when working with files only (e.g. <code>--file &lt;filename&gt;</code> as source).<br>To prevent having a useless % in your filename, <strong>@h</strong> will not replaced by configuration data hostname if this contains &#39;%&#39; characters.</li>
<li><strong>@H</strong><br>If you want to use the network hostname within your filename, use the <strong>@H</strong> replacement macro instead - but be aware this will only replaced if you are using a network device as source (<code>-d</code>, <code>--device</code>, <code>--host</code>); it will not work when using a file as source (<code>-f</code>, <code>--file</code>)</li>
</ul>
</li>
</ul>

View File

@ -1,5 +1,10 @@
# decode-config.py # decode-config.py
_decode-config.py_ backup and restore Sonoff-Tasmota configuration. _decode-config.py_ is able to backup and restore Sonoff-Tasmota configuration.
In contrast to the Tasmota build-in "Backup/Restore Configuration" function,
* _decode-config.py_ uses human readable and editable [JSON](http://www.json.org/)-format for backup/restore,
* _decode-config.py_ can restore previous backuped and changed [JSON](http://www.json.org/)-format files,
* _decode-config.py_ is able to create Tasmota commands based on given configuration
Comparing backup files created by *decode-config.py* and *.dmp files created by Tasmota "Backup/Restore Configuration": Comparing backup files created by *decode-config.py* and *.dmp files created by Tasmota "Backup/Restore Configuration":
@ -10,32 +15,38 @@ Comparing backup files created by *decode-config.py* and *.dmp files created by
| Simply editable | Yes | No | | Simply editable | Yes | No |
| Simply batch processing | Yes | No | | Simply batch processing | Yes | No |
_decode-config.py_ handles Tasmota configurations for release version since 5.10.0 up to now. _decode-config.py_ is able to handle Tasmota configurations for release version starting from 5.10.0 up to now.
# Content # Content
* [Prerequisite](decode-config.md#prerequisite) * [Prerequisite](decode-config.md#prerequisite)
* [File Types](decode-config.md#file-types) * [File Types](decode-config.md#file-types)
* [.dmp File Format](decode-config.md#-dmp-file-format) * [.dmp File Format](decode-config.md#-dmp-format)
* [.json File Format](decode-config.md#-json-file-format) * [.json File Format](decode-config.md#-json-format)
* [.bin File Format](decode-config.md#-bin-file-format) * [.bin File Format](decode-config.md#-bin-format)
* [File extensions](decode-config.md#file-extensions) * [File extensions](decode-config.md#file-extensions)
* [Usage](decode-config.md#usage) * [Usage](decode-config.md#usage)
* [Basics](decode-config.md#basics) * [Basics](decode-config.md#basics)
* [Save backup file](decode-config.md#save-backup-file) * [Save backup file](decode-config.md#save-backup-file)
* [Restore backup file](decode-config.md#restore-backup-file) * [Restore backup file](decode-config.md#restore-backup-file)
* [Output to screen](decode-config.md#output-to-screen)
* [JSON output](decode-config.md#json-output)
* [Tasmota command output](decode-config.md#tasmota-command-output)
* [Filter data](decode-config.md#filter-data)
* [Configuration file](decode-config.md#configuration-file) * [Configuration file](decode-config.md#configuration-file)
* [More program arguments](decode-config.md#more-program-arguments) * [More program arguments](decode-config.md#more-program-arguments)
* [Examples](decode-config.md#examples) * [Examples](decode-config.md#examples)
* [Config file](decode-config.md#config-file) * [Config file](decode-config.md#config-file)
* [Using Tasmota binary configuration files](decode-config.md#using-tasmota-binary-configuration-files) * [Using Tasmota binary configuration files](decode-config.md#using-tasmota-binary-configuration-files)
* [Use batch processing](decode-config.md#use-batch-processing) * [Use batch processing](decode-config.md#use-batch-processing)
* [Notes](decode-config.md#notes)
## Prerequisite ## Prerequisite
* [Python](https://en.wikipedia.org/wiki/Python_(programming_language)) * [Python](https://en.wikipedia.org/wiki/Python_(programming_language))
This program is written in [Python](https://en.wikipedia.org/wiki/Python_(programming_language)) so you need to install a python environment (for details see [Python Setup and Usage](https://docs.python.org/2.7/using/index.html)) This program is written in [Python](https://en.wikipedia.org/wiki/Python_(programming_language)) so you need to install a python environment (for details see [Python Setup and Usage](https://docs.python.org/2.7/using/index.html))
* [Sonoff-Tasmota](https://github.com/arendst/Sonoff-Tasmota) [Firmware](https://github.com/arendst/Sonoff-Tasmota/releases) with enabled Web-Server
To backup or restore configurations from/to a Sonoff-Tasmota device you need a firmare with enabled web-server in admin mode (command [WebServer 2](https://github.com/arendst/Sonoff-Tasmota/wiki/Commands#wifi)). * [Sonoff-Tasmota](https://github.com/arendst/Sonoff-Tasmota) [Firmware](https://github.com/arendst/Sonoff-Tasmota/releases) with Web-Server enabled:
<br />Only self compiled firmware may do not have a web-server sod if you use your own compiled firmware be aware to enable the web-server, otherwise you can only use the `--file` parameter as source. * To backup or restore configurations from/to a Sonoff-Tasmota device you need a firmare with enabled web-server in admin mode (command [WebServer 2](https://github.com/arendst/Sonoff-Tasmota/wiki/Commands#wifi)).
* If using your own compiled firmware be aware to enable the web-server (`#define USE_WEBSERVER` and `#define WEB_SERVER 2`).
## File Types ## File Types
_decode-config.py_ can handle the following backup file types: _decode-config.py_ can handle the following backup file types:
@ -65,7 +76,7 @@ At least pass a source where you want to read the configuration data from using
The source can be either The source can be either
* a Tasmota device hostname or IP by passing it using the `-d <host>` arg * a Tasmota device hostname or IP by passing it using the `-d <host>` arg
* or a previously stored Tasmota *.dmp` configuration file by passing the filename using `-f <filename>` arg * or a previously stored Tasmota `*.dmp` configuration file by passing the filename using `-f <filename>` arg
Example: Example:
@ -109,6 +120,89 @@ with password set by WebPassword:
decode-config.py -d sonoff-4281 -p <yourpassword> --restore-file Config_Sonoff_6.2.1.json decode-config.py -d sonoff-4281 -p <yourpassword> --restore-file Config_Sonoff_6.2.1.json
### Output to screen
Output to screen is default enabled when calling the program with a source arg but without a backup or restore arg.
`--output` arg will force screen output even if you use backup or restore arg.
#### JSON output
The default output format is JSON. You can force JSON output with `--output-format json` arg.
Example:
decode-config.py -d sonoff-4281 -c my.conf -x Wifi --output-format json
{
...
"hostname": "%s-%04d",
"ip_address": [
"0.0.0.0",
"192.168.12.1",
"255.255.255.0",
"192.168.12.1"
],
"ntp_server": [
"ntp.localnet.home",
"ntp2.localnet.home",
"192.168.12.1"
],
"sta_active": 0,
"sta_config": 5,
"sta_pwd": [
"myWlAnPaszxwo!z",
"myWlAnPaszxwo!z2"
],
"sta_ssid": [
"wlan.1",
"my-wlan"
],
"web_password": "myPaszxwo!z",
"webserver": 2
...
}
Note: JSON output always contains all configuration data like the backup file except you are using `--group` arg.
#### Tasmota command output
_decode-config.py_ is able to translate the configuration data to (most all) Tasmota commands. To output your configuration as Tasmota commands use `--output-format cmnd` or `--output-format command`.
Example:
decode-config.py -d sonoff-4281 -c my.conf -g Wifi --output-format cmnd
# Wifi:
AP 0
Hostname %s-%04d
IPAddress1 0.0.0.0
IPAddress2 192.168.12.1
IPAddress3 255.255.255.0
IPAddress4 192.168.12.1
NtpServer1 ntp.localnet.home
NtpServer2 ntp2.localnet.home
NtpServer3 192.168.12.1
Password1 myWlAnPaszxwo!z
Password2 myWlAnPaszxwo!z2
SSId1 wlan.1
SSId2 wlan.1
WebPassword myPaszxwo!z
WebServer 2
WifiConfig 5
Note: A few very specific module commands like MPC230xx, KNX and some Display commands are not supported. These are still available by JSON output.
### Filter data
The huge number of Tasmota configuration data can be overstrained and confusing, so the most of the configuration data are grouped into categories.
With _decode-config.py_ the following categories are available: `Display`, `Domoticz`, `Internal`, `KNX`, `Led`, `Logging`, `MCP230xx`, `MQTT`, `Main`, `Management`, `Pow`, `Sensor`, `Serial`, `SetOption`, `SonoffRF`, `System`, `Timers`, `Wifi`
These are similary to the categories on [https://github.com/arendst/Sonoff-Tasmota/wiki/Commands](Tasmota Command Wiki).
To filter outputs to a subset of groups use the `-g` or `--group` arg concatenating the grooup you want, e. g.
decode-config.py -d sonoff-4281 -c my.conf --output-format cmnd --group Main MQTT Management Wifi
### Configuration file ### Configuration file
Each argument that start with `--` (eg. `--file`) can also be set in a config file (specified via -c). Config file syntax allows: key=value, flag=true, stuff=[a,b,c] (for details, see syntax at [https://pypi.org/project/ConfigArgParse](https://pypi.org/project/ConfigArgParse/)). Each argument that start with `--` (eg. `--file`) can also be set in a config file (specified via -c). Config file syntax allows: key=value, flag=true, stuff=[a,b,c] (for details, see syntax at [https://pypi.org/project/ConfigArgParse](https://pypi.org/project/ConfigArgParse/)).
@ -129,7 +223,7 @@ To make a backup file from example above you can now pass the config file instea
### More program arguments ### More program arguments
For better reading your porgram arguments each short written arg (minus sign `-`) has a corresponding readable long version (two minus signs `--`), eg. `--device` for `-d` or `--file` for `-f` (note: not even all `--` arg has a corresponding `-` one). For better reading each short written arg (minus sign `-`) has a corresponding long version (two minus signs `--`), eg. `--device` for `-d` or `--file` for `-f` (note: not even all `--` arg has a corresponding `-` one).
A short list of possible program args is displayed using `-h` or `--help`. A short list of possible program args is displayed using `-h` or `--help`.
@ -137,10 +231,14 @@ For advanced help use `-H` or `--full-help`:
usage: decode-config.py [-f <filename>] [-d <host>] [-P <port>] usage: decode-config.py [-f <filename>] [-d <host>] [-P <port>]
[-u <username>] [-p <password>] [-i <filename>] [-u <username>] [-p <password>] [-i <filename>]
[-o <filename>] [-F json|bin|dmp] [-E] [-e] [-o <filename>] [-t json|bin|dmp] [-E] [-e] [-F]
[--json-indent <indent>] [--json-compact] [--json-indent <indent>] [--json-compact]
[--json-hide-pw] [--json-unhide-pw] [-h] [-H] [-v] [--json-hide-pw] [--json-show-pw]
[-V] [-c <filename>] [--ignore-warnings] [--cmnd-indent <indent>] [--cmnd-groups]
[--cmnd-nogroups] [--cmnd-sort] [--cmnd-unsort]
[-c <filename>] [-S] [-T json|cmnd|command]
[-g {Display,Domoticz,Internal,KNX,Led,Logging,MCP230xx,MQTT,Main,Management,Pow,Sensor,Serial,SetOption,SonoffRF,System,Timers,Wifi} [{Display,Domoticz,Internal,KNX,Led,Logging,MCP230xx,MQTT,Main,Management,Pow,Sensor,Serial,SetOption,SonoffRF,System,Timers,Wifi} ...]]
[--ignore-warnings] [-h] [-H] [-v] [-V]
Backup/Restore Sonoff-Tasmota configuration data. Args that start with '--' Backup/Restore Sonoff-Tasmota configuration data. Args that start with '--'
(eg. -f) can also be set in a config file (specified via -c). Config file (eg. -f) can also be set in a config file (specified via -c). Config file
@ -148,13 +246,6 @@ For advanced help use `-H` or `--full-help`:
https://goo.gl/R74nmi). If an arg is specified in more than one place, then https://goo.gl/R74nmi). If an arg is specified in more than one place, then
commandline values override config file values which override defaults. commandline values override config file values which override defaults.
optional arguments:
-c, --config <filename>
program config file - can be used to set default
command args (default: None)
--ignore-warnings do not exit on warnings. Not recommended, used by your
own responsibility!
Source: Source:
Read/Write Tasmota configuration from/to Read/Write Tasmota configuration from/to
@ -172,35 +263,68 @@ For advanced help use `-H` or `--full-help`:
host HTTP access password (default: None) host HTTP access password (default: None)
Backup/Restore: Backup/Restore:
Backup/Restore configuration file specification Backup & restore specification
-i, --restore-file <filename> -i, --restore-file <filename>
file to restore configuration from (default: None). file to restore configuration from (default: None).
Replacements: @v=firmware version, @f=device friendly Replacements: @v=firmware version from config,
name, @h=device hostname @f=device friendly name from config, @h=device
hostname from config, @H=device hostname from device
(-d arg only)
-o, --backup-file <filename> -o, --backup-file <filename>
file to backup configuration to (default: None). file to backup configuration to (default: None).
Replacements: @v=firmware version, @f=device friendly Replacements: @v=firmware version from config,
name, @h=device hostname @f=device friendly name from config, @h=device
-F, --backup-type json|bin|dmp hostname from config, @H=device hostname from device
(-d arg only)
-t, --backup-type json|bin|dmp
backup filetype (default: 'json') backup filetype (default: 'json')
-E, --extension append filetype extension for -i and -o filename -E, --extension append filetype extension for -i and -o filename
(default) (default)
-e, --no-extension do not append filetype extension, use -i and -o -e, --no-extension do not append filetype extension, use -i and -o
filename as passed filename as passed
-F, --force-restore force restore even configuration is identical
JSON: JSON output:
JSON backup format specification JSON format specification
--json-indent <indent> --json-indent <indent>
pretty-printed JSON output using indent level pretty-printed JSON output using indent level
(default: 'None'). -1 disables indent. (default: 'None'). -1 disables indent.
--json-compact compact JSON output by eliminate whitespace --json-compact compact JSON output by eliminate whitespace
--json-hide-pw hide passwords (default) --json-hide-pw hide passwords
--json-unhide-pw unhide passwords --json-show-pw, --json-unhide-pw
unhide passwords (default)
Tasmota command output:
Tasmota command output format specification
--cmnd-indent <indent>
Tasmota command grouping indent level (default: '2').
0 disables indent
--cmnd-groups group Tasmota commands (default)
--cmnd-nogroups leave Tasmota commands ungrouped
--cmnd-sort sort Tasmota commands (default)
--cmnd-unsort leave Tasmota commands unsorted
Common:
Optional arguments
-c, --config <filename>
program config file - can be used to set default
command args (default: None)
-S, --output display output regardsless of backup/restore usage
(default do not output on backup or restore usage)
-T, --output-format json|cmnd|command
display output format (default: 'json')
-g, --group {Display,Domoticz,Internal,KNX,Led,Logging,MCP230xx,MQTT,Main,Management,Pow,Sensor,Serial,SetOption,SonoffRF,System,Timers,Wifi}
limit data processing to command groups (default no
filter)
--ignore-warnings do not exit on warnings. Not recommended, used by your
own responsibility!
Info: Info:
additional information Extra information
-h, --help show usage help message and exit -h, --help show usage help message and exit
-H, --full-help show full help message and exit -H, --full-help show full help message and exit
@ -209,6 +333,10 @@ For advanced help use `-H` or `--full-help`:
Either argument -d <host> or -f <filename> must be given. Either argument -d <host> or -f <filename> must be given.
### Program parameter notes
_decode-config.py_
### Examples ### Examples
The most of the examples are for linux command line. Under Windows call the program using `python decode-config.py ...`. The most of the examples are for linux command line. Under Windows call the program using `python decode-config.py ...`.
@ -251,3 +379,12 @@ or under windows
for device in (sonoff1 sonoff2 sonoff3) do python decode-config.py -c my.conf -d %device -o Config_@f_@v for device in (sonoff1 sonoff2 sonoff3) do python decode-config.py -c my.conf -d %device -o Config_@f_@v
will produce JSON configuration files for host sonoff1, sonoff2 and sonoff3 using friendly name and Tasmota firmware version for backup filenames. will produce JSON configuration files for host sonoff1, sonoff2 and sonoff3 using friendly name and Tasmota firmware version for backup filenames.
## Notes
Some general notes:
* Filename replacement macros **@h** and **@H**:
* **@h**
The **@h** replacement macro uses the hostname configured with the Tasomta Wifi `Hostname <host>` command (defaults to `%s-%04d`). It will not use the network hostname of your device because this is not available when working with files only (e.g. `--file <filename>` as source).
To prevent having a useless % in your filename, **@h** will not replaced by configuration data hostname if this contains '%' characters.
* **@H**
If you want to use the network hostname within your filename, use the **@H** replacement macro instead - but be aware this will only replaced if you are using a network device as source (`-d`, `--device`, `--host`); it will not work when using a file as source (`-f`, `--file`)

File diff suppressed because it is too large Load Diff