Skip to content

Commit c666a7b

Browse files
committed
Fix for issue #108 - Make sure the buffer is large enough before every send
1 parent f683e3c commit c666a7b

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

adafruit_wiznet5k/adafruit_wiznet5k_dhcp.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@
8686
_OPT_END = 255
8787

8888
# Packet buffer
89-
_BUFF = bytearray(318)
89+
_BUFF_SIZE = const(318)
90+
_BUFF = bytearray(_BUFF_SIZE)
9091

9192

9293
class DHCP:
@@ -166,7 +167,7 @@ def send_dhcp_message(
166167
:param float time_elapsed: Number of seconds elapsed since DHCP process started
167168
:param bool renew: Set True for renew and rebind, defaults to False
168169
"""
169-
_BUFF[:] = b"\x00" * len(_BUFF)
170+
_BUFF = bytearray(_BUFF_SIZE)
170171
# OP
171172
_BUFF[0] = _DHCP_BOOT_REQUEST
172173
# HTYPE

0 commit comments

Comments
 (0)