Skip to content

Commit 50dff34

Browse files
committed
Ethernet: fix calculation of T2 in DHCP
1 parent 2b089e6 commit 50dff34

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

libraries/Ethernet/src/Dhcp.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,14 +94,14 @@ int DhcpClass::request_DHCP_lease(){
9494
if(_dhcpLeaseTime == 0){
9595
_dhcpLeaseTime = DEFAULT_LEASE;
9696
}
97-
//calculate T1 & T2 if we didn't get it
97+
// Calculate T1 & T2 if we didn't get it
9898
if(_dhcpT1 == 0){
99-
//T1 should be 50% of _dhcpLeaseTime
99+
// T1 should be 50% of _dhcpLeaseTime
100100
_dhcpT1 = _dhcpLeaseTime >> 1;
101101
}
102102
if(_dhcpT2 == 0){
103-
//T2 should be 87.5% (7/8ths) of _dhcpLeaseTime
104-
_dhcpT2 = _dhcpT1 << 1;
103+
// T2 should be 87.5% (7/8ths) of _dhcpLeaseTime
104+
_dhcpT2 = _dhcpLeaseTime - (_dhcpLeaseTime >> 3);
105105
}
106106
_renewInSec = _dhcpT1;
107107
_rebindInSec = _dhcpT2;

0 commit comments

Comments
 (0)