@@ -15,8 +15,6 @@ Introduction
15
15
16
16
Pure-Python interface for WIZNET 5k ethernet modules.
17
17
18
- NOTE: This library does not currently contain a DNS client. You will need to include a server ip address and destination port in your code.
19
-
20
18
Dependencies
21
19
=============
22
20
This driver depends on:
@@ -67,24 +65,21 @@ wifitest.adafruit.com.
67
65
from adafruit_wiznet5k.adafruit_wiznet5k import WIZNET
68
66
import adafruit_wiznet5k.adafruit_wiznet5k_socket as socket
69
67
70
- # Name address for wifitest.adafruit.com
71
- SERVER_ADDRESS = ((' 104.236.193.178' ), 80 )
72
-
73
68
cs = digitalio.DigitalInOut(board.D10)
74
69
spi_bus = busio.SPI(board.SCK , MOSI = board.MOSI , MISO = board.MISO )
75
70
76
71
# Initialize ethernet interface with DHCP
77
- eth = WIZNET (spi_bus, cs)
72
+ eth = WIZNET5K (spi_bus, cs, debug = True )
78
73
79
74
print (" DHCP Assigned IP: " , eth.pretty_ip(eth.ip_address))
80
75
81
76
socket.set_interface(eth)
82
77
83
- # Create a new socket
84
- sock = socket.socket()
78
+ host = ' wifitest.adafruit.com '
79
+ port = 80
85
80
86
- print ( " Connecting to: " , SERVER_ADDRESS [ 0 ] )
87
- sock.connect( SERVER_ADDRESS )
81
+ addr_info = socket.getaddrinfo(host, port, 0 , socket. SOCK_STREAM )
82
+ sock = socket.socket(addr_info[ 0 ], addr_info[ 1 ], addr_info[ 2 ] )
88
83
89
84
print (" Connected to " , sock.getpeername())
90
85
0 commit comments