Commit Graph
5 Commits
Author SHA1 Message Date
Jon Shallow 02923e7ffb Update resource documentation
man/coap_resource.txt.in:

Add in coap_resource_set_userdata() and coap_resource_get_userdata()
documentation

include/coap2/resource.h:

Re-organize order and put into appropriate doxygen groups

include/coap2/subscribe.h:

Fix Doxygen title case
2019-11-28 16:19:18 +00:00
Jon Shallow 2900f72a64 Make coap_subscription_t and coap_endpoint_t opaque to applications
include/coap2/coap_subscribe_internal.h and
include/coap2/coap_session_internal.h contain the information not exposed
to applications.

This internal information was moved out of the respective
include/coap2/subscribe.h and include/coap2/coap_session.h files comprising of
the coap_subscription_t and coap_endpoint_t definitions.

To ease inter .h file dependencies, a new file
include/coap2/coap_forward_decls.h is added to include forward declarations
for both libcoap and applications.

Makefile.am:

Include include/coap2/coap_*internal.h as files for distribution, but not
installed for applications to use.
Include include/coap2/coap_forward_decls.h, so it is installed for
applications.

include/coap2/coap.h.in:

Include "coap_forward_decls.h"

include/coap2/coap_forward_decls.h: (New)

Forward declare structures and typedef the structures defined in
coap_internal.h.

include/coap2/coap_internal.h: (New)

Includes all the required #include files that libcoap internally needs.

include/coap2/coap_session_internal.h: (New)

Include the coap_endpoint_t information taken from
include/coap2/coap_session.h.

include/coap2/coap_session.h:

Remove coap_endpoint_t definition.

include/coap2/lwippools.h:

Add in coap_forward_decls.h and coap_internal.h to handle the LwIP memory
allocations.

include/coap2/resource.h:

Add in "block.h" to allow things to build.

include/coap2/coap_subscribe_internal.h: (New)

Include the coap_subscription_t information taken from
include/coap2/subscribe.h.

include/coap2/subscribe.h:

Remove coap_subscription_t definition.

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

Updated, removing coap_subscription_init().

src/address.c:
src/asyn.c:
src/block.c:
src/coap_debug.c:
src/coap_event.c:
src/coap_gnutls.c:
src/coap_hashkey.c:
src/coap_io.c:
src/coap_io_lwip.c:
src/coap_notls.c:
src/coap_openssl.c:
src/coap_session.c:
src/coap_time.c:
src/coap_tinydtls.c:
src/encode.c:
src/mem.c:
src/net.c:
src/option.c:
src/pdu.c:
src/resource.c:
src/str.c:
src/subscribe.c:
src/uri.c:

Add in '#include "coap_internal.h"' to the source files.
Remove other libcoap #include files.

win32/libcoap.vcxproj:
win32/libcoap.vcxproj.filters:

Update for Windows build (not tested).

examples/contiki/server.c:
src/coap_io.c:

Remove knowledge of endpoint from the server and update Contiki's
version of coap_run_once() to do the work instead.

====
Other structures (plus some internal required #defines) will follow as
separate PRs.
2019-09-03 11:59:07 +01:00
Jon Shallow 7a4d2db8f3 Fix RST deleting observer for non-confirmable observe
Code works as expected for confirmable observes as the sent pdu is
retained for potential re-transmission.

For non-confirmable observes, the RST is seen in the response packet but
previously had no way of finding the observe/subscription to cancel.

Keep the last sent message id in coap_subscription_t (as tid) and when the
RST comes in, search for the subscription that has the same message id as
the pdu and remove that subscription.

include/coap2/subscribe.h:

Add in tid to coap_subscription_t (as per coap_pdu_t).

src/net.c:

Match tid in incoming RST pdu with a subscription.  If found, delete the
subscription.

src/resource.c:

Save tid in both pdu and subscription when sending off an observe response.

To test code, make the following temporary change to coap-client

diff --git a/examples/client.c b/examples/client.c
index 4d3e4c7..0020b68 100644
--- a/examples/client.c
+++ b/examples/client.c
@@ -348,7 +348,8 @@ message_handler(struct coap_context_t *ctx,
 #endif

   /* check if this is a response to our original request */
-  if (!check_token(received)) {
+static int count = 0;
+  if (!check_token(received) || ++count == 5) {
     /* drop if this was just some message, or send RST in case of notification */
     if (!sent && (received->type == COAP_MESSAGE_CON ||
                   received->type == COAP_MESSAGE_NON))

and run (coap-server running on the same host)

coap-client -N -s 10 coap://127.0.0.1/time
2019-04-25 08:45:19 +01:00
Jon Shallow 55d579449c Reserved Identifier fixes
include/coap2/libcoap.h
_LIBCOAP_H_ to COAP_LIBCOAP_H_
src/coap_session.c
_COAP_SESSION_H_ to COAP_SESSION_C_
include/coap2/coap_session.h
_SESSION_H_ to COAP_SESSION_H_

otherwise, all #define _COAP_xxxxx wrappers are now COAP_xxxxx

Fixes #291
2019-01-29 15:30:42 +00:00
Carsten Schoenert f584abc19e include: move header files to include/coap2
Automake is using the variable 'libcoap_include_HEADERS' as the list to
install the header files and is this list installing to $(prefix)
basically.
This commit is changing the primary installation folder for the header
files in addition to the previous commit.
2018-10-04 12:21:12 +02:00