diff --git a/backend/headers/backend.h b/backend/headers/backend.h index 432c2ac..9c6c3f3 100644 --- a/backend/headers/backend.h +++ b/backend/headers/backend.h @@ -22,6 +22,8 @@ typedef enum _action_type { No_Action, Set_ID, + Set_Name, + Blink, Update_Firmware, Get_Firm_status, }action_type; @@ -65,6 +67,8 @@ backend_error set_ip(char *ipAddr); backend_error get_devices(can_device_t *devices, int maxDeviceCount, int *deviceCount); backend_error set_device_id(const can_device_t *device, int id, backend_callback callback); +backend_error set_device_name(const can_device_t *device, const char *name, backend_callback callback); +backend_error blink_device(const can_device_t *device, backend_callback callback); backend_error update_device_firmware(const can_device_t *device, const char *firmware_file, void (*firm_upgrade_callback)(double, int), backend_callback callback); #endif diff --git a/backend/lib/libPenguin_Backend.so b/backend/lib/libPenguin_Backend.so index 258685e..e2c7743 100755 Binary files a/backend/lib/libPenguin_Backend.so and b/backend/lib/libPenguin_Backend.so differ diff --git a/native/include/can_devices.h b/native/include/can_devices.h index 869b47f..c0eab41 100644 --- a/native/include/can_devices.h +++ b/native/include/can_devices.h @@ -8,6 +8,7 @@ void add_slct_device_selection(GtkTreeSelection *selector); void add_lbl_selected_device(GtkLabel *lbl); void add_txt_change_id(GtkSpinButton *idTxt); void add_btn_firmware_file(GtkFileChooserButton *btn); +void add_txt_device_name(GtkEntry *entry); can_device_t get_selected_device(); void set_selected_device(can_device_t newDevice); @@ -15,6 +16,8 @@ void set_selected_device(can_device_t newDevice); void react_changed_id(GtkWidget *widget, gpointer data); void react_changed_device(GtkWidget *widget, gpointer data); void react_update_firmware(GtkWidget *widget, gpointer data); +void react_changed_name(GtkWidget *widget, gpointer data); +void react_blink_device(GtkWidget *widget, gpointer data); #endif diff --git a/native/src/app_callbacks.c b/native/src/app_callbacks.c index c63bd66..80b677e 100644 --- a/native/src/app_callbacks.c +++ b/native/src/app_callbacks.c @@ -165,14 +165,21 @@ int connect_all_signals() /* Connect device stuff to can_devices file */ obj = gtk_builder_get_object(builder, "btn_change_id"); g_signal_connect(obj, "clicked", G_CALLBACK(react_changed_id), NULL); + obj = gtk_builder_get_object(builder, "btn_update_devices"); + g_signal_connect(obj, "clicked", G_CALLBACK(react_update_firmware), NULL); + obj = gtk_builder_get_object(builder, "btn_change_name"); + g_signal_connect(obj, "clicked", G_CALLBACK(react_changed_name), NULL); + obj = gtk_builder_get_object(builder, "btn_blink"); + g_signal_connect(obj, "clicked", G_CALLBACK(react_blink_device), NULL); + obj = gtk_builder_get_object(builder, "txt_device_id"); add_txt_change_id((GtkSpinButton *)obj); obj = gtk_builder_get_object(builder, "btn_choose_firmware"); add_btn_firmware_file((GtkFileChooserButton *)obj); - obj = gtk_builder_get_object(builder, "btn_update_devices"); - g_signal_connect(obj, "clicked", G_CALLBACK(react_update_firmware), NULL); obj = gtk_builder_get_object(builder, "prg_firm_upgrade_status"); _module.firmUpgradeStatus = (GtkLevelBar *)obj; + obj = gtk_builder_get_object(builder, "txt_device_name"); + add_txt_device_name((GtkEntry *)obj); /* Connect server address and port text change to react function */ diff --git a/native/src/can_devices.c b/native/src/can_devices.c index 45c7bf0..0e57d3c 100644 --- a/native/src/can_devices.c +++ b/native/src/can_devices.c @@ -9,6 +9,7 @@ static struct GtkLabel *selected_device_label; GtkSpinButton *txt_dev_id; GtkFileChooserButton *btn_firmware_file; + GtkEntry *txt_device_name; can_device_t selected_device; }_module; @@ -36,6 +37,12 @@ void add_btn_firmware_file(GtkFileChooserButton *btn) _module.btn_firmware_file = btn; } +void add_txt_device_name(GtkEntry *entry) +{ + _module.txt_device_name = entry; +} + + can_device_t get_selected_device() { return _module.selected_device; @@ -65,17 +72,18 @@ void react_changed_device(GtkWidget *widget, gpointer data) GValue value = G_VALUE_INIT; gtk_tree_model_get_value(tree, &iter, 0, &value); /* Device Name */ strcpy(_module.selected_device.name, g_value_get_string(&value)); + gtk_entry_set_text(_module.txt_device_name, g_value_get_string(&value)); g_value_unset(&value); } { GValue value = G_VALUE_INIT; - gtk_tree_model_get_value(tree, &iter, 2, &value); /* Device Name */ + gtk_tree_model_get_value(tree, &iter, 2, &value); /* Hardware */ strcpy(_module.selected_device.model, g_value_get_string(&value)); g_value_unset(&value); } { GValue value = G_VALUE_INIT; - gtk_tree_model_get_value(tree, &iter, 3, &value); /* Device Name */ + gtk_tree_model_get_value(tree, &iter, 3, &value); /* Device ID */ _module.selected_device.id = g_value_get_int(&value); g_value_unset(&value); } @@ -105,3 +113,13 @@ void react_update_firmware(GtkWidget *widget, gpointer data) update_device_firmware(&_module.selected_device, firmware_file, frontend_update_firm_status, frontend_callback); } +void react_changed_name(GtkWidget *widget, gpointer data) +{ + const char *new_name = gtk_entry_get_text(_module.txt_device_name); + set_device_name(&_module.selected_device, new_name, frontend_callback); +} +void react_blink_device(GtkWidget *widget, gpointer data) +{ + blink_device(&_module.selected_device, frontend_callback); +} + diff --git a/version.txt b/version.txt index 50919a9..13abad7 100644 --- a/version.txt +++ b/version.txt @@ -1,4 +1,4 @@ VERSION_MAJOR 0 -VERSION_MINOR 1 +VERSION_MINOR 2 VERSION_PATCH 0