minor fixes
This commit is contained in:
@@ -4,7 +4,6 @@ set(PICO_SDK_PATH /home/kenji/programming/pico/c/pico-sdk)
|
|||||||
if (NOT DEFINED PICO_BOARD)
|
if (NOT DEFINED PICO_BOARD)
|
||||||
set(PICO_BOARD pico_w)
|
set(PICO_BOARD pico_w)
|
||||||
endif()
|
endif()
|
||||||
#set(PICO_BOARD pico2_w)
|
|
||||||
include (${PICO_SDK_PATH}/external/pico_sdk_import.cmake)
|
include (${PICO_SDK_PATH}/external/pico_sdk_import.cmake)
|
||||||
project(${PROJECT} C CXX ASM)
|
project(${PROJECT} C CXX ASM)
|
||||||
|
|
||||||
|
|||||||
@@ -332,6 +332,7 @@ function sendKeys(curKeys, is_mouse) {
|
|||||||
}
|
}
|
||||||
} else if (socket.readyState == WebSocket.CLOSED) {
|
} else if (socket.readyState == WebSocket.CLOSED) {
|
||||||
socket = new WebSocket("ws://" + window.location.hostname + ":8080/");
|
socket = new WebSocket("ws://" + window.location.hostname + ":8080/");
|
||||||
|
socket.onmessage = function (event) { updateLEDs(event.data); };
|
||||||
setTimeout( function () { sendKeys(curKeys, is_mouse); }, 10);
|
setTimeout( function () { sendKeys(curKeys, is_mouse); }, 10);
|
||||||
} else {
|
} else {
|
||||||
setTimeout( function () { sendKeys(curKeys, is_mouse); }, 10);
|
setTimeout( function () { sendKeys(curKeys, is_mouse); }, 10);
|
||||||
|
|||||||
+5
-10
@@ -70,7 +70,7 @@ static void ws_state_free(struct ws_state *wss) {
|
|||||||
} else {
|
} else {
|
||||||
struct ws_state * last;
|
struct ws_state * last;
|
||||||
for (last = ws_connections; last->next != NULL; last = last->next) {
|
for (last = ws_connections; last->next != NULL; last = last->next) {
|
||||||
if (last->next = wss) {
|
if (last->next == wss) {
|
||||||
last->next = wss->next;
|
last->next = wss->next;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -187,6 +187,8 @@ static err_t ws_recv(void *arg, struct altcp_pcb *pcb, struct pbuf *p, err_t err
|
|||||||
|
|
||||||
// called when data has been sent over the websocket
|
// called when data has been sent over the websocket
|
||||||
static err_t ws_sent(void *arg, struct altcp_pcb *pcb, uint16_t len) {
|
static err_t ws_sent(void *arg, struct altcp_pcb *pcb, uint16_t len) {
|
||||||
|
(void) pcb;
|
||||||
|
|
||||||
struct ws_state *wss = (struct ws_state *)arg;
|
struct ws_state *wss = (struct ws_state *)arg;
|
||||||
|
|
||||||
LWIP_DEBUGF(WS_DEBUG | LWIP_DBG_TRACE, ("ws_sent %p\n", (void*) pcb));
|
LWIP_DEBUGF(WS_DEBUG | LWIP_DBG_TRACE, ("ws_sent %p\n", (void*) pcb));
|
||||||
@@ -309,13 +311,11 @@ static err_t ws_handshake(struct altcp_pcb *pcb, struct ws_state *wss, struct pb
|
|||||||
|
|
||||||
// create response packet with encoded response key
|
// create response packet with encoded response key
|
||||||
unsigned char response[sizeof(WS_RESPONSE) + sizeof(key_base64)+3];
|
unsigned char response[sizeof(WS_RESPONSE) + sizeof(key_base64)+3];
|
||||||
//strncpy(response, WS_RESPONSE, sizeof(WS_RESPONSE));
|
|
||||||
//strlcpy(&response[sizeof(WS_RESPONSE)-1], key_base64, strlen(key_base64));
|
|
||||||
size_t count = sprintf(response, "%s%s\r\n\r\n", WS_RESPONSE, key_base64);
|
size_t count = sprintf(response, "%s%s\r\n\r\n", WS_RESPONSE, key_base64);
|
||||||
|
|
||||||
// send completed data packet
|
// send completed data packet
|
||||||
LWIP_DEBUGF(WS_DEBUG, ("ws_handshake: sending response\n"));
|
LWIP_DEBUGF(WS_DEBUG, ("ws_handshake: sending response\n"));
|
||||||
if(altcp_write(pcb, response, strlen(response), TCP_WRITE_FLAG_COPY) == ERR_OK) {
|
if(altcp_write(pcb, response, count, TCP_WRITE_FLAG_COPY) == ERR_OK) {
|
||||||
wss->active = true;
|
wss->active = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -341,6 +341,7 @@ static err_t ws_handshake(struct altcp_pcb *pcb, struct ws_state *wss, struct pb
|
|||||||
|
|
||||||
// handle reading of websocket data and pass to ws_receive_cb
|
// handle reading of websocket data and pass to ws_receive_cb
|
||||||
static err_t ws_read(struct altcp_pcb *pcb, struct ws_state *wss, struct pbuf *p) {
|
static err_t ws_read(struct altcp_pcb *pcb, struct ws_state *wss, struct pbuf *p) {
|
||||||
|
(void) pcb;
|
||||||
uint8_t *data = (uint8_t *) p->payload;
|
uint8_t *data = (uint8_t *) p->payload;
|
||||||
uint16_t len = p->len;
|
uint16_t len = p->len;
|
||||||
|
|
||||||
@@ -365,12 +366,6 @@ static err_t ws_read(struct altcp_pcb *pcb, struct ws_state *wss, struct pbuf *p
|
|||||||
// lwIP's pbuf only handles 16-bit lengths, so error
|
// lwIP's pbuf only handles 16-bit lengths, so error
|
||||||
LWIP_DEBUGF(WS_DEBUG, ("ws_read: received 64-bit length %u\n", msg_len));
|
LWIP_DEBUGF(WS_DEBUG, ("ws_read: received 64-bit length %u\n", msg_len));
|
||||||
return ERR_MEM;
|
return ERR_MEM;
|
||||||
|
|
||||||
//memcpy(&msg_len, &data[2], 4);
|
|
||||||
//if (len >= 10) {
|
|
||||||
// msg = &data[10];
|
|
||||||
//}
|
|
||||||
//break;
|
|
||||||
default:
|
default:
|
||||||
if (len >= 6) {
|
if (len >= 6) {
|
||||||
msg = &data[6];
|
msg = &data[6];
|
||||||
|
|||||||
Reference in New Issue
Block a user