Created
June 23, 2018 04:50
-
-
Save boochow/f677b75a5ff999cc8b66465c975ddddd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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