Yes We Can / yeswecancoap

Dependencies:   DebugLib EthernetInterface cantcoap mbed-rtos

Dependents:   COAP coap

Fork of yeswecancoap by Sille Van Landschoot

Files at this revision

API Documentation at this revision

Comitter:
sillevl
Date:
Wed Oct 21 11:34:15 2015 +0000
Parent:
7:1bed29e1b0a4
Child:
12:e2b427effaad
Commit message:
different method resources now working

Changed in this revision

server.cpp Show annotated file Show diff for this revision Revisions of this file
server.h Show annotated file Show diff for this revision Revisions of this file
--- 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
--- a/server.h	Wed Oct 21 10:23:21 2015 +0000
+++ b/server.h	Wed Oct 21 11:34:15 2015 +0000
@@ -15,7 +15,7 @@
     public:
     Server();
     
-    void add(char* uri, void (*fnc)(Request*, Response*), Method method);
+    void add(char* uri, void (*fnc)(Request*, Response*), CoapPDU::Code method);
     void waitForRequest();
     
     
@@ -32,7 +32,7 @@
     
     std::vector<Resource> resources;
     
-    int findResource(char* uri, CoapPDU::Code code);
+    int findResource(char* uri, CoapPDU::Code method);
     
     static const int UDP_BUFFER_SIZE = 256;
     static const int TOKEN_BUFFER_SIZE = 8;