Допилена функция обнолвения портов

This commit is contained in:
Alexander Popov 2023-08-29 23:06:24 +03:00
parent dbf789d209
commit 19e6066a57
Signed by: iiiypuk
GPG Key ID: E47FE0AB36CD5ED6
5 changed files with 24 additions and 9 deletions

View File

@ -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('Отсутсвуют подключённые устройства!');

11
src/config.h Normal file
View File

@ -0,0 +1,11 @@
/*
* AUTHOR: Alexander Popov <iiiypuk {at} fastmail.fm>
* DESC: ...
*/
#ifndef CONFIG_H_
#define CONFIG_H_
#define DEBUG
#endif

View File

@ -2,6 +2,8 @@
#include <string.h>
#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 {
#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);

View File

@ -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) {

View File

@ -11,6 +11,7 @@
#include <jansson.h>
#include "webui.h"
#include "config.h"
#include "device.h"
void close_app(webui_event_t* e);