coap_send(): Consolidate coap_send() and coap_send_large() for applications

As it is not that intuitive when to use coap_send() or coap_send_large()
in applications, rename libcoap usage of coap_send() to coap_send_internal()
and then all usages of coap_send_large() to coap_send() so that only
coap_send() is required in applications.

Documentation updated accordingly.
This commit is contained in:
Jon Shallow committed 2021-05-29 14:08:00 +01:00
1 parent 62b2be4da1
commit 8d73044579
15 files changed
+81 -92

No files matched your search

+3 -3
View File
@@ -219,7 +219,7 @@ typedef void (*coap_release_large_data_t)(coap_session_t *session,
* coap_add_data_large_request() (or the alternative coap_add_data_large_*()
* functions) must be called only once per PDU and must be the last PDU update
* before the PDU is transmitted. The (potentially) initial data will get
* transmitted when coap_send() or preferably coap_send_large() is invoked.
* transmitted when coap_send() is invoked.
*
* Note: COAP_BLOCK_USE_LIBCOAP must be set by coap_context_set_block_mode()
* for libcoap to work correctly when using this function.
@@ -326,8 +326,8 @@ void coap_context_set_block_mode(coap_context_t *context,
uint8_t block_mode);
/**
* Cancel an observe that is being tracked by the client large receive logic
* when using coap_send_large().
* Cancel an observe that is being tracked by the client large receive logic.
* (coap_context_set_block_mode() has to be called)
* This will trigger the sending of an observe cancel pdu to the server.
*
* @param session The session that is being used for the observe.
+17
View File
@@ -341,6 +341,23 @@ coap_pdu_t *coap_wellknown_response(coap_context_t *context,
*/
unsigned int coap_calc_timeout(coap_session_t *session, unsigned char r);
/**
* Sends a CoAP message to given peer. The memory that is
* allocated for the pdu will be released by coap_send_internal().
* The caller must not use the pdu after calling coap_send_internal().
*
* If the response body is split into multiple payloads using blocks, libcoap
* will handle asking for the subsequent blocks and any necessary recovery
* needed.
*
* @param session The CoAP session.
* @param pdu The CoAP PDU to send.
*
* @return The message id of the sent message or @c
* COAP_INVALID_MID on error.
*/
coap_mid_t coap_send_internal(coap_session_t *session, coap_pdu_t *pdu);
/** @} */
#endif /* COAP_NET_INTERNAL_H_ */
+1 -16
View File
@@ -464,22 +464,7 @@ coap_send_rst(coap_session_t *session, const coap_pdu_t *request) {
*/
coap_mid_t coap_send( coap_session_t *session, coap_pdu_t *pdu );
/**
* Sends a CoAP message to given peer. The memory that is
* allocated for the pdu will be released by coap_send_large().
* The caller must not use the pdu after calling coap_send_large().
*
* If the response body is split into multiple payloads using blocks, libcoap
* will handle asking for the subsequent blocks and any necessary recovery
* needed.
*
* @param session The CoAP session.
* @param pdu The CoAP PDU to send.
*
* @return The message id of the sent message or @c
* COAP_INVALID_MID on error.
*/
coap_mid_t coap_send_large(coap_session_t *session, coap_pdu_t *pdu);
#define coap_send_large(session, pdu) coap_send(session, pdu)
/**
* Invokes the event handler of @p context for the given @p event and
+4 -4
View File
@@ -337,8 +337,8 @@ typedef enum coap_pdu_code_t {
* Creates a new CoAP PDU with at least enough storage space for the given
* @p size maximum message size. The function returns a pointer to the
* node coap_pdu_t object on success, or @c NULL on error. The storage allocated
* for the result must be released with coap_delete_pdu() if coap_send() or
* coap_send_large() is not called.
* for the result must be released with coap_delete_pdu() if coap_send()
* is not called.
*
* @param type The type of the PDU (one of COAP_MESSAGE_CON, COAP_MESSAGE_NON,
* COAP_MESSAGE_ACK, COAP_MESSAGE_RST).
@@ -366,8 +366,8 @@ coap_pdu_t *coap_new_pdu(coap_pdu_type_t type, coap_pdu_code_t code,
/**
* Dispose of an CoAP PDU and frees associated storage.
* Not that in general you should not call this function directly.
* When a PDU is sent with coap_send() or coap_send_large(), coap_delete_pdu()
* will be called automatically for you.
* When a PDU is sent with coap_send(), coap_delete_pdu() will be called
* automatically for you.
*
* @param pdu The PDU for free off.
*/