[riot-notifications] [RIOT-OS/RIOT] sys/net/gcoap: allow seperate response (#16578)

chrysn notifications at github.com
Mon Jun 28 17:18:31 CEST 2021


@chrysn commented on this pull request.



> @@ -224,6 +224,9 @@ typedef struct {
     const char *path;               /**< URI path of resource               */
     coap_method_flags_t methods;    /**< OR'ed methods this resource allows */
     coap_handler_t handler;         /**< ptr to resource handler            */
+#ifdef MODULE_GCOAP
+    uint8_t flags;                  /**< flags e.g. for separate response   */
+#endif
     void *context;                  /**< ptr to user defined context data   */
 } coap_resource_t;

This can likely be merged wlth methods, also to avoid API breakage. There is precedent for that (MATCH_SUBTREE).

> @@ -364,6 +364,27 @@ static size_t _handle_req(coap_pkt_t *pdu, uint8_t *buf, size_t len,
             return gcoap_response(pdu, buf, len, COAP_CODE_INTERNAL_SERVER_ERROR);
             break;
     }
+    
+    if (resource->flags & COAP_SEPARATE_RESPONSE) {
+        coap_pkt_t pdu_sep;
+        uint8_t buf_sep[CONFIG_GCOAP_PDU_BUF_SIZE] = { 0 };
+        memcpy(buf_sep, buf, len);
+        ssize_t res = coap_parse(&pdu_sep, buf_sep, len);
+        if (res < 0) {
+            DEBUG("gcoap: parse failure: %d\n", (int)res);

There is a tighter bound than CONFIG_GCOAP_PDU_BUF_SIZE on this (header plus maximal token).

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/RIOT-OS/RIOT/pull/16578#pullrequestreview-694080528
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20210628/87762ab4/attachment-0001.htm>


More information about the notifications mailing list