nanocoap: add Uri-Query handling capabilities#16
Conversation
nanocoap/nanocoap.c
Outdated
| { | ||
| size_t url_len = strlen(url); | ||
| assert(url_len); | ||
| char seperator = (optnum == COAP_OPT_URI_PATH) ? '/' : '&'; |
|
@haukepetersen, thanks for creating this PR. Overall, this work looks good to me. See the inline comment on a typo. I don't see the decoding for a Uri-Query option in I agree that I'm not sure the complexity required to reuse the single 'url' attribute in coap_pkt_t to include the query is worth it for now. Below are my thoughts as I worked through it though. Use of a single I'm not familiar with the details of RFC 3986, but sec. 3.4 says: "The query component is indicated by the first question mark ("?") character". Seems like not much extra code for At the same time, nanocoap's |
|
fixed typo. I have actually not spend much thought on the decoding and presentation of the Uri-Query when receiving packets - I basically go on a 'add what I need for the next step' flow currently :-) But my current thought is to handle it in the following way: when receiving a packet that contains a query string, we copy the query string into coap_qs_filter(coap_pkt_t *pkt, coap_qs_filter_t filter_function, void *output_buffer);This way, users can pass custom filter functions, that fit to their needs. For example a function that fills a custom struct holding values for As general optimization we should however definitely think about getting rid of the additional buffers for |
|
The In general, the URL parameter is more usable as a complete string. However, even here RIOT has an open PR to group handling of resource names based on a common prefix. So, /app/foo, /app/bar, and /app/baz could be handled by a single /app/* resource. I agree about the longer term goal to eliminate storage of |
|
So aside from the uri-query handling on the receiving side, so you guys agree on the changes of this PR for now so we can proceed? |
|
I will test this PR as part of reviewing RIOT #7402. As I mentioned there, I would prefer not to see the addition of the |
|
RIOT #7402 tests fine on native. So, ACK here in the interest of moving forward. |
+1, ACK. |
Uri-query strings are needed for e.g.
lwm2mor CoAP resource directories (RD). This PR adds the capability to addCOAP_OPT_URI_QUERYoptions to CoAP requests.This PR adds an additional buffer to hold the raw query string in the
coap_pkt_tstructure. The alternative would be to write the query string into theurlbuffer, but this would make the parsing of options quite a bit harder, so I went with this (for now?!).