adafruit / Adafruit_CircuitPython_Wiznet5k

Pure-Python interface for WIZNET 5k Ethernet modules
Other
15 stars 37 forks source link

`maintain_dhcp_lease()` Always triggers lease renewal #168

Closed Jahor closed 3 months ago

Jahor commented 4 months ago

Calling maintain_dhcp_lease() always starts renew process (before lease has expired).

In DHCP implementation Lease time, T1 and T2 used as if they are in milliseconds (with ticks_add and _start_ticks, which is in ms), but DHCP defines them in seconds, so they must be multiplied by 1000 when read from packet (lines 628, 634, 636).

On a side note, it looks rather confusing when _lease, _t1, _t2 are used both to store time period and time instant. It saves a few bytes, but does not help readability.

FoamyGuy commented 4 months ago

Thanks for reporting this issue. Are you interested / willing to make a PR with the fix?