j
Dependencies: mbed yeswecancoap C12832 LM75B
main.cpp
- Committer:
- arnedesmet
- Date:
- 2015-10-23
- Revision:
- 0:92d2ef9f009d
- Child:
- 1:92958e26bf2e
File content as of revision 0:92d2ef9f009d:
#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(); } }