mirror of
https://github.com/obgm/libcoap.git
synced 2026-11-12 11:40:39 +03:00
hashkey.[ch] files restored (now prefixed with coap_) LWIP and Contiki builds now include these files block.[ch]: New function coap_add_data_blocked_response() to simplify GET responses and handle adding in BLOCK2 options as appropriate. Needs coap_hash() to generate ETag option. net.c: Determine if Block2 is in use, and add to coap_add_observer(). resource.[ch]: Include Block2 request in coap_add_observer(). subscribe.h: Include Block2 definition in coap_subscriber_t for using during observe responses. pdu.h: Update comment. coap-client.c: No longer causes duplicate calls to coap_show_pdu() (one in library, one in coap-client for the same PDU). If a block'ed response received and observing, now observing continues. (Fixes #166). Send Observe Cancel with Block2 option if -b defined coap-server.c: Replaced all option setting, data addition etc. with new coap_add_data_blocked_response() function in the GET handlers. (Fixes #246 Issue 2). Support PUT with BLOCK1. (Fixes #246 Issue 1). Add in -N option to send observe responses as non-confirmable. Handle small wait_ms values correctly (after being decremented) for testing whether observe should be triggered or not. Refresh time every second by making COAP_RESOURCE_CHECK_TIME 1 Manuals: Add in new function coap_add_data_blocked_response() Update coap_observe with coap_delete_observer(s) functions Correct example typo and use new function in hnd_get_time(). Add in -N option to coap-server(5) Be more specific about COAP_RESOURCE_FLAGS_NOTIFY_NON and COAP_RESOURCE_FLAGS_NOTIFY_CON usage for observe. Files: Makefile.am Makefile.libcoap examples/client.c examples/coap-server.c examples/lwip/Makefile include/coap/block.h include/coap/coap_hashkey.h include/coap/pdu.h include/coap/resource.h include/coap/subscribe.h libcoap-2.map libcoap-2.sym man/Makefile.am man/coap-server.txt.in man/coap_handler.txt.in man/coap_observe.txt.in man/coap_pdu_setup.txt.in man/coap_resource.txt.in src/block.c src/coap_hashkey.c src/net.c src/resource.c
77 lines
2.4 KiB
C
77 lines
2.4 KiB
C
/*
|
|
* subscribe.h -- subscription handling for CoAP
|
|
* see RFC7641
|
|
*
|
|
* Copyright (C) 2010-2012,2014-2015 Olaf Bergmann <bergmann@tzi.org>
|
|
*
|
|
* This file is part of the CoAP library libcoap. Please see README for terms
|
|
* of use.
|
|
*/
|
|
|
|
|
|
#ifndef _COAP_SUBSCRIBE_H_
|
|
#define _COAP_SUBSCRIBE_H_
|
|
|
|
#include "address.h"
|
|
#include "coap_io.h"
|
|
#include "block.h"
|
|
|
|
/**
|
|
* @defgroup observe Resource observation
|
|
* API functions for interfacing with the observe handling (RFC7641)
|
|
* @{
|
|
*/
|
|
|
|
/**
|
|
* The value COAP_OBSERVE_ESTABLISH in a GET request indicates a new observe
|
|
* relationship for (sender address, token) is requested.
|
|
*/
|
|
#define COAP_OBSERVE_ESTABLISH 0
|
|
|
|
/**
|
|
* The value COAP_OBSERVE_CANCEL in a GET request indicates that the observe
|
|
* relationship for (sender address, token) must be cancelled.
|
|
*/
|
|
#define COAP_OBSERVE_CANCEL 1
|
|
|
|
#ifndef COAP_OBS_MAX_NON
|
|
/**
|
|
* Number of notifications that may be sent non-confirmable before a confirmable
|
|
* message is sent to detect if observers are alive. The maximum allowed value
|
|
* here is @c 15.
|
|
*/
|
|
#define COAP_OBS_MAX_NON 5
|
|
#endif /* COAP_OBS_MAX_NON */
|
|
|
|
#ifndef COAP_OBS_MAX_FAIL
|
|
/**
|
|
* Number of confirmable notifications that may fail (i.e. time out without
|
|
* being ACKed) before an observer is removed. The maximum value for
|
|
* COAP_OBS_MAX_FAIL is @c 3.
|
|
*/
|
|
#define COAP_OBS_MAX_FAIL 3
|
|
#endif /* COAP_OBS_MAX_FAIL */
|
|
|
|
/** Subscriber information */
|
|
typedef struct coap_subscription_t {
|
|
struct coap_subscription_t *next; /**< next element in linked list */
|
|
coap_session_t *session; /**< subscriber session */
|
|
|
|
unsigned int non_cnt:4; /**< up to 15 non-confirmable notifies allowed */
|
|
unsigned int fail_cnt:2; /**< up to 3 confirmable notifies can fail */
|
|
unsigned int dirty:1; /**< set if the notification temporarily could not be
|
|
* sent (in that case, the resource's partially
|
|
* dirty flag is set too) */
|
|
unsigned int has_block2:1; /**< GET request had Block2 definition */
|
|
coap_block_t block2; /**< GET request Block2 definition */
|
|
size_t token_length; /**< actual length of token */
|
|
unsigned char token[8]; /**< token used for subscription */
|
|
coap_string_t *query; /**< query string used for subscription, if any */
|
|
} coap_subscription_t;
|
|
|
|
void coap_subscription_init(coap_subscription_t *);
|
|
|
|
/** @} */
|
|
|
|
#endif /* _COAP_SUBSCRIBE_H_ */
|