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