This commit is contained in:
j3d1 2022-09-22 21:48:36 +02:00
parent ce8b71daf0
commit 9c5fb65a90
6 changed files with 390 additions and 30 deletions

View file

@ -30,6 +30,8 @@ using namespace fiatlux;
#define vTaskDelayMs(ms) vTaskDelay((ms) / portTICK_PERIOD_MS)
const char hex_lookup[] = "0123456789ABCDEF\0\0";
uint16_t voltage_val;
struct {
@ -230,6 +232,8 @@ void websocket_task(void *pvParameter) {
vTaskDelete(nullptr);
}
char str[] = "L00000000\n";
/**
* This function is called when websocket frame is received.
*
@ -254,6 +258,47 @@ void websocket_cb(struct tcp_pcb *pcb, char *data, u16_t data_len,
// Clear Config
res.cmd = (messages::id) 'X';
res.ret = OK;
} else if(data[0] == 'B') {
// Disable LED
uint32_t val = data[4] | (data[5] << 8) | (data[6] << 16) | (data[7] << 24);
bottom_color.r = data[7];
bottom_color.g = data[6];
bottom_color.b = data[5];
str[0] = 'B';
str[2] = hex_lookup[val & 0xF];
str[1] = hex_lookup[(val >> 4) & 0xF];
str[4] = hex_lookup[(val >> 8) & 0xF];
str[3] = hex_lookup[(val >> 12) & 0xF];
str[6] = hex_lookup[(val >> 16) & 0xF];
str[5] = hex_lookup[(val >> 20) & 0xF];
str[8] = hex_lookup[(val >> 24) & 0xF];
str[7] = hex_lookup[(val >> 28) & 0xF];
//
syslog(str);
//signal_led(false);
res.cmd = (messages::id) 'B';
res.ret = OK;
res.val = 1;
} else if(data[0] == 'T') {
// Disable LED
uint32_t val = data[4] | (data[5] << 8) | (data[6] << 16) | (data[7] << 24);
top_color.r = data[7];
top_color.g = data[6];
top_color.b = data[5];
str[0] = 'T';
str[2] = hex_lookup[val & 0xF];
str[1] = hex_lookup[(val >> 4) & 0xF];
str[4] = hex_lookup[(val >> 8) & 0xF];
str[3] = hex_lookup[(val >> 12) & 0xF];
str[6] = hex_lookup[(val >> 16) & 0xF];
str[5] = hex_lookup[(val >> 20) & 0xF];
str[8] = hex_lookup[(val >> 24) & 0xF];
str[7] = hex_lookup[(val >> 28) & 0xF];
syslog(str);
//signal_led(false);
res.cmd = (messages::id) 'T';
res.ret = OK;
res.val = 1;
} else if(data[0] == 'D') {
// Disable LED
syslog("G\n");