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

Revision:
11:642eaabf1c2b
Parent:
7:1bed29e1b0a4
Child:
16:62a87be3f0b8
--- a/server.cpp	Wed Oct 21 10:23:21 2015 +0000
+++ b/server.cpp	Wed Oct 21 11:34:15 2015 +0000
@@ -13,7 +13,7 @@
     server.bind(5683);
 }
 
-void Server::add(char* uri, void (*fnc)(Request*, Response*), Method method)
+void Server::add(char* uri, void (*fnc)(Request*, Response*), CoapPDU::Code method)
 {
     Resource res = {uri, fnc, method};
     resources.push_back(res);
@@ -70,10 +70,10 @@
     }
 }
 
-int Server::findResource(char* uri, CoapPDU::Code code)
+int Server::findResource(char* uri, CoapPDU::Code method)
 {
     for(int i = 0; i < resources.size(); i++){
-        if(strcmp(uri, resources[i].uri) == 0) return i;
+        if(strcmp(uri, resources[i].uri) == 0 && method == resources[i].method) return i;
     }
     return -1;
 }
\ No newline at end of file