Skip to content

Commit ba001b7

Browse files
author
BiffoBear
committed
Move move get UDP port to _handle_dhcp_message.
1 parent 5fd1245 commit ba001b7

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

adafruit_wiznet5k/adafruit_wiznet5k_dhcp.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,6 @@ def _dsm_reset(self) -> None:
197197
state machine INIT state."""
198198
debug_msg("Resetting DHCP state machine.", self._debug)
199199
self._socket_release()
200-
self._dhcp_connection_setup()
201200
self.dhcp_server_ip = _BROADCAST_SERVER_ADDR
202201
self._eth.ifconfig = (
203202
_UNASSIGNED_IP_ADDR,
@@ -366,6 +365,7 @@ def _handle_dhcp_message(self) -> int:
366365
raise ValueError(
367366
"FSM can only send messages while in SELECTING or REQUESTING states."
368367
)
368+
self._dhcp_connection_setup()
369369
message_length = self._generate_dhcp_message(message_type=msg_type_out)
370370
for attempt in range(4): # Initial attempt plus 3 retries.
371371
if self._renew:
@@ -431,15 +431,13 @@ def _dhcp_state_machine(self, *, blocking: bool = False) -> None:
431431
if self._dhcp_state == _STATE_RENEWING:
432432
debug_msg("FSM state is RENEWING.", self._debug)
433433
self._renew = "renew"
434-
self._dhcp_connection_setup()
435434
self._start_time = time.monotonic()
436435
self._dhcp_state = _STATE_REQUESTING
437436

438437
if self._dhcp_state == _STATE_REBINDING:
439438
debug_msg("FSM state is REBINDING.", self._debug)
440439
self._renew = "rebind"
441440
self.dhcp_server_ip = _BROADCAST_SERVER_ADDR
442-
self._dhcp_connection_setup()
443441
self._start_time = time.monotonic()
444442
self._dhcp_state = _STATE_REQUESTING
445443

0 commit comments

Comments
 (0)