-
-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Closed
Labels
Description
Port, board and/or hardware
rp2 port, Raspberry Pi PICO W
MicroPython version
MicroPython v1.24.0 on 2024-10-25; Raspberry Pi Pico W with RP2040
Reproduction
import network
import time
import socket
import struct
import sys
ssid = None
password = None
MCAST_GROUP = '239.3.3.3'
MCAST_PORT = 50007
def inet_aton(ip_str):
return bytes(map(int, ip_str.split('.')))
wlan = network.WLAN(network.STA_IF)
wlan.active(True)
if ssid:
wlan.connect(ssid, password)
while not wlan.isconnected():
time.sleep(0.25)
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
mreq = struct.pack("4sL", inet_aton(MCAST_GROUP), 0)
print ('mreq:', mreq)
try:
sock.setsockopt(socket.IPPROTO_IP, socket.IP_ADD_MEMBERSHIP, mreq)
print("success")
except Exception as e:
sys.print_exception(e)
sys.exit()
while True:
try:
print('recv:', sock.recv(1024))
except Exception as e:
sys.print_exception(e)
sys.exit()
Expected behaviour
mreq: b'\xef\x03\x03\x03\x00\x00\x00\x00'
success
Observed behaviour
mreq: b'\xef\x03\x03\x03\x00\x00\x00\x00'
Traceback (most recent call last):
File "<stdin>", line 30, in <module>
ValueError:
Additional Information
This works on v1.23.0 provided wlan is active.
Code of Conduct
Yes, I agree