ESP32 - unable to receive multicast if ESP32 is access point

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
Post Reply
ZKDMun
Posts: 42
Joined: Thu Nov 24, 2016 2:34 pm
Location: Hamburg

ESP32 - unable to receive multicast if ESP32 is access point

Post by ZKDMun » Wed Jun 20, 2018 2:03 pm

First, my MCAST-sender-receiver code:

Code: Select all

#MCAST_ADDR = "239.255.255.250"
MCAST_PORT = 9898

sock = socket.socket(socket.AF_INET,socket.SOCK_DGRAM)
sock.setsockopt(socket.SOL_SOCKET,socket.SO_REUSEADDR,1)
addr = socket.getaddrinfo("0.0.0.0",MCAST_PORT)[0][-1]
sock.bind(addr)
opt = bytes([239,255,255,250])+bytes([0,0,0,0])
sock.setsockopt(socket.IPPROTO_IP,socket.IP_ADD_MEMBERSHIP,opt)
Now the problem:
I testet the following two network-configurations:

Conf1:
Access-Point: an ESP32
the clients are ESP8266 or ESP32

Conf2:
Access-Point: an ESP8266
the clients are ESP8266 and ESP32

For Conf1:
if I connect some ESP8266 and some ESP32 to an ESP32 as an AP, the ESP8266 are able to send (socket.sendto()) multicast-messages to other ESP8266 - but the ESP32s can not receive (socket.recvfrom()) any multicast-messages.
The ESP32s are only able to send multicast-messages (and the only clients which can receive the messages are ESP8266s).
The ESP8266s are not affected to this problem.

For example:
AP = ESP32 (STA.active(False), AP.active(True))
Client1 = ESP32, Client2 = ESP8266, Client3 = ESP8266 (every device is connected to AP; STA.active(True), AP.active(False))

Client1 is sending a message (socket.sendto(b"TEST-APESP32-FROMESP32",("239.255.255.250",9898)):
Client2 will receive the message! (socket.recvfrom(100))
Client3 will receive the message! (socket.recvfrom(100))

----
Client2 ist sending a message (socket.sendto(b"TEST-APESP32-FROMESP8266",("239.255.255.250",9898)):
Client3 will receive the message! (socket.recvfrom(100))
Client1 will never receive the message! (socket.recvfrom(100)) <<== FAILED!



My first guess was, that there is a problem for the ESP32 to receive multicast-messages... but the result of Conf2:
With an ESP8266 as an access point, the connected devices are all able to send and receive multicast-messages - ESP32s and ESP8266s.

For example:
AP = ESP8266 (STA.active(False), AP.active(True))
Client1 = ESP32, Client2 = ESP32, Client3 = ESP8266 (every device is connected to AP; STA.active(True), AP.active(False))

Client1 is sending a message (socket.sendto(b"TEST-APESP8266-FROMESP32",("239.255.255.250",9898)):
Client2 will receive the message! (socket.recvfrom(100))
Client3 will receive the message! (socket.recvfrom(100))

----
Client3 is sending a message (socket.sendto(b"TEST-ESP8266-FROMESP8266",("239.255.255.250",9898)):
Client1 will receive the message! (socket.recvfrom(100))
Client2 will receive the message! (socket.recvfrom(100))


There is only a problem if I use an ESP32 as access point - and only ESP32-clients are affected to this problem.


/The used firmwares are:
ESP8266: "MicroPython v1.9.4-170-g564abb0 on 2018-06-18" and "MicroPython v1.9.4-8-ga9a3caad0 on 2018-05-11"
ESP32: "MicroPython v1.9.4-183-g6d8816f-dirty on 2018-06-19" (build yesterday)

Eider
Posts: 3
Joined: Tue Jun 25, 2019 2:43 pm

Re: ESP32 - unable to receive multicast if ESP32 is access point

Post by Eider » Thu Jul 04, 2019 8:00 pm

Saludos Amigo

Necesito de tu ayuda :roll:
Será que podrías facilitarme el código que utilizaste para comunicar los dispositivos entre si es que llevo mucho tiempo buscando e intentando de muchas formas y no he podido.

Te agradecería que me pudieras ayudar :)

Post Reply