mirror of
https://github.com/oliverschmidt/contiki.git
synced 2024-09-05 12:29:38 +00:00
Added Content-Type to observe notifications.
This commit is contained in:
parent
949ba03bda
commit
c023faead2
@ -259,7 +259,7 @@ resource_t resource_##name = {NULL, flags, url, attributes, name##_handler, NULL
|
|||||||
* Macro to define a sub-resource
|
* Macro to define a sub-resource
|
||||||
* Make sure to define its parent resource beforehand and set 'parent' to that name.
|
* Make sure to define its parent resource beforehand and set 'parent' to that name.
|
||||||
*/
|
*/
|
||||||
#define SUB_RESOURCE(name, flags, url, attributes, parent) \
|
#define SUB_RESOURCE(name, flags, url, attributes, parent) \
|
||||||
resource_t resource_##name = {NULL, flags, url, attributes, parent##_handler, NULL, NULL, NULL}
|
resource_t resource_##name = {NULL, flags, url, attributes, parent##_handler, NULL, NULL, NULL}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -482,9 +482,12 @@ obs_periodic_handler(resource_t *r)
|
|||||||
PRINTF("TICK %u for /%s\n", obs_counter, r->url);
|
PRINTF("TICK %u for /%s\n", obs_counter, r->url);
|
||||||
|
|
||||||
/* Build notification. */
|
/* Build notification. */
|
||||||
|
/*TODO: REST.new_response() */
|
||||||
coap_packet_t notification[1]; /* This way the packet can be treated as pointer as usual. */
|
coap_packet_t notification[1]; /* This way the packet can be treated as pointer as usual. */
|
||||||
coap_init_message(notification, COAP_TYPE_NON, CONTENT_2_05, 0 );
|
coap_init_message(notification, COAP_TYPE_NON, CONTENT_2_05, 0 );
|
||||||
coap_set_payload(notification, obs_content, snprintf(obs_content, sizeof(obs_content), "TICK %u", obs_counter));
|
|
||||||
|
REST.set_response_payload(notification, obs_content, snprintf(obs_content, sizeof(obs_content), "TICK %u", obs_counter));
|
||||||
|
REST.set_header_content_type(notification, REST.type.TEXT_PLAIN);
|
||||||
|
|
||||||
/* Notify the registered observers with the given message type, observe option, and payload. */
|
/* Notify the registered observers with the given message type, observe option, and payload. */
|
||||||
REST.notify_subscribers(r, obs_counter, notification);
|
REST.notify_subscribers(r, obs_counter, notification);
|
||||||
|
Loading…
Reference in New Issue
Block a user