renamed coap packet to coap message - for naming closer to RFC

This commit is contained in:
Joakim Eriksson 2017-11-14 21:32:43 +01:00 committed by Niclas Finne
parent a866fcbfad
commit c86b763e5d
69 changed files with 417 additions and 394 deletions

View File

@ -76,7 +76,7 @@ static int uri_switch = 0;
/* This function is will be passed to COAP_BLOCKING_REQUEST() to handle responses. */ /* This function is will be passed to COAP_BLOCKING_REQUEST() to handle responses. */
void void
client_chunk_handler(coap_packet_t *response) client_chunk_handler(coap_message_t *response)
{ {
const uint8_t *chunk; const uint8_t *chunk;
@ -89,7 +89,7 @@ PROCESS_THREAD(er_example_client, ev, data)
coap_endpoint_t server_ep; coap_endpoint_t server_ep;
PROCESS_BEGIN(); PROCESS_BEGIN();
static coap_packet_t request[1]; /* This way the packet can be treated as pointer as usual. */ static coap_message_t request[1]; /* This way the packet can be treated as pointer as usual. */
/* SERVER_NODE(&server_ipaddr); */ /* SERVER_NODE(&server_ipaddr); */

View File

@ -41,8 +41,8 @@
#include "coap.h" #include "coap.h"
#include "plugtest.h" #include "plugtest.h"
static void res_put_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset); static void res_put_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
static void res_delete_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset); static void res_delete_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
RESOURCE(res_plugtest_create1, RESOURCE(res_plugtest_create1,
"title=\"Creates on PUT\"", "title=\"Creates on PUT\"",
@ -54,7 +54,7 @@ RESOURCE(res_plugtest_create1,
static uint8_t create1_exists = 0; static uint8_t create1_exists = 0;
static void static void
res_put_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset) res_put_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{ {
PRINTF("/create1 PUT"); PRINTF("/create1 PUT");
@ -71,7 +71,7 @@ res_put_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer
} }
} }
static void static void
res_delete_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset) res_delete_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{ {
PRINTF("/create1 DELETE "); PRINTF("/create1 DELETE ");
coap_set_status_code(response, DELETED_2_02); coap_set_status_code(response, DELETED_2_02);

View File

@ -41,7 +41,7 @@
#include "coap.h" #include "coap.h"
#include "plugtest.h" #include "plugtest.h"
static void res_post_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset); static void res_post_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
RESOURCE(res_plugtest_create2, RESOURCE(res_plugtest_create2,
"title=\"Creates on POST\"", "title=\"Creates on POST\"",
@ -51,7 +51,7 @@ RESOURCE(res_plugtest_create2,
NULL); NULL);
static void static void
res_post_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset) res_post_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{ {
PRINTF("/create2 "); PRINTF("/create2 ");

View File

@ -41,8 +41,8 @@
#include "coap.h" #include "coap.h"
#include "plugtest.h" #include "plugtest.h"
static void res_put_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset); static void res_put_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
static void res_delete_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset); static void res_delete_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
RESOURCE(res_plugtest_create3, RESOURCE(res_plugtest_create3,
"title=\"Default test resource\"", "title=\"Default test resource\"",
@ -54,7 +54,7 @@ RESOURCE(res_plugtest_create3,
static uint8_t create3_exists = 0; static uint8_t create3_exists = 0;
static void static void
res_put_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset) res_put_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{ {
PRINTF("/create3 PUT "); PRINTF("/create3 PUT ");
@ -71,7 +71,7 @@ res_put_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer
} }
} }
static void static void
res_delete_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset) res_delete_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{ {
PRINTF("/create3 DELETE "); PRINTF("/create3 DELETE ");
coap_set_status_code(response, DELETED_2_02); coap_set_status_code(response, DELETED_2_02);

View File

@ -41,7 +41,7 @@
#include "coap.h" #include "coap.h"
#include "plugtest.h" #include "plugtest.h"
static void res_post_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset); static void res_post_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
/* /*
* Large resource that can be created using POST method * Large resource that can be created using POST method
@ -54,9 +54,9 @@ RESOURCE(res_plugtest_large_create,
NULL); NULL);
static void static void
res_post_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset) res_post_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{ {
coap_packet_t *const coap_req = (coap_packet_t *)request; coap_message_t *const coap_req = (coap_message_t *)request;
uint8_t *incoming = NULL; uint8_t *incoming = NULL;
size_t len = 0; size_t len = 0;

View File

@ -43,8 +43,8 @@
#include "coap.h" #include "coap.h"
#include "plugtest.h" #include "plugtest.h"
static void res_get_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset); static void res_get_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
static void res_put_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset); static void res_put_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
RESOURCE( RESOURCE(
res_plugtest_large_update, res_plugtest_large_update,
@ -59,7 +59,7 @@ static uint8_t large_update_store[MAX_PLUGFEST_BODY] = { 0 };
static unsigned int large_update_ct = APPLICATION_OCTET_STREAM; static unsigned int large_update_ct = APPLICATION_OCTET_STREAM;
static void static void
res_get_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset) res_get_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{ {
/* Check the offset for boundaries of the resource data. */ /* Check the offset for boundaries of the resource data. */
if(*offset >= large_update_size) { if(*offset >= large_update_size) {
@ -84,9 +84,9 @@ res_get_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer
} }
} }
static void static void
res_put_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset) res_put_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{ {
coap_packet_t *const coap_req = (coap_packet_t *)request; coap_message_t *const coap_req = (coap_message_t *)request;
uint8_t *incoming = NULL; uint8_t *incoming = NULL;
size_t len = 0; size_t len = 0;

View File

@ -42,7 +42,7 @@
#include "coap.h" #include "coap.h"
#include "plugtest.h" #include "plugtest.h"
static void res_get_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset); static void res_get_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
RESOURCE(res_plugtest_large, RESOURCE(res_plugtest_large,
"title=\"Large resource\";rt=\"block\";sz=\"" TO_STRING(CHUNKS_TOTAL) "\"", "title=\"Large resource\";rt=\"block\";sz=\"" TO_STRING(CHUNKS_TOTAL) "\"",
@ -52,7 +52,7 @@ RESOURCE(res_plugtest_large,
NULL); NULL);
static void static void
res_get_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset) res_get_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{ {
int32_t strpos = 0; int32_t strpos = 0;

View File

@ -41,7 +41,7 @@
#include "coap.h" #include "coap.h"
#include "plugtest.h" #include "plugtest.h"
static void res_get_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset); static void res_get_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
RESOURCE(res_plugtest_link1, RESOURCE(res_plugtest_link1,
"rt=\"Type1 Type2\";if=\"If1\"", "rt=\"Type1 Type2\";if=\"If1\"",
@ -63,7 +63,7 @@ RESOURCE(res_plugtest_link3,
NULL); NULL);
static void static void
res_get_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset) res_get_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{ {
const char *msg = "Dummy link"; const char *msg = "Dummy link";
coap_set_header_content_format(response, TEXT_PLAIN); coap_set_header_content_format(response, TEXT_PLAIN);

View File

@ -41,7 +41,7 @@
#include "coap.h" #include "coap.h"
#include "plugtest.h" #include "plugtest.h"
static void res_post_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset); static void res_post_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
RESOURCE(res_plugtest_locquery, RESOURCE(res_plugtest_locquery,
"title=\"Resource accepting query parameters\"", "title=\"Resource accepting query parameters\"",
@ -51,10 +51,10 @@ RESOURCE(res_plugtest_locquery,
NULL); NULL);
static void static void
res_post_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset) res_post_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{ {
#if DEBUG #if DEBUG
coap_packet_t *const coap_req = (coap_packet_t *)request; coap_message_t *const coap_req = (coap_message_t *)request;
#endif #endif
PRINTF( PRINTF(

View File

@ -43,7 +43,7 @@
#include "coap.h" #include "coap.h"
#include "plugtest.h" #include "plugtest.h"
static void res_get_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset); static void res_get_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
RESOURCE(res_plugtest_longpath, RESOURCE(res_plugtest_longpath,
"title=\"Long path resource\"", "title=\"Long path resource\"",
@ -53,9 +53,9 @@ RESOURCE(res_plugtest_longpath,
NULL); NULL);
static void static void
res_get_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset) res_get_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{ {
coap_packet_t *const coap_req = (coap_packet_t *)request; coap_message_t *const coap_req = (coap_message_t *)request;
PRINTF("/seg1/seg2/seg3 GET "); PRINTF("/seg1/seg2/seg3 GET ");
/* Code 2.05 CONTENT is default. */ /* Code 2.05 CONTENT is default. */

View File

@ -42,7 +42,7 @@
#include "coap.h" #include "coap.h"
#include "plugtest.h" #include "plugtest.h"
static void res_get_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset); static void res_get_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
RESOURCE(res_plugtest_multi, RESOURCE(res_plugtest_multi,
"title=\"Resource providing text/plain and application/xml\";ct=\"0 41\"", "title=\"Resource providing text/plain and application/xml\";ct=\"0 41\"",
@ -52,9 +52,9 @@ RESOURCE(res_plugtest_multi,
NULL); NULL);
static void static void
res_get_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset) res_get_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{ {
coap_packet_t *const coap_req = (coap_packet_t *)request; coap_message_t *const coap_req = (coap_message_t *)request;
unsigned int accept = -1; unsigned int accept = -1;
coap_get_header_accept(request, &accept); coap_get_header_accept(request, &accept);

View File

@ -43,9 +43,9 @@
#include "coap-observe.h" #include "coap-observe.h"
#include "plugtest.h" #include "plugtest.h"
static void res_get_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset); static void res_get_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
static void res_put_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset); static void res_put_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
static void res_delete_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset); static void res_delete_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
static void res_periodic_handler(void); static void res_periodic_handler(void);
PERIODIC_RESOURCE(res_plugtest_obs, PERIODIC_RESOURCE(res_plugtest_obs,
@ -71,7 +71,7 @@ obs_purge_list()
coap_remove_observer_by_uri(NULL, res_plugtest_obs.url); coap_remove_observer_by_uri(NULL, res_plugtest_obs.url);
} }
static void static void
res_get_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset) res_get_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{ {
/* Keep server log clean from ticking events */ /* Keep server log clean from ticking events */
if(request != NULL) { if(request != NULL) {
@ -91,7 +91,7 @@ res_get_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer
/* A post_handler that handles subscriptions will be called for periodic resources by the CoAP framework. */ /* A post_handler that handles subscriptions will be called for periodic resources by the CoAP framework. */
} }
static void static void
res_put_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset) res_put_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{ {
uint8_t *incoming = NULL; uint8_t *incoming = NULL;
unsigned int ct = -1; unsigned int ct = -1;
@ -113,7 +113,7 @@ res_put_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer
coap_set_status_code(response, CHANGED_2_04); coap_set_status_code(response, CHANGED_2_04);
} }
static void static void
res_delete_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset) res_delete_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{ {
PRINTF("/obs DELETE\n"); PRINTF("/obs DELETE\n");

View File

@ -42,7 +42,7 @@
#include "coap.h" #include "coap.h"
#include "plugtest.h" #include "plugtest.h"
static void res_get_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset); static void res_get_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
PARENT_RESOURCE(res_plugtest_path, PARENT_RESOURCE(res_plugtest_path,
"title=\"Path test resource\";ct=\"40\"", "title=\"Path test resource\";ct=\"40\"",
@ -52,7 +52,7 @@ PARENT_RESOURCE(res_plugtest_path,
NULL); NULL);
static void static void
res_get_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, res_get_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer,
uint16_t preferred_size, int32_t *offset) uint16_t preferred_size, int32_t *offset)
{ {

View File

@ -42,7 +42,7 @@
#include "coap.h" #include "coap.h"
#include "plugtest.h" #include "plugtest.h"
static void res_get_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset); static void res_get_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
RESOURCE(res_plugtest_query, RESOURCE(res_plugtest_query,
"title=\"Resource accepting query parameters\"", "title=\"Resource accepting query parameters\"",
@ -52,9 +52,9 @@ RESOURCE(res_plugtest_query,
NULL); NULL);
static void static void
res_get_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset) res_get_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{ {
coap_packet_t *const coap_req = (coap_packet_t *)request; coap_message_t *const coap_req = (coap_message_t *)request;
int len = 0; int len = 0;
const char *query = NULL; const char *query = NULL;

View File

@ -44,7 +44,7 @@
#include "coap-separate.h" #include "coap-separate.h"
#include "plugtest.h" #include "plugtest.h"
static void res_get_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset); static void res_get_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
static void res_resume_handler(void); static void res_resume_handler(void);
PERIODIC_RESOURCE(res_plugtest_separate, PERIODIC_RESOURCE(res_plugtest_separate,
@ -68,9 +68,9 @@ static uint8_t separate_active = 0;
static application_separate_store_t separate_store[1]; static application_separate_store_t separate_store[1];
void void
res_get_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset) res_get_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{ {
coap_packet_t *const coap_req = (coap_packet_t *)request; coap_message_t *const coap_req = (coap_message_t *)request;
PRINTF("/separate "); PRINTF("/separate ");
if(separate_active) { if(separate_active) {
@ -102,7 +102,7 @@ res_resume_handler()
PRINTF( PRINTF(
"RESPONSE (%s %u)\n", separate_store->request_metadata.type == COAP_TYPE_CON ? "CON" : "NON", separate_store->request_metadata.mid); "RESPONSE (%s %u)\n", separate_store->request_metadata.type == COAP_TYPE_CON ? "CON" : "NON", separate_store->request_metadata.mid);
coap_packet_t response[1]; /* This way the packet can be treated as pointer as usual. */ coap_message_t response[1]; /* This way the message can be treated as pointer as usual. */
/* Restore the request information for the response. */ /* Restore the request information for the response. */
coap_separate_resume(response, &separate_store->request_metadata, CONTENT_2_05); coap_separate_resume(response, &separate_store->request_metadata, CONTENT_2_05);
@ -120,8 +120,8 @@ res_resume_handler()
separate_store->request_metadata.block2_size); separate_store->request_metadata.block2_size);
/* Warning: No check for serialization error. */ /* Warning: No check for serialization error. */
transaction->packet_len = coap_serialize_message(response, transaction->message_len = coap_serialize_message(response,
transaction->packet); transaction->message);
coap_send_transaction(transaction); coap_send_transaction(transaction);
/* The engine will clear the transaction (right after send for NON, after acked for CON). */ /* The engine will clear the transaction (right after send for NON, after acked for CON). */

View File

@ -43,10 +43,10 @@
#include "plugtest.h" #include "plugtest.h"
#include "random.h" #include "random.h"
static void res_get_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset); static void res_get_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
static void res_post_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset); static void res_post_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
static void res_put_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset); static void res_put_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
static void res_delete_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset); static void res_delete_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
RESOURCE(res_plugtest_test, "title=\"Default test resource\"", res_get_handler, res_post_handler, res_put_handler, res_delete_handler); RESOURCE(res_plugtest_test, "title=\"Default test resource\"", res_get_handler, res_post_handler, res_put_handler, res_delete_handler);
@ -71,9 +71,9 @@ test_update_etag()
PRINTF("### SERVER ACTION ### Changed ETag %u [0x%02X%02X%02X%02X%02X%02X%02X%02X]\n", test_etag_len, test_etag[0], test_etag[1], test_etag[2], test_etag[3], test_etag[4], test_etag[5], test_etag[6], test_etag[7]); PRINTF("### SERVER ACTION ### Changed ETag %u [0x%02X%02X%02X%02X%02X%02X%02X%02X]\n", test_etag_len, test_etag[0], test_etag[1], test_etag[2], test_etag[3], test_etag[4], test_etag[5], test_etag[6], test_etag[7]);
} }
static void static void
res_get_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset) res_get_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{ {
coap_packet_t *const coap_req = (coap_packet_t *)request; coap_message_t *const coap_req = (coap_message_t *)request;
if(test_change) { if(test_change) {
test_update_etag(); test_update_etag();
@ -101,20 +101,20 @@ res_get_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer
} }
} }
static void static void
res_post_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset) res_post_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{ {
#if DEBUG #if DEBUG
coap_packet_t *const coap_req = (coap_packet_t *)request; coap_message_t *const coap_req = (coap_message_t *)request;
PRINTF("/test POST (%s %u)\n", coap_req->type == COAP_TYPE_CON ? "CON" : "NON", coap_req->mid); PRINTF("/test POST (%s %u)\n", coap_req->type == COAP_TYPE_CON ? "CON" : "NON", coap_req->mid);
#endif #endif
coap_set_status_code(response, CREATED_2_01); coap_set_status_code(response, CREATED_2_01);
coap_set_header_location_path(response, "/location1/location2/location3"); coap_set_header_location_path(response, "/location1/location2/location3");
} }
static void static void
res_put_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset) res_put_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{ {
#if DEBUG #if DEBUG
coap_packet_t *const coap_req = (coap_packet_t *)request; coap_message_t *const coap_req = (coap_message_t *)request;
PRINTF("/test PUT (%s %u)\n", coap_req->type == COAP_TYPE_CON ? "CON" : "NON", coap_req->mid); PRINTF("/test PUT (%s %u)\n", coap_req->type == COAP_TYPE_CON ? "CON" : "NON", coap_req->mid);
#endif #endif
@ -154,10 +154,10 @@ res_put_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer
} }
} }
static void static void
res_delete_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset) res_delete_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{ {
#if DEBUG #if DEBUG
coap_packet_t *const coap_req = (coap_packet_t *)request; coap_message_t *const coap_req = (coap_message_t *)request;
PRINTF("/test DELETE (%s %u)\n", coap_req->type == COAP_TYPE_CON ? "CON" : "NON", coap_req->mid); PRINTF("/test DELETE (%s %u)\n", coap_req->type == COAP_TYPE_CON ? "CON" : "NON", coap_req->mid);
#endif #endif
coap_set_status_code(response, DELETED_2_02); coap_set_status_code(response, DELETED_2_02);

View File

@ -43,8 +43,8 @@
#include "plugtest.h" #include "plugtest.h"
#include "random.h" #include "random.h"
static void res_get_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset); static void res_get_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
static void res_put_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset); static void res_put_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
RESOURCE(res_plugtest_validate, RESOURCE(res_plugtest_validate,
"title=\"Validation test resource\"", "title=\"Validation test resource\"",
@ -74,9 +74,9 @@ validate_update_etag()
validate_etag_len, validate_etag[0], validate_etag[1], validate_etag[2], validate_etag[3], validate_etag[4], validate_etag[5], validate_etag[6], validate_etag[7]); validate_etag_len, validate_etag[0], validate_etag[1], validate_etag[2], validate_etag[3], validate_etag[4], validate_etag[5], validate_etag[6], validate_etag[7]);
} }
static void static void
res_get_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset) res_get_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{ {
coap_packet_t *const coap_req = (coap_packet_t *)request; coap_message_t *const coap_req = (coap_message_t *)request;
if(validate_change) { if(validate_change) {
validate_update_etag(); validate_update_etag();
@ -106,10 +106,10 @@ res_get_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer
} }
} }
static void static void
res_put_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset) res_put_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{ {
#if DEBUG #if DEBUG
coap_packet_t *const coap_req = (coap_packet_t *)request; coap_message_t *const coap_req = (coap_message_t *)request;
#endif #endif
PRINTF("/validate PUT "); PRINTF("/validate PUT ");

View File

@ -43,7 +43,7 @@
#include "coap-separate.h" #include "coap-separate.h"
#include "coap-transactions.h" #include "coap-transactions.h"
static void res_post_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset); static void res_post_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
SEPARATE_RESOURCE(res_b1_sep_b2, "title=\"Block1 + Separate + Block2 demo\"", NULL, res_post_handler, NULL, NULL, NULL); SEPARATE_RESOURCE(res_b1_sep_b2, "title=\"Block1 + Separate + Block2 demo\"", NULL, res_post_handler, NULL, NULL, NULL);
#define MAX_DATA_LEN 256 #define MAX_DATA_LEN 256
@ -53,7 +53,7 @@ static size_t big_msg_len = 0;
static coap_separate_t request_metadata; static coap_separate_t request_metadata;
static void static void
res_post_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset) res_post_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{ {
/* Example allows only one request on time. There are no checks for multiply access !!! */ /* Example allows only one request on time. There are no checks for multiply access !!! */
if(*offset == 0) { if(*offset == 0) {
@ -77,7 +77,7 @@ res_post_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffe
/* Send first block */ /* Send first block */
coap_transaction_t *transaction = NULL; coap_transaction_t *transaction = NULL;
if((transaction = coap_new_transaction(request_metadata.mid, &request_metadata.endpoint))) { if((transaction = coap_new_transaction(request_metadata.mid, &request_metadata.endpoint))) {
coap_packet_t resp[1]; /* This way the packet can be treated as pointer as usual. */ coap_message_t resp[1]; /* This way the message can be treated as pointer as usual. */
/* Restore the request information for the response. */ /* Restore the request information for the response. */
coap_separate_resume(resp, &request_metadata, CONTENT_2_05); coap_separate_resume(resp, &request_metadata, CONTENT_2_05);
@ -89,7 +89,7 @@ res_post_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffe
} }
/* Warning: No check for serialization error. */ /* Warning: No check for serialization error. */
transaction->packet_len = coap_serialize_message(resp, transaction->packet); transaction->message_len = coap_serialize_message(resp, transaction->message);
coap_send_transaction(transaction); coap_send_transaction(transaction);
} }
} else { } else {

View File

@ -45,7 +45,7 @@
#include "coap-engine.h" #include "coap-engine.h"
#include "dev/battery-sensor.h" #include "dev/battery-sensor.h"
static void res_get_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset); static void res_get_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
/* A simple getter example. Returns the reading from light sensor with a simple etag */ /* A simple getter example. Returns the reading from light sensor with a simple etag */
RESOURCE(res_battery, RESOURCE(res_battery,
@ -56,7 +56,7 @@ RESOURCE(res_battery,
NULL); NULL);
static void static void
res_get_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset) res_get_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{ {
int battery = battery_sensor.value(0); int battery = battery_sensor.value(0);

View File

@ -40,7 +40,7 @@
#include <string.h> #include <string.h>
#include "coap-engine.h" #include "coap-engine.h"
static void res_get_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset); static void res_get_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
/* /*
* For data larger than COAP_MAX_CHUNK_SIZE (e.g., when stored in flash) resources must be aware of the buffer limitation * For data larger than COAP_MAX_CHUNK_SIZE (e.g., when stored in flash) resources must be aware of the buffer limitation
@ -59,7 +59,7 @@ RESOURCE(res_chunks,
#define CHUNKS_TOTAL 2050 #define CHUNKS_TOTAL 2050
static void static void
res_get_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset) res_get_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{ {
int32_t strpos = 0; int32_t strpos = 0;

View File

@ -53,7 +53,7 @@
#define PRINTLLADDR(addr) #define PRINTLLADDR(addr)
#endif #endif
static void res_get_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset); static void res_get_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
static void res_event_handler(void); static void res_event_handler(void);
/* /*
@ -75,7 +75,7 @@ EVENT_RESOURCE(res_event,
static int32_t event_counter = 0; static int32_t event_counter = 0;
static void static void
res_get_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset) res_get_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{ {
coap_set_header_content_format(response, TEXT_PLAIN); coap_set_header_content_format(response, TEXT_PLAIN);
coap_set_payload(response, buffer, snprintf((char *)buffer, preferred_size, "EVENT %lu", (unsigned long) event_counter)); coap_set_payload(response, buffer, snprintf((char *)buffer, preferred_size, "EVENT %lu", (unsigned long) event_counter));

View File

@ -40,7 +40,7 @@
#include <string.h> #include <string.h>
#include "coap-engine.h" #include "coap-engine.h"
static void res_get_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset); static void res_get_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
/* /*
* A handler function named [resource name]_handler must be implemented for each RESOURCE. * A handler function named [resource name]_handler must be implemented for each RESOURCE.
@ -56,7 +56,7 @@ RESOURCE(res_hello,
NULL); NULL);
static void static void
res_get_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset) res_get_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{ {
const char *len = NULL; const char *len = NULL;
/* Some data that has the length up to REST_MAX_CHUNK_SIZE. For more, see the chunk resource. */ /* Some data that has the length up to REST_MAX_CHUNK_SIZE. For more, see the chunk resource. */

View File

@ -55,7 +55,7 @@
#define PRINTLLADDR(addr) #define PRINTLLADDR(addr)
#endif #endif
static void res_post_put_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset); static void res_post_put_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
/* A simple actuator example, depending on the color query parameter and post variable mode, corresponding led is activated or deactivated */ /* A simple actuator example, depending on the color query parameter and post variable mode, corresponding led is activated or deactivated */
RESOURCE(res_leds, RESOURCE(res_leds,
@ -66,7 +66,7 @@ RESOURCE(res_leds,
NULL); NULL);
static void static void
res_post_put_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset) res_post_put_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{ {
size_t len = 0; size_t len = 0;
const char *color = NULL; const char *color = NULL;

View File

@ -45,7 +45,7 @@
#include "coap-engine.h" #include "coap-engine.h"
#include "dev/light-sensor.h" #include "dev/light-sensor.h"
static void res_get_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset); static void res_get_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
/* A simple getter example. Returns the reading from light sensor with a simple etag */ /* A simple getter example. Returns the reading from light sensor with a simple etag */
RESOURCE(res_light, RESOURCE(res_light,
@ -56,7 +56,7 @@ RESOURCE(res_light,
NULL); NULL);
static void static void
res_get_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset) res_get_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{ {
uint16_t light_photosynthetic = light_sensor.value(LIGHT_SENSOR_PHOTOSYNTHETIC); uint16_t light_photosynthetic = light_sensor.value(LIGHT_SENSOR_PHOTOSYNTHETIC);
uint16_t light_solar = light_sensor.value(LIGHT_SENSOR_TOTAL_SOLAR); uint16_t light_solar = light_sensor.value(LIGHT_SENSOR_TOTAL_SOLAR);

View File

@ -53,7 +53,7 @@
#define PRINTLLADDR(addr) #define PRINTLLADDR(addr)
#endif #endif
static void res_any_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset); static void res_any_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
/* This resource mirrors the incoming request. It shows how to access the options and how to set them for the response. */ /* This resource mirrors the incoming request. It shows how to access the options and how to set them for the response. */
RESOURCE(res_mirror, RESOURCE(res_mirror,
@ -64,7 +64,7 @@ RESOURCE(res_mirror,
res_any_handler); res_any_handler);
static void static void
res_any_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset) res_any_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{ {
/* The ETag and Token is copied to the header. */ /* The ETag and Token is copied to the header. */
uint8_t opaque[] = { 0x0A, 0xBC, 0xDE }; uint8_t opaque[] = { 0x0A, 0xBC, 0xDE };
@ -122,7 +122,7 @@ res_any_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer
strpos += snprintf((char *)buffer + strpos, REST_MAX_CHUNK_SIZE - strpos + 1, "LQ %.*s\n", len, str); strpos += snprintf((char *)buffer + strpos, REST_MAX_CHUNK_SIZE - strpos + 1, "LQ %.*s\n", len, str);
/* CoAP-specific example: actions not required for normal RESTful Web service. */ /* CoAP-specific example: actions not required for normal RESTful Web service. */
} }
coap_packet_t *const coap_pkt = (coap_packet_t *)request; coap_message_t *const coap_pkt = (coap_message_t *)request;
if(strpos <= REST_MAX_CHUNK_SIZE && coap_pkt->token_len > 0) { if(strpos <= REST_MAX_CHUNK_SIZE && coap_pkt->token_len > 0) {
strpos += snprintf((char *)buffer + strpos, REST_MAX_CHUNK_SIZE - strpos + 1, "To 0x"); strpos += snprintf((char *)buffer + strpos, REST_MAX_CHUNK_SIZE - strpos + 1, "To 0x");

View File

@ -41,7 +41,7 @@
#include "coap-engine.h" #include "coap-engine.h"
#include "coap.h" #include "coap.h"
static void res_get_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset); static void res_get_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
static void res_periodic_handler(void); static void res_periodic_handler(void);
PERIODIC_RESOURCE(res_push, PERIODIC_RESOURCE(res_push,
@ -59,7 +59,7 @@ PERIODIC_RESOURCE(res_push,
static int32_t event_counter = 0; static int32_t event_counter = 0;
static void static void
res_get_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset) res_get_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{ {
/* /*
* For minimal complexity, request query and options should be ignored for GET on observable resources. * For minimal complexity, request query and options should be ignored for GET on observable resources.

View File

@ -44,7 +44,7 @@
#include "coap-engine.h" #include "coap-engine.h"
#include "net/netstack.h" #include "net/netstack.h"
static void res_get_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset); static void res_get_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
/* A simple getter example. Returns the reading of the rssi/lqi from radio sensor */ /* A simple getter example. Returns the reading of the rssi/lqi from radio sensor */
RESOURCE(res_radio, RESOURCE(res_radio,
@ -55,7 +55,7 @@ RESOURCE(res_radio,
NULL); NULL);
static void static void
res_get_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset) res_get_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{ {
size_t len = 0; size_t len = 0;
const char *p = NULL; const char *p = NULL;

View File

@ -42,7 +42,7 @@
#include "coap-separate.h" #include "coap-separate.h"
#include "coap-transactions.h" #include "coap-transactions.h"
static void res_get_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset); static void res_get_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
static void res_resume_handler(void); static void res_resume_handler(void);
SEPARATE_RESOURCE(res_separate, SEPARATE_RESOURCE(res_separate,
@ -69,7 +69,7 @@ static uint8_t separate_active = 0;
static application_separate_store_t separate_store[COAP_MAX_OPEN_SEPARATE]; static application_separate_store_t separate_store[COAP_MAX_OPEN_SEPARATE];
static void static void
res_get_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset) res_get_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{ {
/* /*
* Example allows only one open separate response. * Example allows only one open separate response.
@ -98,7 +98,7 @@ res_resume_handler()
if(separate_active) { if(separate_active) {
coap_transaction_t *transaction = NULL; coap_transaction_t *transaction = NULL;
if((transaction = coap_new_transaction(separate_store->request_metadata.mid, &separate_store->request_metadata.endpoint))) { if((transaction = coap_new_transaction(separate_store->request_metadata.mid, &separate_store->request_metadata.endpoint))) {
coap_packet_t response[1]; /* This way the packet can be treated as pointer as usual. */ coap_message_t response[1]; /* This way the message can be treated as pointer as usual. */
/* Restore the request information for the response. */ /* Restore the request information for the response. */
coap_separate_resume(response, &separate_store->request_metadata, CONTENT_2_05); coap_separate_resume(response, &separate_store->request_metadata, CONTENT_2_05);
@ -112,7 +112,7 @@ res_resume_handler()
coap_set_header_block2(response, separate_store->request_metadata.block2_num, 0, separate_store->request_metadata.block2_size); coap_set_header_block2(response, separate_store->request_metadata.block2_num, 0, separate_store->request_metadata.block2_size);
/* Warning: No check for serialization error. */ /* Warning: No check for serialization error. */
transaction->packet_len = coap_serialize_message(response, transaction->packet); transaction->message_len = coap_serialize_message(response, transaction->message);
coap_send_transaction(transaction); coap_send_transaction(transaction);
/* The engine will clear the transaction (right after send for NON, after acked for CON). */ /* The engine will clear the transaction (right after send for NON, after acked for CON). */

View File

@ -48,7 +48,7 @@
#include "coap-engine.h" #include "coap-engine.h"
#include "dev/sht11/sht11-sensor.h" #include "dev/sht11/sht11-sensor.h"
static void res_get_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset); static void res_get_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
/* Get Method Example. Returns the reading from temperature and humidity sensors. */ /* Get Method Example. Returns the reading from temperature and humidity sensors. */
RESOURCE(res_sht11, RESOURCE(res_sht11,
@ -59,7 +59,7 @@ RESOURCE(res_sht11,
NULL); NULL);
static void static void
res_get_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset) res_get_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{ {
/* Temperature in Celsius (t in 14 bits resolution at 3 Volts) /* Temperature in Celsius (t in 14 bits resolution at 3 Volts)
* T = -39.60 + 0.01*t * T = -39.60 + 0.01*t

View File

@ -40,7 +40,7 @@
#include <string.h> #include <string.h>
#include "coap-engine.h" #include "coap-engine.h"
static void res_get_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset); static void res_get_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
/* /*
* Example for a resource that also handles all its sub-resources. * Example for a resource that also handles all its sub-resources.
@ -54,7 +54,7 @@ PARENT_RESOURCE(res_sub,
NULL); NULL);
static void static void
res_get_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset) res_get_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{ {
coap_set_header_content_format(response, TEXT_PLAIN); coap_set_header_content_format(response, TEXT_PLAIN);

View File

@ -49,7 +49,7 @@
#include "coap-engine.h" #include "coap-engine.h"
#include "dev/temperature-sensor.h" #include "dev/temperature-sensor.h"
static void res_get_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset); static void res_get_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
static void res_periodic_handler(void); static void res_periodic_handler(void);
#define MAX_AGE 60 #define MAX_AGE 60
@ -70,7 +70,7 @@ PERIODIC_RESOURCE(res_temperature,
res_periodic_handler); res_periodic_handler);
static void static void
res_get_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset) res_get_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{ {
/* /*
* For minimal complexity, request query and options should be ignored for GET on observable resources. * For minimal complexity, request query and options should be ignored for GET on observable resources.

View File

@ -45,7 +45,7 @@
#include "coap-engine.h" #include "coap-engine.h"
#include "dev/leds.h" #include "dev/leds.h"
static void res_post_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset); static void res_post_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
/* A simple actuator example. Toggles the red led */ /* A simple actuator example. Toggles the red led */
RESOURCE(res_toggle, RESOURCE(res_toggle,
@ -56,7 +56,7 @@ RESOURCE(res_toggle,
NULL); NULL);
static void static void
res_post_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset) res_post_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{ {
leds_toggle(LEDS_RED); leds_toggle(LEDS_RED);
} }

View File

@ -257,8 +257,8 @@ setup_network(void)
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
PROCESS_THREAD(router_process, ev, data) PROCESS_THREAD(router_process, ev, data)
{ {
/* This way the packet can be treated as pointer as usual. */ /* This way the message can be treated as pointer as usual. */
static coap_packet_t request[1]; static coap_message_t request[1];
static struct etimer timer; static struct etimer timer;
uip_ds6_route_t *r; uip_ds6_route_t *r;
uip_ipaddr_t *nexthop; uip_ipaddr_t *nexthop;

View File

@ -49,7 +49,7 @@ const char *forbidden_payload = "Name to advertise unspecified.\n"
"Use name=<name> in the request"; "Use name=<name> in the request";
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static void static void
res_ble_post_put_handler(coap_packet_t *request, coap_packet_t *response, res_ble_post_put_handler(coap_message_t *request, coap_message_t *response,
uint8_t *buffer, uint8_t *buffer,
uint16_t preferred_size, int32_t *offset) uint16_t preferred_size, int32_t *offset)
{ {

View File

@ -75,7 +75,7 @@ detect_chip(void)
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static void static void
res_get_handler_hw(coap_packet_t *request, coap_packet_t *response, res_get_handler_hw(coap_message_t *request, coap_message_t *response,
uint8_t *buffer, uint8_t *buffer,
uint16_t preferred_size, int32_t *offset) uint16_t preferred_size, int32_t *offset)
{ {
@ -111,7 +111,7 @@ res_get_handler_hw(coap_packet_t *request, coap_packet_t *response,
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static void static void
res_get_handler_sw(coap_packet_t *request, coap_packet_t *response, res_get_handler_sw(coap_message_t *request, coap_message_t *response,
uint8_t *buffer, uint8_t *buffer,
uint16_t preferred_size, int32_t *offset) uint16_t preferred_size, int32_t *offset)
{ {
@ -144,7 +144,7 @@ res_get_handler_sw(coap_packet_t *request, coap_packet_t *response,
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static void static void
res_get_handler_uptime(coap_packet_t *request, coap_packet_t *response, res_get_handler_uptime(coap_message_t *request, coap_message_t *response,
uint8_t *buffer, uint8_t *buffer,
uint16_t preferred_size, int32_t *offset) uint16_t preferred_size, int32_t *offset)
{ {
@ -177,7 +177,7 @@ res_get_handler_uptime(coap_packet_t *request, coap_packet_t *response,
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static void static void
res_post_handler_cfg_reset(coap_packet_t *request, coap_packet_t *response, res_post_handler_cfg_reset(coap_message_t *request, coap_message_t *response,
uint8_t *buffer, uint8_t *buffer,
uint16_t preferred_size, int32_t *offset) uint16_t preferred_size, int32_t *offset)
{ {

View File

@ -46,7 +46,7 @@
#include <string.h> #include <string.h>
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static void static void
res_post_put_handler(coap_packet_t *request, coap_packet_t *response, res_post_put_handler(coap_message_t *request, coap_message_t *response,
uint8_t *buffer, uint8_t *buffer,
uint16_t preferred_size, int32_t *offset) uint16_t preferred_size, int32_t *offset)
{ {

View File

@ -51,7 +51,7 @@
extern int def_rt_rssi; extern int def_rt_rssi;
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static void static void
res_get_handler_parent_rssi(coap_packet_t *request, coap_packet_t *response, res_get_handler_parent_rssi(coap_message_t *request, coap_message_t *response,
uint8_t *buffer, uint8_t *buffer,
uint16_t preferred_size, int32_t *offset) uint16_t preferred_size, int32_t *offset)
{ {
@ -84,7 +84,7 @@ res_get_handler_parent_rssi(coap_packet_t *request, coap_packet_t *response,
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static void static void
res_get_handler_pref_parent(coap_packet_t *request, coap_packet_t *response, res_get_handler_pref_parent(coap_message_t *request, coap_message_t *response,
uint8_t *buffer, uint8_t *buffer,
uint16_t preferred_size, int32_t *offset) uint16_t preferred_size, int32_t *offset)
{ {

View File

@ -51,8 +51,8 @@
* called by all handlers and populates the CoAP response * called by all handlers and populates the CoAP response
*/ */
static void static void
res_get_handler_all(int sens_type, coap_packet_t *request, res_get_handler_all(int sens_type, coap_message_t *request,
coap_packet_t *response, coap_message_t *response,
uint8_t *buffer, uint16_t preferred_size, int32_t *offset) uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{ {
unsigned int accept = -1; unsigned int accept = -1;
@ -97,7 +97,7 @@ res_get_handler_all(int sens_type, coap_packet_t *request,
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/* BatMon resources and handler: Temperature, Voltage */ /* BatMon resources and handler: Temperature, Voltage */
static void static void
res_get_handler_batmon_temp(coap_packet_t *request, coap_packet_t *response, res_get_handler_batmon_temp(coap_message_t *request, coap_message_t *response,
uint8_t *buffer, uint8_t *buffer,
uint16_t preferred_size, int32_t *offset) uint16_t preferred_size, int32_t *offset)
{ {
@ -106,7 +106,7 @@ res_get_handler_batmon_temp(coap_packet_t *request, coap_packet_t *response,
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static void static void
res_get_handler_batmon_volt(coap_packet_t *request, coap_packet_t *response, res_get_handler_batmon_volt(coap_message_t *request, coap_message_t *response,
uint8_t *buffer, uint8_t *buffer,
uint16_t preferred_size, int32_t *offset) uint16_t preferred_size, int32_t *offset)
{ {
@ -123,7 +123,7 @@ RESOURCE(res_batmon_volt, "title=\"Battery Voltage\";rt=\"mV\"",
#if CC26XX_WEB_DEMO_ADC_DEMO #if CC26XX_WEB_DEMO_ADC_DEMO
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static void static void
res_get_handler_adc_dio23(coap_packet_t *request, coap_packet_t *response, res_get_handler_adc_dio23(coap_message_t *request, coap_message_t *response,
uint8_t *buffer, uint8_t *buffer,
uint16_t preferred_size, int32_t *offset) uint16_t preferred_size, int32_t *offset)
{ {
@ -140,7 +140,7 @@ RESOURCE(res_adc_dio23, "title=\"ADC DIO23\";rt=\"mV\"",
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/* MPU resources and handler: Accelerometer and Gyro */ /* MPU resources and handler: Accelerometer and Gyro */
static void static void
res_get_handler_mpu_acc_x(coap_packet_t *request, coap_packet_t *response, res_get_handler_mpu_acc_x(coap_message_t *request, coap_message_t *response,
uint8_t *buffer, uint8_t *buffer,
uint16_t preferred_size, int32_t *offset) uint16_t preferred_size, int32_t *offset)
{ {
@ -149,7 +149,7 @@ res_get_handler_mpu_acc_x(coap_packet_t *request, coap_packet_t *response,
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static void static void
res_get_handler_mpu_acc_y(coap_packet_t *request, coap_packet_t *response, res_get_handler_mpu_acc_y(coap_message_t *request, coap_message_t *response,
uint8_t *buffer, uint8_t *buffer,
uint16_t preferred_size, int32_t *offset) uint16_t preferred_size, int32_t *offset)
{ {
@ -158,7 +158,7 @@ res_get_handler_mpu_acc_y(coap_packet_t *request, coap_packet_t *response,
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static void static void
res_get_handler_mpu_acc_z(coap_packet_t *request, coap_packet_t *response, res_get_handler_mpu_acc_z(coap_message_t *request, coap_message_t *response,
uint8_t *buffer, uint8_t *buffer,
uint16_t preferred_size, int32_t *offset) uint16_t preferred_size, int32_t *offset)
{ {
@ -167,7 +167,7 @@ res_get_handler_mpu_acc_z(coap_packet_t *request, coap_packet_t *response,
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static void static void
res_get_handler_mpu_gyro_x(coap_packet_t *request, coap_packet_t *response, res_get_handler_mpu_gyro_x(coap_message_t *request, coap_message_t *response,
uint8_t *buffer, uint8_t *buffer,
uint16_t preferred_size, int32_t *offset) uint16_t preferred_size, int32_t *offset)
{ {
@ -176,7 +176,7 @@ res_get_handler_mpu_gyro_x(coap_packet_t *request, coap_packet_t *response,
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static void static void
res_get_handler_mpu_gyro_y(coap_packet_t *request, coap_packet_t *response, res_get_handler_mpu_gyro_y(coap_message_t *request, coap_message_t *response,
uint8_t *buffer, uint8_t *buffer,
uint16_t preferred_size, int32_t *offset) uint16_t preferred_size, int32_t *offset)
{ {
@ -185,7 +185,7 @@ res_get_handler_mpu_gyro_y(coap_packet_t *request, coap_packet_t *response,
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static void static void
res_get_handler_mpu_gyro_z(coap_packet_t *request, coap_packet_t *response, res_get_handler_mpu_gyro_z(coap_message_t *request, coap_message_t *response,
uint8_t *buffer, uint8_t *buffer,
uint16_t preferred_size, int32_t *offset) uint16_t preferred_size, int32_t *offset)
{ {
@ -209,7 +209,7 @@ RESOURCE(res_mpu_gyro_z, "title=\"Gyro Z\";rt=\"deg/sec\"",
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/* TMP sensor resources and handlers: Object, Ambient */ /* TMP sensor resources and handlers: Object, Ambient */
static void static void
res_get_handler_obj_temp(coap_packet_t *request, coap_packet_t *response, res_get_handler_obj_temp(coap_message_t *request, coap_message_t *response,
uint8_t *buffer, uint8_t *buffer,
uint16_t preferred_size, int32_t *offset) uint16_t preferred_size, int32_t *offset)
{ {
@ -218,7 +218,7 @@ res_get_handler_obj_temp(coap_packet_t *request, coap_packet_t *response,
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static void static void
res_get_handler_amb_temp(coap_packet_t *request, coap_packet_t *response, res_get_handler_amb_temp(coap_message_t *request, coap_message_t *response,
uint8_t *buffer, uint8_t *buffer,
uint16_t preferred_size, int32_t *offset) uint16_t preferred_size, int32_t *offset)
{ {
@ -234,7 +234,7 @@ RESOURCE(res_tmp007_amb, "title=\"Temperature (Ambient)\";rt=\"C\"",
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/* BMP sensor resources: Temperature, Pressure */ /* BMP sensor resources: Temperature, Pressure */
static void static void
res_get_handler_bmp_temp(coap_packet_t *request, coap_packet_t *response, res_get_handler_bmp_temp(coap_message_t *request, coap_message_t *response,
uint8_t *buffer, uint8_t *buffer,
uint16_t preferred_size, int32_t *offset) uint16_t preferred_size, int32_t *offset)
{ {
@ -243,7 +243,7 @@ res_get_handler_bmp_temp(coap_packet_t *request, coap_packet_t *response,
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static void static void
res_get_handler_bmp_press(coap_packet_t *request, coap_packet_t *response, res_get_handler_bmp_press(coap_message_t *request, coap_message_t *response,
uint8_t *buffer, uint8_t *buffer,
uint16_t preferred_size, int32_t *offset) uint16_t preferred_size, int32_t *offset)
{ {
@ -260,7 +260,7 @@ RESOURCE(res_bmp280_press,
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/* HDC1000 sensor resources and handler: Temperature, Pressure */ /* HDC1000 sensor resources and handler: Temperature, Pressure */
static void static void
res_get_handler_hdc_temp(coap_packet_t *request, coap_packet_t *response, res_get_handler_hdc_temp(coap_message_t *request, coap_message_t *response,
uint8_t *buffer, uint8_t *buffer,
uint16_t preferred_size, int32_t *offset) uint16_t preferred_size, int32_t *offset)
{ {
@ -269,7 +269,7 @@ res_get_handler_hdc_temp(coap_packet_t *request, coap_packet_t *response,
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static void static void
res_get_handler_hdc_humidity(coap_packet_t *request, coap_packet_t *response, res_get_handler_hdc_humidity(coap_message_t *request, coap_message_t *response,
uint8_t *buffer, uint8_t *buffer,
uint16_t preferred_size, int32_t *offset) uint16_t preferred_size, int32_t *offset)
{ {
@ -285,7 +285,7 @@ RESOURCE(res_hdc1000_hum, "title=\"Humidity\";rt=\"%RH\"",
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/* Illuminance resources and handler */ /* Illuminance resources and handler */
static void static void
res_get_handler_opt(coap_packet_t *request, coap_packet_t *response, res_get_handler_opt(coap_message_t *request, coap_message_t *response,
uint8_t *buffer, uint8_t *buffer,
uint16_t preferred_size, int32_t *offset) uint16_t preferred_size, int32_t *offset)
{ {

View File

@ -48,7 +48,7 @@
#include <string.h> #include <string.h>
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static void static void
res_post_handler_red(coap_packet_t *request, coap_packet_t *response, res_post_handler_red(coap_message_t *request, coap_message_t *response,
uint8_t *buffer, uint8_t *buffer,
uint16_t preferred_size, int32_t *offset) uint16_t preferred_size, int32_t *offset)
{ {
@ -56,7 +56,7 @@ res_post_handler_red(coap_packet_t *request, coap_packet_t *response,
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static void static void
res_post_handler_green(coap_packet_t *request, coap_packet_t *response, res_post_handler_green(coap_message_t *request, coap_message_t *response,
uint8_t *buffer, uint8_t *buffer,
uint16_t preferred_size, int32_t *offset) uint16_t preferred_size, int32_t *offset)
{ {
@ -83,7 +83,7 @@ RESOURCE(res_toggle_green,
#if BOARD_SMARTRF06EB #if BOARD_SMARTRF06EB
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static void static void
res_post_handler_yellow(coap_packet_t *request, coap_packet_t *response, res_post_handler_yellow(coap_message_t *request, coap_message_t *response,
uint8_t *buffer, uint8_t *buffer,
uint16_t preferred_size, int32_t *offset) uint16_t preferred_size, int32_t *offset)
{ {
@ -91,7 +91,7 @@ res_post_handler_yellow(coap_packet_t *request, coap_packet_t *response,
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static void static void
res_post_handler_orange(coap_packet_t *request, coap_packet_t *response, res_post_handler_orange(coap_message_t *request, coap_message_t *response,
uint8_t *buffer, uint8_t *buffer,
uint16_t preferred_size, int32_t *offset) uint16_t preferred_size, int32_t *offset)
{ {

View File

@ -104,7 +104,7 @@ PROCESS(very_sleepy_demo_process, "CC13xx/CC26xx very sleepy process");
AUTOSTART_PROCESSES(&very_sleepy_demo_process); AUTOSTART_PROCESSES(&very_sleepy_demo_process);
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static void static void
readings_get_handler(coap_packet_t *request, coap_packet_t *response, readings_get_handler(coap_message_t *request, coap_message_t *response,
uint8_t *buffer, uint16_t preferred_size, int32_t *offset) uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{ {
unsigned int accept = -1; unsigned int accept = -1;
@ -144,7 +144,7 @@ RESOURCE(readings_resource, "title=\"Sensor Readings\";obs",
readings_get_handler, NULL, NULL, NULL); readings_get_handler, NULL, NULL, NULL);
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static void static void
conf_get_handler(coap_packet_t *request, coap_packet_t *response, conf_get_handler(coap_message_t *request, coap_message_t *response,
uint8_t *buffer, uint16_t preferred_size, int32_t *offset) uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{ {
unsigned int accept = -1; unsigned int accept = -1;
@ -175,7 +175,7 @@ conf_get_handler(coap_packet_t *request, coap_packet_t *response,
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static void static void
conf_post_handler(coap_packet_t *request, coap_packet_t *response, conf_post_handler(coap_message_t *request, coap_message_t *response,
uint8_t *buffer, uint16_t preferred_size, int32_t *offset) uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{ {
const char *ptr = NULL; const char *ptr = NULL;

View File

@ -41,7 +41,7 @@
#include "dev/leds.h" #include "dev/leds.h"
static void ct_callback(void *ptr); static void ct_callback(void *ptr);
static void put_post_led_toggle_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset); static void put_post_led_toggle_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
static char content[COAP_MAX_CHUNK_SIZE]; static char content[COAP_MAX_CHUNK_SIZE];
static int content_len = 0; static int content_len = 0;
@ -77,7 +77,7 @@ RESOURCE(resource_led_toggle,
put_post_led_toggle_handler, put_post_led_toggle_handler,
NULL); NULL);
static void static void
put_post_led_toggle_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset) put_post_led_toggle_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{ {
static int led_state = 0; static int led_state = 0;
unsigned int accept = -1; unsigned int accept = -1;

View File

@ -46,17 +46,17 @@
#include <stdlib.h> #include <stdlib.h>
static void event_sensors_dr1175_handler(void); static void event_sensors_dr1175_handler(void);
static void get_sensors_dr1175_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset); static void get_sensors_dr1175_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
static void get_light_sensor_value_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset); static void get_light_sensor_value_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
static void get_light_sensor_unit_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset); static void get_light_sensor_unit_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
static void get_temperature_value_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset); static void get_temperature_value_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
static void get_temperature_unit_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset); static void get_temperature_unit_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
static void get_humidity_value_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset); static void get_humidity_value_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
static void get_humidity_unit_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset); static void get_humidity_unit_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
static void put_post_white_led_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset); static void put_post_white_led_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
static void put_post_rgb_led_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset); static void put_post_rgb_led_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
static void put_post_led_d3_1174_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset); static void put_post_led_d3_1174_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
static void put_post_led_d6_1174_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset); static void put_post_led_d6_1174_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
static char content[COAP_MAX_CHUNK_SIZE]; static char content[COAP_MAX_CHUNK_SIZE];
static int content_len = 0; static int content_len = 0;
@ -90,7 +90,7 @@ EVENT_RESOURCE(resource_sensors_dr1175, /* name */
NULL, /* DELETE handler */ NULL, /* DELETE handler */
event_sensors_dr1175_handler); /* event handler */ event_sensors_dr1175_handler); /* event handler */
static void static void
get_sensors_dr1175_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset) get_sensors_dr1175_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{ {
unsigned int accept = -1; unsigned int accept = -1;
coap_get_header_accept(request, &accept); coap_get_header_accept(request, &accept);
@ -121,7 +121,7 @@ RESOURCE(resource_light_sensor_value,
NULL, NULL,
NULL); NULL);
static void static void
get_light_sensor_value_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset) get_light_sensor_value_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{ {
unsigned int accept = -1; unsigned int accept = -1;
coap_get_header_accept(request, &accept); coap_get_header_accept(request, &accept);
@ -142,7 +142,7 @@ RESOURCE(resource_light_sensor_unit,
NULL, NULL,
NULL); NULL);
static void static void
get_light_sensor_unit_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset) get_light_sensor_unit_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{ {
unsigned int accept = -1; unsigned int accept = -1;
coap_get_header_accept(request, &accept); coap_get_header_accept(request, &accept);
@ -163,7 +163,7 @@ RESOURCE(resource_temperature_value,
NULL, NULL,
NULL); NULL);
static void static void
get_temperature_value_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset) get_temperature_value_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{ {
unsigned int accept = -1; unsigned int accept = -1;
coap_get_header_accept(request, &accept); coap_get_header_accept(request, &accept);
@ -184,7 +184,7 @@ RESOURCE(resource_temperature_unit,
NULL, NULL,
NULL); NULL);
static void static void
get_temperature_unit_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset) get_temperature_unit_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{ {
unsigned int accept = -1; unsigned int accept = -1;
coap_get_header_accept(request, &accept); coap_get_header_accept(request, &accept);
@ -205,7 +205,7 @@ RESOURCE(resource_humidity_value,
NULL, NULL,
NULL); NULL);
static void static void
get_humidity_value_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset) get_humidity_value_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{ {
unsigned int accept = -1; unsigned int accept = -1;
coap_get_header_accept(request, &accept); coap_get_header_accept(request, &accept);
@ -226,7 +226,7 @@ RESOURCE(resource_humidity_unit,
NULL, NULL,
NULL); NULL);
static void static void
get_humidity_unit_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset) get_humidity_unit_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{ {
unsigned int accept = -1; unsigned int accept = -1;
coap_get_header_accept(request, &accept); coap_get_header_accept(request, &accept);
@ -247,7 +247,7 @@ RESOURCE(resource_white_led,
put_post_white_led_handler, put_post_white_led_handler,
NULL); NULL);
static void static void
put_post_white_led_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset) put_post_white_led_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{ {
const uint8_t *request_content = NULL; const uint8_t *request_content = NULL;
int level; int level;
@ -271,7 +271,7 @@ RESOURCE(resource_rgb_led,
put_post_rgb_led_handler, put_post_rgb_led_handler,
NULL); NULL);
static void static void
put_post_rgb_led_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset) put_post_rgb_led_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{ {
const uint8_t *request_content = NULL; const uint8_t *request_content = NULL;
char *pch; char *pch;
@ -306,7 +306,7 @@ RESOURCE(resource_led_d3_1174,
put_post_led_d3_1174_handler, put_post_led_d3_1174_handler,
NULL); NULL);
static void static void
put_post_led_d3_1174_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset) put_post_led_d3_1174_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{ {
const uint8_t *request_content; const uint8_t *request_content;
unsigned int accept = -1; unsigned int accept = -1;
@ -326,7 +326,7 @@ RESOURCE(resource_led_d6_1174,
put_post_led_d6_1174_handler, put_post_led_d6_1174_handler,
NULL); NULL);
static void static void
put_post_led_d6_1174_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset) put_post_led_d6_1174_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{ {
const uint8_t *request_content; const uint8_t *request_content;
unsigned int accept = -1; unsigned int accept = -1;

View File

@ -46,19 +46,19 @@ static char content[COAP_MAX_CHUNK_SIZE];
static int content_len = 0; static int content_len = 0;
static void event_sensors_dr1199_handler(); static void event_sensors_dr1199_handler();
static void get_sensors_dr1199_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset); static void get_sensors_dr1199_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
static void get_switch_sw1_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset); static void get_switch_sw1_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
static void get_switch_sw2_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset); static void get_switch_sw2_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
static void get_switch_sw3_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset); static void get_switch_sw3_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
static void get_switch_sw4_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset); static void get_switch_sw4_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
static void get_switch_dio8_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset); static void get_switch_dio8_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
static void get_pot_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset); static void get_pot_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
static void put_post_led_d1_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset); static void put_post_led_d1_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
static void put_post_led_d2_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset); static void put_post_led_d2_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
static void put_post_led_d3_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset); static void put_post_led_d3_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
static void put_post_led_d3_1174_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset); static void put_post_led_d3_1174_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
static void put_post_led_d6_1174_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset); static void put_post_led_d6_1174_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
static void put_post_led_all_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset); static void put_post_led_all_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
#define CONTENT_PRINTF(...) { if(content_len < sizeof(content)) { content_len += snprintf(content + content_len, sizeof(content) - content_len, __VA_ARGS__); } } #define CONTENT_PRINTF(...) { if(content_len < sizeof(content)) { content_len += snprintf(content + content_len, sizeof(content) - content_len, __VA_ARGS__); } }
@ -93,7 +93,7 @@ EVENT_RESOURCE(resource_sensors_dr1199, /* name */
NULL, /* DELETE handler */ NULL, /* DELETE handler */
event_sensors_dr1199_handler); /* event handler */ event_sensors_dr1199_handler); /* event handler */
static void static void
get_sensors_dr1199_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset) get_sensors_dr1199_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{ {
unsigned int accept = -1; unsigned int accept = -1;
coap_get_header_accept(request, &accept); coap_get_header_accept(request, &accept);
@ -123,7 +123,7 @@ RESOURCE(resource_switch_sw1,
NULL, NULL,
NULL); NULL);
static void static void
get_switch_sw1_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset) get_switch_sw1_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{ {
content_len = 0; content_len = 0;
unsigned int accept = -1; unsigned int accept = -1;
@ -141,7 +141,7 @@ RESOURCE(resource_switch_sw2,
NULL, NULL,
NULL); NULL);
static void static void
get_switch_sw2_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset) get_switch_sw2_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{ {
content_len = 0; content_len = 0;
unsigned int accept = -1; unsigned int accept = -1;
@ -159,7 +159,7 @@ RESOURCE(resource_switch_sw3,
NULL, NULL,
NULL); NULL);
static void static void
get_switch_sw3_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset) get_switch_sw3_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{ {
content_len = 0; content_len = 0;
unsigned int accept = -1; unsigned int accept = -1;
@ -177,7 +177,7 @@ RESOURCE(resource_switch_sw4,
NULL, NULL,
NULL); NULL);
static void static void
get_switch_sw4_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset) get_switch_sw4_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{ {
content_len = 0; content_len = 0;
unsigned int accept = -1; unsigned int accept = -1;
@ -195,7 +195,7 @@ RESOURCE(resource_switch_dio8,
NULL, NULL,
NULL); NULL);
static void static void
get_switch_dio8_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset) get_switch_dio8_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{ {
content_len = 0; content_len = 0;
unsigned int accept = -1; unsigned int accept = -1;
@ -216,7 +216,7 @@ RESOURCE(resource_pot,
NULL, NULL,
NULL); NULL);
static void static void
get_pot_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset) get_pot_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{ {
content_len = 0; content_len = 0;
unsigned int accept = -1; unsigned int accept = -1;
@ -237,7 +237,7 @@ RESOURCE(resource_led_d1,
put_post_led_d1_handler, put_post_led_d1_handler,
NULL); NULL);
static void static void
put_post_led_d1_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset) put_post_led_d1_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{ {
const uint8_t *request_content; const uint8_t *request_content;
unsigned int accept = -1; unsigned int accept = -1;
@ -254,7 +254,7 @@ RESOURCE(resource_led_d2,
put_post_led_d2_handler, put_post_led_d2_handler,
NULL); NULL);
static void static void
put_post_led_d2_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset) put_post_led_d2_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{ {
const uint8_t *request_content; const uint8_t *request_content;
unsigned int accept = -1; unsigned int accept = -1;
@ -271,7 +271,7 @@ RESOURCE(resource_led_d3,
put_post_led_d3_handler, put_post_led_d3_handler,
NULL); NULL);
static void static void
put_post_led_d3_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset) put_post_led_d3_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{ {
const uint8_t *request_content; const uint8_t *request_content;
unsigned int accept = -1; unsigned int accept = -1;
@ -288,7 +288,7 @@ RESOURCE(resource_led_d3_1174,
put_post_led_d3_1174_handler, put_post_led_d3_1174_handler,
NULL); NULL);
static void static void
put_post_led_d3_1174_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset) put_post_led_d3_1174_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{ {
const uint8_t *request_content; const uint8_t *request_content;
unsigned int accept = -1; unsigned int accept = -1;
@ -305,7 +305,7 @@ RESOURCE(resource_led_d6_1174,
put_post_led_d6_1174_handler, put_post_led_d6_1174_handler,
NULL); NULL);
static void static void
put_post_led_d6_1174_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset) put_post_led_d6_1174_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{ {
const uint8_t *request_content; const uint8_t *request_content;
unsigned int accept = -1; unsigned int accept = -1;
@ -322,7 +322,7 @@ RESOURCE(resource_led_all,
put_post_led_all_handler, put_post_led_all_handler,
NULL); NULL);
static void static void
put_post_led_all_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset) put_post_led_all_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{ {
const uint8_t *request_content; const uint8_t *request_content;
unsigned int accept = -1; unsigned int accept = -1;

View File

@ -42,8 +42,8 @@
#include <stdlib.h> #include <stdlib.h>
#include <AppHardwareApi.h> #include <AppHardwareApi.h>
static void set_tx_power_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset); static void set_tx_power_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
static void get_tx_power_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset); static void get_tx_power_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
static char content[COAP_MAX_CHUNK_SIZE]; static char content[COAP_MAX_CHUNK_SIZE];
static int content_len = 0; static int content_len = 0;
@ -63,7 +63,7 @@ RESOURCE(resource_set_tx_power,
set_tx_power_handler, set_tx_power_handler,
NULL); NULL);
static void static void
set_tx_power_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset) set_tx_power_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{ {
const uint8_t *request_content = NULL; const uint8_t *request_content = NULL;
int tx_level; int tx_level;
@ -84,7 +84,7 @@ RESOURCE(resource_get_tx_power,
NULL, NULL,
NULL); NULL);
static void static void
get_tx_power_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset) get_tx_power_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{ {
int tx_level; int tx_level;
unsigned int accept = -1; unsigned int accept = -1;

View File

@ -56,8 +56,8 @@
static uip_ipaddr_t prefix; static uip_ipaddr_t prefix;
static uint8_t prefix_set; static uint8_t prefix_set;
static void get_rssi_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset); static void get_rssi_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
static void get_last_rssi_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset); static void get_last_rssi_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
static char content[COAP_MAX_CHUNK_SIZE]; static char content[COAP_MAX_CHUNK_SIZE];
static int content_len = 0; static int content_len = 0;
@ -74,7 +74,7 @@ RESOURCE(resource_get_rssi,
NULL, NULL,
NULL); NULL);
static void static void
get_rssi_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset) get_rssi_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{ {
int rssi_level; int rssi_level;
unsigned int accept = -1; unsigned int accept = -1;
@ -95,7 +95,7 @@ RESOURCE(resource_get_last_rssi,
NULL, NULL,
NULL); NULL);
static void static void
get_last_rssi_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset) get_last_rssi_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{ {
int last_rssi_level; int last_rssi_level;
unsigned int accept = -1; unsigned int accept = -1;

View File

@ -42,9 +42,9 @@
#include "uart1.h" #include "uart1.h"
#include <AppHardwareApi.h> #include <AppHardwareApi.h>
static void get_coap_rx_uart1_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset); static void get_coap_rx_uart1_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
static void event_coap_rx_uart1_handler(void); static void event_coap_rx_uart1_handler(void);
static void put_post_tx_uart1_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset); static void put_post_tx_uart1_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
static void string2uart1(uint8_t *c); static void string2uart1(uint8_t *c);
static int handleRxChar(uint8_t c); static int handleRxChar(uint8_t c);
static int get_ringbuf(uint8_t *c); static int get_ringbuf(uint8_t *c);
@ -85,7 +85,7 @@ EVENT_RESOURCE(resource_coap_rx_uart1, /* name */
NULL, /* DELETE handler */ NULL, /* DELETE handler */
event_coap_rx_uart1_handler); /* event handler */ event_coap_rx_uart1_handler); /* event handler */
static void static void
get_coap_rx_uart1_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset) get_coap_rx_uart1_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{ {
unsigned int accept = -1; unsigned int accept = -1;
coap_get_header_accept(request, &accept); coap_get_header_accept(request, &accept);
@ -115,7 +115,7 @@ RESOURCE(resource_coap_tx_uart1, /* name */
NULL); /* DELETE handler */ NULL); /* DELETE handler */
static void static void
put_post_tx_uart1_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset) put_post_tx_uart1_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{ {
const uint8_t *request_content = NULL; const uint8_t *request_content = NULL;
unsigned int accept = -1; unsigned int accept = -1;

View File

@ -48,12 +48,12 @@
#include "net/ipv6/uip-debug.h" #include "net/ipv6/uip-debug.h"
static void static void
res_post_put_handler(coap_packet_t *request, coap_packet_t *response, res_post_put_handler(coap_message_t *request, coap_message_t *response,
uint8_t *buffer, uint8_t *buffer,
uint16_t preferred_size, int32_t *offset); uint16_t preferred_size, int32_t *offset);
static void static void
res_get_handler(coap_packet_t *request, coap_packet_t *response, res_get_handler(coap_message_t *request, coap_message_t *response,
uint8_t *buffer, uint8_t *buffer,
uint16_t preferred_size, int32_t *offset); uint16_t preferred_size, int32_t *offset);
@ -71,7 +71,7 @@ EVENT_RESOURCE(res_led3,
); );
static void static void
res_post_put_handler(coap_packet_t *request, coap_packet_t *response, res_post_put_handler(coap_message_t *request, coap_message_t *response,
uint8_t *buffer, uint16_t preferred_size, int32_t *offset) uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{ {
const uint8_t *payload; const uint8_t *payload;
@ -91,7 +91,7 @@ res_post_put_handler(coap_packet_t *request, coap_packet_t *response,
} }
static void static void
res_get_handler(coap_packet_t *request, coap_packet_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset) res_get_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{ {
coap_set_header_content_format(response, TEXT_PLAIN); coap_set_header_content_format(response, TEXT_PLAIN);
coap_set_payload(response, buffer, snprintf((char *)buffer, preferred_size, "%d", (leds_get() & LEDS_3) ? 1 : 0)); coap_set_payload(response, buffer, snprintf((char *)buffer, preferred_size, "%d", (leds_get() & LEDS_3) ? 1 : 0));

View File

@ -73,7 +73,7 @@
* -1 if initialisation failed * -1 if initialisation failed
*/ */
int int
coap_block1_handler(coap_packet_t *request, coap_packet_t *response, coap_block1_handler(coap_message_t *request, coap_message_t *response,
uint8_t *target, size_t *len, size_t max_len) uint8_t *target, size_t *len, size_t max_len)
{ {
const uint8_t *payload = 0; const uint8_t *payload = 0;

View File

@ -43,7 +43,7 @@
#include <stddef.h> #include <stddef.h>
#include <stdint.h> #include <stdint.h>
int coap_block1_handler(coap_packet_t *request, coap_packet_t *response, int coap_block1_handler(coap_message_t *request, coap_message_t *response,
uint8_t *target, size_t *len, size_t max_len); uint8_t *target, size_t *len, size_t max_len);
#endif /* COAP_BLOCK1_H_ */ #endif /* COAP_BLOCK1_H_ */

View File

@ -55,7 +55,7 @@
/*- Client Part -------------------------------------------------------------*/ /*- Client Part -------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
void void
coap_blocking_request_callback(void *callback_data, coap_packet_t *response) coap_blocking_request_callback(void *callback_data, coap_message_t *response)
{ {
coap_request_state_t *state = (coap_request_state_t *)callback_data; coap_request_state_t *state = (coap_request_state_t *)callback_data;
@ -66,7 +66,7 @@ coap_blocking_request_callback(void *callback_data, coap_packet_t *response)
PT_THREAD(coap_blocking_request PT_THREAD(coap_blocking_request
(coap_request_state_t *state, process_event_t ev, (coap_request_state_t *state, process_event_t ev,
coap_endpoint_t *remote_ep, coap_endpoint_t *remote_ep,
coap_packet_t *request, coap_message_t *request,
coap_blocking_response_handler_t request_callback)) coap_blocking_response_handler_t request_callback))
{ {
PT_BEGIN(&state->pt); PT_BEGIN(&state->pt);
@ -93,10 +93,10 @@ PT_THREAD(coap_blocking_request
coap_set_header_block2(request, state->block_num, 0, coap_set_header_block2(request, state->block_num, 0,
COAP_MAX_CHUNK_SIZE); COAP_MAX_CHUNK_SIZE);
} }
state->transaction->packet_len = coap_serialize_message(request, state->transaction->message_len = coap_serialize_message(request,
state-> state->
transaction-> transaction->
packet); message);
coap_send_transaction(state->transaction); coap_send_transaction(state->transaction);
PRINTF("Requested #%lu (MID %u)\n", state->block_num, request->mid); PRINTF("Requested #%lu (MID %u)\n", state->block_num, request->mid);

View File

@ -42,16 +42,16 @@ typedef struct coap_request_state {
struct pt pt; struct pt pt;
struct process *process; struct process *process;
coap_transaction_t *transaction; coap_transaction_t *transaction;
coap_packet_t *response; coap_message_t *response;
uint32_t block_num; uint32_t block_num;
} coap_request_state_t; } coap_request_state_t;
typedef void (* coap_blocking_response_handler_t)(coap_packet_t *response); typedef void (* coap_blocking_response_handler_t)(coap_message_t *response);
PT_THREAD(coap_blocking_request PT_THREAD(coap_blocking_request
(coap_request_state_t *state, process_event_t ev, (coap_request_state_t *state, process_event_t ev,
coap_endpoint_t *remote, coap_endpoint_t *remote,
coap_packet_t *request, coap_message_t *request,
coap_blocking_response_handler_t request_callback)); coap_blocking_response_handler_t request_callback));
#define COAP_BLOCKING_REQUEST(server_endpoint, request, chunk_handler) \ #define COAP_BLOCKING_REQUEST(server_endpoint, request, chunk_handler) \

View File

@ -60,13 +60,13 @@ static uint32_t res_block;
static uint8_t more; static uint8_t more;
static uint8_t block_error; static uint8_t block_error;
static void coap_request_callback(void *callback_data, coap_packet_t *response); static void coap_request_callback(void *callback_data, coap_message_t *response);
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static void static void
progress_request(coap_request_state_t *state) { progress_request(coap_request_state_t *state) {
coap_packet_t *request = state->request; coap_message_t *request = state->request;
request->mid = coap_get_mid(); request->mid = coap_get_mid();
if((state->transaction = if((state->transaction =
coap_new_transaction(request->mid, state->remote_endpoint))) { coap_new_transaction(request->mid, state->remote_endpoint))) {
@ -77,8 +77,8 @@ progress_request(coap_request_state_t *state) {
coap_set_header_block2(request, state->block_num, 0, coap_set_header_block2(request, state->block_num, 0,
COAP_MAX_CHUNK_SIZE); COAP_MAX_CHUNK_SIZE);
} }
state->transaction->packet_len = state->transaction->message_len =
coap_serialize_message(request, state->transaction->packet); coap_serialize_message(request, state->transaction->message);
coap_send_transaction(state->transaction); coap_send_transaction(state->transaction);
PRINTF("Requested #%lu (MID %u)\n", (unsigned long) state->block_num, PRINTF("Requested #%lu (MID %u)\n", (unsigned long) state->block_num,
@ -89,7 +89,7 @@ progress_request(coap_request_state_t *state) {
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static void static void
coap_request_callback(void *callback_data, coap_packet_t *response) coap_request_callback(void *callback_data, coap_message_t *response)
{ {
coap_request_state_t *state = (coap_request_state_t *)callback_data; coap_request_state_t *state = (coap_request_state_t *)callback_data;
uint32_t res_block1; uint32_t res_block1;
@ -137,7 +137,7 @@ coap_request_callback(void *callback_data, coap_packet_t *response)
void void
coap_send_request(coap_request_state_t *state, coap_endpoint_t *endpoint, coap_send_request(coap_request_state_t *state, coap_endpoint_t *endpoint,
coap_packet_t *request, coap_message_t *request,
void (*callback)(coap_request_state_t *state)) void (*callback)(coap_request_state_t *state))
{ {
/* can we have these variables shared between multiple requests? */ /* can we have these variables shared between multiple requests? */

View File

@ -51,8 +51,8 @@ typedef struct coap_request_state coap_request_state_t;
struct coap_request_state { struct coap_request_state {
coap_transaction_t *transaction; coap_transaction_t *transaction;
coap_packet_t *response; coap_message_t *response;
coap_packet_t *request; coap_message_t *request;
coap_endpoint_t *remote_endpoint; coap_endpoint_t *remote_endpoint;
uint32_t block_num; uint32_t block_num;
void *user_data; void *user_data;
@ -61,7 +61,7 @@ struct coap_request_state {
}; };
void coap_send_request(coap_request_state_t *state, coap_endpoint_t *endpoint, void coap_send_request(coap_request_state_t *state, coap_endpoint_t *endpoint,
coap_packet_t *request, coap_message_t *request,
void (*callback)(coap_request_state_t *state)); void (*callback)(coap_request_state_t *state));
#endif /* COAP_CALLBACK_API_H_ */ #endif /* COAP_CALLBACK_API_H_ */

View File

@ -62,8 +62,8 @@ static void process_callback(coap_timer_t *t);
* To be called by HTTP/COAP server as a callback function when a new service * To be called by HTTP/COAP server as a callback function when a new service
* request appears. This function dispatches the corresponding CoAP service. * request appears. This function dispatches the corresponding CoAP service.
*/ */
static int invoke_coap_resource_service(coap_packet_t *request, static int invoke_coap_resource_service(coap_message_t *request,
coap_packet_t *response, coap_message_t *response,
uint8_t *buffer, uint16_t buffer_size, uint8_t *buffer, uint16_t buffer_size,
int32_t *offset); int32_t *offset);
@ -91,7 +91,7 @@ coap_remove_handler(coap_handler_t *handler)
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
coap_handler_status_t coap_handler_status_t
coap_call_handlers(coap_packet_t *request, coap_packet_t *response, coap_call_handlers(coap_message_t *request, coap_message_t *response,
uint8_t *buffer, uint16_t buffer_size, int32_t *offset) uint8_t *buffer, uint16_t buffer_size, int32_t *offset)
{ {
coap_handler_status_t status; coap_handler_status_t status;
@ -115,7 +115,7 @@ coap_call_handlers(coap_packet_t *request, coap_packet_t *response,
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static CC_INLINE coap_handler_status_t static CC_INLINE coap_handler_status_t
call_service(coap_packet_t *request, coap_packet_t *response, call_service(coap_message_t *request, coap_message_t *response,
uint8_t *buffer, uint16_t buffer_size, int32_t *offset) uint8_t *buffer, uint16_t buffer_size, int32_t *offset)
{ {
coap_handler_status_t status; coap_handler_status_t status;
@ -148,8 +148,8 @@ coap_receive(const coap_endpoint_t *src,
uint8_t *payload, uint16_t payload_length) uint8_t *payload, uint16_t payload_length)
{ {
/* static declaration reduces stack peaks and program code size */ /* static declaration reduces stack peaks and program code size */
static coap_packet_t message[1]; /* this way the packet can be treated as pointer as usual */ static coap_message_t message[1]; /* this way the message can be treated as pointer as usual */
static coap_packet_t response[1]; static coap_message_t response[1];
coap_transaction_t *transaction = NULL; coap_transaction_t *transaction = NULL;
coap_handler_status_t status; coap_handler_status_t status;
@ -203,7 +203,7 @@ coap_receive(const coap_endpoint_t *src,
/* call CoAP framework and check if found and allowed */ /* call CoAP framework and check if found and allowed */
status = call_service(message, response, status = call_service(message, response,
transaction->packet + COAP_MAX_HEADER_SIZE, transaction->message + COAP_MAX_HEADER_SIZE,
block_size, &new_offset); block_size, &new_offset);
if(status != COAP_HANDLER_STATUS_CONTINUE) { if(status != COAP_HANDLER_STATUS_CONTINUE) {
@ -277,9 +277,9 @@ coap_receive(const coap_endpoint_t *src,
/* serialize response */ /* serialize response */
} }
if(coap_status_code == NO_ERROR) { if(coap_status_code == NO_ERROR) {
if((transaction->packet_len = coap_serialize_message(response, if((transaction->message_len = coap_serialize_message(response,
transaction-> transaction->
packet)) == message)) ==
0) { 0) {
coap_status_code = PACKET_SERIALIZATION_ERROR; coap_status_code = PACKET_SERIALIZATION_ERROR;
} }
@ -434,7 +434,7 @@ coap_get_next_resource(coap_resource_t *resource)
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static int static int
invoke_coap_resource_service(coap_packet_t *request, coap_packet_t *response, invoke_coap_resource_service(coap_message_t *request, coap_message_t *response,
uint8_t *buffer, uint16_t buffer_size, uint8_t *buffer, uint16_t buffer_size,
int32_t *offset) int32_t *offset)
{ {

View File

@ -51,8 +51,8 @@ typedef enum {
} coap_handler_status_t; } coap_handler_status_t;
typedef coap_handler_status_t typedef coap_handler_status_t
(* coap_handler_callback_t)(coap_packet_t *request, (* coap_handler_callback_t)(coap_message_t *request,
coap_packet_t *response, coap_message_t *response,
uint8_t *buffer, uint16_t buffer_size, uint8_t *buffer, uint16_t buffer_size,
int32_t *offset); int32_t *offset);
@ -74,21 +74,21 @@ void coap_engine_init(void);
int coap_receive(const coap_endpoint_t *src, int coap_receive(const coap_endpoint_t *src,
uint8_t *payload, uint16_t payload_length); uint8_t *payload, uint16_t payload_length);
coap_handler_status_t coap_call_handlers(coap_packet_t *request, coap_handler_status_t coap_call_handlers(coap_message_t *request,
coap_packet_t *response, coap_message_t *response,
uint8_t *buffer, uint8_t *buffer,
uint16_t buffer_size, uint16_t buffer_size,
int32_t *offset); int32_t *offset);
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/* signatures of handler functions */ /* signatures of handler functions */
typedef void (* coap_resource_handler_t)(coap_packet_t *request, typedef void (* coap_resource_handler_t)(coap_message_t *request,
coap_packet_t *response, coap_message_t *response,
uint8_t *buffer, uint8_t *buffer,
uint16_t preferred_size, uint16_t preferred_size,
int32_t *offset); int32_t *offset);
typedef void (* coap_resource_periodic_handler_t)(void); typedef void (* coap_resource_periodic_handler_t)(void);
typedef void (* coap_resource_response_handler_t)(void *data, typedef void (* coap_resource_response_handler_t)(void *data,
coap_packet_t *response); coap_message_t *response);
typedef void (* coap_resource_trigger_handler_t)(void); typedef void (* coap_resource_trigger_handler_t)(void);
/* data structure representing a resource in CoAP */ /* data structure representing a resource in CoAP */

View File

@ -62,7 +62,7 @@ LIST(obs_subjects_list);
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
static size_t static size_t
get_token(coap_packet_t *coap_pkt, const uint8_t **token) get_token(coap_message_t *coap_pkt, const uint8_t **token)
{ {
*token = coap_pkt->token; *token = coap_pkt->token;
@ -70,7 +70,7 @@ get_token(coap_packet_t *coap_pkt, const uint8_t **token)
} }
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
static int static int
set_token(coap_packet_t *coap_pkt, const uint8_t *token, size_t token_len) set_token(coap_message_t *coap_pkt, const uint8_t *token, size_t token_len)
{ {
coap_pkt->token_len = MIN(COAP_TOKEN_LEN, token_len); coap_pkt->token_len = MIN(COAP_TOKEN_LEN, token_len);
memcpy(coap_pkt->token, token, coap_pkt->token_len); memcpy(coap_pkt->token, token, coap_pkt->token_len);
@ -172,9 +172,9 @@ coap_obs_remove_observee_by_url(const coap_endpoint_t *endpoint,
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
static void static void
simple_reply(coap_message_type_t type, const coap_endpoint_t *endpoint, simple_reply(coap_message_type_t type, const coap_endpoint_t *endpoint,
coap_packet_t *notification) coap_message_t *notification)
{ {
static coap_packet_t response[1]; static coap_message_t response[1];
size_t len; size_t len;
coap_init_message(response, type, NO_ERROR, notification->mid); coap_init_message(response, type, NO_ERROR, notification->mid);
@ -183,7 +183,7 @@ simple_reply(coap_message_type_t type, const coap_endpoint_t *endpoint,
} }
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
static coap_notification_flag_t static coap_notification_flag_t
classify_notification(coap_packet_t *response, int first) classify_notification(coap_message_t *response, int first)
{ {
if(!response) { if(!response) {
PRINTF("no response\n"); PRINTF("no response\n");
@ -206,7 +206,7 @@ classify_notification(coap_packet_t *response, int first)
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
void void
coap_handle_notification(const coap_endpoint_t *endpoint, coap_handle_notification(const coap_endpoint_t *endpoint,
coap_packet_t *notification) coap_message_t *notification)
{ {
const uint8_t *token; const uint8_t *token;
int token_len; int token_len;
@ -250,7 +250,7 @@ coap_handle_notification(const coap_endpoint_t *endpoint,
} }
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
static void static void
handle_obs_registration_response(void *data, coap_packet_t *response) handle_obs_registration_response(void *data, coap_message_t *response)
{ {
coap_observee_t *obs; coap_observee_t *obs;
notification_callback_t notification_callback; notification_callback_t notification_callback;
@ -284,7 +284,7 @@ coap_obs_request_registration(const coap_endpoint_t *endpoint, char *uri,
notification_callback_t notification_callback, notification_callback_t notification_callback,
void *data) void *data)
{ {
coap_packet_t request[1]; coap_message_t request[1];
coap_transaction_t *t; coap_transaction_t *t;
uint8_t *token; uint8_t *token;
uint8_t token_len; uint8_t token_len;
@ -303,7 +303,7 @@ coap_obs_request_registration(const coap_endpoint_t *endpoint, char *uri,
if(obs) { if(obs) {
t->callback = handle_obs_registration_response; t->callback = handle_obs_registration_response;
t->callback_data = obs; t->callback_data = obs;
t->packet_len = coap_serialize_message(request, t->packet); t->message_len = coap_serialize_message(request, t->message);
coap_send_transaction(t); coap_send_transaction(t);
} else { } else {
PRINTF("Could not allocate obs_subject resource buffer"); PRINTF("Could not allocate obs_subject resource buffer");

View File

@ -107,7 +107,7 @@ int coap_obs_remove_observee_by_url(const coap_endpoint_t *endpoint,
const char *url); const char *url);
void coap_handle_notification(const coap_endpoint_t *endpoint, void coap_handle_notification(const coap_endpoint_t *endpoint,
coap_packet_t *notification); coap_message_t *notification);
coap_observee_t *coap_obs_request_registration(const coap_endpoint_t *endpoint, coap_observee_t *coap_obs_request_registration(const coap_endpoint_t *endpoint,
char *uri, char *uri,

View File

@ -191,8 +191,8 @@ void
coap_notify_observers_sub(coap_resource_t *resource, const char *subpath) coap_notify_observers_sub(coap_resource_t *resource, const char *subpath)
{ {
/* build notification */ /* build notification */
coap_packet_t notification[1]; /* this way the packet can be treated as pointer as usual */ coap_message_t notification[1]; /* this way the message can be treated as pointer as usual */
coap_packet_t request[1]; /* this way the packet can be treated as pointer as usual */ coap_message_t request[1]; /* this way the message can be treated as pointer as usual */
coap_observer_t *obs = NULL; coap_observer_t *obs = NULL;
int url_len, obs_url_len; int url_len, obs_url_len;
char url[COAP_OBSERVER_URL_LEN]; char url[COAP_OBSERVER_URL_LEN];
@ -260,14 +260,14 @@ coap_notify_observers_sub(coap_resource_t *resource, const char *subpath)
notification->mid = transaction->mid; notification->mid = transaction->mid;
/* Either old style get_handler or the full handler */ /* Either old style get_handler or the full handler */
if(coap_call_handlers(request, notification, transaction->packet + if(coap_call_handlers(request, notification, transaction->message +
COAP_MAX_HEADER_SIZE, COAP_MAX_CHUNK_SIZE, COAP_MAX_HEADER_SIZE, COAP_MAX_CHUNK_SIZE,
NULL) > 0) { NULL) > 0) {
PRINTF("Notification on new handlers\n"); PRINTF("Notification on new handlers\n");
} else { } else {
if(resource != NULL) { if(resource != NULL) {
resource->get_handler(request, notification, resource->get_handler(request, notification,
transaction->packet + COAP_MAX_HEADER_SIZE, transaction->message + COAP_MAX_HEADER_SIZE,
COAP_MAX_CHUNK_SIZE, NULL); COAP_MAX_CHUNK_SIZE, NULL);
} else { } else {
/* What to do here? */ /* What to do here? */
@ -282,8 +282,8 @@ coap_notify_observers_sub(coap_resource_t *resource, const char *subpath)
} }
coap_set_token(notification, obs->token, obs->token_len); coap_set_token(notification, obs->token, obs->token_len);
transaction->packet_len = transaction->message_len =
coap_serialize_message(notification, transaction->packet); coap_serialize_message(notification, transaction->message);
coap_send_transaction(transaction); coap_send_transaction(transaction);
} }
@ -292,8 +292,8 @@ coap_notify_observers_sub(coap_resource_t *resource, const char *subpath)
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
void void
coap_observe_handler(coap_resource_t *resource, coap_packet_t *coap_req, coap_observe_handler(coap_resource_t *resource, coap_message_t *coap_req,
coap_packet_t *coap_res) coap_message_t *coap_res)
{ {
const coap_endpoint_t *src_ep; const coap_endpoint_t *src_ep;
coap_observer_t *obs; coap_observer_t *obs;

View File

@ -72,7 +72,7 @@ int coap_remove_observer_by_mid(const coap_endpoint_t *ep,
void coap_notify_observers(coap_resource_t *resource); void coap_notify_observers(coap_resource_t *resource);
void coap_notify_observers_sub(coap_resource_t *resource, const char *subpath); void coap_notify_observers_sub(coap_resource_t *resource, const char *subpath);
void coap_observe_handler(coap_resource_t *resource, coap_packet_t *request, void coap_observe_handler(coap_resource_t *resource, coap_message_t *request,
coap_packet_t *response); coap_message_t *response);
#endif /* COAP_OBSERVE_H_ */ #endif /* COAP_OBSERVE_H_ */

View File

@ -74,7 +74,7 @@
/*- Resource Handlers -------------------------------------------------------*/ /*- Resource Handlers -------------------------------------------------------*/
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static void static void
well_known_core_get_handler(coap_packet_t *request, coap_packet_t *response, well_known_core_get_handler(coap_message_t *request, coap_message_t *response,
uint8_t *buffer, uint16_t preferred_size, uint8_t *buffer, uint16_t preferred_size,
int32_t *offset) int32_t *offset)
{ {

View File

@ -81,7 +81,7 @@ coap_separate_reject()
* then retry later. * then retry later.
*/ */
void void
coap_separate_accept(coap_packet_t *coap_req, coap_separate_t *separate_store) coap_separate_accept(coap_message_t *coap_req, coap_separate_t *separate_store)
{ {
coap_transaction_t *const t = coap_get_transaction_by_mid(coap_req->mid); coap_transaction_t *const t = coap_get_transaction_by_mid(coap_req->mid);
@ -90,7 +90,7 @@ coap_separate_accept(coap_packet_t *coap_req, coap_separate_t *separate_store)
if(t) { if(t) {
/* send separate ACK for CON */ /* send separate ACK for CON */
if(coap_req->type == COAP_TYPE_CON) { if(coap_req->type == COAP_TYPE_CON) {
coap_packet_t ack[1]; coap_message_t ack[1];
const coap_endpoint_t *ep; const coap_endpoint_t *ep;
ep = coap_get_src_endpoint(coap_req); ep = coap_get_src_endpoint(coap_req);
@ -131,7 +131,7 @@ coap_separate_accept(coap_packet_t *coap_req, coap_separate_t *separate_store)
} }
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
void void
coap_separate_resume(coap_packet_t *response, coap_separate_t *separate_store, coap_separate_resume(coap_message_t *response, coap_separate_t *separate_store,
uint8_t code) uint8_t code)
{ {
coap_init_message(response, separate_store->type, code, coap_init_message(response, separate_store->type, code,

View File

@ -59,12 +59,12 @@ typedef struct coap_separate {
uint16_t block2_size; uint16_t block2_size;
} coap_separate_t; } coap_separate_t;
int coap_separate_handler(coap_resource_t *resource, coap_packet_t *request, int coap_separate_handler(coap_resource_t *resource, coap_message_t *request,
coap_packet_t *response); coap_message_t *response);
void coap_separate_reject(void); void coap_separate_reject(void);
void coap_separate_accept(coap_packet_t *request, void coap_separate_accept(coap_message_t *request,
coap_separate_t *separate_store); coap_separate_t *separate_store);
void coap_separate_resume(coap_packet_t *response, void coap_separate_resume(coap_message_t *response,
coap_separate_t *separate_store, coap_separate_t *separate_store,
uint8_t code); uint8_t code);

View File

@ -98,10 +98,10 @@ coap_send_transaction(coap_transaction_t *t)
{ {
PRINTF("Sending transaction %u\n", t->mid); PRINTF("Sending transaction %u\n", t->mid);
coap_sendto(&t->endpoint, t->packet, t->packet_len); coap_sendto(&t->endpoint, t->message, t->message_len);
if(COAP_TYPE_CON == if(COAP_TYPE_CON ==
((COAP_HEADER_TYPE_MASK & t->packet[0]) >> COAP_HEADER_TYPE_POSITION)) { ((COAP_HEADER_TYPE_MASK & t->message[0]) >> COAP_HEADER_TYPE_POSITION)) {
if(t->retrans_counter < COAP_MAX_RETRANSMIT) { if(t->retrans_counter < COAP_MAX_RETRANSMIT) {
/* not timed out yet */ /* not timed out yet */
PRINTF("Keeping transaction %u\n", t->mid); PRINTF("Keeping transaction %u\n", t->mid);

View File

@ -64,8 +64,8 @@ typedef struct coap_transaction {
coap_resource_response_handler_t callback; coap_resource_response_handler_t callback;
void *callback_data; void *callback_data;
uint16_t packet_len; uint16_t message_len;
uint8_t packet[COAP_MAX_PACKET_SIZE + 1]; /* +1 for the terminating '\0' which will not be sent uint8_t message[COAP_MAX_PACKET_SIZE + 1]; /* +1 for the terminating '\0' which will not be sent
* Use snprintf(buf, len+1, "", ...) to completely fill payload */ * Use snprintf(buf, len+1, "", ...) to completely fill payload */
} coap_transaction_t; } coap_transaction_t;

View File

@ -34,8 +34,17 @@
* An implementation of the Constrained Application Protocol (RFC). * An implementation of the Constrained Application Protocol (RFC).
* \author * \author
* Matthias Kovatsch <kovatsch@inf.ethz.ch> * Matthias Kovatsch <kovatsch@inf.ethz.ch>
*
* Joakim Eriksson, joakim.eriksson@ri.se
* Niclas Finne, niclas.finne@ri.se
*/ */
/**
* \addtogroup coap
* @{
*/
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include "sys/cc.h" #include "sys/cc.h"
@ -290,11 +299,11 @@ coap_get_mid()
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
void void
coap_init_message(coap_packet_t *coap_pkt, coap_message_type_t type, coap_init_message(coap_message_t *coap_pkt, coap_message_type_t type,
uint8_t code, uint16_t mid) uint8_t code, uint16_t mid)
{ {
/* Important thing */ /* Important thing */
memset(coap_pkt, 0, sizeof(coap_packet_t)); memset(coap_pkt, 0, sizeof(coap_message_t));
coap_pkt->type = type; coap_pkt->type = type;
coap_pkt->code = code; coap_pkt->code = code;
@ -302,7 +311,7 @@ coap_init_message(coap_packet_t *coap_pkt, coap_message_type_t type,
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
size_t size_t
coap_serialize_message(coap_packet_t *coap_pkt, uint8_t *buffer) coap_serialize_message(coap_message_t *coap_pkt, uint8_t *buffer)
{ {
uint8_t *option; uint8_t *option;
unsigned int current_number = 0; unsigned int current_number = 0;
@ -325,7 +334,7 @@ coap_serialize_message(coap_packet_t *coap_pkt, uint8_t *buffer)
coap_pkt->buffer[2] = (uint8_t)((coap_pkt->mid) >> 8); coap_pkt->buffer[2] = (uint8_t)((coap_pkt->mid) >> 8);
coap_pkt->buffer[3] = (uint8_t)(coap_pkt->mid); coap_pkt->buffer[3] = (uint8_t)(coap_pkt->mid);
/* empty packet, dont need to do more stuff */ /* empty message, dont need to do more stuff */
if(!coap_pkt->code) { if(!coap_pkt->code) {
PRINTF("-Done serializing empty message at %p-\n", coap_pkt->buffer); PRINTF("-Done serializing empty message at %p-\n", coap_pkt->buffer);
return 4; return 4;
@ -412,16 +421,16 @@ coap_serialize_message(coap_packet_t *coap_pkt, uint8_t *buffer)
coap_pkt->buffer[5], coap_pkt->buffer[6], coap_pkt->buffer[7] coap_pkt->buffer[5], coap_pkt->buffer[6], coap_pkt->buffer[7]
); );
return (option - buffer) + coap_pkt->payload_len; /* packet length */ return (option - buffer) + coap_pkt->payload_len; /* message length */
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
coap_status_t coap_status_t
coap_parse_message(coap_packet_t *coap_pkt, uint8_t *data, uint16_t data_len) coap_parse_message(coap_message_t *coap_pkt, uint8_t *data, uint16_t data_len)
{ {
/* initialize packet */ /* initialize message */
memset(coap_pkt, 0, sizeof(coap_packet_t)); memset(coap_pkt, 0, sizeof(coap_message_t));
/* pointer to packet bytes */ /* pointer to message bytes */
coap_pkt->buffer = data; coap_pkt->buffer = data;
/* parse header fields */ /* parse header fields */
@ -505,7 +514,7 @@ coap_parse_message(coap_packet_t *coap_pkt, uint8_t *data, uint16_t data_len)
if(current_option + option_length > data + data_len) { if(current_option + option_length > data + data_len) {
/* Malformed CoAP - out of bounds */ /* Malformed CoAP - out of bounds */
PRINTF("BAD REQUEST: options outside data packet: %u > %u\n", PRINTF("BAD REQUEST: options outside data message: %u > %u\n",
(unsigned)(current_option + option_length - data), data_len); (unsigned)(current_option + option_length - data), data_len);
return BAD_REQUEST_4_00; return BAD_REQUEST_4_00;
} }
@ -601,7 +610,7 @@ coap_parse_message(coap_packet_t *coap_pkt, uint8_t *data, uint16_t data_len)
PRINTF("Uri-Port [%u]\n", coap_pkt->uri_port); PRINTF("Uri-Port [%u]\n", coap_pkt->uri_port);
break; break;
case COAP_OPTION_URI_PATH: case COAP_OPTION_URI_PATH:
/* coap_merge_multi_option() operates in-place on the IPBUF, but final packet field should be const string -> cast to string */ /* coap_merge_multi_option() operates in-place on the IPBUF, but final message field should be const string -> cast to string */
coap_merge_multi_option((char **)&(coap_pkt->uri_path), coap_merge_multi_option((char **)&(coap_pkt->uri_path),
&(coap_pkt->uri_path_len), current_option, &(coap_pkt->uri_path_len), current_option,
option_length, '/'); option_length, '/');
@ -609,7 +618,7 @@ coap_parse_message(coap_packet_t *coap_pkt, uint8_t *data, uint16_t data_len)
PRINTF("]\n"); PRINTF("]\n");
break; break;
case COAP_OPTION_URI_QUERY: case COAP_OPTION_URI_QUERY:
/* coap_merge_multi_option() operates in-place on the IPBUF, but final packet field should be const string -> cast to string */ /* coap_merge_multi_option() operates in-place on the IPBUF, but final message field should be const string -> cast to string */
coap_merge_multi_option((char **)&(coap_pkt->uri_query), coap_merge_multi_option((char **)&(coap_pkt->uri_query),
&(coap_pkt->uri_query_len), current_option, &(coap_pkt->uri_query_len), current_option,
option_length, '&'); option_length, '&');
@ -618,7 +627,7 @@ coap_parse_message(coap_packet_t *coap_pkt, uint8_t *data, uint16_t data_len)
break; break;
case COAP_OPTION_LOCATION_PATH: case COAP_OPTION_LOCATION_PATH:
/* coap_merge_multi_option() operates in-place on the IPBUF, but final packet field should be const string -> cast to string */ /* coap_merge_multi_option() operates in-place on the IPBUF, but final message field should be const string -> cast to string */
coap_merge_multi_option((char **)&(coap_pkt->location_path), coap_merge_multi_option((char **)&(coap_pkt->location_path),
&(coap_pkt->location_path_len), current_option, &(coap_pkt->location_path_len), current_option,
option_length, '/'); option_length, '/');
@ -628,7 +637,7 @@ coap_parse_message(coap_packet_t *coap_pkt, uint8_t *data, uint16_t data_len)
PRINTF("]\n"); PRINTF("]\n");
break; break;
case COAP_OPTION_LOCATION_QUERY: case COAP_OPTION_LOCATION_QUERY:
/* coap_merge_multi_option() operates in-place on the IPBUF, but final packet field should be const string -> cast to string */ /* coap_merge_multi_option() operates in-place on the IPBUF, but final message field should be const string -> cast to string */
coap_merge_multi_option((char **)&(coap_pkt->location_query), coap_merge_multi_option((char **)&(coap_pkt->location_query),
&(coap_pkt->location_query_len), current_option, &(coap_pkt->location_query_len), current_option,
option_length, '&'); option_length, '&');
@ -693,7 +702,7 @@ coap_parse_message(coap_packet_t *coap_pkt, uint8_t *data, uint16_t data_len)
/*- CoAP Engine API ---------------------------------------------------------*/ /*- CoAP Engine API ---------------------------------------------------------*/
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
int int
coap_get_query_variable(coap_packet_t *coap_pkt, coap_get_query_variable(coap_message_t *coap_pkt,
const char *name, const char **output) const char *name, const char **output)
{ {
if(coap_is_option(coap_pkt, COAP_OPTION_URI_QUERY)) { if(coap_is_option(coap_pkt, COAP_OPTION_URI_QUERY)) {
@ -703,7 +712,7 @@ coap_get_query_variable(coap_packet_t *coap_pkt,
return 0; return 0;
} }
int int
coap_get_post_variable(coap_packet_t *coap_pkt, coap_get_post_variable(coap_message_t *coap_pkt,
const char *name, const char **output) const char *name, const char **output)
{ {
if(coap_pkt->payload_len) { if(coap_pkt->payload_len) {
@ -714,10 +723,10 @@ coap_get_post_variable(coap_packet_t *coap_pkt,
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
int int
coap_set_status_code(coap_packet_t *packet, unsigned int code) coap_set_status_code(coap_message_t *message, unsigned int code)
{ {
if(code <= 0xFF) { if(code <= 0xFF) {
packet->code = (uint8_t)code; message->code = (uint8_t)code;
return 1; return 1;
} else { } else {
return 0; return 0;
@ -725,7 +734,7 @@ coap_set_status_code(coap_packet_t *packet, unsigned int code)
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
int int
coap_set_token(coap_packet_t *coap_pkt, const uint8_t *token, size_t token_len) coap_set_token(coap_message_t *coap_pkt, const uint8_t *token, size_t token_len)
{ {
coap_pkt->token_len = MIN(COAP_TOKEN_LEN, token_len); coap_pkt->token_len = MIN(COAP_TOKEN_LEN, token_len);
memcpy(coap_pkt->token, token, coap_pkt->token_len); memcpy(coap_pkt->token, token, coap_pkt->token_len);
@ -736,7 +745,7 @@ coap_set_token(coap_packet_t *coap_pkt, const uint8_t *token, size_t token_len)
/*- CoAP Implementation API -------------------------------------------------*/ /*- CoAP Implementation API -------------------------------------------------*/
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
int int
coap_get_header_content_format(coap_packet_t *coap_pkt, unsigned int *format) coap_get_header_content_format(coap_message_t *coap_pkt, unsigned int *format)
{ {
if(!coap_is_option(coap_pkt, COAP_OPTION_CONTENT_FORMAT)) { if(!coap_is_option(coap_pkt, COAP_OPTION_CONTENT_FORMAT)) {
return 0; return 0;
@ -745,7 +754,7 @@ coap_get_header_content_format(coap_packet_t *coap_pkt, unsigned int *format)
return 1; return 1;
} }
int int
coap_set_header_content_format(coap_packet_t *coap_pkt, unsigned int format) coap_set_header_content_format(coap_message_t *coap_pkt, unsigned int format)
{ {
coap_pkt->content_format = format; coap_pkt->content_format = format;
coap_set_option(coap_pkt, COAP_OPTION_CONTENT_FORMAT); coap_set_option(coap_pkt, COAP_OPTION_CONTENT_FORMAT);
@ -753,7 +762,7 @@ coap_set_header_content_format(coap_packet_t *coap_pkt, unsigned int format)
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
int int
coap_get_header_accept(coap_packet_t *coap_pkt, unsigned int *accept) coap_get_header_accept(coap_message_t *coap_pkt, unsigned int *accept)
{ {
if(!coap_is_option(coap_pkt, COAP_OPTION_ACCEPT)) { if(!coap_is_option(coap_pkt, COAP_OPTION_ACCEPT)) {
return 0; return 0;
@ -762,7 +771,7 @@ coap_get_header_accept(coap_packet_t *coap_pkt, unsigned int *accept)
return 1; return 1;
} }
int int
coap_set_header_accept(coap_packet_t *coap_pkt, unsigned int accept) coap_set_header_accept(coap_message_t *coap_pkt, unsigned int accept)
{ {
coap_pkt->accept = accept; coap_pkt->accept = accept;
coap_set_option(coap_pkt, COAP_OPTION_ACCEPT); coap_set_option(coap_pkt, COAP_OPTION_ACCEPT);
@ -770,7 +779,7 @@ coap_set_header_accept(coap_packet_t *coap_pkt, unsigned int accept)
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
int int
coap_get_header_max_age(coap_packet_t *coap_pkt, uint32_t *age) coap_get_header_max_age(coap_message_t *coap_pkt, uint32_t *age)
{ {
if(!coap_is_option(coap_pkt, COAP_OPTION_MAX_AGE)) { if(!coap_is_option(coap_pkt, COAP_OPTION_MAX_AGE)) {
*age = COAP_DEFAULT_MAX_AGE; *age = COAP_DEFAULT_MAX_AGE;
@ -779,7 +788,7 @@ coap_get_header_max_age(coap_packet_t *coap_pkt, uint32_t *age)
} return 1; } return 1;
} }
int int
coap_set_header_max_age(coap_packet_t *coap_pkt, uint32_t age) coap_set_header_max_age(coap_message_t *coap_pkt, uint32_t age)
{ {
coap_pkt->max_age = age; coap_pkt->max_age = age;
coap_set_option(coap_pkt, COAP_OPTION_MAX_AGE); coap_set_option(coap_pkt, COAP_OPTION_MAX_AGE);
@ -787,7 +796,7 @@ coap_set_header_max_age(coap_packet_t *coap_pkt, uint32_t age)
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
int int
coap_get_header_etag(coap_packet_t *coap_pkt, const uint8_t **etag) coap_get_header_etag(coap_message_t *coap_pkt, const uint8_t **etag)
{ {
if(!coap_is_option(coap_pkt, COAP_OPTION_ETAG)) { if(!coap_is_option(coap_pkt, COAP_OPTION_ETAG)) {
return 0; return 0;
@ -796,7 +805,7 @@ coap_get_header_etag(coap_packet_t *coap_pkt, const uint8_t **etag)
return coap_pkt->etag_len; return coap_pkt->etag_len;
} }
int int
coap_set_header_etag(coap_packet_t *coap_pkt, const uint8_t *etag, size_t etag_len) coap_set_header_etag(coap_message_t *coap_pkt, const uint8_t *etag, size_t etag_len)
{ {
coap_pkt->etag_len = MIN(COAP_ETAG_LEN, etag_len); coap_pkt->etag_len = MIN(COAP_ETAG_LEN, etag_len);
memcpy(coap_pkt->etag, etag, coap_pkt->etag_len); memcpy(coap_pkt->etag, etag, coap_pkt->etag_len);
@ -807,7 +816,7 @@ coap_set_header_etag(coap_packet_t *coap_pkt, const uint8_t *etag, size_t etag_l
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/*FIXME support multiple ETags */ /*FIXME support multiple ETags */
int int
coap_get_header_if_match(coap_packet_t *coap_pkt, const uint8_t **etag) coap_get_header_if_match(coap_message_t *coap_pkt, const uint8_t **etag)
{ {
if(!coap_is_option(coap_pkt, COAP_OPTION_IF_MATCH)) { if(!coap_is_option(coap_pkt, COAP_OPTION_IF_MATCH)) {
return 0; return 0;
@ -816,7 +825,7 @@ coap_get_header_if_match(coap_packet_t *coap_pkt, const uint8_t **etag)
return coap_pkt->if_match_len; return coap_pkt->if_match_len;
} }
int int
coap_set_header_if_match(coap_packet_t *coap_pkt, const uint8_t *etag, size_t etag_len) coap_set_header_if_match(coap_message_t *coap_pkt, const uint8_t *etag, size_t etag_len)
{ {
coap_pkt->if_match_len = MIN(COAP_ETAG_LEN, etag_len); coap_pkt->if_match_len = MIN(COAP_ETAG_LEN, etag_len);
memcpy(coap_pkt->if_match, etag, coap_pkt->if_match_len); memcpy(coap_pkt->if_match, etag, coap_pkt->if_match_len);
@ -826,19 +835,19 @@ coap_set_header_if_match(coap_packet_t *coap_pkt, const uint8_t *etag, size_t et
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
int int
coap_get_header_if_none_match(coap_packet_t *packet) coap_get_header_if_none_match(coap_message_t *message)
{ {
return coap_is_option(packet, COAP_OPTION_IF_NONE_MATCH) ? 1 : 0; return coap_is_option(message, COAP_OPTION_IF_NONE_MATCH) ? 1 : 0;
} }
int int
coap_set_header_if_none_match(coap_packet_t *packet) coap_set_header_if_none_match(coap_message_t *message)
{ {
coap_set_option(packet, COAP_OPTION_IF_NONE_MATCH); coap_set_option(message, COAP_OPTION_IF_NONE_MATCH);
return 1; return 1;
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
int int
coap_get_header_proxy_uri(coap_packet_t *coap_pkt, const char **uri) coap_get_header_proxy_uri(coap_message_t *coap_pkt, const char **uri)
{ {
if(!coap_is_option(coap_pkt, COAP_OPTION_PROXY_URI)) { if(!coap_is_option(coap_pkt, COAP_OPTION_PROXY_URI)) {
return 0; return 0;
@ -847,7 +856,7 @@ coap_get_header_proxy_uri(coap_packet_t *coap_pkt, const char **uri)
return coap_pkt->proxy_uri_len; return coap_pkt->proxy_uri_len;
} }
int int
coap_set_header_proxy_uri(coap_packet_t *coap_pkt, const char *uri) coap_set_header_proxy_uri(coap_message_t *coap_pkt, const char *uri)
{ {
/* TODO Provide alternative that sets Proxy-Scheme and Uri-* options and provide coap-conf define */ /* TODO Provide alternative that sets Proxy-Scheme and Uri-* options and provide coap-conf define */
@ -859,7 +868,7 @@ coap_set_header_proxy_uri(coap_packet_t *coap_pkt, const char *uri)
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
int int
coap_get_header_uri_host(coap_packet_t *coap_pkt, const char **host) coap_get_header_uri_host(coap_message_t *coap_pkt, const char **host)
{ {
if(!coap_is_option(coap_pkt, COAP_OPTION_URI_HOST)) { if(!coap_is_option(coap_pkt, COAP_OPTION_URI_HOST)) {
return 0; return 0;
@ -868,7 +877,7 @@ coap_get_header_uri_host(coap_packet_t *coap_pkt, const char **host)
return coap_pkt->uri_host_len; return coap_pkt->uri_host_len;
} }
int int
coap_set_header_uri_host(coap_packet_t *coap_pkt, const char *host) coap_set_header_uri_host(coap_message_t *coap_pkt, const char *host)
{ {
coap_pkt->uri_host = host; coap_pkt->uri_host = host;
coap_pkt->uri_host_len = strlen(host); coap_pkt->uri_host_len = strlen(host);
@ -878,7 +887,7 @@ coap_set_header_uri_host(coap_packet_t *coap_pkt, const char *host)
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
int int
coap_get_header_uri_path(coap_packet_t *coap_pkt, const char **path) coap_get_header_uri_path(coap_message_t *coap_pkt, const char **path)
{ {
if(!coap_is_option(coap_pkt, COAP_OPTION_URI_PATH)) { if(!coap_is_option(coap_pkt, COAP_OPTION_URI_PATH)) {
return 0; return 0;
@ -887,7 +896,7 @@ coap_get_header_uri_path(coap_packet_t *coap_pkt, const char **path)
return coap_pkt->uri_path_len; return coap_pkt->uri_path_len;
} }
int int
coap_set_header_uri_path(coap_packet_t *coap_pkt, const char *path) coap_set_header_uri_path(coap_message_t *coap_pkt, const char *path)
{ {
while(path[0] == '/') { while(path[0] == '/') {
++path; ++path;
@ -901,7 +910,7 @@ coap_set_header_uri_path(coap_packet_t *coap_pkt, const char *path)
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
int int
coap_get_header_uri_query(coap_packet_t *coap_pkt, const char **query) coap_get_header_uri_query(coap_message_t *coap_pkt, const char **query)
{ {
if(!coap_is_option(coap_pkt, COAP_OPTION_URI_QUERY)) { if(!coap_is_option(coap_pkt, COAP_OPTION_URI_QUERY)) {
return 0; return 0;
@ -910,7 +919,7 @@ coap_get_header_uri_query(coap_packet_t *coap_pkt, const char **query)
return coap_pkt->uri_query_len; return coap_pkt->uri_query_len;
} }
int int
coap_set_header_uri_query(coap_packet_t *coap_pkt, const char *query) coap_set_header_uri_query(coap_message_t *coap_pkt, const char *query)
{ {
while(query[0] == '?') { while(query[0] == '?') {
++query; ++query;
@ -924,7 +933,7 @@ coap_set_header_uri_query(coap_packet_t *coap_pkt, const char *query)
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
int int
coap_get_header_location_path(coap_packet_t *coap_pkt, const char **path) coap_get_header_location_path(coap_message_t *coap_pkt, const char **path)
{ {
if(!coap_is_option(coap_pkt, COAP_OPTION_LOCATION_PATH)) { if(!coap_is_option(coap_pkt, COAP_OPTION_LOCATION_PATH)) {
return 0; return 0;
@ -933,7 +942,7 @@ coap_get_header_location_path(coap_packet_t *coap_pkt, const char **path)
return coap_pkt->location_path_len; return coap_pkt->location_path_len;
} }
int int
coap_set_header_location_path(coap_packet_t *coap_pkt, const char *path) coap_set_header_location_path(coap_message_t *coap_pkt, const char *path)
{ {
char *query; char *query;
@ -955,7 +964,7 @@ coap_set_header_location_path(coap_packet_t *coap_pkt, const char *path)
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
int int
coap_get_header_location_query(coap_packet_t *coap_pkt, const char **query) coap_get_header_location_query(coap_message_t *coap_pkt, const char **query)
{ {
if(!coap_is_option(coap_pkt, COAP_OPTION_LOCATION_QUERY)) { if(!coap_is_option(coap_pkt, COAP_OPTION_LOCATION_QUERY)) {
return 0; return 0;
@ -964,7 +973,7 @@ coap_get_header_location_query(coap_packet_t *coap_pkt, const char **query)
return coap_pkt->location_query_len; return coap_pkt->location_query_len;
} }
int int
coap_set_header_location_query(coap_packet_t *coap_pkt, const char *query) coap_set_header_location_query(coap_message_t *coap_pkt, const char *query)
{ {
while(query[0] == '?') { while(query[0] == '?') {
++query; ++query;
@ -978,7 +987,7 @@ coap_set_header_location_query(coap_packet_t *coap_pkt, const char *query)
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
int int
coap_get_header_observe(coap_packet_t *coap_pkt, uint32_t *observe) coap_get_header_observe(coap_message_t *coap_pkt, uint32_t *observe)
{ {
if(!coap_is_option(coap_pkt, COAP_OPTION_OBSERVE)) { if(!coap_is_option(coap_pkt, COAP_OPTION_OBSERVE)) {
return 0; return 0;
@ -987,7 +996,7 @@ coap_get_header_observe(coap_packet_t *coap_pkt, uint32_t *observe)
return 1; return 1;
} }
int int
coap_set_header_observe(coap_packet_t *coap_pkt, uint32_t observe) coap_set_header_observe(coap_message_t *coap_pkt, uint32_t observe)
{ {
coap_pkt->observe = observe; coap_pkt->observe = observe;
coap_set_option(coap_pkt, COAP_OPTION_OBSERVE); coap_set_option(coap_pkt, COAP_OPTION_OBSERVE);
@ -995,7 +1004,7 @@ coap_set_header_observe(coap_packet_t *coap_pkt, uint32_t observe)
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
int int
coap_get_header_block2(coap_packet_t *coap_pkt, uint32_t *num, uint8_t *more, coap_get_header_block2(coap_message_t *coap_pkt, uint32_t *num, uint8_t *more,
uint16_t *size, uint32_t *offset) uint16_t *size, uint32_t *offset)
{ {
if(!coap_is_option(coap_pkt, COAP_OPTION_BLOCK2)) { if(!coap_is_option(coap_pkt, COAP_OPTION_BLOCK2)) {
@ -1017,7 +1026,7 @@ coap_get_header_block2(coap_packet_t *coap_pkt, uint32_t *num, uint8_t *more,
return 1; return 1;
} }
int int
coap_set_header_block2(coap_packet_t *coap_pkt, uint32_t num, uint8_t more, coap_set_header_block2(coap_message_t *coap_pkt, uint32_t num, uint8_t more,
uint16_t size) uint16_t size)
{ {
if(size < 16) { if(size < 16) {
@ -1038,7 +1047,7 @@ coap_set_header_block2(coap_packet_t *coap_pkt, uint32_t num, uint8_t more,
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
int int
coap_get_header_block1(coap_packet_t *coap_pkt, uint32_t *num, uint8_t *more, coap_get_header_block1(coap_message_t *coap_pkt, uint32_t *num, uint8_t *more,
uint16_t *size, uint32_t *offset) uint16_t *size, uint32_t *offset)
{ {
if(!coap_is_option(coap_pkt, COAP_OPTION_BLOCK1)) { if(!coap_is_option(coap_pkt, COAP_OPTION_BLOCK1)) {
@ -1060,7 +1069,7 @@ coap_get_header_block1(coap_packet_t *coap_pkt, uint32_t *num, uint8_t *more,
return 1; return 1;
} }
int int
coap_set_header_block1(coap_packet_t *coap_pkt, uint32_t num, uint8_t more, coap_set_header_block1(coap_message_t *coap_pkt, uint32_t num, uint8_t more,
uint16_t size) uint16_t size)
{ {
if(size < 16) { if(size < 16) {
@ -1081,7 +1090,7 @@ coap_set_header_block1(coap_packet_t *coap_pkt, uint32_t num, uint8_t more,
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
int int
coap_get_header_size2(coap_packet_t *coap_pkt, uint32_t *size) coap_get_header_size2(coap_message_t *coap_pkt, uint32_t *size)
{ {
if(!coap_is_option(coap_pkt, COAP_OPTION_SIZE2)) { if(!coap_is_option(coap_pkt, COAP_OPTION_SIZE2)) {
return 0; return 0;
@ -1090,7 +1099,7 @@ coap_get_header_size2(coap_packet_t *coap_pkt, uint32_t *size)
return 1; return 1;
} }
int int
coap_set_header_size2(coap_packet_t *coap_pkt, uint32_t size) coap_set_header_size2(coap_message_t *coap_pkt, uint32_t size)
{ {
coap_pkt->size2 = size; coap_pkt->size2 = size;
coap_set_option(coap_pkt, COAP_OPTION_SIZE2); coap_set_option(coap_pkt, COAP_OPTION_SIZE2);
@ -1098,7 +1107,7 @@ coap_set_header_size2(coap_packet_t *coap_pkt, uint32_t size)
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
int int
coap_get_header_size1(coap_packet_t *coap_pkt, uint32_t *size) coap_get_header_size1(coap_message_t *coap_pkt, uint32_t *size)
{ {
if(!coap_is_option(coap_pkt, COAP_OPTION_SIZE1)) { if(!coap_is_option(coap_pkt, COAP_OPTION_SIZE1)) {
return 0; return 0;
@ -1107,7 +1116,7 @@ coap_get_header_size1(coap_packet_t *coap_pkt, uint32_t *size)
return 1; return 1;
} }
int int
coap_set_header_size1(coap_packet_t *coap_pkt, uint32_t size) coap_set_header_size1(coap_message_t *coap_pkt, uint32_t size)
{ {
coap_pkt->size1 = size; coap_pkt->size1 = size;
coap_set_option(coap_pkt, COAP_OPTION_SIZE1); coap_set_option(coap_pkt, COAP_OPTION_SIZE1);
@ -1115,7 +1124,7 @@ coap_set_header_size1(coap_packet_t *coap_pkt, uint32_t size)
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
int int
coap_get_payload(coap_packet_t *coap_pkt, const uint8_t **payload) coap_get_payload(coap_message_t *coap_pkt, const uint8_t **payload)
{ {
if(coap_pkt->payload) { if(coap_pkt->payload) {
*payload = coap_pkt->payload; *payload = coap_pkt->payload;
@ -1126,7 +1135,7 @@ coap_get_payload(coap_packet_t *coap_pkt, const uint8_t **payload)
} }
} }
int int
coap_set_payload(coap_packet_t *coap_pkt, const void *payload, size_t length) coap_set_payload(coap_message_t *coap_pkt, const void *payload, size_t length)
{ {
coap_pkt->payload = (uint8_t *)payload; coap_pkt->payload = (uint8_t *)payload;
coap_pkt->payload_len = MIN(COAP_MAX_CHUNK_SIZE, length); coap_pkt->payload_len = MIN(COAP_MAX_CHUNK_SIZE, length);
@ -1134,3 +1143,4 @@ coap_set_payload(coap_packet_t *coap_pkt, const void *payload, size_t length)
return coap_pkt->payload_len; return coap_pkt->payload_len;
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/** @} */

View File

@ -36,6 +36,14 @@
* Matthias Kovatsch <kovatsch@inf.ethz.ch> * Matthias Kovatsch <kovatsch@inf.ethz.ch>
*/ */
/**
* \defgroup coap CoAP
* @{
*
* The Constrained Application Protocol - RFC 7252
*/
#ifndef COAP_H_ #ifndef COAP_H_
#define COAP_H_ #define COAP_H_
@ -44,6 +52,9 @@
#include "coap-conf.h" #include "coap-conf.h"
#include "coap-transport.h" #include "coap-transport.h"
/**
* \brief The max size of the CoAP messages
*/
#define COAP_MAX_PACKET_SIZE (COAP_MAX_HEADER_SIZE + COAP_MAX_CHUNK_SIZE) #define COAP_MAX_PACKET_SIZE (COAP_MAX_HEADER_SIZE + COAP_MAX_CHUNK_SIZE)
/* COAP_MAX_CHUNK_SIZE can be different from 2^x so we need to get next lower 2^x for COAP_MAX_BLOCK_SIZE */ /* COAP_MAX_CHUNK_SIZE can be different from 2^x so we need to get next lower 2^x for COAP_MAX_BLOCK_SIZE */
@ -62,7 +73,7 @@
/* parsed message struct */ /* parsed message struct */
typedef struct { typedef struct {
uint8_t *buffer; /* pointer to CoAP header / incoming packet buffer / memory to serialize packet */ uint8_t *buffer; /* pointer to CoAP header / incoming message buffer / memory to serialize message */
uint8_t version; uint8_t version;
coap_message_type_t type; coap_message_type_t type;
@ -113,23 +124,23 @@ typedef struct {
uint16_t payload_len; uint16_t payload_len;
uint8_t *payload; uint8_t *payload;
} coap_packet_t; } coap_message_t;
static inline int static inline int
coap_set_option(coap_packet_t *packet, unsigned int opt) coap_set_option(coap_message_t *message, unsigned int opt)
{ {
if(opt > COAP_OPTION_SIZE1) { if(opt > COAP_OPTION_SIZE1) {
return 0; return 0;
} }
packet->options[opt / OPTION_MAP_SIZE] |= 1 << (opt % OPTION_MAP_SIZE); message->options[opt / OPTION_MAP_SIZE] |= 1 << (opt % OPTION_MAP_SIZE);
return 1; return 1;
} }
static inline int static inline int
coap_is_option(const coap_packet_t *packet, unsigned int opt) coap_is_option(const coap_message_t *message, unsigned int opt)
{ {
return (opt <= COAP_OPTION_SIZE1) && return (opt <= COAP_OPTION_SIZE1) &&
(packet->options[opt / OPTION_MAP_SIZE] & (1 << (opt % OPTION_MAP_SIZE))) != 0; (message->options[opt / OPTION_MAP_SIZE] & (1 << (opt % OPTION_MAP_SIZE))) != 0;
} }
/* option format serialization */ /* option format serialization */
@ -180,110 +191,112 @@ extern const char *coap_error_message;
void coap_init_connection(void); void coap_init_connection(void);
uint16_t coap_get_mid(void); uint16_t coap_get_mid(void);
void coap_init_message(coap_packet_t *packet, coap_message_type_t type, void coap_init_message(coap_message_t *message, coap_message_type_t type,
uint8_t code, uint16_t mid); uint8_t code, uint16_t mid);
size_t coap_serialize_message(coap_packet_t *packet, uint8_t *buffer); size_t coap_serialize_message(coap_message_t *message, uint8_t *buffer);
coap_status_t coap_parse_message(coap_packet_t *request, uint8_t *data, coap_status_t coap_parse_message(coap_message_t *request, uint8_t *data,
uint16_t data_len); uint16_t data_len);
int coap_get_query_variable(coap_packet_t *packet, const char *name, int coap_get_query_variable(coap_message_t *message, const char *name,
const char **output); const char **output);
int coap_get_post_variable(coap_packet_t *packet, const char *name, int coap_get_post_variable(coap_message_t *message, const char *name,
const char **output); const char **output);
static inline coap_resource_flags_t static inline coap_resource_flags_t
coap_get_method_type(coap_packet_t *packet) coap_get_method_type(coap_message_t *message)
{ {
return (coap_resource_flags_t)(1 << (packet->code - 1)); return (coap_resource_flags_t)(1 << (message->code - 1));
} }
static inline const coap_endpoint_t * static inline const coap_endpoint_t *
coap_get_src_endpoint(coap_packet_t *request) coap_get_src_endpoint(coap_message_t *request)
{ {
return request->src_ep; return request->src_ep;
} }
static inline void static inline void
coap_set_src_endpoint(coap_packet_t *request, const coap_endpoint_t *ep) coap_set_src_endpoint(coap_message_t *request, const coap_endpoint_t *ep)
{ {
request->src_ep = ep; request->src_ep = ep;
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
int coap_set_status_code(coap_packet_t *packet, unsigned int code); int coap_set_status_code(coap_message_t *message, unsigned int code);
int coap_set_token(coap_packet_t *packet, const uint8_t *token, int coap_set_token(coap_message_t *message, const uint8_t *token,
size_t token_len); size_t token_len);
int coap_get_header_content_format(coap_packet_t *packet, unsigned int *format); int coap_get_header_content_format(coap_message_t *message, unsigned int *format);
int coap_set_header_content_format(coap_packet_t *packet, unsigned int format); int coap_set_header_content_format(coap_message_t *message, unsigned int format);
int coap_get_header_accept(coap_packet_t *packet, unsigned int *accept); int coap_get_header_accept(coap_message_t *message, unsigned int *accept);
int coap_set_header_accept(coap_packet_t *packet, unsigned int accept); int coap_set_header_accept(coap_message_t *message, unsigned int accept);
int coap_get_header_max_age(coap_packet_t *packet, uint32_t *age); int coap_get_header_max_age(coap_message_t *message, uint32_t *age);
int coap_set_header_max_age(coap_packet_t *packet, uint32_t age); int coap_set_header_max_age(coap_message_t *message, uint32_t age);
int coap_get_header_etag(coap_packet_t *packet, const uint8_t **etag); int coap_get_header_etag(coap_message_t *message, const uint8_t **etag);
int coap_set_header_etag(coap_packet_t *packet, const uint8_t *etag, int coap_set_header_etag(coap_message_t *message, const uint8_t *etag,
size_t etag_len); size_t etag_len);
int coap_get_header_if_match(coap_packet_t *packet, const uint8_t **etag); int coap_get_header_if_match(coap_message_t *message, const uint8_t **etag);
int coap_set_header_if_match(coap_packet_t *packet, const uint8_t *etag, int coap_set_header_if_match(coap_message_t *message, const uint8_t *etag,
size_t etag_len); size_t etag_len);
int coap_get_header_if_none_match(coap_packet_t *packet); int coap_get_header_if_none_match(coap_message_t *message);
int coap_set_header_if_none_match(coap_packet_t *packet); int coap_set_header_if_none_match(coap_message_t *message);
/* in-place string might not be 0-terminated. */ /* in-place string might not be 0-terminated. */
int coap_get_header_proxy_uri(coap_packet_t *packet, const char **uri); int coap_get_header_proxy_uri(coap_message_t *message, const char **uri);
int coap_set_header_proxy_uri(coap_packet_t *packet, const char *uri); int coap_set_header_proxy_uri(coap_message_t *message, const char *uri);
/* in-place string might not be 0-terminated. */ /* in-place string might not be 0-terminated. */
int coap_get_header_proxy_scheme(coap_packet_t *packet, const char **scheme); int coap_get_header_proxy_scheme(coap_message_t *message, const char **scheme);
int coap_set_header_proxy_scheme(coap_packet_t *packet, const char *scheme); int coap_set_header_proxy_scheme(coap_message_t *message, const char *scheme);
/* in-place string might not be 0-terminated. */ /* in-place string might not be 0-terminated. */
int coap_get_header_uri_host(coap_packet_t *packet, const char **host); int coap_get_header_uri_host(coap_message_t *message, const char **host);
int coap_set_header_uri_host(coap_packet_t *packet, const char *host); int coap_set_header_uri_host(coap_message_t *message, const char *host);
/* in-place string might not be 0-terminated. */ /* in-place string might not be 0-terminated. */
int coap_get_header_uri_path(coap_packet_t *packet, const char **path); int coap_get_header_uri_path(coap_message_t *message, const char **path);
int coap_set_header_uri_path(coap_packet_t *packet, const char *path); int coap_set_header_uri_path(coap_message_t *message, const char *path);
/* in-place string might not be 0-terminated. */ /* in-place string might not be 0-terminated. */
int coap_get_header_uri_query(coap_packet_t *packet, const char **query); int coap_get_header_uri_query(coap_message_t *message, const char **query);
int coap_set_header_uri_query(coap_packet_t *packet, const char *query); int coap_set_header_uri_query(coap_message_t *message, const char *query);
/* in-place string might not be 0-terminated. */ /* in-place string might not be 0-terminated. */
int coap_get_header_location_path(coap_packet_t *packet, const char **path); int coap_get_header_location_path(coap_message_t *message, const char **path);
/* also splits optional query into Location-Query option. */ /* also splits optional query into Location-Query option. */
int coap_set_header_location_path(coap_packet_t *packet, const char *path); int coap_set_header_location_path(coap_message_t *message, const char *path);
/* in-place string might not be 0-terminated. */ /* in-place string might not be 0-terminated. */
int coap_get_header_location_query(coap_packet_t *packet, const char **query); int coap_get_header_location_query(coap_message_t *message, const char **query);
int coap_set_header_location_query(coap_packet_t *packet, const char *query); int coap_set_header_location_query(coap_message_t *message, const char *query);
int coap_get_header_observe(coap_packet_t *packet, uint32_t *observe); int coap_get_header_observe(coap_message_t *message, uint32_t *observe);
int coap_set_header_observe(coap_packet_t *packet, uint32_t observe); int coap_set_header_observe(coap_message_t *message, uint32_t observe);
int coap_get_header_block2(coap_packet_t *packet, uint32_t *num, uint8_t *more, int coap_get_header_block2(coap_message_t *message, uint32_t *num, uint8_t *more,
uint16_t *size, uint32_t *offset); uint16_t *size, uint32_t *offset);
int coap_set_header_block2(coap_packet_t *packet, uint32_t num, uint8_t more, int coap_set_header_block2(coap_message_t *message, uint32_t num, uint8_t more,
uint16_t size); uint16_t size);
int coap_get_header_block1(coap_packet_t *packet, uint32_t *num, uint8_t *more, int coap_get_header_block1(coap_message_t *message, uint32_t *num, uint8_t *more,
uint16_t *size, uint32_t *offset); uint16_t *size, uint32_t *offset);
int coap_set_header_block1(coap_packet_t *packet, uint32_t num, uint8_t more, int coap_set_header_block1(coap_message_t *message, uint32_t num, uint8_t more,
uint16_t size); uint16_t size);
int coap_get_header_size2(coap_packet_t *packet, uint32_t *size); int coap_get_header_size2(coap_message_t *message, uint32_t *size);
int coap_set_header_size2(coap_packet_t *packet, uint32_t size); int coap_set_header_size2(coap_message_t *message, uint32_t size);
int coap_get_header_size1(coap_packet_t *packet, uint32_t *size); int coap_get_header_size1(coap_message_t *message, uint32_t *size);
int coap_set_header_size1(coap_packet_t *packet, uint32_t size); int coap_set_header_size1(coap_message_t *message, uint32_t size);
int coap_get_payload(coap_packet_t *packet, const uint8_t **payload); int coap_get_payload(coap_message_t *message, const uint8_t **payload);
int coap_set_payload(coap_packet_t *packet, const void *payload, size_t length); int coap_set_payload(coap_message_t *message, const void *payload, size_t length);
#endif /* COAP_H_ */ #endif /* COAP_H_ */
/** @} */

View File

@ -120,8 +120,8 @@ static uint64_t lwm2m_buf_lock_timeout = 0;
static lwm2m_write_opaque_callback current_opaque_callback; static lwm2m_write_opaque_callback current_opaque_callback;
static int current_opaque_offset = 0; static int current_opaque_offset = 0;
static coap_handler_status_t lwm2m_handler_callback(coap_packet_t *request, static coap_handler_status_t lwm2m_handler_callback(coap_message_t *request,
coap_packet_t *response, coap_message_t *response,
uint8_t *buffer, uint8_t *buffer,
uint16_t buffer_size, uint16_t buffer_size,
int32_t *offset); int32_t *offset);
@ -350,7 +350,7 @@ parse_path(const char *path, int path_len,
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
static int static int
lwm2m_engine_parse_context(const char *path, int path_len, lwm2m_engine_parse_context(const char *path, int path_len,
coap_packet_t *request, coap_packet_t *response, coap_message_t *request, coap_message_t *response,
uint8_t *outbuf, size_t outsize, uint8_t *outbuf, size_t outsize,
lwm2m_context_t *context) lwm2m_context_t *context)
{ {
@ -470,7 +470,7 @@ lwm2m_engine_set_rd_data(lwm2m_buffer_t *outbuf, int block)
} }
if(instance == NULL && object == NULL && lwm2m_buf.len <= maxsize) { if(instance == NULL && object == NULL && lwm2m_buf.len <= maxsize) {
/* Data generation is done. No more packets are needed after this. */ /* Data generation is done. No more messages are needed after this. */
break; break;
} }
} }
@ -1296,7 +1296,7 @@ next_object_instance(const lwm2m_context_t *context, lwm2m_object_t *object,
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static coap_handler_status_t static coap_handler_status_t
lwm2m_handler_callback(coap_packet_t *request, coap_packet_t *response, lwm2m_handler_callback(coap_message_t *request, coap_message_t *response,
uint8_t *buffer, uint16_t buffer_size, int32_t *offset) uint8_t *buffer, uint16_t buffer_size, int32_t *offset)
{ {
const char *url; const char *url;
@ -1568,7 +1568,7 @@ lwm2m_handler_callback(coap_packet_t *request, coap_packet_t *response,
if(context.writer_flags & WRITER_HAS_MORE) { if(context.writer_flags & WRITER_HAS_MORE) {
*offset = context.offset; *offset = context.offset;
} else { } else {
/* this signals to CoAP that there is no more CoAP packets to expect */ /* this signals to CoAP that there is no more CoAP messages to expect */
*offset = -1; *offset = -1;
} }
} }

View File

@ -180,8 +180,8 @@ typedef struct lwm2m_context {
uint8_t level; /* 0/1/2/3 = 3 = resource */ uint8_t level; /* 0/1/2/3 = 3 = resource */
lwm2m_operation_t operation; lwm2m_operation_t operation;
coap_packet_t *request; coap_message_t *request;
coap_packet_t *response; coap_message_t *response;
unsigned int content_type; unsigned int content_type;
lwm2m_buffer_t *outbuf; lwm2m_buffer_t *outbuf;

View File

@ -92,7 +92,7 @@
static struct lwm2m_session_info session_info; static struct lwm2m_session_info session_info;
static coap_request_state_t rd_request_state; static coap_request_state_t rd_request_state;
static coap_packet_t request[1]; /* This way the packet can be treated as pointer as usual. */ static coap_message_t request[1]; /* This way the message can be treated as pointer as usual. */
/* The states for the RD client state machine */ /* The states for the RD client state machine */
/* When node is unregistered it ends up in UNREGISTERED /* When node is unregistered it ends up in UNREGISTERED
@ -135,7 +135,7 @@ static void check_periodic_observations();
static void update_callback(coap_request_state_t *state); static void update_callback(coap_request_state_t *state);
static int static int
set_rd_data(coap_packet_t *request) set_rd_data(coap_message_t *request)
{ {
lwm2m_buffer_t outbuf; lwm2m_buffer_t outbuf;
@ -157,7 +157,7 @@ set_rd_data(coap_packet_t *request)
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static void static void
prepare_update(coap_packet_t *request, int triggered) { prepare_update(coap_message_t *request, int triggered) {
coap_init_message(request, COAP_TYPE_CON, COAP_POST, 0); coap_init_message(request, COAP_TYPE_CON, COAP_POST, 0);
coap_set_header_uri_path(request, session_info.assigned_ep); coap_set_header_uri_path(request, session_info.assigned_ep);