Skip to content

Commit 8aae595

Browse files
author
brentru
committed
fixme fixed!
1 parent 2582506 commit 8aae595

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

adafruit_wiznet5k/adafruit_wiznet5k_dhcp.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,10 @@ def send_dhcp_message(self, state, time_elapsed):
179179
# Option - Host Name
180180
_buff[252] = 12
181181
_buff[253] = len(b"Wiznet") + 6
182-
# NOTE/TODO: This appends invalid ? chars. onto hostname instead of string
183-
_buff[254:266] = b"Wizneteeeeee"
182+
_buff[254:260] = b"WIZnet"
183+
184+
for mac in range(0, 5):
185+
_buff[260+mac] = self._mac_address[mac]
184186

185187
if state == DHCP_REQUEST:
186188
# Set the parsed local IP addr
@@ -218,7 +220,6 @@ def parse_dhcp_response(self, response_timeout):
218220
219221
:param int response_timeout: Time to wait for server to return packet, in seconds.
220222
"""
221-
print("STATE: ", self._dhcp_state)
222223
start_time = time.monotonic()
223224
packet_sz = self._sock.available()
224225
while packet_sz <= 0:
@@ -259,10 +260,8 @@ def parse_dhcp_response(self, response_timeout):
259260
self._lease_time = int.from_bytes(_buff[251:255], 'l')
260261
# T1 value
261262
self._t1 = int.from_bytes(_buff[257:261], 'l')
262-
# print("T1: ", self._t1)
263263
# T2 value
264264
self._t2 = int.from_bytes(_buff[263:267], 'l')
265-
# print("T2: ", self._t2)
266265
# Subnet Mask
267266
self.subnet_mask = _buff[269:273]
268267
# DNS Server
@@ -283,24 +282,20 @@ def request_dhcp_lease(self):
283282

284283
while self._dhcp_state != STATE_DHCP_LEASED:
285284
if self._dhcp_state == STATE_DHCP_START:
286-
print("START")
287285
self._transaction_id += 1
288286
self._sock.connect((BROADCAST_SERVER_ADDR, DHCP_SERVER_PORT))
289287
self.send_dhcp_message(STATE_DHCP_DISCOVER,
290288
((time.monotonic() - start_time) / 1000))
291289
self._dhcp_state = STATE_DHCP_DISCOVER
292290
elif self._dhcp_state == STATE_DHCP_DISCOVER:
293-
print("DISCOVER")
294291
msg_type, xid = self.parse_dhcp_response(self._timeout)
295292
if msg_type == DHCP_OFFER:
296293
# use the _transaction_id the offer returned,
297294
# rather than the current one
298295
self._transaction_id = self._transaction_id.from_bytes(xid, 'l')
299-
print("REQUEST")
300296
self.send_dhcp_message(DHCP_REQUEST, ((time.monotonic() - start_time) / 1000))
301297
self._dhcp_state = STATE_DHCP_REQUEST
302298
elif STATE_DHCP_REQUEST:
303-
print("LEASE")
304299
msg_type, xid = self.parse_dhcp_response(self._timeout)
305300
if msg_type == DHCP_ACK:
306301
self._dhcp_state = STATE_DHCP_LEASED

0 commit comments

Comments
 (0)