From 9a97a0eee988bc508ad8c64eb4b83a9018819d27 Mon Sep 17 00:00:00 2001 From: Florian Didron Date: Tue, 26 Nov 2019 11:02:19 +0900 Subject: feat: add landing page url command --- tmk_core/common/webusb.c | 21 +++++++++++++++++++++ tmk_core/common/webusb.h | 6 ++++-- 2 files changed, 25 insertions(+), 2 deletions(-) (limited to 'tmk_core/common') diff --git a/tmk_core/common/webusb.c b/tmk_core/common/webusb.c index 82e8fe1c83..63b967b7bf 100644 --- a/tmk_core/common/webusb.c +++ b/tmk_core/common/webusb.c @@ -1,3 +1,4 @@ +#include #include "webusb.h" #include "wait.h" @@ -6,6 +7,8 @@ webusb_state_t webusb_state = { .pairing = false, }; +#define pl u8"https://plop.com" + void webusb_receive(uint8_t *data, uint8_t length) { uint8_t command = data[0]; @@ -20,6 +23,24 @@ void webusb_receive(uint8_t *data, uint8_t length) { return; } + if(command == WEBUSB_GET_LANDING_PAGE) { + uint8_t lp_size = sizeof(WEBUSB_LANDING_PAGE_URL); + uint8_t url[lp_size]; + memcpy(url, WEBUSB_LANDING_PAGE_URL, lp_size); + + uint8_t event[2]; + event[0] = WEBUSB_STATUS_OK; + event[1] = WEBUSB_EVT_LANDING_PAGE; + + uint8_t stop[1]; + stop[0] = WEBUSB_STOP_BIT; + + webusb_send(event, sizeof(event)); + webusb_send(url, lp_size); + webusb_send(stop, 1); + return; + } + if(webusb_state.paired == true) { switch(command) { //Handle commands in here diff --git a/tmk_core/common/webusb.h b/tmk_core/common/webusb.h index c49a9f48a8..873ecb7ce2 100644 --- a/tmk_core/common/webusb.h +++ b/tmk_core/common/webusb.h @@ -26,12 +26,14 @@ enum Webusb_Status_Code { }; enum Webusb_Command_Code { - WEBUSB_CMD_PAIR + WEBUSB_CMD_PAIR, + WEBUSB_GET_LANDING_PAGE }; enum Webusb_Event_Code { WEBUSB_EVT_PAIRED, WEBUSB_EVT_KEYDOWN, WEBUSB_EVT_KEYUP, - WEBUSB_EVT_LAYER + WEBUSB_EVT_LAYER, + WEBUSB_EVT_LANDING_PAGE }; -- cgit v1.2.3