@@ -1009,6 +1009,18 @@ bool ETHClass::fullDuplex() const {
1009
1009
return (link_duplex == ETH_DUPLEX_FULL);
1010
1010
}
1011
1011
1012
+ bool ETHClass::setFullDuplex (bool on) {
1013
+ if (_eth_handle == NULL ) {
1014
+ return false ;
1015
+ }
1016
+ eth_duplex_t link_duplex = on ? ETH_DUPLEX_FULL : ETH_DUPLEX_HALF;
1017
+ esp_err_t err = esp_eth_ioctl (_eth_handle, ETH_CMD_S_DUPLEX_MODE, &link_duplex);
1018
+ if (err != ESP_OK) {
1019
+ log_e (" Failed to set duplex mode: 0x%x: %s" , err, esp_err_to_name (err));
1020
+ }
1021
+ return err == ESP_OK;
1022
+ }
1023
+
1012
1024
bool ETHClass::autoNegotiation () const {
1013
1025
if (_eth_handle == NULL ) {
1014
1026
return false ;
@@ -1018,6 +1030,17 @@ bool ETHClass::autoNegotiation() const {
1018
1030
return auto_nego;
1019
1031
}
1020
1032
1033
+ bool ETHClass::setAutoNegotiation (bool on) {
1034
+ if (_eth_handle == NULL ) {
1035
+ return false ;
1036
+ }
1037
+ esp_err_t err = esp_eth_ioctl (_eth_handle, ETH_CMD_S_AUTONEGO, &on);
1038
+ if (err != ESP_OK) {
1039
+ log_e (" Failed to set auto negotiation: 0x%x: %s" , err, esp_err_to_name (err));
1040
+ }
1041
+ return err == ESP_OK;
1042
+ }
1043
+
1021
1044
uint32_t ETHClass::phyAddr () const {
1022
1045
if (_eth_handle == NULL ) {
1023
1046
return 0 ;
@@ -1027,7 +1050,7 @@ uint32_t ETHClass::phyAddr() const {
1027
1050
return phy_addr;
1028
1051
}
1029
1052
1030
- uint8_t ETHClass::linkSpeed () const {
1053
+ uint16_t ETHClass::linkSpeed () const {
1031
1054
if (_eth_handle == NULL ) {
1032
1055
return 0 ;
1033
1056
}
@@ -1036,6 +1059,18 @@ uint8_t ETHClass::linkSpeed() const {
1036
1059
return (link_speed == ETH_SPEED_10M) ? 10 : 100 ;
1037
1060
}
1038
1061
1062
+ bool ETHClass::setLinkSpeed (uint16_t speed) {
1063
+ if (_eth_handle == NULL ) {
1064
+ return false ;
1065
+ }
1066
+ eth_speed_t link_speed = (speed == 10 ) ? ETH_SPEED_10M : ETH_SPEED_100M;
1067
+ esp_err_t err = esp_eth_ioctl (_eth_handle, ETH_CMD_S_SPEED, &link_speed);
1068
+ if (err != ESP_OK) {
1069
+ log_e (" Failed to set link speed: 0x%x: %s" , err, esp_err_to_name (err));
1070
+ }
1071
+ return err == ESP_OK;
1072
+ }
1073
+
1039
1074
// void ETHClass::getMac(uint8_t* mac)
1040
1075
// {
1041
1076
// if(_eth_handle != NULL && mac != NULL){
0 commit comments