This is CoAP library with a focus on simplicity. It offers minimal CoAP PDU construction and decoding to and from byte buffers.
Dependents: cantcoap_cellular_test yeswecancoap
You are viewing an older revision! See the latest version
Homepage
This is CoAP library with a focus on simplicity Github page is here:
https://github.com/staropram/cantcoap
Doxygen documentation on github here:
http://staropram.github.io/cantcoap/index.html
Example:
CoapPDU *pdu = new CoapPDU(); pdu->setType(CoapPDU::COAP_CONFIRMABLE); pdu->setCode(CoapPDU::COAP_GET); pdu->setToken((uint8_t*)"\3\2\1\0",4); pdu->setMessageID(0x0005); pdu->setURI((char*)"test",4); // send packet ret = send(sockfd,pdu->getPDUPointer(),pdu->getPDULength(),0);
...
// receive packet ret = recvfrom(sockfd,&buffer,BUF_LEN,0,(sockaddr*)&recvAddr,&recvAddrLen); CoapPDU *recvPDU = new CoapPDU((uint8_t*)buffer,ret); if(recvPDU->validate()) { recvPDU->getURI(uriBuffer,URI_BUF_LEN,&recvURILen); ... }