aboutsummaryrefslogtreecommitdiff
path: root/README.md
blob: de5494f1e044c73931d0a9fe21159c8abd404474 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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"