riot_sys

Function gcoap_req_init_path_buffer

Source
pub unsafe extern "C" fn gcoap_req_init_path_buffer(
    pdu: *mut coap_pkt_t,
    buf: *mut u8,
    len: size_t,
    code: c_uint,
    path: *const c_char,
    path_len: size_t,
) -> c_int
Expand description

@brief Initializes a CoAP request PDU on a buffer.

If @p code is COAP_CODE_EMPTY, prepares a complete “CoAP ping” 4 byte empty message request, ready to send.

With module module [nanocoap_cache](@ref net_nanocoap_cache) an all-zero ETag option of length 8 which is updated with a value or removed in @ref gcoap_req_send() / @ref gcoap_req_send_tl() depending on existing cache entries for cache (re-)validation. If you do not use the given send functions or do not want cache entries to revalidated for any reason, remove that empty option using @ref coap_opt_remove().

@param[out] pdu Request metadata @param[out] buf Buffer containing the PDU @param[in] len Length of the buffer @param[in] code Request code, one of COAP_METHOD_XXX or COAP_CODE_EMPTY to ping @param[in] path Resource path, may be NULL. @p path_len will be ignored in that case. @param[in] path_len Length of @p path.

@pre @p path must start with / if not NULL

@return 0 on success @return < 0 on error