Use this forum to chat about hardware specific topics for the ESP8266 (peripherals, memory, clocks, JTAG, programming)

User avatar
By 4rm4n
#84181 Hi,
I Implemented a coap server :
Code: Select all#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 :
Code: Select allhello
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.