Files
libcoap/include/coap2/subscribe.h
T
Jon Shallow da18643702 coap_resource_t: Obfuscate coap_resource_t from applications.
Create a new include/coap2/coap_resource_internal.h to hold all the information
not available to applications.

Makefile.am:

Include coap_resource_internal.h in EXTRA_DIST.
Remove functions no longer visible from CTAGS_IGNORE.

examples/coap-rd.c:
examples/contiki/server.c:
examples/etsi_iot_01.c:
tests/test_wellknown.c

Replace direct access to coap_resource_t variables with functions as
appropriate.

include/coap2/resource.h:
include/coap2/subscribe.h:
include/coap2/coap_resource_internal.h: (New)
include/coap2/coap_subscribe_internal.h:

Move coap_resource_t, coap_addr_t, non API #defines and non API functions from
resource.h into coap_resource_internal.h, coap_subscribe_internal.h and
subscribe.h.

Replace inline functions accessing coap_resource_t with actual function
definitions.

Add new functions coap_resource_release_userdata_handler() and
coap_attr_get_value().

include/coap2/block.h:

Use coap_resource_t typedef.

include/coap2/coap_forward_decls.h:

Include coap_resource_t and coap_addr_t typedefs.  Also typedef coap_context_t
to get rid of #include circular requirements.

include/coap2/coap_internal.h:
win32/libcoap.vcxproj:
win32/libcoap.vcxproj.filters:

Include coap_resource_internal.h.

include/coap2/net.h:

Remove "typedef struct coap_context_t" and do this in coap_forward_decls.h.

src/resource.c:

Update with the replaced inline functions. Add in the new functions
coap_resource_release_userdata_handler() and coap_attr_get_value().

libcoap-2.map:
libcoap-2.sym:

Update with new function visibility.

man/Makefile.am:
man/coap_attribute.txt.in:
man/coap_observe.txt.in:
man/coap_resource.txt.in:

Update with the new coap_resource_t and coap_attr_t usage.
2021-02-24 16:34:27 +00:00

67 lines
1.9 KiB
C

/*
* subscribe.h -- subscription handling for CoAP
* see RFC7641
*
* Copyright (C) 2010-2012,2014-2021 Olaf Bergmann <bergmann@tzi.org>
*
* This file is part of the CoAP library libcoap. Please see README for terms
* of use.
*/
/**
* @file subscribe.h
* @brief Defines the application visible subscribe information
*/
#ifndef COAP_SUBSCRIBE_H_
#define COAP_SUBSCRIBE_H_
/**
* @defgroup observe Resource Observation
* API functions for interfacing with the observe handling (RFC7641)
* @{
*/
/**
* The value COAP_OBSERVE_ESTABLISH in a GET/FETCH request option
* COAP_OPTION_OBSERVE indicates a new observe relationship for (sender
* address, token) is requested.
*/
#define COAP_OBSERVE_ESTABLISH 0
/**
* The value COAP_OBSERVE_CANCEL in a GET/FETCH request option
* COAP_OPTION_OBSERVE indicates that the observe relationship for (sender
* address, token) must be cancelled.
*/
#define COAP_OBSERVE_CANCEL 1
/**
* Set whether a @p resource is observable. If the resource is observable
* and the client has set the COAP_OPTION_OBSERVE in a request packet, then
* whenever the state of the resource changes (a call to
* coap_resource_trigger_observe()), an Observer response will get sent.
*
* @param resource The CoAP resource to use.
* @param mode @c 1 if Observable is to be set, @c 0 otherwise.
*
*/
void coap_resource_set_get_observable(coap_resource_t *resource, int mode);
/**
* Initiate the sending of an Observe packet for all observers of @p resource,
* optionally matching @p query if not NULL
*
* @param resource The CoAP resource to use.
* @param query The Query to match against or NULL
*
* @return @c 1 if the Observe has been triggered, @c 0 otherwise.
*/
int
coap_resource_notify_observers(coap_resource_t *resource,
const coap_string_t *query);
/** @} */
#endif /* COAP_SUBSCRIBE_H_ */