summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Shawcroft <scott@tannewt.org>2020-08-14 15:52:18 -0700
committerScott Shawcroft <scott@tannewt.org>2020-08-19 14:23:28 -0700
commitb3a449c2764f25a3c4becdbbed47e02ca36f755b (patch)
treeb63fea00a0aae5179609868c01f7d17db78bf067
parent430530c74ba0780b2afb232756d3f5cd3b417179 (diff)
Turn on json and enable socket.close
-rw-r--r--ports/esp32s2/mpconfigport.h2
-rw-r--r--shared-bindings/socketpool/Socket.c28
-rw-r--r--shared-bindings/socketpool/Socket.h1
3 files changed, 4 insertions, 27 deletions
diff --git a/ports/esp32s2/mpconfigport.h b/ports/esp32s2/mpconfigport.h
index d340bb480..c06e63439 100644
--- a/ports/esp32s2/mpconfigport.h
+++ b/ports/esp32s2/mpconfigport.h
@@ -31,7 +31,7 @@
#define CIRCUITPY_INTERNAL_NVM_SIZE (0)
#define MICROPY_NLR_THUMB (0)
-#define MICROPY_PY_UJSON (0)
+#define MICROPY_PY_UJSON (1)
#define MICROPY_USE_INTERNAL_PRINTF (0)
#include "py/circuitpy_mpconfig.h"
diff --git a/shared-bindings/socketpool/Socket.c b/shared-bindings/socketpool/Socket.c
index f6f90ceb1..64a051301 100644
--- a/shared-bindings/socketpool/Socket.c
+++ b/shared-bindings/socketpool/Socket.c
@@ -155,32 +155,8 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(socketpool_socket___exit___obj, 4, 4,
//| """Closes this Socket and makes its resources available to its SocketPool."""
//|
STATIC mp_obj_t socketpool_socket_close(mp_obj_t self_in) {
- // mod_network_socket_obj_t *self = MP_OBJ_TO_PTR(self_in);
-
- // // create new socket object
- // // starts with empty NIC so that finaliser doesn't run close() method if accept() fails
- // mod_network_socket_obj_t *socket2 = m_new_obj_with_finaliser(mod_network_socket_obj_t);
- // socket2->base.type = &socket_type;
- // socket2->nic = MP_OBJ_NULL;
- // socket2->nic_type = NULL;
-
- // // accept incoming connection
- // uint8_t ip[MOD_NETWORK_IPADDR_BUF_SIZE];
- // mp_uint_t port;
- // int _errno;
- // if (self->nic_type->accept(self, socket2, ip, &port, &_errno) != 0) {
- // mp_raise_OSError(_errno);
- // }
-
- // // new socket has valid state, so set the NIC to the same as parent
- // socket2->nic = self->nic;
- // socket2->nic_type = self->nic_type;
-
- // // make the return value
- // mp_obj_tuple_t *client = MP_OBJ_TO_PTR(mp_obj_new_tuple(2, NULL));
- // client->items[0] = MP_OBJ_FROM_PTR(socket2);
- // client->items[1] = netutils_format_inet_addr(ip, port, NETUTILS_BIG);
-
+ socketpool_socket_obj_t *self = MP_OBJ_TO_PTR(self_in);
+ common_hal_socketpool_socket_close(self);
return mp_const_none;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(socketpool_socket_close_obj, socketpool_socket_close);
diff --git a/shared-bindings/socketpool/Socket.h b/shared-bindings/socketpool/Socket.h
index 94c939e7b..a1aeccbe3 100644
--- a/shared-bindings/socketpool/Socket.h
+++ b/shared-bindings/socketpool/Socket.h
@@ -35,5 +35,6 @@ void common_hal_socketpool_socket_settimeout(socketpool_socket_obj_t* self, mp_u
bool common_hal_socketpool_socket_connect(socketpool_socket_obj_t* self, const char* host, size_t hostlen, mp_int_t port);
mp_uint_t common_hal_socketpool_socket_send(socketpool_socket_obj_t* self, const uint8_t* buf, mp_uint_t len);
mp_uint_t common_hal_socketpool_socket_recv_into(socketpool_socket_obj_t* self, const uint8_t* buf, mp_uint_t len);
+void common_hal_socketpool_socket_close(socketpool_socket_obj_t* self);
#endif // MICROPY_INCLUDED_SHARED_BINDINGS_SOCKETPOOL_SOCKET_H