I meet some issue , and i would like to solve it for me , and other who can meet these also.
Here is my network diagram :
In my example, i have 4 ESP8266 ESP-12F, called ESP1 ESP2 ESP3 ESP4
ESP1 is connected to my home router by STA at 192.168.0.20
ESP2 is connecter to ESP1 AP at 192.168.4.2
ESP3 is connected to ESP2 AP at 192.168.4.2
ESP4 is connected to ESP3 AP at 192.168.4.2
I will call SLAVE esp wich is connect to another esp , side of udp is down
I will call MASTER esp who have one or more esp wich is connected to, side of udp is up
I use WiFiUpd.h lib
#include <Thread.h>
Thread myThread = Thread();
#include <WiFiUdp.h> // UDP protocol
WiFiUDP udp;
i use Thread.h to catch udp every 50ms .
Server on each esp !
udp.begin(localUdpPort); // 4210 localUdpPort
Serial.println ( "*** UDP server started" );
Serial.printf("*** UDP : Now listening at IP %s, UDP port %d\n", WiFi.localIP().toString().c_str(), localUdpPort);
I can send datagram to SLAVE with this:
case 1:{
udp.beginPacketMulticast(IPAddress(192,168,4,255), localUdpPort, WiFi.localIP());
M = "DOWN|"+M;
Serial.println("-->-- "+M);
break;
}
in fact i use broadcast ip to AP for slave .
udp.beginPacketMulticast(IPAddress(192,168,4,255), localUdpPort, IPAddress(192.168.4.2));
I can send datagram to MASTER with this:
case 0:{
udp.beginPacket(IPAddress(192,168,0,255), localUdpPort);
udp.write(strToCharArray(String("05|")+M));
udp.endPacket();
}
Yes but ....
That is work only for the way of ESP2 to ESP1
ESP1 received datagram :
--<-- Udp Incomming From:33859776 Port:4210 Data:05|UP|NODE|CF7F165038|______________1|349
--<-- Udp Incomming From:33859776 Port:4210 Data:05a|UP|NODE|CF7F165038|______________1|349
I replace 192.168.0.255 , by IP of wifi.localIP() of master, so , the slave send to master ip's wifi.local(ip)
udp.beginPacket(UpIP, localUdpPort);
udp.write(strToCharArray(String("05a|")+M));
udp.endPacket();
UpIP is send to salve by udp datagram
ESP2 receive this:
--<-- Udp Incomming From:17082560 Port:4210 Data:DOWN|NODE|CF7F8C0125|______________1|192|168|0|255|2277
ESP3 reveive this
--<-- Udp Incomming From:17082560 Port:4210 Data:DOWN|NODE|CF7F165038|______________1|192|168|4|255|1395
And now , ESP3 can't send udp to ESP2 !
ESP4 can't send upd to ESP1!
I tried several case of ip and multicast sending with no result .
if anybody have any kind of idea.
Hope that i explain correctly.
If needed i can send more detail
Thanks, best regards !
Windows 10
Arduino IDE 1.6.13
ESP8266 2.3-RC-2 + git ESP8266 core