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.
Dependencies: DebugLib EthernetInterface cantcoap mbed-rtos
Fork of yeswecancoap by
Server Class Reference
Coap Server class Used to process and respond to coap requests. More...
#include <server.h>
Public Member Functions | |
| Server () | |
| Create a new Server instance. | |
| void | add (char *uri, void(*function)(Request *, Response *), CoapCode method) |
| Add a coap resource. | |
| void | waitForRequest () |
| Wait for a request and process that request. | |
| void | enableBroadcast (int broadcast=true) |
| Enable broadcast functionality. | |
Detailed Description
Coap Server class Used to process and respond to coap requests.
#include "mbed.h" #include "coap.h" void get_demo(Request* req, Response* res) { // do your stuff here } int main() { Server server; server.add("/demo", &get_led, GET); while(1) { server.waitForRequest(); }; }
Definition at line 37 of file server.h.
Constructor & Destructor Documentation
| Server | ( | ) |
Create a new Server instance.
Definition at line 4 of file server.cpp.
Member Function Documentation
Add a coap resource.
- Parameters:
-
uri The resource URI to respond on function The corresponding function to call when a request for this resource is received method The method to respond to (GET, POST, PUT or DELETE)
Definition at line 26 of file server.cpp.
| void enableBroadcast | ( | int | broadcast = true ) |
Enable broadcast functionality.
- Parameters:
-
broadcast Boolean value to enable or disable broadcasting functionality
Definition at line 21 of file server.cpp.
| void waitForRequest | ( | ) |
Wait for a request and process that request.
- Note:
- This is usually placed inside a loop
Definition at line 32 of file server.cpp.
Generated on Wed Jul 13 2022 18:09:57 by
1.7.2
