示例#1
0
// method socket.accept()
STATIC mp_obj_t esp_socket_accept(mp_obj_t self_in) {
    esp_socket_obj_t *s = self_in;

    if (s->connlist == NULL) {
        nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError,
            "not listening"));
    }

    do {
        mp_uint_t len;
        mp_obj_t *items;

        mp_obj_list_get(s->connlist, &len, &items);
        if (len == 0) {
            break;
        }

        esp_socket_obj_t *rs = items[0];
        mp_obj_list_remove(s->connlist, rs);
        if (rs->espconn->state != ESPCONN_CLOSE) {
            return rs;
        }
    } while (true);

    nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError,
        "no connection in queue"));
}
示例#2
0
/// \method delete()
/// Deinits the UART and removes its references so that it can be cleaned by the gc
STATIC mp_obj_t pyb_uart_delete(mp_obj_t self_in) {
    pyb_uart_obj_t *self = self_in;

    // deinit the peripheral
    pyb_uart_deinit(self);
    // remove it from the list
    mp_obj_list_remove(&MP_STATE_PORT(pyb_uart_list), self);

    return mp_const_none;
}
示例#3
0
STATIC mp_obj_t esp_socket_onconnect(mp_obj_t self_in, mp_obj_t lambda_in) {
    esp_socket_obj_t *s = self_in;
    s->cb_connect = lambda_in;

    if (s->connlist != NULL) {
        do {
            mp_uint_t len;
            mp_obj_t *items;

            mp_obj_list_get(s->connlist, &len, &items);
            if (len == 0) {
                break;
            }

            esp_socket_obj_t *rs = items[0];
            mp_obj_list_remove(s->connlist, rs);
            if (s->espconn->state != ESPCONN_CLOSE) {
                call_function_1_protected(s->cb_connect, rs);
            }
        } while (true);
    }

    return mp_const_none;
}
示例#4
0
void mp_irq_remove (const mp_obj_t parent) {
    mp_irq_obj_t *callback_obj;
    if ((callback_obj = mp_irq_find(parent))) {
        mp_obj_list_remove(&MP_STATE_PORT(mp_irq_obj_list), callback_obj);
    }
}
示例#5
0
void pyb_sleep_remove (const mp_obj_t obj) {
    pyb_sleep_obj_t *sleep_obj;
    if ((sleep_obj = pyb_sleep_find(obj))) {
        mp_obj_list_remove(&MP_STATE_PORT(pyb_sleep_obj_list), sleep_obj);
    }
}