libcoap 4.3.2rc2

coap_subscribe.h
Go to the documentation of this file.
1/*
2 * coap_subscribe.h -- subscription handling for CoAP
3 * see RFC7641
4 *
5 * Copyright (C) 2010-2012,2014-2023 Olaf Bergmann <bergmann@tzi.org>
6 *
7 * SPDX-License-Identifier: BSD-2-Clause
8 *
9 * This file is part of the CoAP library libcoap. Please see README for terms
10 * of use.
11 */
12
18#ifndef COAP_SUBSCRIBE_H_
19#define COAP_SUBSCRIBE_H_
20
33#define COAP_OBSERVE_ESTABLISH 0
34
40#define COAP_OBSERVE_CANCEL 1
41
52 void coap_resource_set_get_observable(coap_resource_t *resource, int mode);
53
63 int coap_resource_notify_observers(coap_resource_t *resource,
64 const coap_string_t *query);
65
84 typedef int (*coap_observe_added_t)(coap_session_t *session,
85 coap_subscription_t *observe_key,
86 coap_proto_t e_proto,
87 coap_address_t *e_listen_addr,
88 coap_addr_tuple_t *s_addr_info,
89 coap_bin_const_t *raw_packet,
90 coap_bin_const_t *oscore_info,
91 void *user_data);
92
104 typedef int (*coap_observe_deleted_t)(coap_session_t *session,
105 coap_subscription_t *observe_key,
106 void *user_data);
107
123 typedef int (*coap_track_observe_value_t)(coap_context_t *context,
124 coap_str_const_t *resource_name,
125 uint32_t observe_num,
126 void *user_data);
127
141 typedef int (*coap_dyn_resource_added_t)(coap_session_t *session,
142 coap_str_const_t *resource_name,
143 coap_bin_const_t *raw_packet,
144 void *user_data);
145
160 typedef int (*coap_resource_deleted_t)(coap_context_t *context,
161 coap_str_const_t *resource_name,
162 void *user_data);
163
181 void coap_persist_track_funcs(coap_context_t *context,
182 coap_observe_added_t observe_added,
183 coap_observe_deleted_t observe_deleted,
184 coap_track_observe_value_t track_observe_value,
185 coap_dyn_resource_added_t dyn_resource_added,
186 coap_resource_deleted_t resource_deleted,
187 uint32_t save_freq,
188 void *user_data);
189
208 coap_subscription_t *coap_persist_observe_add(coap_context_t *context,
209 coap_proto_t e_proto,
210 const coap_address_t *e_listen_addr,
211 const coap_addr_tuple_t *s_addr_info,
212 const coap_bin_const_t *raw_packet,
213 const coap_bin_const_t *oscore_info);
214
232 int coap_persist_startup(coap_context_t *context,
233 const char *dyn_resource_save_file,
234 const char *observe_save_file,
235 const char *obs_cnt_save_file,
236 uint32_t save_freq);
237
250 void coap_persist_stop(coap_context_t *context);
251
258 void coap_persist_set_observe_num(coap_resource_t *resource,
259 uint32_t observe_num);
260
263#endif /* COAP_SUBSCRIBE_H_ */
coap_resource_notify_observers
int coap_resource_notify_observers(coap_resource_t *resource, const coap_string_t *query)
Initiate the sending of an Observe packet for all observers of resource, optionally matching query if...
coap_dyn_resource_added_t
int(* coap_dyn_resource_added_t)(coap_session_t *session, coap_str_const_t *resource_name, coap_bin_const_t *raw_packet, void *user_data)
Callback handler definition called when a dynamic resource is getting created, as defined in coap_per...
Definition: coap_subscribe.h:141
coap_persist_stop
void coap_persist_stop(coap_context_t *context)
Stop tracking persist information, leaving the current persist information in the files defined in co...
coap_persist_set_observe_num
void coap_persist_set_observe_num(coap_resource_t *resource, uint32_t observe_num)
Sets the current observe number value.
coap_resource_set_get_observable
void coap_resource_set_get_observable(coap_resource_t *resource, int mode)
Set whether a resource is observable.
coap_resource_deleted_t
int(* coap_resource_deleted_t)(coap_context_t *context, coap_str_const_t *resource_name, void *user_data)
Callback handler definition called when resource is removed, as defined in coap_persist_track_funcs()...
Definition: coap_subscribe.h:160
coap_observe_added_t
int(* coap_observe_added_t)(coap_session_t *session, coap_subscription_t *observe_key, coap_proto_t e_proto, coap_address_t *e_listen_addr, coap_addr_tuple_t *s_addr_info, coap_bin_const_t *raw_packet, coap_bin_const_t *oscore_info, void *user_data)
Callback handler definition called when a new observe has been set up, as defined in coap_persist_tra...
Definition: coap_subscribe.h:84
coap_persist_track_funcs
void coap_persist_track_funcs(coap_context_t *context, coap_observe_added_t observe_added, coap_observe_deleted_t observe_deleted, coap_track_observe_value_t track_observe_value, coap_dyn_resource_added_t dyn_resource_added, coap_resource_deleted_t resource_deleted, uint32_t save_freq, void *user_data)
Set up callbacks to handle persist tracking so on a coap-server inadvertent restart,...
coap_track_observe_value_t
int(* coap_track_observe_value_t)(coap_context_t *context, coap_str_const_t *resource_name, uint32_t observe_num, void *user_data)
Callback handler definition called when an observe unsolicited response is being sent,...
Definition: coap_subscribe.h:123
coap_observe_deleted_t
int(* coap_observe_deleted_t)(coap_session_t *session, coap_subscription_t *observe_key, void *user_data)
Callback handler definition called when an observe is being removed, as defined in coap_persist_track...
Definition: coap_subscribe.h:104
coap_persist_startup
int coap_persist_startup(coap_context_t *context, const char *dyn_resource_save_file, const char *observe_save_file, const char *obs_cnt_save_file, uint32_t save_freq)
Start up persist tracking using the libcoap module.
coap_persist_observe_add
coap_subscription_t * coap_persist_observe_add(coap_context_t *context, coap_proto_t e_proto, const coap_address_t *e_listen_addr, const coap_addr_tuple_t *s_addr_info, const coap_bin_const_t *raw_packet, const coap_bin_const_t *oscore_info)
Set up an active subscription for an observe that was previously active over a coap-server inadvertan...
coap_proto_t
coap_proto_t
CoAP protocol types.
Definition: coap_pdu.h:304
coap_addr_tuple_t
Definition: coap_io.h:55
coap_address_t
Multi-purpose address abstraction.
Definition: coap_address.h:109
coap_bin_const_t
CoAP binary data definition with const data.
Definition: coap_str.h:64
coap_context_t
The CoAP stack's global state is stored in a coap_context_t object.
Definition: coap_net_internal.h:49
coap_resource_t
Abstraction of resource that can be attached to coap_context_t.
Definition: coap_resource_internal.h:53
coap_session_t
Abstraction of virtual session that can be attached to coap_context_t (client) or coap_endpoint_t (se...
Definition: coap_session_internal.h:68
coap_str_const_t
CoAP string data definition with const data.
Definition: coap_str.h:46
coap_string_t
CoAP string data definition.
Definition: coap_str.h:38
coap_subscription_t
Number of notifications that may be sent non-confirmable before a confirmable message is sent to dete...
Definition: coap_subscribe_internal.h:57