Answers for "cannot reach esp8266 via udp while he is running with a static ip"

C
0

cannot reach esp8266 via udp while he is running with a static ip

#include <ESP8266WiFi.h>
#include <WiFiUdp.h>

IPAddress ip_ap(192, 168, 1, 123);
IPAddress gw_ap(192, 168, 1, 1);
IPAddress sn_ap(255, 255, 255, 0);
WiFiUDP udp;

void setup() {
	Serial1.begin(921600);
	WiFi.softAPConfig(ip_ap, gw_ap, sn_ap);
	WiFi.softAP("testtest", "testtest");
}

void loop() {
	delay(1000);
	udp.beginPacket(IPAddress(192, 168, 1, 255), 2424);
	udp.print("TEST TEST");
	udp.endPacket();
}
Posted by: Guest on November-19-2020
0

cannot reach esp8266 via udp while he is running with a static ip

#include <ESP8266WiFi.h>
#include <ESPAsyncUDP.h>

IPAddress ip_ap(192, 168, 1, 123);
IPAddress gw_ap(192, 168, 1, 1);
IPAddress sn_ap(255, 255, 255, 0);
AsyncUDP udp;

void setup() {
	Serial1.begin(921600);
	WiFi.softAPConfig(ip_ap, gw_ap, sn_ap);
	WiFi.softAP("testtest", "testtest");
}

void loop() {
	delay(1000);
	udp.broadcastTo("Anyone here?", 2424);
	Serial1.println("LOOP");
}
Posted by: Guest on November-19-2020
0

cannot reach esp8266 via udp while he is running with a static ip

#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);
	}
}
Posted by: Guest on November-19-2020

Code answers related to "cannot reach esp8266 via udp while he is running with a static ip"

Code answers related to "C"

Browse Popular Code Answers by Language