Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
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);
...
}