Ejemplo n.º 1
0
static void on_disconnect(void)
{
    if (waiton == DISCONNECT) {
        gateway.port = 0;
        result = EMCUTE_OK;
        thread_flags_set((thread_t *)timer.arg, TFLAGS_RESP);
    }
}
Ejemplo n.º 2
0
Archivo: rdcli.c Proyecto: kbumsik/RIOT
static void _on_update_remove(unsigned req_state, coap_pkt_t *pdu, uint8_t code)
{
    thread_flags_t flag = FLAG_ERR;

    if ((req_state == GCOAP_MEMO_RESP) && (pdu->hdr->code == code)) {
        flag = FLAG_SUCCESS;
    }
    else if (req_state == GCOAP_MEMO_TIMEOUT) {
        flag = FLAG_TIMEOUT;
    }

    thread_flags_set((thread_t *)_waiter, flag);
}
Ejemplo n.º 3
0
static void on_ack(uint8_t type, int id_pos, int ret_pos, int res_pos)
{
    if ((waiton == type) &&
        (!id_pos || (waitonid == byteorder_lebuftohs(&rbuf[id_pos])))) {
        if (!ret_pos || (rbuf[ret_pos] == ACCEPT)) {
            if (res_pos == 0) {
                result = EMCUTE_OK;
            } else {
                result = (int)byteorder_lebuftohs(&rbuf[res_pos]);
            }
        } else {
            result = EMCUTE_REJECT;
        }
        thread_flags_set((thread_t *)timer.arg, TFLAGS_RESP);
    }
}
Ejemplo n.º 4
0
Archivo: rdcli.c Proyecto: kbumsik/RIOT
static void _on_discover(unsigned req_state, coap_pkt_t *pdu,
                         sock_udp_ep_t *remote)
{
    thread_flags_t flag = RDCLI_NORD;
    (void)remote;

    if (req_state == GCOAP_MEMO_RESP) {
        unsigned ct = coap_get_content_type(pdu);
        if (ct != COAP_FORMAT_LINK) {
            goto end;
        }
        if (pdu->payload_len == 0) {
            goto end;
        }
        /* do simplified parsing of registration interface location */
        char *start = (char *)pdu->payload;
        char *end;
        char *limit = (char *)(pdu->payload + pdu->payload_len);
        while ((*start != '<') && (start < limit)) {
            start++;
        }
        if (*start != '<') {
            goto end;
        }
        end = ++start;
        while ((*end != '>') && (end < limit)) {
            end++;
        }
        if (*end != '>') {
            goto end;
        }
        /* TODO: verify size of interface resource identifier */
        size_t uri_len = (size_t)(end - start);
        if (uri_len >= _regif_buf_len) {
            goto end;
        }
        memcpy(_regif_buf, start, uri_len);
        memset((_regif_buf + uri_len), 0, (_regif_buf_len - uri_len));
        flag = FLAG_SUCCESS;
    }
    else if (req_state == GCOAP_MEMO_TIMEOUT) {
        flag = FLAG_TIMEOUT;
    }

end:
    thread_flags_set((thread_t *)_waiter, flag);
}
Ejemplo n.º 5
0
Archivo: rdcli.c Proyecto: kbumsik/RIOT
static void _on_register(unsigned req_state, coap_pkt_t* pdu,
                        sock_udp_ep_t *remote)
{
    thread_flags_t flag = FLAG_ERR;

    if ((req_state == GCOAP_MEMO_RESP) &&
        (pdu->hdr->code == COAP_CODE_CREATED)) {
        /* read the location header and save the RD details on success */
        if (coap_get_location_path(pdu, (uint8_t *)_rd_loc,
                                   sizeof(_rd_loc)) > 0) {
            memcpy(&_rd_remote, remote, sizeof(_rd_remote));
            flag = FLAG_SUCCESS;
        }
        else {
            /* reset RD entry */
            flag = FLAG_OVERFLOW;
        }
    }
    else if (req_state == GCOAP_MEMO_TIMEOUT) {
        flag = FLAG_TIMEOUT;
    }

    thread_flags_set((thread_t *)_waiter, flag);
}
Ejemplo n.º 6
0
static void time_evt(void *arg)
{
    thread_flags_set((thread_t *)arg, TFLAGS_TIMEOUT);
}
Ejemplo n.º 7
0
static void _set(thread_t *thread, thread_flags_t flags)
{
    printf("main(): setting flag 0x%04x\n", (unsigned)flags & 0xFFFF);
    thread_flags_set(thread, flags);
}
Ejemplo n.º 8
0
static void time_evt(void *arg)
{
    thread_flags_set((thread_t *)arg, 0x1);
}