diff --git a/gui/app.js b/gui/app.js index 2d9da03..604efe6 100644 --- a/gui/app.js +++ b/gui/app.js @@ -97,7 +97,7 @@ function refresh_ports() { const ports_array = response; // Проверка длины массива - if (ports_array.length > 0) { + if (ports_array.ports.length > 0) { port_selector.innerHTML = ''; } else { alert('Отсутсвуют подключённые устройства!'); diff --git a/src/config.h b/src/config.h new file mode 100644 index 0000000..f2da001 --- /dev/null +++ b/src/config.h @@ -0,0 +1,11 @@ +/* + * AUTHOR: Alexander Popov + * DESC: ... + */ + +#ifndef CONFIG_H_ +#define CONFIG_H_ + +#define DEBUG + +#endif diff --git a/src/main.c b/src/main.c index 842536e..703c916 100644 --- a/src/main.c +++ b/src/main.c @@ -2,6 +2,8 @@ #include #include "webui.h" + +#include "config.h" #include "html.h" #include "ui.h" #include "device.h" @@ -12,13 +14,10 @@ int main(int argc, char const *argv[]) { int app_window = webui_new_window(); html_document[html_document_len] = '\0'; - // html_document[html_document_len + 1] = '\0'; - if (argc > 1 && strcmp(argv[1], "icanthink") == 0) { - } - else { - webui_set_kiosk(app_window, true); - } +#ifdef DEBUG + webui_set_kiosk(app_window, true); +#endif webui_bind(app_window, "close_app", close_app); webui_bind(app_window, "webui_refresh_ports", refresh_devices); diff --git a/src/ui.c b/src/ui.c index 0627e00..599b597 100644 --- a/src/ui.c +++ b/src/ui.c @@ -12,9 +12,13 @@ void close_app(webui_event_t* e) { } void refresh_devices(webui_event_t* e) { - printf("ololo\n"); + const char *available_ports = json_dumps(get_serial_ports(), 0); - webui_return_string(e, json_dumps(get_serial_ports(), 0)); +#ifdef DEBUG + printf("Доступные порты:\n%s\n", available_ports); +#endif + + webui_return_string(e, available_ports); } void connect_device(webui_event_t* e) { diff --git a/src/ui.h b/src/ui.h index 3832895..fd37599 100644 --- a/src/ui.h +++ b/src/ui.h @@ -11,6 +11,7 @@ #include #include "webui.h" +#include "config.h" #include "device.h" void close_app(webui_event_t* e);