logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

coap_deprecated, coap_clear_event_handler, coap_context_set_psk, coap_encode_var_bytes,

Authors

       The libcoap project <libcoap-developers@lists.sourceforge.net>

coap_deprecated 4.3.4                              04/15/2024                                 COAP_DEPRECATED(3)

Bugs

       Please report bugs on the mailing list for libcoap: libcoap-developers@lists.sourceforge.net or raise an
       issue on GitHub at https://github.com/obgm/libcoap/issues

Description

       Several of the existing CoAP API functions have been deprecated. These are listed here, along with the
       functions that should now be used instead.

Functions

Function:coap_clear_event_handler()

       The coap_clear_event_handler() function is replaced by coap_register_event_handler(3), using NULL for
       handler.

       Function:coap_context_set_psk()

       The coap_context_set_psk() function is replaced by coap_context_set_psk2(3) which gives additional PSK
       configuration capability by the use of the coap_dtls_spsk_t structure.

       Function:coap_encode_var_bytes()

       The coap_encode_var_bytes() function is replaced by coap_encode_var_safe(3).

       Function:coap_new_client_session_psk()

       The coap_new_client_session_psk() function is replaced by coap_new_client_session_psk2(3) which gives
       additional PSK configuration capability by the use of the coap_dtls_cpsk_t structure.

       Function:coap_option_clrb()

       The coap_option_clrb() function is replaced by coap_option_filter_unset(3).

       Function:coap_option_getb()

       The coap_option_getb() function is replaced by coap_option_filter_get(3).

       Function:coap_option_setb()

       The coap_option_setb() function is replaced by coap_option_filter_set(3).

       Function:coap_read()

       The coap_read() function is replaced by coap_io_do_io(3).

       Function:coap_register_handler()

       The coap_register_handler() function is replaced by coap_register_request_handler(3).

       Function:coap_resource_set_dirty()

       The coap_resource_set_dirty() function is replaced by coap_resource_notify_observers(3).

       Function:coap_run_once()

       The coap_run_once() function is replaced by coap_io_process(3).

       Function:coap_set_event_handler()

       The coap_set_event_handler() function is replaced by coap_register_event_handler(3).

       Function:coap_clear_event_handler()

       The coap_write() function is replaced by coap_io_prepare_io(3).

Further Information

       See

       "RFC7252: The Constrained Application Protocol (CoAP)"

       for further information.

Name

       coap_deprecated, coap_clear_event_handler, coap_context_set_psk, coap_encode_var_bytes,
       coap_new_client_session_psk, coap_option_clrb, coap_option_getb, coap_option_setb, coap_read,
       coap_register_handler, coap_resource_set_dirty, coap_run_once, coap_set_event_handler, coap_write - Work
       with CoAP deprecated functions

Return Values

coap_context_set_psk() returns 1 if success, 0 on failure.

       coap_encode_var_bytes() returns either the length of bytes encoded (which can be 0 when encoding 0) or 0
       on failure.

       coap_new_client_session_psk() returns a new session if success, NULL on failure.

       coap_option_clrb() returns 1 if bit was set, -1 otherwise.

       coap_option_getb() returns 1 if bit was set, 0 if not.

       coap_option_setb() returns 1 if bit was set, -1 otherwise.

       coap_resource_set_dirty() returns 1 if success, 0 on failure.

       coap_run_once() returns number of milliseconds spent in function or -1 if there was an error.

       coap_write() returns the number of milli-seconds that need to be waited before the function should next
       be called.

See Also

coap_endpoint_client(3), coap_endpoint_server(3), coap_handler(3), coap_io(3), coap_observe(3),
       coap_pdu_access(3) and coap_pdu_setup(3).

Synopsis

#include<coap3/coap.h>voidcoap_clear_event_handler(coap_context_t*context);intcoap_context_set_psk(coap_context_t*context,constchar*hint,constuint8_t*key,size_tkey_len);intcoap_encode_var_bytes(uint8_t*buffer,unsignedintvalue);coap_session_t*coap_new_client_session_psk(coap_context_t*context,constcoap_address_t*local_if,constcoap_address_t*server,coap_proto_tproto,constchar*identity,constuint8_t*key,unsignedkey_len);intcoap_option_clrb(coap_opt_filter_t*filter,uint16_ttype);intcoap_option_getb(coap_opt_filter_t*filter,uint16_ttype);intcoap_option_setb(coap_opt_filter_t*filter,uint16_ttype);voidcoap_read(coap_context_t*context,coap_tick_tnow);voidcoap_register_handler(coap_resource_t*resource,coap_request_tmethod,coap_method_handler_thandler);intcoap_resource_set_dirty(coap_resource_t*resource,constcoap_string_t*query);intcoap_run_once(coap_context_t*context,uint32_ttimeout_ms);voidcoap_set_event_handler(coap_context_t*context,coap_event_handler_thandler);unsignedintcoap_write(coap_context_t*context,coap_socket_t*sockets[],unsignedintmax_sockets,unsignedint*num_sockets,coap_tick_tnow);

       For specific (D)TLS library support, link with -lcoap-3-notls, -lcoap-3-gnutls, -lcoap-3-openssl,
       -lcoap-3-mbedtls or -lcoap-3-tinydtls. Otherwise, link with -lcoap-3 to get the default (D)TLS library
       support.

See Also