Skip to content

Commit f8be05e

Browse files
committed
add phy_address check
1 parent 49f7862 commit f8be05e

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

Diff for: libraries/Ethernet/src/ETH.cpp

+8
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,10 @@ bool ETHClass::begin(eth_phy_type_t type, int32_t phy_addr, int mdc, int mdio, i
8888
if(_esp_netif != NULL){
8989
return true;
9090
}
91+
if(phy_addr < ETH_PHY_ADDR_AUTO){
92+
log_e("Invalid PHY address: %d, set to ETH_PHY_ADDR_AUTO for auto detection", phy_addr);
93+
return false;
94+
}
9195
perimanSetBusDeinit(ESP32_BUS_TYPE_ETHERNET_RMII, ETHClass::ethDetachBus);
9296
perimanSetBusDeinit(ESP32_BUS_TYPE_ETHERNET_CLK, ETHClass::ethDetachBus);
9397
perimanSetBusDeinit(ESP32_BUS_TYPE_ETHERNET_MCD, ETHClass::ethDetachBus);
@@ -360,6 +364,10 @@ bool ETHClass::beginSPI(eth_phy_type_t type, int32_t phy_addr, int cs, int irq,
360364
#endif
361365
return false;
362366
}
367+
if(phy_addr < ETH_PHY_ADDR_AUTO){
368+
log_e("Invalid PHY address: %d, set to ETH_PHY_ADDR_AUTO for auto detection", phy_addr);
369+
return false;
370+
}
363371

364372
perimanSetBusDeinit(ESP32_BUS_TYPE_ETHERNET_SPI, ETHClass::ethDetachBus);
365373

0 commit comments

Comments
 (0)