Second set of eyes - Reflect back UDP Packet

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
AgentSmithers
Posts: 8
Joined: Fri Feb 17, 2017 6:23 pm

Second set of eyes - Reflect back UDP Packet

Post by AgentSmithers » Fri Feb 17, 2017 6:26 pm

Hi Everyone,
I am trying to just bounce a UDP packet from its source. I launched wireshark but I do not see it flying back with the destination address pointing back to the sender. Am I missing a piece of Logic here?
-Agent
[code]import array, network, ubinascii, socket
ap_if = network.WLAN(network.AP_IF)
network.WLAN(network.STA_IF).active(False)
essid = b"ESP8266-%s" % ubinascii.hexlify(ap_if.config("mac")[-3:])
ap_if.config(essid=essid, authmode=network.AUTH_WPA_WPA2_PSK, password=b"1234567890")

s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.bind(socket.getaddrinfo('0.0.0.0', 53)[0][-1])
while 1:
try:
m, addr = s.recvfrom(256)
print("Response: ", repr(m))
s.sendto(m, addr)
print("")
except KeyboardInterrupt as e:
print("KeyboardInterrupt: {0}".format(e), type(e))
except Exception as e:
print("Exception: {0}".format(e), type(e))[/code]

AgentSmithers
Posts: 8
Joined: Fri Feb 17, 2017 6:23 pm

Re: Second set of eyes - Reflect back UDP Packet

Post by AgentSmithers » Fri Feb 17, 2017 11:01 pm

Everyone, I got it. It appeared to be an issue with my indentation. I appreciate the views.
Sorry about taking up a post.

Post Reply