26
26
27
27
* Adafruit's Bus Device library: https://github.com/adafruit/Adafruit_CircuitPython_BusDevice
28
28
"""
29
+
30
+ __version__ = "0.0.0+auto.0"
31
+ __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_Wiznet5k.git"
32
+
29
33
# pylint: disable=too-many-lines
30
34
try :
31
35
from typing import Optional , Union , List , Tuple , Sequence
43
47
import adafruit_wiznet5k .adafruit_wiznet5k_dhcp as dhcp
44
48
import adafruit_wiznet5k .adafruit_wiznet5k_dns as dns
45
49
46
-
47
- __version__ = "0.0.0+auto.0"
48
- __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_Wiznet5k.git"
49
-
50
-
51
50
# Wiznet5k Registers
52
51
REG_MR = const (0x0000 ) # Mode
53
52
REG_GAR = const (0x0001 ) # Gateway IP Address
@@ -223,7 +222,7 @@ def set_dhcp(
223
222
:param Optional[str] hostname: The desired hostname for the DHCP server with optional {} to
224
223
fill in the MAC address, defaults to None.
225
224
:param float response_timeout: Time to wait for server to return packet in seconds,
226
- defaults to 30.
225
+ defaults to 30.0.
227
226
228
227
:return int: 0 if DHCP configured, -1 otherwise.
229
228
"""
@@ -359,7 +358,6 @@ def pretty_mac(
359
358
:param bytearray mac: The MAC address.
360
359
361
360
:return str: Mac Address in the form 00:00:00:00:00:00
362
-
363
361
"""
364
362
return "%s:%s:%s:%s:%s:%s" % (
365
363
hex (mac [0 ]),
@@ -420,7 +418,7 @@ def ifconfig(
420
418
Network configuration information.
421
419
422
420
:return Tuple[bytearray, bytearray, bytearray, Tuple[int, int, int, int]]: \
423
- The IP address, subnet mask, gateway address and DNS server address."""
421
+ The IP address, subnet mask, gateway address and DNS server address."""
424
422
return (
425
423
self .ip_address ,
426
424
self .read (REG_SUBR , 0x00 , 4 ),
@@ -435,8 +433,8 @@ def ifconfig(
435
433
"""
436
434
Set network configuration.
437
435
438
- :params Tuple[bytearray, bytearray, bytearray, Tuple[int, int, int, int]]: \
439
- Configuration settings - (ip_address, subnet_mask, gateway_address, dns_server).
436
+ :param Tuple[bytearray, bytearray, bytearray, Tuple[int, int, int, int]]:
437
+ Configuration settings - (ip_address, subnet_mask, gateway_address, dns_server).
440
438
"""
441
439
ip_address , subnet_mask , gateway_address , dns_server = params
442
440
@@ -606,12 +604,11 @@ def write(
606
604
607
605
def socket_available (self , socket_num : int , sock_type : int = SNMR_TCP ) -> int :
608
606
"""
609
- Return the number of bytes available to be read from the socket.
607
+ Number of bytes available to be read from the socket.
610
608
611
609
:param int socket_num: Socket to check for available bytes.
612
610
:param int sock_type: Socket type. Use SNMR_TCP for TCP or SNMR_UDP for UDP, \
613
- defaults to SNMR_TCP.
614
-
611
+ defaults to SNMR_TCP.
615
612
:return int: Number of bytes available to read.
616
613
"""
617
614
if self ._debug :
@@ -642,7 +639,7 @@ def socket_available(self, socket_num: int, sock_type: int = SNMR_TCP) -> int:
642
639
643
640
def socket_status (self , socket_num : int ) -> Optional [bytearray ]:
644
641
"""
645
- Return the socket connection status.
642
+ Socket connection status.
646
643
647
644
Can be: SNSR_SOCK_CLOSED, SNSR_SOCK_INIT, SNSR_SOCK_LISTEN, SNSR_SOCK_SYNSENT,
648
645
SNSR_SOCK_SYNRECV, SNSR_SYN_SOCK_ESTABLISHED, SNSR_SOCK_FIN_WAIT,
@@ -671,7 +668,7 @@ def socket_connect(
671
668
:param Union[bytes, bytearray] dest: The destination as a host name or IP address.
672
669
:param int port: Port to connect to (0 - 65,536).
673
670
:param int conn_mode: The connection mode. Use SNMR_TCP for TCP or SNMR_UDP for UDP,
674
- defaults to SNMR_TCP.
671
+ defaults to SNMR_TCP.
675
672
"""
676
673
assert self .link_status , "Ethernet cable disconnected!"
677
674
if self ._debug :
@@ -712,7 +709,7 @@ def _send_socket_cmd(self, socket: int, cmd: int) -> None:
712
709
def get_socket (self ) -> int :
713
710
"""Request, allocate and return a socket from the W5k chip.
714
711
715
- Cycles through the sockets to find the first available one, if any.
712
+ Cycle through the sockets to find the first available one, if any.
716
713
717
714
:return int: The first available socket. Returns 0xFF if no sockets are free.
718
715
"""
@@ -773,7 +770,6 @@ def socket_accept(
773
770
the IP address and port of the incoming connection.
774
771
775
772
:param int socket_num: Socket number with connection to check.
776
-
777
773
:return Tuple[int, Tuple[Union[str, bytearray], Union[int, bytearray]]]:
778
774
If successful, the next (socket number, (destination IP address, destination port)).
779
775
@@ -799,8 +795,7 @@ def socket_open(self, socket_num: int, conn_mode: int = SNMR_TCP) -> int:
799
795
800
796
:param int socket_num: The socket number to open.
801
797
:param int conn_mode: The protocol to use. Use SNMR_TCP for TCP or SNMR_UDP for \
802
- UDP, defaults to SNMR_TCP.
803
-
798
+ UDP, defaults to SNMR_TCP.
804
799
:return int: 1 if the socket was opened, 0 if not.
805
800
"""
806
801
assert self .link_status , "Ethernet cable disconnected!"
@@ -874,9 +869,9 @@ def socket_read(
874
869
:param int length: The number of bytes to read from the socket.
875
870
876
871
:return Tuple[int, Union[int, bytearray]]: If the read was successful then the first
877
- item of the tuple is the length of the data and the second is the data. If the read
878
- was unsuccessful then both items equal an error code, 0 for no data waiting and -1
879
- for no connection to the socket.
872
+ item of the tuple is the length of the data and the second is the data. If the read
873
+ was unsuccessful then both items equal an error code, 0 for no data waiting and -1
874
+ for no connection to the socket.
880
875
"""
881
876
assert self .link_status , "Ethernet cable disconnected!"
882
877
assert socket_num <= self .max_sockets , "Provided socket exceeds max_sockets."
0 commit comments