summaryrefslogtreecommitdiff
path: root/tmk_core/common
diff options
context:
space:
mode:
authorFlorian Didron <fd@librem.one>2019-11-26 11:02:19 +0900
committerFlorian Didron <fdidron@users.noreply.github.com>2019-12-06 08:20:51 +0900
commit9a97a0eee988bc508ad8c64eb4b83a9018819d27 (patch)
tree0445c39a52d73107d39de5e530c3193578df0c24 /tmk_core/common
parent925c43c4c0e9360d2fe0032b3c41c2a84e1a4d8b (diff)
feat: add landing page url command
Diffstat (limited to 'tmk_core/common')
-rw-r--r--tmk_core/common/webusb.c21
-rw-r--r--tmk_core/common/webusb.h6
2 files changed, 25 insertions, 2 deletions
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 <string.h>
#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
};