mirror of https://github.com/jetkvm/kvm.git
allow to toggle dhcp client via touchscreen
This commit is contained in:
parent
bb45be1d6d
commit
1ad44ed461
|
|
@ -43,6 +43,13 @@ func updateDisplay() {
|
|||
|
||||
nativeInstance.UpdateLabelIfChanged("home_info_mac_addr", networkManager.MACString())
|
||||
|
||||
switch config.NetworkConfig.DHCPClient.String {
|
||||
case "jetdhcpc":
|
||||
nativeInstance.UpdateLabelIfChanged("dhcp_client_change_label", "Change to udhcpc")
|
||||
case "udhcpc":
|
||||
nativeInstance.UpdateLabelIfChanged("dhcp_client_change_label", "Change to JetKVM")
|
||||
}
|
||||
|
||||
if usbState == "configured" {
|
||||
nativeInstance.UpdateLabelIfChanged("usb_status_label", "Connected")
|
||||
_, _ = nativeInstance.UIObjAddState("usb_status_label", "LV_STATE_CHECKED")
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -75,15 +75,19 @@ void action_about_screen_gesture(lv_event_t * e) {
|
|||
// user_data doesn't seem to be working, so we use a global variable here
|
||||
static uint32_t t_reset_config;
|
||||
static uint32_t t_reboot;
|
||||
static uint32_t t_dhcpc;
|
||||
|
||||
static bool b_reboot = false;
|
||||
static bool b_reset_config = false;
|
||||
static bool b_dhcpc = false;
|
||||
|
||||
static bool b_reboot_lock = false;
|
||||
static bool b_reset_config_lock = false;
|
||||
static bool b_dhcpc_lock = false;
|
||||
|
||||
const int RESET_CONFIG_HOLD_TIME = 10;
|
||||
const int REBOOT_HOLD_TIME = 5;
|
||||
const int DHCPC_HOLD_TIME = 5;
|
||||
|
||||
typedef struct {
|
||||
uint32_t *start_time;
|
||||
|
|
@ -153,6 +157,22 @@ void action_reset_config(lv_event_t * e) {
|
|||
handle_hold_action(e, &config);
|
||||
}
|
||||
|
||||
void action_dhcpc(lv_event_t * e) {
|
||||
hold_action_config_t config = {
|
||||
.start_time = &t_dhcpc,
|
||||
.completed = &b_dhcpc,
|
||||
.lock = &b_dhcpc_lock,
|
||||
.hold_time_seconds = DHCPC_HOLD_TIME,
|
||||
.rpc_method = "toggleDHCPClient",
|
||||
.button_obj = NULL, // No button/spinner for reboot
|
||||
.spinner_obj = NULL,
|
||||
.label_obj = objects.dhcpc_label,
|
||||
.default_text = "Press and hold for\n5 seconds"
|
||||
};
|
||||
|
||||
handle_hold_action(e, &config);
|
||||
}
|
||||
|
||||
void action_reboot(lv_event_t * e) {
|
||||
hold_action_config_t config = {
|
||||
.start_time = &t_reboot,
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ extern void action_handle_common_press_event(lv_event_t * e);
|
|||
extern void action_reset_config(lv_event_t * e);
|
||||
extern void action_reboot(lv_event_t * e);
|
||||
extern void action_switch_to_reboot(lv_event_t * e);
|
||||
extern void action_dhcpc(lv_event_t * e);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
|||
|
|
@ -887,6 +887,26 @@ void create_screen_menu_advanced_screen() {
|
|||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
// MenuBtnDHCPClient
|
||||
lv_obj_t *obj = lv_button_create(parent_obj);
|
||||
objects.menu_btn_dhcp_client = obj;
|
||||
lv_obj_set_pos(obj, 0, 0);
|
||||
lv_obj_set_size(obj, LV_PCT(100), 50);
|
||||
lv_obj_add_event_cb(obj, action_switch_to_reboot, LV_EVENT_PRESSED, (void *)0);
|
||||
lv_obj_clear_flag(obj, LV_OBJ_FLAG_SNAPPABLE);
|
||||
add_style_menu_button(obj);
|
||||
{
|
||||
lv_obj_t *parent_obj = obj;
|
||||
{
|
||||
lv_obj_t *obj = lv_label_create(parent_obj);
|
||||
lv_obj_set_pos(obj, 0, 0);
|
||||
lv_obj_set_size(obj, LV_SIZE_CONTENT, LV_SIZE_CONTENT);
|
||||
add_style_menu_button_label(obj);
|
||||
lv_label_set_text(obj, "DHCP Client");
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
// MenuBtnAdvancedResetConfig
|
||||
lv_obj_t *obj = lv_button_create(parent_obj);
|
||||
|
|
@ -2197,6 +2217,221 @@ void create_screen_rebooting_screen() {
|
|||
void tick_screen_rebooting_screen() {
|
||||
}
|
||||
|
||||
void create_screen_switch_dhcp_client_screen() {
|
||||
lv_obj_t *obj = lv_obj_create(0);
|
||||
objects.switch_dhcp_client_screen = obj;
|
||||
lv_obj_set_pos(obj, 0, 0);
|
||||
lv_obj_set_size(obj, 300, 240);
|
||||
lv_obj_add_event_cb(obj, action_about_screen_gesture, LV_EVENT_GESTURE, (void *)0);
|
||||
add_style_flex_screen_menu(obj);
|
||||
{
|
||||
lv_obj_t *parent_obj = obj;
|
||||
{
|
||||
lv_obj_t *obj = lv_obj_create(parent_obj);
|
||||
lv_obj_set_pos(obj, 0, 0);
|
||||
lv_obj_set_size(obj, LV_PCT(100), LV_PCT(100));
|
||||
lv_obj_set_style_pad_left(obj, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
|
||||
lv_obj_set_style_pad_top(obj, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
|
||||
lv_obj_set_style_pad_right(obj, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
|
||||
lv_obj_set_style_pad_bottom(obj, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
|
||||
lv_obj_set_style_bg_opa(obj, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
|
||||
lv_obj_set_style_border_width(obj, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
|
||||
lv_obj_set_style_radius(obj, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
|
||||
lv_obj_clear_flag(obj, LV_OBJ_FLAG_SCROLLABLE);
|
||||
add_style_flex_start(obj);
|
||||
{
|
||||
lv_obj_t *parent_obj = obj;
|
||||
{
|
||||
// DHCPClientHeader
|
||||
lv_obj_t *obj = lv_obj_create(parent_obj);
|
||||
objects.dhcp_client_header = obj;
|
||||
lv_obj_set_pos(obj, 0, 0);
|
||||
lv_obj_set_size(obj, LV_PCT(100), LV_SIZE_CONTENT);
|
||||
lv_obj_set_style_pad_left(obj, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
|
||||
lv_obj_set_style_pad_top(obj, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
|
||||
lv_obj_set_style_pad_bottom(obj, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
|
||||
lv_obj_set_style_bg_opa(obj, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
|
||||
lv_obj_set_style_border_width(obj, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
|
||||
lv_obj_set_style_radius(obj, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
|
||||
add_style_flow_row_space_between(obj);
|
||||
lv_obj_set_style_pad_right(obj, 4, LV_PART_MAIN | LV_STATE_DEFAULT);
|
||||
{
|
||||
lv_obj_t *parent_obj = obj;
|
||||
{
|
||||
lv_obj_t *obj = lv_button_create(parent_obj);
|
||||
lv_obj_set_pos(obj, 0, 0);
|
||||
lv_obj_set_size(obj, 32, 32);
|
||||
lv_obj_add_event_cb(obj, action_switch_to_menu, LV_EVENT_CLICKED, (void *)0);
|
||||
add_style_back_button(obj);
|
||||
{
|
||||
lv_obj_t *parent_obj = obj;
|
||||
{
|
||||
lv_obj_t *obj = lv_image_create(parent_obj);
|
||||
lv_obj_set_pos(obj, -1, 2);
|
||||
lv_obj_set_size(obj, LV_SIZE_CONTENT, LV_SIZE_CONTENT);
|
||||
lv_image_set_src(obj, &img_back_caret);
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
lv_obj_t *obj = lv_label_create(parent_obj);
|
||||
lv_obj_set_pos(obj, LV_PCT(0), LV_PCT(0));
|
||||
lv_obj_set_size(obj, LV_SIZE_CONTENT, LV_SIZE_CONTENT);
|
||||
add_style_header_link(obj);
|
||||
lv_label_set_text(obj, "Reset Config");
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
// DHCPClientContainer
|
||||
lv_obj_t *obj = lv_obj_create(parent_obj);
|
||||
objects.dhcp_client_container = obj;
|
||||
lv_obj_set_pos(obj, 0, 0);
|
||||
lv_obj_set_size(obj, LV_PCT(100), LV_PCT(80));
|
||||
lv_obj_set_style_pad_left(obj, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
|
||||
lv_obj_set_style_pad_top(obj, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
|
||||
lv_obj_set_style_pad_bottom(obj, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
|
||||
lv_obj_set_style_bg_opa(obj, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
|
||||
lv_obj_set_style_border_width(obj, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
|
||||
lv_obj_set_style_radius(obj, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
|
||||
lv_obj_set_scrollbar_mode(obj, LV_SCROLLBAR_MODE_AUTO);
|
||||
lv_obj_set_scroll_dir(obj, LV_DIR_VER);
|
||||
lv_obj_set_scroll_snap_x(obj, LV_SCROLL_SNAP_START);
|
||||
add_style_flex_column_start(obj);
|
||||
lv_obj_set_style_pad_right(obj, 4, LV_PART_MAIN | LV_STATE_DEFAULT);
|
||||
{
|
||||
lv_obj_t *parent_obj = obj;
|
||||
{
|
||||
lv_obj_t *obj = lv_obj_create(parent_obj);
|
||||
lv_obj_set_pos(obj, 0, 0);
|
||||
lv_obj_set_size(obj, LV_PCT(100), LV_SIZE_CONTENT);
|
||||
lv_obj_set_style_pad_left(obj, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
|
||||
lv_obj_set_style_pad_top(obj, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
|
||||
lv_obj_set_style_pad_bottom(obj, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
|
||||
lv_obj_set_style_bg_opa(obj, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
|
||||
lv_obj_set_style_border_width(obj, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
|
||||
lv_obj_set_style_radius(obj, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
|
||||
lv_obj_clear_flag(obj, LV_OBJ_FLAG_SCROLLABLE);
|
||||
add_style_flex_column_start(obj);
|
||||
lv_obj_set_style_pad_right(obj, 10, LV_PART_MAIN | LV_STATE_DEFAULT);
|
||||
{
|
||||
lv_obj_t *parent_obj = obj;
|
||||
{
|
||||
// DHCPClientLabelContainer
|
||||
lv_obj_t *obj = lv_obj_create(parent_obj);
|
||||
objects.dhcp_client_label_container = obj;
|
||||
lv_obj_set_pos(obj, 0, 0);
|
||||
lv_obj_set_size(obj, LV_PCT(100), LV_SIZE_CONTENT);
|
||||
lv_obj_set_style_bg_opa(obj, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
|
||||
lv_obj_set_style_border_width(obj, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
|
||||
lv_obj_set_style_radius(obj, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
|
||||
lv_obj_clear_flag(obj, LV_OBJ_FLAG_SCROLLABLE);
|
||||
add_style_flex_column_start(obj);
|
||||
lv_obj_set_style_pad_right(obj, 10, LV_PART_MAIN | LV_STATE_DEFAULT);
|
||||
lv_obj_set_style_pad_left(obj, 10, LV_PART_MAIN | LV_STATE_DEFAULT);
|
||||
lv_obj_set_style_pad_top(obj, 10, LV_PART_MAIN | LV_STATE_DEFAULT);
|
||||
lv_obj_set_style_pad_bottom(obj, 10, LV_PART_MAIN | LV_STATE_DEFAULT);
|
||||
{
|
||||
lv_obj_t *parent_obj = obj;
|
||||
{
|
||||
// DHCPC_Label
|
||||
lv_obj_t *obj = lv_label_create(parent_obj);
|
||||
objects.dhcpc_label = obj;
|
||||
lv_obj_set_pos(obj, 0, 0);
|
||||
lv_obj_set_size(obj, LV_PCT(100), LV_SIZE_CONTENT);
|
||||
add_style_info_content_label(obj);
|
||||
lv_obj_set_style_text_font(obj, &ui_font_font_book20, LV_PART_MAIN | LV_STATE_DEFAULT);
|
||||
lv_label_set_text(obj, "Press and hold for\n10 seconds");
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
// DHCPClientSpinner
|
||||
lv_obj_t *obj = lv_obj_create(parent_obj);
|
||||
objects.dhcp_client_spinner = obj;
|
||||
lv_obj_set_pos(obj, 0, 0);
|
||||
lv_obj_set_size(obj, LV_PCT(100), LV_SIZE_CONTENT);
|
||||
lv_obj_set_style_pad_left(obj, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
|
||||
lv_obj_set_style_pad_top(obj, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
|
||||
lv_obj_set_style_pad_right(obj, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
|
||||
lv_obj_set_style_pad_bottom(obj, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
|
||||
lv_obj_set_style_bg_opa(obj, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
|
||||
lv_obj_set_style_border_width(obj, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
|
||||
lv_obj_set_style_radius(obj, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
|
||||
lv_obj_add_flag(obj, LV_OBJ_FLAG_HIDDEN);
|
||||
lv_obj_clear_flag(obj, LV_OBJ_FLAG_CLICKABLE|LV_OBJ_FLAG_SCROLLABLE);
|
||||
add_style_flex_column_start(obj);
|
||||
lv_obj_set_style_flex_main_place(obj, LV_FLEX_ALIGN_CENTER, LV_PART_MAIN | LV_STATE_DEFAULT);
|
||||
lv_obj_set_style_flex_cross_place(obj, LV_FLEX_ALIGN_CENTER, LV_PART_MAIN | LV_STATE_DEFAULT);
|
||||
lv_obj_set_style_flex_track_place(obj, LV_FLEX_ALIGN_CENTER, LV_PART_MAIN | LV_STATE_DEFAULT);
|
||||
{
|
||||
lv_obj_t *parent_obj = obj;
|
||||
{
|
||||
lv_obj_t *obj = lv_spinner_create(parent_obj);
|
||||
lv_obj_set_pos(obj, 0, 0);
|
||||
lv_obj_set_size(obj, 80, 80);
|
||||
lv_spinner_set_anim_params(obj, 1000, 60);
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
// DHCPClientButton
|
||||
lv_obj_t *obj = lv_obj_create(parent_obj);
|
||||
objects.dhcp_client_button = obj;
|
||||
lv_obj_set_pos(obj, 0, 0);
|
||||
lv_obj_set_size(obj, LV_PCT(100), LV_SIZE_CONTENT);
|
||||
lv_obj_set_style_pad_left(obj, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
|
||||
lv_obj_set_style_pad_top(obj, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
|
||||
lv_obj_set_style_pad_right(obj, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
|
||||
lv_obj_set_style_pad_bottom(obj, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
|
||||
lv_obj_set_style_bg_opa(obj, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
|
||||
lv_obj_set_style_border_width(obj, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
|
||||
lv_obj_set_style_radius(obj, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
|
||||
lv_obj_clear_flag(obj, LV_OBJ_FLAG_SCROLLABLE);
|
||||
add_style_flex_column_start(obj);
|
||||
{
|
||||
lv_obj_t *parent_obj = obj;
|
||||
{
|
||||
lv_obj_t *obj = lv_button_create(parent_obj);
|
||||
objects.obj2 = obj;
|
||||
lv_obj_set_pos(obj, 0, 0);
|
||||
lv_obj_set_size(obj, LV_PCT(100), 50);
|
||||
lv_obj_add_event_cb(obj, action_dhcpc, LV_EVENT_PRESSED, (void *)0);
|
||||
lv_obj_add_event_cb(obj, action_dhcpc, LV_EVENT_PRESSING, (void *)0);
|
||||
lv_obj_add_event_cb(obj, action_dhcpc, LV_EVENT_RELEASED, (void *)0);
|
||||
lv_obj_set_style_bg_color(obj, lv_color_hex(0xffdc2626), LV_PART_MAIN | LV_STATE_DEFAULT);
|
||||
lv_obj_set_style_text_align(obj, LV_TEXT_ALIGN_LEFT, LV_PART_MAIN | LV_STATE_DEFAULT);
|
||||
lv_obj_set_style_pad_right(obj, 13, LV_PART_MAIN | LV_STATE_DEFAULT);
|
||||
{
|
||||
lv_obj_t *parent_obj = obj;
|
||||
{
|
||||
// DHCPClientChangeLabel
|
||||
lv_obj_t *obj = lv_label_create(parent_obj);
|
||||
objects.dhcp_client_change_label = obj;
|
||||
lv_obj_set_pos(obj, 0, 0);
|
||||
lv_obj_set_size(obj, LV_SIZE_CONTENT, LV_SIZE_CONTENT);
|
||||
lv_obj_set_style_align(obj, LV_ALIGN_CENTER, LV_PART_MAIN | LV_STATE_DEFAULT);
|
||||
lv_obj_set_style_text_align(obj, LV_TEXT_ALIGN_LEFT, LV_PART_MAIN | LV_STATE_DEFAULT);
|
||||
lv_label_set_text(obj, "Switch to udhcpc");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tick_screen_switch_dhcp_client_screen();
|
||||
}
|
||||
|
||||
void tick_screen_switch_dhcp_client_screen() {
|
||||
}
|
||||
|
||||
|
||||
|
||||
typedef void (*tick_screen_func_t)();
|
||||
|
|
@ -2212,6 +2447,7 @@ tick_screen_func_t tick_screen_funcs[] = {
|
|||
tick_screen_reset_config_screen,
|
||||
tick_screen_reboot_screen,
|
||||
tick_screen_rebooting_screen,
|
||||
tick_screen_switch_dhcp_client_screen,
|
||||
};
|
||||
void tick_screen(int screen_index) {
|
||||
tick_screen_funcs[screen_index]();
|
||||
|
|
@ -2236,4 +2472,5 @@ void create_screens() {
|
|||
create_screen_reset_config_screen();
|
||||
create_screen_reboot_screen();
|
||||
create_screen_rebooting_screen();
|
||||
create_screen_switch_dhcp_client_screen();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ typedef struct _objects_t {
|
|||
lv_obj_t *reset_config_screen;
|
||||
lv_obj_t *reboot_screen;
|
||||
lv_obj_t *rebooting_screen;
|
||||
lv_obj_t *switch_dhcp_client_screen;
|
||||
lv_obj_t *boot_logo;
|
||||
lv_obj_t *boot_screen_version;
|
||||
lv_obj_t *no_network_header_container;
|
||||
|
|
@ -54,6 +55,7 @@ typedef struct _objects_t {
|
|||
lv_obj_t *menu_btn_advanced_developer_mode;
|
||||
lv_obj_t *menu_btn_advanced_usb_emulation;
|
||||
lv_obj_t *menu_btn_advanced_reboot;
|
||||
lv_obj_t *menu_btn_dhcp_client;
|
||||
lv_obj_t *menu_btn_advanced_reset_config;
|
||||
lv_obj_t *menu_header_container_2;
|
||||
lv_obj_t *menu_items_container_2;
|
||||
|
|
@ -101,6 +103,14 @@ typedef struct _objects_t {
|
|||
lv_obj_t *obj1;
|
||||
lv_obj_t *reboot_in_progress_logo;
|
||||
lv_obj_t *reboot_in_progress_label;
|
||||
lv_obj_t *dhcp_client_header;
|
||||
lv_obj_t *dhcp_client_container;
|
||||
lv_obj_t *dhcp_client_label_container;
|
||||
lv_obj_t *dhcpc_label;
|
||||
lv_obj_t *dhcp_client_spinner;
|
||||
lv_obj_t *dhcp_client_button;
|
||||
lv_obj_t *obj2;
|
||||
lv_obj_t *dhcp_client_change_label;
|
||||
} objects_t;
|
||||
|
||||
extern objects_t objects;
|
||||
|
|
@ -117,6 +127,7 @@ enum ScreensEnum {
|
|||
SCREEN_ID_RESET_CONFIG_SCREEN = 9,
|
||||
SCREEN_ID_REBOOT_SCREEN = 10,
|
||||
SCREEN_ID_REBOOTING_SCREEN = 11,
|
||||
SCREEN_ID_SWITCH_DHCP_CLIENT_SCREEN = 12,
|
||||
};
|
||||
|
||||
void create_screen_boot_screen();
|
||||
|
|
@ -151,6 +162,9 @@ void tick_screen_reboot_screen();
|
|||
|
||||
void create_screen_rebooting_screen();
|
||||
void tick_screen_rebooting_screen();
|
||||
|
||||
void create_screen_switch_dhcp_client_screen();
|
||||
void tick_screen_switch_dhcp_client_screen();
|
||||
|
||||
void tick_screen_by_id(enum ScreensEnum screenId);
|
||||
void tick_screen(int screen_index);
|
||||
|
|
|
|||
|
|
@ -43,6 +43,8 @@ func initNative(systemVersion *semver.Version, appVersion *semver.Version) {
|
|||
_ = rpcReboot(true)
|
||||
case "reboot":
|
||||
_ = rpcReboot(true)
|
||||
case "toggleDHCPClient":
|
||||
_ = rpcToggleDHCPClient()
|
||||
default:
|
||||
nativeLogger.Warn().Str("event", event).Msg("unknown rpc event received")
|
||||
}
|
||||
|
|
|
|||
11
network.go
11
network.go
|
|
@ -193,3 +193,14 @@ func rpcSetNetworkSettings(settings RpcNetworkSettings) (*RpcNetworkSettings, er
|
|||
func rpcRenewDHCPLease() error {
|
||||
return networkManager.RenewDHCPLease(NetIfName)
|
||||
}
|
||||
|
||||
func rpcToggleDHCPClient() error {
|
||||
switch config.NetworkConfig.DHCPClient.String {
|
||||
case "jetdhcpc":
|
||||
config.NetworkConfig.DHCPClient.String = "udhcpc"
|
||||
case "udhcpc":
|
||||
config.NetworkConfig.DHCPClient.String = "jetdhcpc"
|
||||
}
|
||||
|
||||
return rpcReboot(false)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue