diff --git a/examples/client.c b/examples/client.c index 6329ab3f..e391079b 100644 --- a/examples/client.c +++ b/examples/client.c @@ -86,6 +86,7 @@ coap_new_request( method_t m, coap_list_t *options ) { return NULL; pdu->hdr->type = COAP_MESSAGE_CON; + pdu->hdr->id = rand(); /* use a random transaction id */ pdu->hdr->code = m; for (opt = options; opt; opt = opt->next) { @@ -95,6 +96,8 @@ coap_new_request( method_t m, coap_list_t *options ) { } if (payload.length) { + /* TODO: must handle block */ + coap_add_data(pdu, payload.length, payload.s); } diff --git a/net.c b/net.c index 7a6bdde2..ffccfa5e 100644 --- a/net.c +++ b/net.c @@ -305,12 +305,8 @@ coap_send_impl( coap_context_t *context, const struct sockaddr_in6 *dst, coap_pd return ntohs(pdu->hdr->id); } -#define create_transaction_id(T) do { T = (unsigned short)rand(); } while ( T == COAP_INVALID_TID ); - coap_tid_t coap_send( coap_context_t *context, const struct sockaddr_in6 *dst, coap_pdu_t *pdu ) { - if ( ntohs(pdu->hdr->id) == COAP_INVALID_TID ) - create_transaction_id( pdu->hdr->id ); return coap_send_impl( context, dst, pdu, 1 ); } @@ -323,9 +319,6 @@ coap_tid_t coap_send_confirmed( coap_context_t *context, const struct sockaddr_in6 *dst, coap_pdu_t *pdu ) { coap_queue_t *node; - if ( ntohs(pdu->hdr->id) == COAP_INVALID_TID ) - create_transaction_id( pdu->hdr->id ); - /* send once, and enter into message queue for retransmission unless * retransmission counter is reached */ diff --git a/pdu.h b/pdu.h index 939a97a8..df1141af 100644 --- a/pdu.h +++ b/pdu.h @@ -95,8 +95,9 @@ #define COAP_MEDIATYPE_ANY 0xff /* any media type */ /* CoAP transaction id */ -typedef unsigned short coap_tid_t; -#define COAP_INVALID_TID 0 +/*typedef unsigned short coap_tid_t; */ +typedef int coap_tid_t; +#define COAP_INVALID_TID -1 #ifndef BYTE_ORDER # if (BSD >= 199103)