Your new topic does not fit any of the above??? Check first. Then post here. Thanks.

Moderator: igrr

User avatar
By mrburnette
#57067 Take a look at the ESP8266 receiver code in my Tardis Time project.

Essentially, the trick I used was to add:
Code: Select all <...>
    UDP.read(packetBuffer, UDP_TX_PACKET_MAX_SIZE);         // read
    UDP.beginPacket(apIP, UDP.remotePort());                // send a reply
    UDP.write(ReplyBuffer);   // should not be necessary
    UDP.endPacket();          // stablized by the inclusion of the send


Ray
User avatar
By Shadow351
#57089
mrburnette wrote:Take a look at the ESP8266 receiver code in my Tardis Time project.

Essentially, the trick I used was to add:
Code: Select all <...>
    UDP.read(packetBuffer, UDP_TX_PACKET_MAX_SIZE);         // read
    UDP.beginPacket(apIP, UDP.remotePort());                // send a reply
    UDP.write(ReplyBuffer);   // should not be necessary
    UDP.endPacket();          // stablized by the inclusion of the send


Ray


hmm, I actually use a similar reply with my code already, mainly because early in my UDP endeavors I was experiencing packet loss and needed to verify the packet was received. I do make sure that the packet received wasn't itself an acknowledged packet first (to prevent a loop) and then send an acknowledge packet back
Code: Select all    if (ack && (strcmp(packetBuffer,"acknowledged") != 0))
    {
      // send a reply, to the IP address and port that sent us the packet we received
      Udp.beginPacket(Udp.remoteIP(), port);
      Udp.write(ReplyBuffer);
      Udp.endPacket();
    }


As for the UDP not delivering issue, Everything appeared to be working well until sometime this morning, so it worked and continued to respond for at least 36 hours. I checked before I went to sleep last night and it was still responding but when I woke up this morning, It was still sending "PING" packets to the computer but would not receive packets from the computer.

Edit: So I was working on another project while my prototype ran on the desk beside me, and I noticed the "WiFi Connected" LED flashed off and then back on again, like it lost WiFi for a second then reconnected. I wonder if something like this may be happening and either the ESP or router thinks the connection is completely dead so it drops communication. I added ESP.restart() to the code under the LED off code and I will let it run to see if that helps.