Coap Client and Server

Dependencies:   DebugLib EthernetInterface cantcoap mbed-rtos

Dependents:   COAP coap

Fork of yeswecancoap by Sille Van Landschoot

YesWeCanCoap

Is a small coap client and server library for mbed based on the cantcoap library.

Import librarycantcoap

This is CoAP library with a focus on simplicity. It offers minimal CoAP PDU construction and decoding to and from byte buffers.

yeswecancoap server enables easy implementation of coap resources, each with a dedicated function. When the function is registered by the server, it will do the rest.

Coap server example

Repository: YesWeCanCoap-example

Coap client example

under construction

Committer:
sillevl
Date:
Tue Nov 17 16:44:39 2015 +0000
Revision:
29:62113a57353b
Parent:
26:22849ab35dc2
added method to get the ip address

Who changed what in which revision?

UserRevisionLine numberNew contents of line
sillevl 0:9f557e9a792f 1 #pragma once
sillevl 0:9f557e9a792f 2
sillevl 0:9f557e9a792f 3 #include "mbed.h"
sillevl 0:9f557e9a792f 4 #include "EthernetInterface.h"
sillevl 0:9f557e9a792f 5 #include "cantcoap.h"
sillevl 0:9f557e9a792f 6 #include "dbg.h"
sillevl 0:9f557e9a792f 7
sillevl 1:ab04e3d36ade 8 #include "server.h"
dwini 8:0169da22e764 9 #include "client.h"
sillevl 24:8319d71d6749 10
sillevl 24:8319d71d6749 11 /// CoapCode enum, alias for CoapPDU::Code enum
sillevl 23:019c530468b4 12 enum CoapCode {
sillevl 23:019c530468b4 13 EMPTY = CoapPDU::COAP_EMPTY,
sillevl 17:3e1d176e2d4a 14 GET = CoapPDU::COAP_GET,
sillevl 17:3e1d176e2d4a 15 POST = CoapPDU::COAP_POST,
sillevl 17:3e1d176e2d4a 16 PUT = CoapPDU::COAP_PUT,
sillevl 23:019c530468b4 17 DELETE = CoapPDU::COAP_DELETE,
sillevl 23:019c530468b4 18 CREATED = CoapPDU::COAP_CREATED,
sillevl 23:019c530468b4 19 DELETED = CoapPDU::COAP_DELETED,
sillevl 23:019c530468b4 20 VALID = CoapPDU::COAP_VALID,
sillevl 23:019c530468b4 21 CHANGED = CoapPDU::COAP_CHANGED,
sillevl 23:019c530468b4 22 CONTENT = CoapPDU::COAP_CONTENT,
sillevl 23:019c530468b4 23 BAD_REQUEST = CoapPDU::COAP_BAD_REQUEST,
sillevl 23:019c530468b4 24 UNAUTHORIZED = CoapPDU::COAP_UNAUTHORIZED,
sillevl 23:019c530468b4 25 BAD_OPTION = CoapPDU::COAP_BAD_OPTION,
sillevl 23:019c530468b4 26 FORBIDDEN = CoapPDU::COAP_FORBIDDEN,
sillevl 23:019c530468b4 27 NOT_FOUND = CoapPDU::COAP_NOT_FOUND,
sillevl 23:019c530468b4 28 METHOD_NOT_ALLOWED = CoapPDU::COAP_METHOD_NOT_ALLOWED,
sillevl 23:019c530468b4 29 NOT_ACCEPTABLE = CoapPDU::COAP_NOT_ACCEPTABLE,
sillevl 23:019c530468b4 30 PRECONDITION_FAILED = CoapPDU::COAP_PRECONDITION_FAILED,
sillevl 23:019c530468b4 31 REQUEST_ENTITY_TOO_LARGE = CoapPDU::COAP_REQUEST_ENTITY_TOO_LARGE,
sillevl 23:019c530468b4 32 UNSUPPORTED_CONTENT_FORMAT = CoapPDU::COAP_UNSUPPORTED_CONTENT_FORMAT,
sillevl 23:019c530468b4 33 INTERNAL_SERVER_ERROR = CoapPDU::COAP_INTERNAL_SERVER_ERROR,
sillevl 23:019c530468b4 34 NOT_IMPLEMENTED = CoapPDU::COAP_NOT_IMPLEMENTED,
sillevl 23:019c530468b4 35 BAD_GATEWAY = CoapPDU::COAP_BAD_GATEWAY,
sillevl 23:019c530468b4 36 SERVICE_UNAVAILABLE = CoapPDU::COAP_SERVICE_UNAVAILABLE,
sillevl 23:019c530468b4 37 GATEWAY_TIMEOUT = CoapPDU::COAP_GATEWAY_TIMEOUT,
sillevl 23:019c530468b4 38 PROXYING_NOT_SUPPORTED = CoapPDU::COAP_PROXYING_NOT_SUPPORTED,
sillevl 23:019c530468b4 39 UNDEFINED_CODE = CoapPDU::COAP_UNDEFINED_CODE
sillevl 23:019c530468b4 40 };
sillevl 1:ab04e3d36ade 41
sillevl 24:8319d71d6749 42 /// CoapType enum, alias for CoapPDU::Type enum
sillevl 24:8319d71d6749 43 enum CoapType {
sillevl 24:8319d71d6749 44 CONFIRMABLE = CoapPDU::COAP_CONFIRMABLE,
sillevl 24:8319d71d6749 45 NON_CONFIRMABLE = CoapPDU::COAP_NON_CONFIRMABLE,
sillevl 24:8319d71d6749 46 ACKNOWLEDGEMENT = CoapPDU::COAP_ACKNOWLEDGEMENT,
sillevl 24:8319d71d6749 47 RESET = CoapPDU::COAP_RESET
sillevl 26:22849ab35dc2 48 };
sillevl 24:8319d71d6749 49
sillevl 0:9f557e9a792f 50 class Coap{
sillevl 0:9f557e9a792f 51 public:
sillevl 0:9f557e9a792f 52 Coap();
sillevl 0:9f557e9a792f 53
sillevl 0:9f557e9a792f 54 protected:
sillevl 0:9f557e9a792f 55
sillevl 0:9f557e9a792f 56 };