Non-blocking send

This commit is contained in:
Ralf Schlatterbeck 2015-01-26 17:59:14 +01:00
parent 42f985a297
commit 301d8d77bb

View file

@ -201,15 +201,21 @@ PROCESS_THREAD(poti, ev, data)
val = (sum / 5) >> 2; val = (sum / 5) >> 2;
if ((interval > 0 && count > interval) || (val != lastval)) { if ((interval > 0 && count > interval) || (val != lastval)) {
char buf [4]; char buf [4];
coap_transaction_t *transaction;
sprintf (buf, "%d", val); sprintf (buf, "%d", val);
lastval = val; lastval = val;
printf ("Sending Value: %d\n", val); printf ("Sending Value: %d\n", val);
coap_init_message (request, COAP_TYPE_CON, COAP_PUT, 0); coap_init_message (request, COAP_TYPE_NON, COAP_PUT, 0);
coap_set_header_uri_path (request, server_resource); coap_set_header_uri_path (request, server_resource);
coap_set_header_content_format (request, REST.type.TEXT_PLAIN); coap_set_header_content_format (request, REST.type.TEXT_PLAIN);
coap_set_payload (request, buf, strlen (buf)); coap_set_payload (request, buf, strlen (buf));
COAP_BLOCKING_REQUEST request->mid = coap_get_mid ();
(&server_ipaddr, REMOTE_PORT, request, chunk_handler); transaction = coap_new_transaction
(request->mid, &server_ipaddr, REMOTE_PORT);
transaction->packet_len = coap_serialize_message
(request, transaction->packet);
coap_send_transaction (transaction);
count = 0; count = 0;
} }
etimer_reset (&loop_timer); etimer_reset (&loop_timer);