Chat freely about anything...

User avatar
By Stévanovich
#58751 Hello everybody,

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 :

Image

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


Code: Select all#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 !
Code: Select all 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:

Code: Select all      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:

Code: Select allcase 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)
Code: Select all          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 !
User avatar
By Stévanovich
#58769 Some news,
Change core to 2.3.0 (Stable)

ESP3 to ESP2 receive only one datagram !!!


Code: Select all          udp.beginPacket(IPAddress(192,168,4,1), localUdpPort);
          udp.write(strToCharArray(String("01|")+M));
          delay(1);
          udp.endPacket();
          delay(1);



--<-- Udp Incomming From:192.168.4.1 Port:4210 Data:01|UP|NODE|CF7F21F485|______________1|2365


I read on another post that adding delay(1) after write could help data to be send .... (nothing change in my case) , yes but only first time.

Hope will have some good news to solve this bug ?
User avatar
By Stévanovich
#58813 Hello,

You will found a very helpfull answer :
https://github.com/me-no-dev/ESPAsyncUDP/issues/9#issuecomment-263151175

Thanks me-no-dev !

Now, i have to put some code ....