-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
nanocoap: add Uri-Query handling capabilities #16
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) ? '/' : '&'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seperator -> separator
@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.
lwm2m
or CoAP resource directories (RD). This PR adds the capability to addCOAP_OPT_URI_QUERY
options to CoAP requests.This PR adds an additional buffer to hold the raw query string in the
coap_pkt_t
structure. The alternative would be to write the query string into theurl
buffer, but this would make the parsing of options quite a bit harder, so I went with this (for now?!).