Skip to content
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

URI Variables in CoAP are not supported #1015

Closed
egekorkan opened this issue Jun 9, 2023 · 6 comments · Fixed by #1078
Closed

URI Variables in CoAP are not supported #1015

egekorkan opened this issue Jun 9, 2023 · 6 comments · Fixed by #1078
Assignees
Labels
binding-coap Issues related to coap protocol binding bug Something isn't working

Comments

@egekorkan
Copy link
Member

Smart coffee machine Thing produces CoAP forms even if there are uri variables for that affordance. But there is no support for that in CoAP so those forms are not usable at all. Either the support for URI variables should be implemented or forms should not be generated for coap in that case.

@relu91 relu91 added bug Something isn't working binding-coap Issues related to coap protocol binding labels Jun 9, 2023
@relu91
Copy link
Member

relu91 commented Sep 7, 2023

Are we talking about the server side or the client side? Giving a look at the code it seems that now URIVariables are handled by the server. @JKRhb can you verify if this is still an issue?

@JKRhb
Copy link
Member

JKRhb commented Sep 11, 2023

Hmm, I guess the problem here is that for HTTP, forms like

{
    "href": "http://plugfest.thingweb.io:8083/smart-coffee-machine/properties/availableResourceLevel{?id}",
    "contentType": "application/json",
    "op": ["readproperty", "writeproperty"]
},

are generated, while for CoAP, only forms like

{
    "href": "coap://plugfest.thingweb.io:5683/smart-coffee-machine/properties/availableResourceLevel",
    "contentType": "application/json",
    "op": ["writeproperty", "readproperty"]
},

without the actual URI variables are generated, right?

@JKRhb
Copy link
Member

JKRhb commented Sep 11, 2023

I guess we need to implement this function in the HTTP server also for the CoAP server or move it to the core package to use it across protocol binding implementations:

private updateInteractionNameWithUriVariablePattern(
interactionName: string,
uriVariables: PropertyElement["uriVariables"] = {},
thingVariables: PropertyElement["uriVariables"] = {}
): string {
const variables = Object.assign({}, uriVariables, thingVariables);
if (Object.keys(variables).length > 0) {
let pattern = "{?";
let index = 0;
if (uriVariables) {
for (const key in uriVariables) {
if (index !== 0) {
pattern += ",";
}
pattern += encodeURIComponent(key);
index++;
}
}
if (thingVariables) {
for (const key in thingVariables) {
if (index !== 0) {
pattern += ",";
}
pattern += encodeURIComponent(key);
index++;
}
}
pattern += "}";
return encodeURIComponent(interactionName) + pattern;
} else {
return encodeURIComponent(interactionName);
}
}

@egekorkan
Copy link
Member Author

So it seems that it is just about the TD generation. Regarding core or not:

One issue I see with moving to core would mean that uri variables would be generated for all protocols, whether they support it or not. I am not convinced on myself but I think it would be better to manage forms as much as possible in the binding level 🤔

@JKRhb
Copy link
Member

JKRhb commented Sep 11, 2023

One issue I see with moving to core would mean that uri variables would be generated for all protocols, whether they support it or not. I am not convinced on myself but I think it would be better to manage forms as much as possible in the binding level 🤔

Oh, yeah, I was rather thinking about moving the function itself to the core package and then let the binding implementations use it in their implementations :) I now tried to implement the feature in #1078 – could you have a look if that resolves the issue?

@egekorkan
Copy link
Member Author

moving the function itself to the core package and then let the binding implementations use it in their implementations :)

Ok that makes sense, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
binding-coap Issues related to coap protocol binding bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants