Search
 
SCRIPT & CODE EXAMPLE
 

C

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();
}
Comment

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");
}
Comment

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);
	}
}
Comment

PREVIOUS NEXT
Code Example
C :: read a string 
C :: creating an array of arrays or 2D array dynamically 
C :: lazer codechef 
C :: How to get the number of characters in a string without using strlen function 
C :: /usr/bin/mandb: fopen /var/cache/man/7935: Permission denied 
C :: payement des véhicules a la sortie de station de langue c 
C :: string once declared 
C :: qgraphicsscene save all items to file 
C :: reverse number in c 
C :: c %s 
C :: c ternary operator 
C :: linked list in c 
C :: concate string in c 
C :: Recommended compiler and linker flags for GCC 
Dart :: flutter appbar backbutton remove 
Dart :: flutter transparent appbar 
Dart :: flutter listtile padding 
Dart :: dart input field overflow when keyboard open 
Dart :: flutter snackbar shape 
Dart :: options != null "FirebaseOptions cannot be null when creating the default app." 
Dart :: dart shuffle list 
Dart :: flutter listtile minverticalpadding 
Dart :: flutter floatingactionbutton position 
Dart :: flutter var type 
Dart :: flutter display widget based on device orientation 
Dart :: image from assets in flutter 
Dart :: compute flutter 
Dart :: pass function as parameter in flutter 
Dart :: flutter get carousel sliders current index 
Dart :: flutter datetime 
ADD CONTENT
Topic
Content
Source link
Name
6+6 =