Created
November 23, 2017 00:57
-
-
Save boochow/547f1509c048c4422b2ff126ef24e9de to your computer and use it in GitHub Desktop.
This file contains 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
def lan_connect(spi, cs, reset): | |
import network | |
nic = network.WIZNET5K(spi,cs,reset) | |
while not nic.isconnected(): | |
pass | |
nic.active(True) | |
nic.ifconfig('dhcp') | |
print('network config:', nic.ifconfig()) | |
def main(): | |
import socket | |
from machine import Pin | |
lan_connect(pyb.SPI(2), Pin('PB12'), Pin('PC8')) | |
addr = socket.getaddrinfo('towel.blinkenlights.nl', 23)[0][-1] | |
s = socket.socket() | |
s.connect(addr) | |
while True: | |
data = s.recv(1500) | |
print(data.decode('utf-8'), end='') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
http://blog.boochow.com/article/455072433.html