GithubHelp home page GithubHelp logo

coapex's Introduction

Coapex

CoAP (rfc7252) stands for Constrained Application Protocol and is intended for use in embedded devices (e.g IoT stuff).

A quick (but not quite exact) comparison is "CoAP is a HTTP with binary header". CoAP supports REST as well, but it does support further things like "observation" of resources (like a Publish/Subscribe system).

Done

  • Encoder: allows the user to build a CoAP binary message from a %Message struct
iex> msg = Coapex.Message.init(:request,
                       type: :con, code: :get, msg_id: 123,
                       options: [uri_host: "example.com", accept: "application/json"])
%Coapex.Message{code: :get, msg_id: 123,
 options: [uri_host: "example.com", accept: "application/json"], payload: nil,
 token: nil, type: :con, version: <<1::size(2)>>}
iex> Coapex.Encoder.encode(msg)
<<64, 1, 0, 123, 59, 101, 120, 97, 109, 112, 108, 101, 46, 99, 111, 109, 221, 1,
  3, 97, 112, 112, 108, 105, 99, 97, 116, 105, 111, 110, 47, 106, 115, 111, 110,
  255>>
  • Decoder: convert a CoAP binary message into a friendly %Message struct
iex> msg = Coapex.Message.init(:request,
                       type: :con, code: :get, msg_id: 123,
                       options: [uri_host: "example.com", accept: "application/json"])
iex> bin_msg = Coapex.Encoder.encode(msg)
iex> msg = Coapex.Decoder.decode(bin_msg)
%Coapex.Message{code: :get, msg_id: 123,
 options: [uri_host: "example.com", accept: "application/json"], payload: nil,
 token: nil, type: :con, version: <<1::size(2)>>}

TODO:

  • Server: understand & implement how to serve CoAP resources. Note: CoAP runs over UDP.
  • Client: build a CoAP client

extra thinking

what if we turn this into a Plug-like CoAP thing?

coapex's People

Contributors

geonnave avatar philss avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

coapex's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.