Fix empty friendlyname (#2420)

This commit is contained in:
Theo Arends 2018-04-11 17:56:18 +02:00
parent 18074dbce3
commit 208f64fd8f

View File

@ -558,7 +558,7 @@ void MqttDataHandler(char* topic, byte* data, unsigned int data_len)
XsnsCall(FUNC_COMMAND);
// if (!XsnsCall(FUNC_COMMAND)) type = NULL;
}
else if ((CMND_SETOPTION == command_code) && ((index <= 23) || ((index > 31) && (index <= P_MAX_PARAM8 + 31)))) {
else if ((CMND_SETOPTION == command_code) && ((index <= 21) || ((index > 31) && (index <= P_MAX_PARAM8 + 31)))) {
if (index <= 31) {
ptype = 0; // SetOption0 .. 31
} else {
@ -588,7 +588,8 @@ void MqttDataHandler(char* topic, byte* data, unsigned int data_len)
case 19: // hass_discovery
case 20: // not_power_linked
case 21: // no_power_on_check
case 23: // rules_enabled
// case 22: // mqtt_serial - use commands SerialSend and SerialLog
// case 23: // rules_enabled - use command Rule
bitWrite(Settings.flag.data, index, payload);
}
if (12 == index) { // stop_flash_rotate
@ -1258,7 +1259,7 @@ void PublishStatus(uint8_t payload)
if (!energy_flg && (9 == payload)) payload = 99;
if ((0 == payload) || (99 == payload)) {
uint8_t maxfn = (devices_present > MAX_FRIENDLYNAMES) ? MAX_FRIENDLYNAMES : devices_present;
uint8_t maxfn = (devices_present > MAX_FRIENDLYNAMES) ? MAX_FRIENDLYNAMES : (!devices_present) ? 1 : devices_present;
stemp[0] = '\0';
for (byte i = 0; i < maxfn; i++) {
snprintf_P(stemp, sizeof(stemp), PSTR("%s%s\"%s\"" ), stemp, (i > 0 ? "," : ""), Settings.friendlyname[i]);