-->
Page 1 of 1

coap always receives packets from no where!

PostPosted: Wed Oct 16, 2019 5:37 am
by 4rm4n
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.

Re: coap always receives packets from no where!

PostPosted: Thu Oct 17, 2019 5:19 am
by eriksl
You might want to explain what "coap" is.

Also, I don't think it's a "hardware specific" question? More like "COAP specific"?

Re: coap always receives packets from no where!

PostPosted: Fri Oct 18, 2019 2:41 am
by QuickFix
Constrained Application Protocol (CoAP) and indeed I guess this is a protocol implementation issue, not hardware.