I Implemented a coap server :
#include <coap_server.h>
coapServer coap;
void getListOfWiFi(coapPacket *packet, IPAddress ip, int port, int obs) //id = 0 GET
{
Serial.println("hello");
int numberOfNetworks = WiFi.scanNetworks();
String WifiList = "";
for (int i = 0; i < numberOfNetworks - 1; i++)
{
WifiList += WiFi.SSID(i) + "####";
}
WifiList += WiFi.SSID(numberOfNetworks - 1);
char *temp = new char[WifiList.length() + 1];
WifiList.toCharArray(temp, WifiList.length() + 1);
coap.sendResponse(ip, port, temp);
Serial.println("goodbye");
}
void setup()
{
coap.server(getListOfWiFi, "wifilist");
coap.start(5683);
}
void loop()
{
coap.loop();
}
When start the esp, the output of serial monitor is :
hello
goodbye
hello
goodbye
hello
goodbye
hello
goodbye
hello
goodbye
hello
goodbye
And it keeps printing this without any receiving packets or requests...
Why this happens ?
Thanks.