@@ -1010,6 +1010,18 @@ bool ETHClass::fullDuplex() const {
10101010 return (link_duplex == ETH_DUPLEX_FULL);
10111011}
10121012
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+
10131025bool ETHClass::autoNegotiation () const {
10141026 if (_eth_handle == NULL ) {
10151027 return false ;
@@ -1019,6 +1031,17 @@ bool ETHClass::autoNegotiation() const {
10191031 return auto_nego;
10201032}
10211033
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+
10221045uint32_t ETHClass::phyAddr () const {
10231046 if (_eth_handle == NULL ) {
10241047 return 0 ;
@@ -1028,7 +1051,7 @@ uint32_t ETHClass::phyAddr() const {
10281051 return phy_addr;
10291052}
10301053
1031- uint8_t ETHClass::linkSpeed () const {
1054+ uint16_t ETHClass::linkSpeed () const {
10321055 if (_eth_handle == NULL ) {
10331056 return 0 ;
10341057 }
@@ -1037,6 +1060,18 @@ uint8_t ETHClass::linkSpeed() const {
10371060 return (link_speed == ETH_SPEED_10M) ? 10 : 100 ;
10381061}
10391062
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+
10401075// void ETHClass::getMac(uint8_t* mac)
10411076// {
10421077// if(_eth_handle != NULL && mac != NULL){
0 commit comments