From f2a89605af0179b51ee23458ec6da5fb0725608c Mon Sep 17 00:00:00 2001 From: to-scho Date: Thu, 2 Jan 2020 12:37:07 +0100 Subject: [PATCH] Add response to ShutterCalibration command When ShutterCalibration is called without any arguments no response was given before that allows to read out setting like for other commands. Workaround was to call ShutterRelay . --- tasmota/xdrv_27_shutter.ino | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tasmota/xdrv_27_shutter.ino b/tasmota/xdrv_27_shutter.ino index 457d2870f..bc2e3066d 100644 --- a/tasmota/xdrv_27_shutter.ino +++ b/tasmota/xdrv_27_shutter.ino @@ -731,20 +731,24 @@ void CmndShutterCalibration(void) // ???? // Loop through the version string, splitting on '.' seperators. for (char *str = strtok_r(version_dup, " ", &str_ptr); str && i < 5; str = strtok_r(nullptr, " ", &str_ptr), i++) { int field = atoi(str); - // The fields in a version string can only range from 1-255. + // The fields in a version string can only range from 1-30000. // and following value must be higher than previous one - if ((field <= 0) || (field > 255) || ( (i>0) && (field <= messwerte[i-1]) ) ) { - free(version_dup); + if ((field <= 0) || (field > 30000) || ( (i>0) && (field <= messwerte[i-1]) ) ) { break; } messwerte[i] = field; } + free(version_dup); for (i=0 ; i < 5 ; i++) { - Settings.shuttercoeff[i][XdrvMailbox.index -1] = messwerte[i] * 1000 / messwerte[4]; + Settings.shuttercoeff[i][XdrvMailbox.index -1] = (uint32_t)messwerte[i] * 1000 / messwerte[4]; AddLog_P2(LOG_LEVEL_INFO, PSTR("Settings.shuttercoeff: %d, i: %d, value: %d, messwert %d"), i,XdrvMailbox.index -1,Settings.shuttercoeff[i][XdrvMailbox.index -1], messwerte[i]); } ShutterInit(); ResponseCmndIdxChar(XdrvMailbox.data); + } else { + char setting_chr[30] = "0"; + snprintf_P(setting_chr, sizeof(setting_chr), PSTR("%d %d %d %d %d"), Settings.shuttercoeff[0][XdrvMailbox.index -1], Settings.shuttercoeff[1][XdrvMailbox.index -1], Settings.shuttercoeff[2][XdrvMailbox.index -1], Settings.shuttercoeff[3][XdrvMailbox.index -1], Settings.shuttercoeff[4][XdrvMailbox.index -1]); + ResponseCmndIdxChar(setting_chr); } } }