feat: add landing page url command

This commit is contained in:
Florian Didron
2019-11-26 11:02:19 +09:00
committed by Drashna Jael're
parent 1f926d5431
commit c80f69639b
2 changed files with 25 additions and 2 deletions

View File

@@ -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

View File

@@ -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
};