From 761281e55c5d91f75dca742ffc10e87316884e45 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Wed, 16 Dec 2020 12:34:43 +0100 Subject: [PATCH] Fix ESP32 command ``gpio 255`` output Fix ESP32 command ``gpio 255`` output --- tasmota/support_command.ino | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/tasmota/support_command.ino b/tasmota/support_command.ino index 6d127e0bb..099d4f468 100644 --- a/tasmota/support_command.ino +++ b/tasmota/support_command.ino @@ -1154,11 +1154,15 @@ void CmndGpio(void) TasmotaGlobal.restart_flag = 2; } } - Response_P(PSTR("{")); bool jsflg = false; + bool jsflg2 = false; for (uint32_t i = 0; i < ARRAY_SIZE(Settings.my_gp.io); i++) { if (ValidGPIO(i, template_gp.io[i]) || ((255 == XdrvMailbox.payload) && !FlashPin(i))) { - if (jsflg) { ResponseAppend_P(PSTR(",")); } + if (!jsflg) { + Response_P(PSTR("{")); + } else { + ResponseAppend_P(PSTR(",")); + } jsflg = true; uint32_t sensor_type = Settings.my_gp.io[i]; if (!ValidGPIO(i, template_gp.io[i])) { @@ -1183,12 +1187,16 @@ void CmndGpio(void) sensor_names = kSensorNamesFixed; } char stemp1[TOPSZ]; - ResponseAppend_P(PSTR("\"" D_CMND_GPIO "%d\":{\"%d\":\"%s%s\"}"), - i, sensor_type, GetTextIndexed(stemp1, sizeof(stemp1), sensor_name_idx, sensor_names), sindex); + if ((ResponseAppend_P(PSTR("\"" D_CMND_GPIO "%d\":{\"%d\":\"%s%s\"}"), i, sensor_type, GetTextIndexed(stemp1, sizeof(stemp1), sensor_name_idx, sensor_names), sindex) > (LOGSZ - TOPSZ)) || (i == ARRAY_SIZE(Settings.my_gp.io) -1)) { + ResponseJsonEndEnd(); + MqttPublishPrefixTopic_P(RESULT_OR_STAT, XdrvMailbox.command); + jsflg2 = true; + jsflg = false; + } } } - if (jsflg) { - ResponseJsonEnd(); + if (jsflg2) { + ResponseClear(); } else { ResponseCmndChar(D_JSON_NOT_SUPPORTED); }