Establishing UDP connection Desktop <-> Rpi Pico W

79 views Asked by At

FIXED: made a firewall rule on port 49555 in the desktop and switched the network type to private

first time on SO. For the last days I've started a project for the which I need to establish a UDP connection between my Pico W and my Desktop, running micro python and python, respectively. These are the facts: -I've been able to send packets from my pc and receive them on the pico without a problem. -I've been able to send packets from the pico to the pc and although they do show up in wireshark, my python script doesn't capture them.

This is the code:

import socket

sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)

sock.bind(("192.168.1.244", 49555))

data, add = sock.recvfrom(1024)

print(data.decode())
print(add)
sock.close()

This is the desktop's script to receive a packet.

import network
import socket

from credentials import router1

wlan = network.WLAN(network.STA_IF)  # Create a station interface object
wlan.active(True)  # Activate the interface

# Replace with your network's SSID and password
wlan.connect(router1.ssid, router1.password)

while not wlan.isconnected():
    pass  # Wait for connection

print("Connected to network!")
print("IP address:", wlan.ifconfig()[0])

sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)


print(sock.sendto("ola".encode(), ("192.168.1.244", 49555)))

sock.close()

This is the pico W's script to send a packet.

Since I've already been able to read a packet in the pico sent from the desktop, I just need help with doing the oposite and having it show up not only in wireshark. Any help is appreciated, thanks.

0

There are 0 answers