Guest User

Untitled

a guest
Jun 24th, 2018
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. # stm32 version of wiznet_connect.py
  2. import network
  3. nic = network.Ethernet()
  4. while not nic.isconnected():
  5. pass
  6. nic.active(True)
  7. nic.ifconfig('dhcp')
  8. print(nic.ifconfig())
  9. import socket
  10. print(socket.getaddrinfo('micropython.org', 80))
  11.  
  12. # usage of static ip address
  13. nic.ifconfig(('192.168.0.123','255.255.255.0','192.168.0.1','192.168.0.1'))
  14. print(nic.ifconfig())
  15.  
  16. # ascii art star wars
  17. addr = socket.getaddrinfo("towel.blinkenlights.nl", 23)[0][-1]
  18. s = socket.socket()
  19. s.connect(addr)
  20. while True:
  21. data = s.recv(500)
  22. print(str(data, 'utf8'), end='')
Add Comment
Please, Sign In to add comment