Skip to content

Commit 31a7bfd

Browse files
author
brentru
committed
add docu
1 parent ce296c3 commit 31a7bfd

File tree

3 files changed

+48
-12
lines changed

3 files changed

+48
-12
lines changed

README.rst

Lines changed: 47 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Introduction
1515

1616
Pure-Python interface for WIZNET 5k ethernet modules.
1717

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.
1819

1920
Dependencies
2021
=============
@@ -29,12 +30,6 @@ This is easily achieved by downloading
2930

3031
Installing from PyPI
3132
=====================
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-
3833
On supported GNU/Linux systems like the Raspberry Pi, you can install the driver locally `from
3934
PyPI <https://pypi.org/project/adafruit-circuitpython-wiznet5k/>`_. To install for current user:
4035

@@ -59,8 +54,53 @@ To install in a virtual environment in your current project:
5954
6055
Usage Example
6156
=============
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")
6295
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)
64104
65105
Contributing
66106
============

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
# Uncomment the below if you use native CircuitPython modules such as
2121
# digitalio, micropython and busio. List the modules you use. Without it, the
2222
# autodoc module docs will fail to generate with a warning.
23-
# autodoc_mock_imports = ["digitalio", "busio"]
23+
autodoc_mock_imports = ["digitalio", "busio"]
2424

2525

2626
intersphinx_mapping = {'python': ('https://docs.python.org/3.4', None),'BusDevice': ('https://circuitpython.readthedocs.io/projects/busdevice/en/latest/', None),'CircuitPython': ('https://circuitpython.readthedocs.io/en/latest/', None)}

docs/index.rst

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,10 @@ Table of Contents
2323
.. toctree::
2424
:caption: Tutorials
2525

26-
.. todo:: Add any Learn guide links here. If there are none, then simply delete this todo and leave
27-
the toctree above for use later.
2826

2927
.. toctree::
3028
:caption: Related Products
3129

32-
.. todo:: Add any product links here. If there are none, then simply delete this todo and leave
33-
the toctree above for use later.
3430

3531
.. toctree::
3632
:caption: Other Links

0 commit comments

Comments
 (0)