ProsecCoAP 🥂
 
Loading...
Searching...
No Matches
server.ino File Reference
#include <Ethernet.h>
#include <EthernetUdp.h>
#include <ProsecCoAP.h>

Macros

#define LEDP   LED_BUILTIN
 

Functions

IPAddress deviceIp (192, 168, 0, 99)
 
void callbackLight (Coap::Message &packet, IPAddress ip, uint16_t port)
 
void callbackResponse (Coap::Message &packet, IPAddress ip, uint16_t port)
 
void setup ()
 
void loop ()
 

Variables

byte mac [] = {0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x02}
 
EthernetUDP Udp
 
Coap::Node coapNode (Udp)
 
bool LED_STATUS
 

Macro Definition Documentation

◆ LEDP

#define LEDP   LED_BUILTIN

A CoAP server.

The current light status can be read using:

coap-client-notls -m get coap://192.168.0.99/light

and the light can be set ON or OFF, respectively, by using:

coap-client-notls -m put coap://192.168.0.99/light -e "1"
coap-client-notls -m put coap://192.168.0.99/light -e "0"

Note that on some boards, ON/OFF logic may be inverted.

In addition, this example also acts as client, sending a GET request every second. To receive such requests, start a CoAP server on the remote machine. To test, you may use:

coap-server-notls -v 9

Function Documentation

◆ callbackLight()

void callbackLight ( Coap::Message & packet,
IPAddress ip,
uint16_t port )

◆ callbackResponse()

void callbackResponse ( Coap::Message & packet,
IPAddress ip,
uint16_t port )

◆ deviceIp()

IPAddress deviceIp ( 192 ,
168 ,
0 ,
99  )

◆ loop()

void loop ( )

◆ setup()

void setup ( )

Variable Documentation

◆ coapNode

Coap::Node coapNode(Udp) ( Udp )

◆ LED_STATUS

bool LED_STATUS

◆ mac

byte mac[] = {0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x02}

◆ Udp

EthernetUDP Udp