Three small ESP web workflow fixes

* Set nonblock on all accepted sockets. Not just ones for user code.
* Close an open websocket if another is accepted.
* Set debug level to INFO rather than DEBUG because DEBUG crashes
  on ESP32-S3 USB OTG.
This commit is contained in:
Scott Shawcroft 2022-12-06 11:49:04 -08:00
parent 5cb867e854
commit b354cec8cb
No known key found for this signature in database
GPG Key ID: 0DFD512649C052DA
3 changed files with 9 additions and 5 deletions

View File

@ -285,6 +285,7 @@ int socketpool_socket_accept(socketpool_socket_obj_t *self, uint8_t *ip, uint32_
accepted->num = newsoc;
accepted->pool = self->pool;
accepted->connected = true;
lwip_fcntl(newsoc, F_SETFL, O_NONBLOCK);
}
return newsoc;
@ -303,7 +304,6 @@ socketpool_socket_obj_t *common_hal_socketpool_socket_accept(socketpool_socket_o
sock->pool = self->pool;
sock->connected = true;
lwip_fcntl(newsoc, F_SETFL, O_NONBLOCK);
return sock;
} else {
mp_raise_OSError(-newsoc);

View File

@ -8,8 +8,8 @@ CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_SIZE=y
# CONFIG_BOOTLOADER_LOG_LEVEL_NONE is not set
# CONFIG_BOOTLOADER_LOG_LEVEL_ERROR is not set
# CONFIG_BOOTLOADER_LOG_LEVEL_WARN is not set
# CONFIG_BOOTLOADER_LOG_LEVEL_INFO is not set
CONFIG_BOOTLOADER_LOG_LEVEL_DEBUG=y
CONFIG_BOOTLOADER_LOG_LEVEL_INFO=y
# CONFIG_BOOTLOADER_LOG_LEVEL_DEBUG is not set
# CONFIG_BOOTLOADER_LOG_LEVEL_VERBOSE is not set
# end of Bootloader config
@ -72,8 +72,8 @@ CONFIG_HAL_DEFAULT_ASSERTION_LEVEL=2
# CONFIG_LOG_DEFAULT_LEVEL_NONE is not set
# CONFIG_LOG_DEFAULT_LEVEL_ERROR is not set
# CONFIG_LOG_DEFAULT_LEVEL_WARN is not set
# CONFIG_LOG_DEFAULT_LEVEL_INFO is not set
CONFIG_LOG_DEFAULT_LEVEL_DEBUG=y
CONFIG_LOG_DEFAULT_LEVEL_INFO=y
# CONFIG_LOG_DEFAULT_LEVEL_DEBUG is not set
# CONFIG_LOG_DEFAULT_LEVEL_VERBOSE is not set
# end of Log output

View File

@ -57,11 +57,15 @@ static _websocket cp_serial;
void websocket_init(void) {
socketpool_socket_reset(&cp_serial.socket);
cp_serial.closed = true;
ringbuf_init(&_incoming_ringbuf, _buf, sizeof(_buf) - 1);
}
void websocket_handoff(socketpool_socket_obj_t *socket) {
if (!cp_serial.closed) {
common_hal_socketpool_socket_close(&cp_serial.socket);
}
socketpool_socket_move(socket, &cp_serial.socket);
cp_serial.closed = false;
cp_serial.opcode = 0;