Skip to content

Commit

Permalink
webserver.c: Expose boot pin over legacy API
Browse files Browse the repository at this point in the history
  • Loading branch information
svenrademakers committed Jul 17, 2023
1 parent 89b576c commit c2973f6
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 3 deletions.
34 changes: 32 additions & 2 deletions app/bmc/webserver.c
Original file line number Diff line number Diff line change
Expand Up @@ -206,13 +206,30 @@ static int get_usbmode(Webs* wp)
}


static int reset_node(Webs* wp)
{
char* node = NULL;
node = websGetVar(wp, "node", NULL);

if(NULL == node )
{
app_webS_PrintJsonErr(wp,400,"node argument is not set");
return -1;
}

tpi_reset_node(atoi(node));

return 0;
}

static int set_usbmode(Webs* wp)
{
char* mode = NULL;
char* node = NULL;
mode = websGetVar(wp, "mode", NULL);
node = websGetVar(wp, "node", NULL);
// env_usb_t usb;
char* boot_pin = websGetVar(wp, "boot_pin", NULL);

if(NULL == node || NULL == mode)
{
app_webS_PrintJsonErr(wp,400,"mode or node is null");
Expand All @@ -222,7 +239,15 @@ static int set_usbmode(Webs* wp)
usb->mode = atoi(mode);
usb->node = atoi(node);
set_env_usb(usb);
tpi_usb_mode(usb->mode,usb->node);

if (NULL == boot_pin) {
tpi_usb_mode_v2(usb->mode,usb->node,1);
} else {
int boot = atoi(boot_pin);
tpi_usb_mode_v2(usb->mode,usb->node, boot);
}


return 0;
}

Expand Down Expand Up @@ -874,6 +899,11 @@ static void bmcdemo(Webs *wp)
{
clear_usb_boot(wp);
}
else if(0==strcasecmp(pType,"reset"))
{
reset_node(wp);
}

strcpy(json_result_buff,"{\"response\":[{\"result\":\"ok\"}]}");
websWrite(wp, "%s", json_result_buff);
websFlush(wp, 0);
Expand Down
2 changes: 1 addition & 1 deletion tp2bmc/package/bmc/bmc.mk
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# bmc
###########################################################

BMC_VERSION:= 1.0.0
BMC_VERSION:= 1.1.0
BMC_SITE:= $(TOPDIR)/../app/bmc
BMC_SITE_METHOD:=local
BMC_INSTALL_TARGET:=YES
Expand Down

0 comments on commit c2973f6

Please sign in to comment.