fix mouse reports and improve timeout handling
This commit is contained in:
+20
-1
@@ -120,6 +120,7 @@ static err_t ws_accept(void *arg, struct altcp_pcb *pcb, err_t err) {
|
||||
|
||||
// register callbacks for tcp events
|
||||
altcp_recv(pcb, ws_recv);
|
||||
altcp_sent(pcb, ws_sent);
|
||||
altcp_poll(pcb, ws_poll, WS_POLL_INTERVAL);
|
||||
altcp_err(pcb, ws_err);
|
||||
|
||||
@@ -166,6 +167,24 @@ static err_t ws_recv(void *arg, struct altcp_pcb *pcb, struct pbuf *p, err_t err
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
// called when data has been sent over the websocket
|
||||
static err_t ws_sent(void *arg, struct altcp_pcb *pcb, uint16_t len) {
|
||||
struct ws_state *wss = (struct ws_state *)arg;
|
||||
|
||||
LWIP_DEBUGF(WS_DEBUG | LWIP_DBG_TRACE, ("ws_sent %p\n", (void*) pcb));
|
||||
|
||||
LWIP_UNUSED_ARG(len);
|
||||
|
||||
if (wss == NULL) {
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
wss->retries = 0;
|
||||
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
// called when there is a websocket error
|
||||
static void ws_err (void *arg, err_t err) {
|
||||
struct ws_state *wss = (struct ws_state *) arg;
|
||||
LWIP_UNUSED_ARG(err);
|
||||
@@ -192,6 +211,7 @@ static err_t ws_close_or_abort_conn(struct altcp_pcb *pcb, struct ws_state *wss,
|
||||
// clear callbacks
|
||||
altcp_arg(pcb, NULL);
|
||||
altcp_recv(pcb, NULL);
|
||||
altcp_sent(pcb, NULL);
|
||||
altcp_poll(pcb, NULL, 0);
|
||||
altcp_err(pcb, NULL);
|
||||
|
||||
@@ -353,7 +373,6 @@ static err_t ws_send(struct ws_state *wss, uint8_t *data, uint16_t len) {
|
||||
err = altcp_write(wss->pcb, buf, len+2, TCP_WRITE_FLAG_COPY);
|
||||
if (err == ERR_OK) {
|
||||
altcp_output(wss->pcb);
|
||||
wss->retries = 0;
|
||||
}
|
||||
|
||||
return err;
|
||||
|
||||
Reference in New Issue
Block a user