45 #ifndef COAP_OBSERVING_CLIENT_H_ 46 #define COAP_OBSERVING_CLIENT_H_ 51 #ifndef COAP_OBSERVE_CLIENT 52 #define COAP_OBSERVE_CLIENT 0 55 #ifdef COAP_CONF_MAX_OBSERVEES 56 #define COAP_MAX_OBSERVEES COAP_CONF_MAX_OBSERVEES 58 #define COAP_MAX_OBSERVEES 4 61 #if COAP_MAX_OPEN_TRANSACTIONS < COAP_MAX_OBSERVEES 62 #warning "COAP_MAX_OPEN_TRANSACTIONS smaller than COAP_MAX_OBSERVEES: " \ 63 "this may be a problem" 66 #define IS_RESPONSE_CODE_2_XX(message) (64 < message->code \ 67 && message->code < 128) 73 OBSERVE_NOT_SUPPORTED,
76 } coap_notification_flag_t;
79 typedef struct coap_observee_s coap_observee_t;
81 typedef void (*notification_callback_t)(coap_observee_t *subject,
83 coap_notification_flag_t);
85 struct coap_observee_s {
86 coap_observee_t *next;
87 coap_endpoint_t endpoint;
90 uint8_t token[COAP_TOKEN_LEN];
92 notification_callback_t notification_callback;
93 uint32_t last_observe;
97 coap_observee_t *coap_obs_add_observee(
const coap_endpoint_t *endpoint,
98 const uint8_t *token,
size_t token_len,
100 notification_callback_t
101 notification_callback,
void *data);
103 void coap_obs_remove_observee(coap_observee_t *o);
105 coap_observee_t *coap_obs_get_observee_by_token(
const uint8_t *token,
108 int coap_obs_remove_observee_by_token(
const coap_endpoint_t *endpoint,
109 uint8_t *token,
size_t token_len);
111 int coap_obs_remove_observee_by_url(
const coap_endpoint_t *endpoint,
114 void coap_handle_notification(
const coap_endpoint_t *endpoint,
115 coap_message_t *notification);
117 coap_observee_t *coap_obs_request_registration(
const coap_endpoint_t *endpoint,
119 notification_callback_t
120 notification_callback,
123 uint8_t coap_generate_token(uint8_t **token_ptr);
CoAP module for reliable transport
An implementation of the Constrained Application Protocol (RFC 7252).