extmod/modnetwork: Add extended socket state.

pull/7793/head
iabdalkader 2021-08-22 17:29:35 +02:00 zatwierdzone przez Damien George
rodzic d889f672da
commit e7429389a6
2 zmienionych plików z 12 dodań i 0 usunięć

Wyświetl plik

@ -85,9 +85,15 @@ typedef struct _mod_network_socket_obj_t {
uint8_t domain;
uint8_t type;
int8_t fileno;
uint8_t bound;
} u_param;
mp_uint_t u_state;
};
#if MICROPY_PY_USOCKET_EXTENDED_STATE
// Extended socket state for NICs/ports that need it.
int32_t timeout;
void *state;
#endif
} mod_network_socket_obj_t;
extern const mod_network_nic_type_t mod_network_nic_type_wiznet5k;

Wyświetl plik

@ -54,6 +54,7 @@ STATIC mp_obj_t socket_make_new(const mp_obj_type_t *type, size_t n_args, size_t
s->u_param.domain = MOD_NETWORK_AF_INET;
s->u_param.type = MOD_NETWORK_SOCK_STREAM;
s->u_param.fileno = -1;
s->u_param.bound = false;
if (n_args >= 1) {
s->u_param.domain = mp_obj_get_int(args[0]);
if (n_args >= 2) {
@ -64,6 +65,11 @@ STATIC mp_obj_t socket_make_new(const mp_obj_type_t *type, size_t n_args, size_t
}
}
#if MICROPY_PY_USOCKET_EXTENDED_STATE
s->timeout = 0;
s->state = NULL;
#endif
return MP_OBJ_FROM_PTR(s);
}