j

Dependencies:   mbed yeswecancoap C12832 LM75B

Revision:
0:92d2ef9f009d
Child:
1:92958e26bf2e
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri Oct 23 11:51:28 2015 +0000
@@ -0,0 +1,42 @@
+#include "mbed.h"
+#include "coap.h"
+#include "Color.h"
+#include "RGB.h"
+
+void get_hello(Request* req, Response* res)
+{
+    
+    
+    res->setContent("Hello World\r\n", 13);
+    res->setCode(CONTENT);
+    //res->setType(NON_CONFIRMABLE);
+}
+
+void post_led(Request* req, Response* res)
+{
+    
+    RGB* led = new RGB(p23,p24,p25);
+    led->setColor(255,0,0);
+    
+    if(req->hasContent()){
+              printf("Content: %s\r\n", req->getContent());
+              int x;
+              x = strtol(req->getContent(), NULL, 16);
+              led->setColor(x);
+           }
+           res->setCode(CHANGED);
+    //res->setType(NON_CONFIRMABLE);
+}
+
+
+
+int main()
+{
+    Server server;
+    server.add("/hello", &get_hello, GET);
+    server.add("/led", &post_led, POST);
+    while(1){
+        server.waitForRequest();
+    }
+    
+}
\ No newline at end of file