@@ -15,6 +15,7 @@ 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.
18
19
19
20
Dependencies
20
21
=============
@@ -29,12 +30,6 @@ This is easily achieved by downloading
29
30
30
31
Installing from PyPI
31
32
=====================
32
- .. note :: This library is not available on PyPI yet. Install documentation is included
33
- as a standard element. Stay tuned for PyPI availability!
34
-
35
- .. todo :: Remove the above note if PyPI version is/will be available at time of release.
36
- If the library is not planned for PyPI, remove the entire 'Installing from PyPI' section.
37
-
38
33
On supported GNU/Linux systems like the Raspberry Pi, you can install the driver locally `from
39
34
PyPI <https://pypi.org/project/adafruit-circuitpython-wiznet5k/> `_. To install for current user:
40
35
@@ -59,8 +54,53 @@ To install in a virtual environment in your current project:
59
54
60
55
Usage Example
61
56
=============
57
+ This example demonstrates making a HTTP GET request to
58
+ wifitest.adafruit.com.
59
+
60
+ .. code-block :: python
61
+
62
+ import time
63
+
64
+ import board
65
+ import busio
66
+ import digitalio
67
+ from adafruit_wiznet5k.adafruit_wiznet5k import WIZNET
68
+ import adafruit_wiznet5k.adafruit_wiznet5k_socket as socket
69
+
70
+ # Name address for wifitest.adafruit.com
71
+ SERVER_ADDRESS = ((' 104.236.193.178' ), 80 )
72
+
73
+ cs = digitalio.DigitalInOut(board.D10)
74
+ spi_bus = busio.SPI(board.SCK , MOSI = board.MOSI , MISO = board.MISO )
75
+
76
+ # Initialize ethernet interface with DHCP
77
+ eth = WIZNET(spi_bus, cs)
78
+
79
+ print (" DHCP Assigned IP: " , eth.pretty_ip(eth.ip_address))
80
+
81
+ socket.set_interface(eth)
82
+
83
+ # Create a new socket
84
+ sock = socket.socket()
85
+
86
+ print (" Connecting to: " , SERVER_ADDRESS [0 ])
87
+ sock.connect(SERVER_ADDRESS )
88
+
89
+ print (" Connected to " , sock.getpeername())
90
+
91
+ # Make a HTTP Request
92
+ sock.send(b " GET /testwifi/index.html HTTP/1.1\n " )
93
+ sock.send(b " Host: 104.236.193.178\n " )
94
+ sock.send(b " Connection: close\n\n " )
62
95
63
- .. todo :: Add a quick, simple example. It and other examples should live in the examples folder and be included in docs/examples.rst.
96
+ bytes_avail = 0
97
+ while not bytes_avail:
98
+ bytes_avail = sock.available()
99
+ if bytes_avail > 0 :
100
+ data = sock.recv(bytes_avail)
101
+ print (data)
102
+ break
103
+ time.sleep(0.05 )
64
104
65
105
Contributing
66
106
============
0 commit comments