diff --git a/src/drivers/ninaw10/src/nina.c b/src/drivers/ninaw10/src/nina.c index 2899f6c1b..d46151948 100644 --- a/src/drivers/ninaw10/src/nina.c +++ b/src/drivers/ninaw10/src/nina.c @@ -477,16 +477,17 @@ int nina_ifconfig(nina_ifconfig_t *ifconfig, bool set) { ARG_BYTE(3), // Valid number of args. {ip_len, ifconfig->ip_addr}, {gw_len, ifconfig->gateway_addr}, - {sub_len, ifconfig->subnet_addr})) != SPI_ACK) { + {sub_len, ifconfig->subnet_addr})) != 0) { return -1; } + uint8_t dns2[4] = {8, 8, 8, 8}; if (nina_send_command_read_ack(NINA_CMD_SET_DNS_CONFIG, 3, ARG_8BITS, NINA_ARGS( ARG_BYTE(1), // Valid number of args. {dns_len, ifconfig->dns_addr}, - {dns_len, ifconfig->dns_addr})) != SPI_ACK) { + {dns_len, dns2})) != SPI_ACK) { return -1; } diff --git a/src/omv/ports/rp2/modules/py_nina.c b/src/omv/ports/rp2/modules/py_nina.c index 188dfeb4f..b746ef24c 100644 --- a/src/omv/ports/rp2/modules/py_nina.c +++ b/src/omv/ports/rp2/modules/py_nina.c @@ -149,6 +149,11 @@ static mp_obj_t py_nina_connect(mp_uint_t n_args, const mp_obj_t *pos_args, mp_m mp_raise_msg(&mp_type_OSError, MP_ERROR_TEXT("Key can't be empty!")); } + // Disconnect active connections first. + if (nina_isconnected()) { + nina_disconnect(); + } + if (self->itf == NINA_WIFI_MODE_STA) { // Initialize WiFi in Station mode. if (nina_connect(ssid, security, key, 0) != 0) { @@ -425,7 +430,7 @@ static mp_uint_t py_nina_socket_send(mod_network_socket_obj_t *socket, const byt if (ret == NINA_ERROR_TIMEOUT) { // The socket is Not closed on timeout when calling functions that accept a timeout. *_errno = MP_ETIMEDOUT; - return 0; + return -1; } else if (ret < 0) { // Close the socket on any other errors. *_errno = ret; @@ -441,7 +446,7 @@ static mp_uint_t py_nina_socket_recv(mod_network_socket_obj_t *socket, byte *buf if (ret == NINA_ERROR_TIMEOUT) { // The socket is Not closed on timeout when calling functions that accept a timeout. *_errno = MP_ETIMEDOUT; - return 0; + return -1; } else if (ret < 0) { // Close the socket on any other errors. *_errno = ret; @@ -475,7 +480,7 @@ static mp_uint_t py_nina_socket_sendto(mod_network_socket_obj_t *socket, if (ret == NINA_ERROR_TIMEOUT) { // The socket is Not closed on timeout when calling functions that accept a timeout. *_errno = MP_ETIMEDOUT; - return 0; + return -1; } else if (ret < 0) { *_errno = ret; py_nina_socket_close(socket); @@ -496,7 +501,7 @@ static mp_uint_t py_nina_socket_recvfrom(mod_network_socket_obj_t *socket, if (ret == NINA_ERROR_TIMEOUT) { // The socket is Not closed on timeout when calling functions that accept a timeout. *_errno = MP_ETIMEDOUT; - return 0; + return -1; } else if (ret < 0) { // Close the socket on any other errors. *_errno = ret;