#include <ESP8266WiFi.h>
#include <WiFiUdp.h>
IPAddress ip_sta;
WiFiUDP udp;
void setup() {
Serial1.begin(921600);
WiFi.begin("testtest", "testtest");
while (WiFi.status() != WL_CONNECTED) {
delay(1000);
Serial1.print(".");
}
//Set client to static IP
ip_sta = WiFi.localIP();
ip_sta[3] = 115;
WiFi.config(ip_sta, WiFi.gatewayIP(), WiFi.subnetMask()); //if comment this line code runs perfectly
udp.begin(2424);
}
void loop() {
int packetsize = udp.parsePacket();
if (packetsize) {
char packetBuffer[32];
int len = udp.read(packetBuffer, 32);
packetBuffer[31] = 0;
Serial1.print("PACKET: "); Serial1.println(packetBuffer);
Serial1.print("LENGTH: "); Serial1.println(len);
}
}