feat: add landing page url command
This commit is contained in:
committed by
Drashna Jael're
parent
1f926d5431
commit
c80f69639b
@@ -1,3 +1,4 @@
|
|||||||
|
#include <string.h>
|
||||||
#include "webusb.h"
|
#include "webusb.h"
|
||||||
#include "wait.h"
|
#include "wait.h"
|
||||||
|
|
||||||
@@ -6,6 +7,8 @@ webusb_state_t webusb_state = {
|
|||||||
.pairing = false,
|
.pairing = false,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define pl u8"https://plop.com"
|
||||||
|
|
||||||
void webusb_receive(uint8_t *data, uint8_t length) {
|
void webusb_receive(uint8_t *data, uint8_t length) {
|
||||||
uint8_t command = data[0];
|
uint8_t command = data[0];
|
||||||
|
|
||||||
@@ -20,6 +23,24 @@ void webusb_receive(uint8_t *data, uint8_t length) {
|
|||||||
return;
|
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) {
|
if(webusb_state.paired == true) {
|
||||||
switch(command) {
|
switch(command) {
|
||||||
//Handle commands in here
|
//Handle commands in here
|
||||||
|
|||||||
@@ -26,12 +26,14 @@ enum Webusb_Status_Code {
|
|||||||
};
|
};
|
||||||
|
|
||||||
enum Webusb_Command_Code {
|
enum Webusb_Command_Code {
|
||||||
WEBUSB_CMD_PAIR
|
WEBUSB_CMD_PAIR,
|
||||||
|
WEBUSB_GET_LANDING_PAGE
|
||||||
};
|
};
|
||||||
|
|
||||||
enum Webusb_Event_Code {
|
enum Webusb_Event_Code {
|
||||||
WEBUSB_EVT_PAIRED,
|
WEBUSB_EVT_PAIRED,
|
||||||
WEBUSB_EVT_KEYDOWN,
|
WEBUSB_EVT_KEYDOWN,
|
||||||
WEBUSB_EVT_KEYUP,
|
WEBUSB_EVT_KEYUP,
|
||||||
WEBUSB_EVT_LAYER
|
WEBUSB_EVT_LAYER,
|
||||||
|
WEBUSB_EVT_LANDING_PAGE
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user