From bd3ae9694c0e8669c8ce53aef685e8afede14f33 Mon Sep 17 00:00:00 2001 From: Guido Günther Date: Sun, 13 Dec 2015 17:47:14 +0100 Subject: Initial commit --- README.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 README.md (limited to 'README.md') 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 + +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" -- cgit v1.2.3