Coap Client and Server
Dependencies: DebugLib EthernetInterface cantcoap mbed-rtos
Fork of yeswecancoap by
early example
Example usage for revision:e03960f91763 https://developer.mbed.org/teams/Yes-We-Can/code/yeswecancoap/rev/e03960f91763
example usage version (20/10/2015)
#include "mbed.h" #include "coap.h" void get_hello(CoapPDU* req, CoapPDU* res) { uint8_t txt[] = "Hello\r\n"; res->setPayload(txt, 7); } void get_hello1(CoapPDU* req, CoapPDU* res) { uint8_t txt[] = "Hello 1\r\n"; res->setPayload(txt, 9); } void get_hello2(CoapPDU* req, CoapPDU* res) { uint8_t txt[] = "Hello 2\r\n"; res->setPayload(txt, 9); } void get_hello3(CoapPDU* req, CoapPDU* res) { uint8_t txt[] = "Hello 3\r\n"; res->setPayload(txt, 9); } int main() { Server server; server.add("/hello", &get_hello, GET); server.add("/hello/1", &get_hello1, GET); server.add("/hello/2", &get_hello2, GET); server.add("/hello/3", &get_hello3, GET); while(1) { server.waitForRequest(); }; }