diff options
author | Guido Günther <agx@sigxcpu.org> | 2015-12-13 17:47:14 +0100 |
---|---|---|
committer | Guido Günther <agx@sigxcpu.org> | 2015-12-13 17:47:14 +0100 |
commit | bd3ae9694c0e8669c8ce53aef685e8afede14f33 (patch) | |
tree | e849857832827f7be9a3166932bae7fe749fc84a /README.md |
Diffstat (limited to 'README.md')
-rw-r--r-- | README.md | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/README.md b/README.md new file mode 100644 index 0000000..de5494f --- /dev/null +++ b/README.md @@ -0,0 +1,19 @@ +Some erlang helpers for COAP messages (RFC7252) + +Copyright 2015 Guido Günther <agx@sigxcpu.org> + +This is by no means a full coap implementation. It merely allows to ease +parsing of messages a bit by putting things into a record. + +Let's assume you receive UDP datagrams in a gen_server. You can then match on +the incoming coap message like: + + handle_info({udp, Socket, Host, Port, Bin}, State) -> + Msg = coap_parse:parse(Bin), + case Msg of + #coap_request{method=post, path= <<"/switches">>, query=[<<"name=", Name/binary>>], payload=Payload} -> + ... + +Which would allow you to process a request like: + + echo '{"mode": "on"}' | coap-client -f- -t application/json -m post "coap://[::1]/switches?name=Lever1" |