rest interface for pins now also shows pin states, i will need it for pin doctor

This commit is contained in:
openshwprojects
2023-05-05 12:08:18 +02:00
parent 2365c9c321
commit 604aa0ff76

View File

@ -645,32 +645,33 @@ static int http_rest_get_pins(http_request_t* request) {
poststr(request, "{\"rolenames\":[");
for (i = 0; i < IOR_Total_Options; i++) {
if (i) {
hprintf255(request, ",\"%s\"", htmlPinRoleNames[i]);
}
else {
hprintf255(request, "\"%s\"", htmlPinRoleNames[i]);
hprintf255(request, ",");
}
hprintf255(request, "\"%s\"", htmlPinRoleNames[i]);
}
poststr(request, "],\"roles\":[");
for (i = 0; i < PLATFORM_GPIO_MAX; i++) {
if (i) {
hprintf255(request, ",%d", g_cfg.pins.roles[i]);
}
else {
hprintf255(request, "%d", g_cfg.pins.roles[i]);
hprintf255(request, ",");
}
hprintf255(request, "%d", g_cfg.pins.roles[i]);
}
// TODO: maybe we should cull futher channels that are not used?
// I support many channels because I plan to use 16x relays module with I2C MCP23017 driver
poststr(request, "],\"channels\":[");
for (i = 0; i < CHANNEL_MAX; i++) {
if (i) {
hprintf255(request, ",%d", g_cfg.pins.channels[i]);
hprintf255(request, ",");
}
else {
hprintf255(request, "%d", g_cfg.pins.channels[i]);
hprintf255(request, "%d", g_cfg.pins.channels[i]);
}
poststr(request, "],\"states\":[");
for (i = 0; i < CHANNEL_MAX; i++) {
if (i) {
hprintf255(request, ",");
}
hprintf255(request, "%d", CHANNEL_Get(g_cfg.pins.channels[i]));
}
poststr(request, "]}");
poststr(request, NULL);