j

Dependencies:   mbed yeswecancoap C12832 LM75B

Committer:
arnedesmet
Date:
Fri Oct 23 11:51:28 2015 +0000
Revision:
0:92d2ef9f009d
Child:
1:92958e26bf2e
hallo;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
arnedesmet 0:92d2ef9f009d 1 #include "mbed.h"
arnedesmet 0:92d2ef9f009d 2 #include "coap.h"
arnedesmet 0:92d2ef9f009d 3 #include "Color.h"
arnedesmet 0:92d2ef9f009d 4 #include "RGB.h"
arnedesmet 0:92d2ef9f009d 5
arnedesmet 0:92d2ef9f009d 6 void get_hello(Request* req, Response* res)
arnedesmet 0:92d2ef9f009d 7 {
arnedesmet 0:92d2ef9f009d 8
arnedesmet 0:92d2ef9f009d 9
arnedesmet 0:92d2ef9f009d 10 res->setContent("Hello World\r\n", 13);
arnedesmet 0:92d2ef9f009d 11 res->setCode(CONTENT);
arnedesmet 0:92d2ef9f009d 12 //res->setType(NON_CONFIRMABLE);
arnedesmet 0:92d2ef9f009d 13 }
arnedesmet 0:92d2ef9f009d 14
arnedesmet 0:92d2ef9f009d 15 void post_led(Request* req, Response* res)
arnedesmet 0:92d2ef9f009d 16 {
arnedesmet 0:92d2ef9f009d 17
arnedesmet 0:92d2ef9f009d 18 RGB* led = new RGB(p23,p24,p25);
arnedesmet 0:92d2ef9f009d 19 led->setColor(255,0,0);
arnedesmet 0:92d2ef9f009d 20
arnedesmet 0:92d2ef9f009d 21 if(req->hasContent()){
arnedesmet 0:92d2ef9f009d 22 printf("Content: %s\r\n", req->getContent());
arnedesmet 0:92d2ef9f009d 23 int x;
arnedesmet 0:92d2ef9f009d 24 x = strtol(req->getContent(), NULL, 16);
arnedesmet 0:92d2ef9f009d 25 led->setColor(x);
arnedesmet 0:92d2ef9f009d 26 }
arnedesmet 0:92d2ef9f009d 27 res->setCode(CHANGED);
arnedesmet 0:92d2ef9f009d 28 //res->setType(NON_CONFIRMABLE);
arnedesmet 0:92d2ef9f009d 29 }
arnedesmet 0:92d2ef9f009d 30
arnedesmet 0:92d2ef9f009d 31
arnedesmet 0:92d2ef9f009d 32
arnedesmet 0:92d2ef9f009d 33 int main()
arnedesmet 0:92d2ef9f009d 34 {
arnedesmet 0:92d2ef9f009d 35 Server server;
arnedesmet 0:92d2ef9f009d 36 server.add("/hello", &get_hello, GET);
arnedesmet 0:92d2ef9f009d 37 server.add("/led", &post_led, POST);
arnedesmet 0:92d2ef9f009d 38 while(1){
arnedesmet 0:92d2ef9f009d 39 server.waitForRequest();
arnedesmet 0:92d2ef9f009d 40 }
arnedesmet 0:92d2ef9f009d 41
arnedesmet 0:92d2ef9f009d 42 }