bportaluri / WiFiEsp

Arduino WiFi library for ESP8266 modules
GNU General Public License v3.0
548 stars 210 forks source link

UDP->remotePort() returns incorrect value #209

Open PsychicSmurf opened 3 years ago

PsychicSmurf commented 3 years ago

Using the example UDP code in the library I have noticed that when it logs the received packet, and serial prints the remote IP Address and port, that a 5-digit port has it's first digit removed.

Using a UDP test tool (Packet Sender), on Windows 10, I transmitted a packet to the Arduino running the test code connected to my local wifi. The test tool doesn't allow me to set the source port, but it does indicate which one its using.

If I'm using UDP:61065 in the Test Tool then the Arduino prints "1065" in the following line: Serial.println(Udp.remotePort()); so the output is "port 1065"

The same happens for each port the test tool uses. The first digit is removed, and the last four digits are correct. This means that the "Ack" response here doesn't work: Udp.beginPacket(Udp.remoteIP(), Udp.remotePort()); Udp.write(ReplyBuffer); Udp.endPacket(); as it uses the wrong port.

When I manually override it, it works perfectly.

JAndrassy commented 3 years ago

This library is not maintained. Even if you provide a PR with a fix I doubt that it will be merged. I made a new library for AT 1.7+. See if you can use it. https://github.com/jandrassy/WiFiEspAT

PsychicSmurf commented 3 years ago

Honestly, I'd love to. I did look at your library first, however I can't get to the point where I could use it.

The serial ESP8266 devices I have are 1MB flash and were shipped with 1.5.4 firmware. And I can't find a UK source for 2MB devices, or devices with newer firmware.

To use your library I would need to flash them and I have yet to find a Windows procedure that would let me (1) Build 1 MB version of the firmware as the download is 2MB and (2) Upload that firmware to the modules.

JAndrassy commented 3 years ago

AT 1.7.4 has a 1 MB version in download from Espressif's site