mirror of
https://github.com/openshwprojects/OpenBK7231T_App.git
synced 2026-02-09 05:55:44 +00:00
add channels 2 to json
This commit is contained in:
@ -658,6 +658,7 @@ static int http_rest_get_seriallog(http_request_t* request) {
|
||||
|
||||
static int http_rest_get_pins(http_request_t* request) {
|
||||
int i;
|
||||
int maxNonZero;
|
||||
http_setup(request, httpMimeTypeJson);
|
||||
poststr(request, "{\"rolenames\":[");
|
||||
for (i = 0; i < IOR_Total_Options; i++) {
|
||||
@ -676,6 +677,15 @@ static int http_rest_get_pins(http_request_t* request) {
|
||||
}
|
||||
// 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
|
||||
|
||||
// find max non-zero ch
|
||||
//maxNonZero = -1;
|
||||
//for (i = 0; i < PLATFORM_GPIO_MAX; i++) {
|
||||
// if (g_cfg.pins.channels[i] != 0) {
|
||||
// maxNonZero = i;
|
||||
// }
|
||||
//}
|
||||
|
||||
poststr(request, "],\"channels\":[");
|
||||
for (i = 0; i < PLATFORM_GPIO_MAX; i++) {
|
||||
if (i) {
|
||||
@ -683,6 +693,22 @@ static int http_rest_get_pins(http_request_t* request) {
|
||||
}
|
||||
hprintf255(request, "%d", g_cfg.pins.channels[i]);
|
||||
}
|
||||
// find max non-zero ch2
|
||||
maxNonZero = -1;
|
||||
for (i = 0; i < PLATFORM_GPIO_MAX; i++) {
|
||||
if (g_cfg.pins.channels2[i] != 0) {
|
||||
maxNonZero = i;
|
||||
}
|
||||
}
|
||||
if (maxNonZero != -1) {
|
||||
poststr(request, "],\"channels2\":[");
|
||||
for (i = 0; i <= maxNonZero; i++) {
|
||||
if (i) {
|
||||
hprintf255(request, ",");
|
||||
}
|
||||
hprintf255(request, "%d", g_cfg.pins.channels2[i]);
|
||||
}
|
||||
}
|
||||
poststr(request, "],\"states\":[");
|
||||
for (i = 0; i < PLATFORM_GPIO_MAX; i++) {
|
||||
if (i) {
|
||||
|
||||
Reference in New Issue
Block a user