Update status 13

This commit is contained in:
Theo Arends 2020-08-20 17:58:58 +02:00
parent 7691abea41
commit 474fb2518a
2 changed files with 28 additions and 24 deletions

View File

@ -117,16 +117,17 @@ String GetResetReason(void)
* Miscellaneous * Miscellaneous
\*********************************************************************************************/ \*********************************************************************************************/
#define BYTE_TO_BINARY_PATTERN "%c%c%c%c%c%c%c%c" String GetBinary(const void* ptr, size_t count) {
#define BYTE_TO_BINARY(byte) \ uint32_t value = *(uint32_t*)ptr;
(byte & 0x80 ? '1' : '0'), \ value <<= (32 - count);
(byte & 0x40 ? '1' : '0'), \ String result;
(byte & 0x20 ? '1' : '0'), \ result.reserve(count + 1);
(byte & 0x10 ? '1' : '0'), \ for (uint32_t i = 0; i < count; i++) {
(byte & 0x08 ? '1' : '0'), \ result += (value &0x80000000) ? '1' : '0';
(byte & 0x04 ? '1' : '0'), \ value <<= 1;
(byte & 0x02 ? '1' : '0'), \ }
(byte & 0x01 ? '1' : '0') return result;
}
// Get span until single character in string // Get span until single character in string
size_t strchrspn(const char *str1, int character) size_t strchrspn(const char *str1, int character)

View File

@ -573,24 +573,27 @@ void CmndStatus(void)
MqttPublishPrefixTopic_P(option, PSTR(D_CMND_STATUS "12")); MqttPublishPrefixTopic_P(option, PSTR(D_CMND_STATUS "12"));
} }
} }
#ifdef USE_SHUTTER #ifdef USE_SHUTTER
if ((0 == payload) || (13 == payload)) { if (Settings.flag3.shutter_mode) {
Response_P(PSTR("{\"" D_CMND_STATUS D_STATUS13_SHUTTER "\":")); if ((0 == payload) || (13 == payload)) {
for (uint8_t i=0; i < MAX_SHUTTERS; i++) Response_P(PSTR("{\"" D_CMND_STATUS D_STATUS13_SHUTTER "\":"));
{ for (uint32_t i = 0; i < MAX_SHUTTERS; i++) {
if (Settings.shutter_startrelay[i]==0) break; if (0 == Settings.shutter_startrelay[i]) { break; }
if (i>0) ResponseAppend_P(PSTR(",")); if (i > 0) { ResponseAppend_P(PSTR(",")); }
ResponseAppend_P(PSTR("{\"" D_STATUS13_SHUTTER "%d\":{\"Relay1\":%d,\"Relay2\":%d,\"Open\":%d,\"Close\":%d,\"50perc\":%d,\"delay\":%d,\"opt\":"BYTE_TO_BINARY_PATTERN",\"calib\":\"%d:%d:%d:%d:%d\"}"), i, ResponseAppend_P(PSTR("{\"" D_STATUS13_SHUTTER "%d\":{\"Relay1\":%d,\"Relay2\":%d,\"Open\":%d,\"Close\":%d,"
Settings.shutter_startrelay[i],Settings.shutter_startrelay[i]+1,Settings.shutter_opentime[i], Settings.shutter_closetime[i], "\"50perc\":%d,\"Delay\":%d,\"Opt\":\"%s\","
Settings.shutter_set50percent[i],Settings.shutter_motordelay[i],BYTE_TO_BINARY(Settings.shutter_options[i]), "\"Calib\":\"%d:%d:%d:%d:%d\"}"),
Settings.shuttercoeff[0][i], Settings.shuttercoeff[1][i], Settings.shuttercoeff[2][i], Settings.shuttercoeff[3][i], Settings.shuttercoeff[4][i]); i, Settings.shutter_startrelay[i], Settings.shutter_startrelay[i] +1, Settings.shutter_opentime[i], Settings.shutter_closetime[i],
Settings.shutter_set50percent[i], Settings.shutter_motordelay[i], GetBinary(&Settings.shutter_options[i], 4).c_str(),
Settings.shuttercoeff[0][i], Settings.shuttercoeff[1][i], Settings.shuttercoeff[2][i], Settings.shuttercoeff[3][i], Settings.shuttercoeff[4][i]);
}
ResponseJsonEnd();
MqttPublishPrefixTopic_P(option, PSTR(D_CMND_STATUS "13"));
} }
ResponseJsonEnd();
MqttPublishPrefixTopic_P(option, PSTR(D_CMND_STATUS "12"));
} }
#endif #endif
#ifdef USE_SCRIPT_STATUS #ifdef USE_SCRIPT_STATUS
if (bitRead(Settings.rule_enabled, 0)) Run_Scripter(">U",2,mqtt_data); if (bitRead(Settings.rule_enabled, 0)) Run_Scripter(">U",2,mqtt_data);
#endif #endif