feat: add fw version webusb cmd

This commit is contained in:
Florian Didron
2019-12-02 18:58:07 +09:00
committed by Drashna Jael're
parent 7c51cd7d99
commit 4ca9256118
2 changed files with 8 additions and 5 deletions
+4 -4
View File
@@ -20,9 +20,9 @@ void webusb_receive(uint8_t *data, uint8_t length) {
return; return;
} }
if(command == WEBUSB_GET_LANDING_PAGE) { if(command == WEBUSB_GET_FW_VERSION) {
// Landing page + packet headers(2) + stop bit(1) // Landing page + packet headers(2) + stop bit(1)
uint8_t lp_size = sizeof(WEBUSB_LANDING_PAGE_URL) + 3; uint8_t lp_size = sizeof(FIRMWARE_VERSION) + 3;
uint8_t url[lp_size]; uint8_t url[lp_size];
uint8_t event[2]; uint8_t event[2];
@@ -33,8 +33,8 @@ void webusb_receive(uint8_t *data, uint8_t length) {
stop[0] = WEBUSB_STOP_BIT; stop[0] = WEBUSB_STOP_BIT;
memcpy(url, event, 2); memcpy(url, event, 2);
memcpy(url + 2, WEBUSB_LANDING_PAGE_URL, sizeof(WEBUSB_LANDING_PAGE_URL)); memcpy(url + 2, FIRMWARE_VERSION, sizeof(FIRMWARE_VERSION));
memcpy(url + 2 + sizeof(WEBUSB_LANDING_PAGE_URL), stop, 1); memcpy(url + 2 + sizeof(FIRMWARE_VERSION), stop, 1);
webusb_send(url, lp_size); webusb_send(url, lp_size);
return; return;
} }
+4 -1
View File
@@ -3,6 +3,9 @@
#include <stdint.h> #include <stdint.h>
#include <stdbool.h> #include <stdbool.h>
#ifndef FIRMWARE_VERSION
#define FIRMWARE_VERSION u8"default"
#endif
#define WEBUSB_STOP_BIT -2 #define WEBUSB_STOP_BIT -2
#define WEBUSB_BLINK_STEPS 512 #define WEBUSB_BLINK_STEPS 512
#define WEBUSB_BLINK_END WEBUSB_BLINK_STEPS * 60 #define WEBUSB_BLINK_END WEBUSB_BLINK_STEPS * 60
@@ -27,7 +30,7 @@ enum Webusb_Status_Code {
enum Webusb_Command_Code { enum Webusb_Command_Code {
WEBUSB_CMD_PAIR, WEBUSB_CMD_PAIR,
WEBUSB_GET_LANDING_PAGE WEBUSB_GET_FW_VERSION
}; };
enum Webusb_Event_Code { enum Webusb_Event_Code {