libcoap  4.3.0rc3
Go to the documentation of this file.
1 /*
2  * coap_subscribe_internal.h -- Structures, Enums & Functions that are not
3  * exposed to application programming
4  *
5  * Copyright (C) 2010-2021 Olaf Bergmann <>
6  *
7  * This file is part of the CoAP library libcoap. Please see README for terms
8  * of use.
9  */
26 #ifndef COAP_OBS_MAX_NON
32 #define COAP_OBS_MAX_NON 5
33 #endif /* COAP_OBS_MAX_NON */
35 #ifndef COAP_OBS_MAX_FAIL
41 #define COAP_OBS_MAX_FAIL 3
42 #endif /* COAP_OBS_MAX_FAIL */
49  unsigned int non_cnt:4;
50  unsigned int fail_cnt:2;
51  unsigned int dirty:1;
54  unsigned int has_block2:1;
58  size_t token_length;
59  unsigned char token[8];
60  struct coap_string_t *query;
61 };
72 void
74  coap_session_t *session,
75  const coap_binary_t *token);
83 void coap_check_notify(coap_context_t *context);
105  coap_session_t *session,
106  const coap_binary_t *token,
107  coap_string_t *query,
108  int has_block2,
109  coap_block_t block2,
110  coap_pdu_code_t code);
122  coap_session_t *session,
123  const coap_binary_t *token);
133 void coap_touch_observer(coap_context_t *context,
134  coap_session_t *session,
135  const coap_binary_t *token);
149  coap_session_t *session,
150  const coap_binary_t *token);
158 void coap_delete_observers(coap_context_t *context, coap_session_t *session);
int coap_mid_t
coap_mid_t is used to store the CoAP Message ID of a CoAP PDU.
Definition: pdu.h:229
Set of codes available for a PDU.
Definition: pdu.h:289
int coap_delete_observer(coap_resource_t *resource, coap_session_t *session, const coap_binary_t *token)
Removes any subscription for observer from resource and releases the allocated storage.
Definition: resource.c:804
coap_subscription_t * coap_find_observer(coap_resource_t *resource, coap_session_t *session, const coap_binary_t *token)
Returns a subscription object for given peer.
Definition: resource.c:684
void coap_delete_observers(coap_context_t *context, coap_session_t *session)
Removes any subscription for session and releases the allocated storage.
Definition: resource.c:830
void coap_check_notify(coap_context_t *context)
Checks all known resources to see if they are dirty and then notifies subscribed observers.
Definition: resource.c:1063
coap_subscription_t * coap_add_observer(coap_resource_t *resource, coap_session_t *session, const coap_binary_t *token, coap_string_t *query, int has_block2, coap_block_t block2, coap_pdu_code_t code)
Adds the specified peer as observer for resource.
Definition: resource.c:720
void coap_handle_failed_notify(coap_context_t *context, coap_session_t *session, const coap_binary_t *token)
Handles a failed observe notify.
Definition: resource.c:1126
void coap_subscription_init(coap_subscription_t *)
Definition: subscribe.c:13
void coap_touch_observer(coap_context_t *context, coap_session_t *session, const coap_binary_t *token)
Flags that data is ready to be sent to observers.
Definition: resource.c:791
CoAP binary data definition.
Definition: str.h:48
Structure of Block options.
Definition: block.h:33
The CoAP stack's global state is stored in a coap_context_t object.
Abstraction of resource that can be attached to coap_context_t.
Abstraction of virtual session that can be attached to coap_context_t (client) or coap_endpoint_t (se...
CoAP string data definition.
Definition: str.h:30
Subscriber information.
coap_block_t block
GET/FETCH request Block definition.
unsigned char token[8]
token used for subscription
unsigned int has_block2
GET request had Block2 definition.
coap_mid_t mid
request type code (GET/FETCH)
unsigned int fail_cnt
up to 3 confirmable notifies can fail
unsigned int non_cnt
up to 15 non-confirmable notifies allowed
size_t token_length
actual length of token
struct coap_session_t * session
subscriber session
unsigned int dirty
set if the notification temporarily could not be sent (in that case, the resource's partially dirty f...
struct coap_subscription_t * next
next element in linked list
struct coap_string_t * query
query string used for subscription, if any