Skip to content

Instantly share code, notes, and snippets.

@boochow
Created June 23, 2018 04:50
Show Gist options
  • Save boochow/f677b75a5ff999cc8b66465c975ddddd to your computer and use it in GitHub Desktop.
Save boochow/f677b75a5ff999cc8b66465c975ddddd to your computer and use it in GitHub Desktop.
# stm32 version of wiznet_connect.py
import network
nic = network.Ethernet()
while not nic.isconnected():
pass
nic.active(True)
nic.ifconfig('dhcp')
print(nic.ifconfig())
import socket
print(socket.getaddrinfo('micropython.org', 80))
# usage of static ip address
nic.ifconfig(('192.168.0.123','255.255.255.0','192.168.0.1','192.168.0.1'))
print(nic.ifconfig())
# ascii art star wars
addr = socket.getaddrinfo("towel.blinkenlights.nl", 23)[0][-1]
s = socket.socket()
s.connect(addr)
while True:
data = s.recv(500)
print(str(data, 'utf8'), end='')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment