Merge pull request #4653 from chaosmaster/patch-2

webserver: swap index and name in module configuration
This commit is contained in:
Theo Arends 2018-12-17 16:44:44 +01:00 committed by GitHub
commit a76ae557f0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 3 deletions

View File

@ -165,7 +165,7 @@ 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'>%s (%02d)}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(){"
@ -798,14 +798,14 @@ void HandleModuleConfiguration(void)
for (byte i = 0; i < MAXMODULE; i++) { for (byte i = 0; i < MAXMODULE; i++) {
midx = pgm_read_byte(kModuleNiceList + i); midx = pgm_read_byte(kModuleNiceList + i);
snprintf_P(stemp, sizeof(stemp), kModules[midx].name); snprintf_P(stemp, sizeof(stemp), kModules[midx].name);
snprintf_P(mqtt_data, sizeof(mqtt_data), HTTP_SCRIPT_MODULE3, midx, midx +1, stemp); snprintf_P(mqtt_data, sizeof(mqtt_data), HTTP_SCRIPT_MODULE3, midx, stemp, midx +1);
page += mqtt_data; page += mqtt_data;
} }
page += "}3"; // String separator means do not use "}3" in Module name and Sensor name page += "}3"; // String separator means do not use "}3" in Module name and Sensor name
for (byte j = 0; j < sizeof(kGpioNiceList); j++) { for (byte j = 0; j < sizeof(kGpioNiceList); j++) {
midx = pgm_read_byte(kGpioNiceList + j); midx = pgm_read_byte(kGpioNiceList + j);
if (!GetUsedInModule(midx, cmodule.gp.io)) { if (!GetUsedInModule(midx, cmodule.gp.io)) {
snprintf_P(mqtt_data, sizeof(mqtt_data), HTTP_SCRIPT_MODULE3, midx, midx, GetTextIndexed(stemp, sizeof(stemp), midx, kSensorNames)); snprintf_P(mqtt_data, sizeof(mqtt_data), HTTP_SCRIPT_MODULE3, midx, GetTextIndexed(stemp, sizeof(stemp), midx, kSensorNames), midx);
page += mqtt_data; page += mqtt_data;
} }
} }