CoAP examples

Does anyone know how CoAP works are even better examples of the code ?

https://coap.technology/

I know that but I was looking more for a working examples here

1 Like

So you want specific Hubitat examples for using the HTTP functions?

I was under the impression that CoAP was made to talk to gateways like HUE hub. Is that correct ?

It's pretty much a simplification of a REST type API. Uses standard HTTP for the communications protocol and uses standard GET, PUT, DELETE etc functions.

It can be as simple or complex as the device manufacturer makes it but generally (at least from info I know) it was to simplify device communications and reduce the size of data transferring to make it easier to support IoT with limited bandwidth and/or thousands of devices. So instead of makes a very complex API with lots of back and forth communications for things make it very simple of a GET of the data in small'ish chunks ie specific data and then a basic PUT to change the data.

3 Likes

Ok that answers a lot of my questions then.

Don’t know if it helps, but the IKEA TRÅDFRI gateway uses CoAP

2 Likes

Excellent example!

You could also in some regard say that Maker API is a CoAP implementation in the sense of using basic HTTP GET with a direct URL for functionality rather than sending complex structures.

1 Like

CoAP has a lot of other nifty things as well... I was reading through the draft RFC and looking at the existing low level and API interfaces for really digging into CoAP from a protocol perspective not just an App usage... If interested here's the link to the RFC.

https://tools.ietf.org/html/rfc7252

1 Like

You got me interested @anon61068208 and I did more looking into CoAP... it's a very interesting low level protocol interface itself. The typical interface I've dealt with is actually a HTTP proxy to the lower level CoAP which is why it just looks/acts seems like a basic HTTP interface. Under that it's quite interesting and has it's own low level interfaces. There are libraries and implementations in several languages including Java which Groovy is sitting on top of. I did not see a groovy implementation from the CoAP docs though.

Thanks for giving me something new/fun to look at today!

2 Likes

Does it? I learned all I know by reading the above, but it looks like CoAP is an alternative protocol to HTTP, while providing a similar interface, presumably intended so the "constrained" devices it was designed for don't have to deal with the overhead of running a full HTTP server. But there is this, which you would likely need to use it from Hubitat with standard HTTP methods unless they ever implement CoAP natively: RFC 8075 - Guidelines for Mapping Implementations: HTTP to the Constrained Application Protocol (CoAP)

Read my other post... CoAP examples where I went back and clarified that the HTTP was actually a proxy interface (I learned something new)... and there was a whole world behind CoAP that I was not aware of...

I've just started to take advantage of the Shelly CoAP implementation. What makes me excited is that it is a broadcast protocol that allows me to discover my devices and listen for state changes. Such a capability would be a valuable addition to the MakerAPI.

Check out https://www.npmjs.com/package/shellies

1 Like

I have asked both @bravenel and @mike.maxwell if they would support CoAP and they declined to do that. If you can manage to get them to do so that would be nice.

That is why I use the Hubitat as a bridge rather than a platform.

1 Like