Skip to content

Commit 06a0982

Browse files
authored
Merge branch 'master' into release/v3.3.x
2 parents 782892e + e8a243c commit 06a0982

File tree

18 files changed

+144
-41
lines changed

18 files changed

+144
-41
lines changed

libraries/Ethernet/src/ETH.cpp

Lines changed: 47 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -271,8 +271,8 @@ bool ETHClass::begin(eth_phy_type_t type, int32_t phy_addr, int mdc, int mdio, i
271271
eth_mac_config.sw_reset_timeout_ms = 1000;
272272
eth_mac_config.rx_task_stack_size = _task_stack_size;
273273

274-
esp_eth_mac_t *mac = esp_eth_mac_new_esp32(&mac_config, &eth_mac_config);
275-
if (mac == NULL) {
274+
_mac = esp_eth_mac_new_esp32(&mac_config, &eth_mac_config);
275+
if (_mac == NULL) {
276276
log_e("esp_eth_mac_new_esp32 failed");
277277
return false;
278278
}
@@ -281,26 +281,25 @@ bool ETHClass::begin(eth_phy_type_t type, int32_t phy_addr, int mdc, int mdio, i
281281
phy_config.phy_addr = phy_addr;
282282
phy_config.reset_gpio_num = _pin_power;
283283

284-
esp_eth_phy_t *phy = NULL;
285284
switch (type) {
286285
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 4, 0)
287-
case ETH_PHY_GENERIC: phy = esp_eth_phy_new_generic(&phy_config); break;
286+
case ETH_PHY_GENERIC: _phy = esp_eth_phy_new_generic(&phy_config); break;
288287
#endif
289-
case ETH_PHY_LAN8720: phy = esp_eth_phy_new_lan87xx(&phy_config); break;
290-
case ETH_PHY_TLK110: phy = esp_eth_phy_new_ip101(&phy_config); break;
291-
case ETH_PHY_RTL8201: phy = esp_eth_phy_new_rtl8201(&phy_config); break;
292-
case ETH_PHY_DP83848: phy = esp_eth_phy_new_dp83848(&phy_config); break;
293-
case ETH_PHY_KSZ8041: phy = esp_eth_phy_new_ksz80xx(&phy_config); break;
294-
case ETH_PHY_KSZ8081: phy = esp_eth_phy_new_ksz80xx(&phy_config); break;
288+
case ETH_PHY_LAN8720: _phy = esp_eth_phy_new_lan87xx(&phy_config); break;
289+
case ETH_PHY_TLK110: _phy = esp_eth_phy_new_ip101(&phy_config); break;
290+
case ETH_PHY_RTL8201: _phy = esp_eth_phy_new_rtl8201(&phy_config); break;
291+
case ETH_PHY_DP83848: _phy = esp_eth_phy_new_dp83848(&phy_config); break;
292+
case ETH_PHY_KSZ8041: _phy = esp_eth_phy_new_ksz80xx(&phy_config); break;
293+
case ETH_PHY_KSZ8081: _phy = esp_eth_phy_new_ksz80xx(&phy_config); break;
295294
default: log_e("Unsupported PHY %d", type); break;
296295
}
297-
if (phy == NULL) {
296+
if (_phy == NULL) {
298297
log_e("esp_eth_phy_new failed");
299298
return false;
300299
}
301300

302301
_eth_handle = NULL;
303-
esp_eth_config_t eth_config = ETH_DEFAULT_CONFIG(mac, phy);
302+
esp_eth_config_t eth_config = ETH_DEFAULT_CONFIG(_mac, _phy);
304303
ret = esp_eth_driver_install(&eth_config, &_eth_handle);
305304
if (ret != ESP_OK) {
306305
log_e("Ethernet driver install failed: %d", ret);
@@ -1010,6 +1009,18 @@ bool ETHClass::fullDuplex() const {
10101009
return (link_duplex == ETH_DUPLEX_FULL);
10111010
}
10121011

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+
10131024
bool ETHClass::autoNegotiation() const {
10141025
if (_eth_handle == NULL) {
10151026
return false;
@@ -1019,6 +1030,17 @@ bool ETHClass::autoNegotiation() const {
10191030
return auto_nego;
10201031
}
10211032

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+
10221044
uint32_t ETHClass::phyAddr() const {
10231045
if (_eth_handle == NULL) {
10241046
return 0;
@@ -1028,7 +1050,7 @@ uint32_t ETHClass::phyAddr() const {
10281050
return phy_addr;
10291051
}
10301052

1031-
uint8_t ETHClass::linkSpeed() const {
1053+
uint16_t ETHClass::linkSpeed() const {
10321054
if (_eth_handle == NULL) {
10331055
return 0;
10341056
}
@@ -1037,6 +1059,18 @@ uint8_t ETHClass::linkSpeed() const {
10371059
return (link_speed == ETH_SPEED_10M) ? 10 : 100;
10381060
}
10391061

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+
10401074
// void ETHClass::getMac(uint8_t* mac)
10411075
// {
10421076
// if(_eth_handle != NULL && mac != NULL){

libraries/Ethernet/src/ETH.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,14 @@ class ETHClass : public NetworkInterface {
192192

193193
// ETH Handle APIs
194194
bool fullDuplex() const;
195-
uint8_t linkSpeed() const;
195+
bool setFullDuplex(bool on);
196+
197+
uint16_t linkSpeed() const;
198+
bool setLinkSpeed(uint16_t speed); //10 or 100
199+
196200
bool autoNegotiation() const;
201+
bool setAutoNegotiation(bool on);
202+
197203
uint32_t phyAddr() const;
198204

199205
esp_eth_handle_t handle() const;

libraries/Matter/examples/MatterColorLight/MatterColorLight.ino

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@ bool setLightState(bool state, espHsvColor_t colorHSV) {
6060
analogWrite(ledPin, colorHSV.v);
6161
#endif
6262
} else {
63+
#ifndef RGB_BUILTIN
64+
// after analogWrite(), it is necessary to set the GPIO to digital mode first
65+
pinMode(ledPin, OUTPUT);
66+
#endif
6367
digitalWrite(ledPin, LOW);
6468
}
6569
// store last HSV Color and OnOff state for when the Light is restarted / power goes off

libraries/Matter/examples/MatterDimmableLight/MatterDimmableLight.ino

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ bool setLightState(bool state, uint8_t brightness) {
5656
analogWrite(ledPin, brightness);
5757
#endif
5858
} else {
59+
#ifndef RGB_BUILTIN
60+
// after analogWrite(), it is necessary to set the GPIO to digital mode first
61+
pinMode(ledPin, OUTPUT);
62+
#endif
5963
digitalWrite(ledPin, LOW);
6064
}
6165
// store last Brightness and OnOff state for when the Light is restarted / power goes off

libraries/Matter/examples/MatterEnhancedColorLight/MatterEnhancedColorLight.ino

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ bool setLightState(bool state, espHsvColor_t colorHSV, uint8_t brighteness, uint
6464
analogWrite(ledPin, colorHSV.v);
6565
#endif
6666
} else {
67+
#ifndef RGB_BUILTIN
68+
// after analogWrite(), it is necessary to set the GPIO to digital mode first
69+
pinMode(ledPin, OUTPUT);
70+
#endif
6771
digitalWrite(ledPin, LOW);
6872
}
6973
// store last HSV Color and OnOff state for when the Light is restarted / power goes off

libraries/Matter/examples/MatterFan/MatterFan.ino

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ void fanDCMotorDrive(bool fanState, uint8_t speedPercent) {
4949
// drive the Fan DC motor
5050
if (fanState == false) {
5151
// turn off the Fan
52+
#ifndef RGB_BUILTIN
53+
// after analogWrite(), it is necessary to set the GPIO to digital mode first
54+
pinMode(dcMotorPin, OUTPUT);
55+
#endif
5256
digitalWrite(dcMotorPin, LOW);
5357
} else {
5458
// set the Fan speed

libraries/Matter/examples/MatterTemperatureLight/MatterTemperatureLight.ino

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ bool setLightState(bool state, uint8_t brightness, uint16_t temperature_Mireds)
6666
analogWrite(ledPin, brightness);
6767
#endif
6868
} else {
69+
#ifndef RGB_BUILTIN
70+
// after analogWrite(), it is necessary to set the GPIO to digital mode first
71+
pinMode(ledPin, OUTPUT);
72+
#endif
6973
digitalWrite(ledPin, LOW);
7074
}
7175
// store last Brightness and OnOff state for when the Light is restarted / power goes off

libraries/Matter/src/MatterEndpoints/MatterColorLight.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ class MatterColorLight : public MatterEndPoint {
6666

6767
protected:
6868
bool started = false;
69-
bool onOffState = false; // default initial state is off, but it can be changed by begin(bool)
70-
espHsvColor_t colorHSV = {0}; // default initial color HSV is black, but it can be changed by begin(bool, espHsvColor_t)
69+
bool onOffState = false; // default initial state is off, but it can be changed by begin(bool)
70+
espHsvColor_t colorHSV = {0, 0, 0}; // default initial color HSV is black, but it can be changed by begin(bool, espHsvColor_t)
7171
EndPointOnOffCB _onChangeOnOffCB = NULL;
7272
EndPointRGBColorCB _onChangeColorCB = NULL;
7373
EndPointCB _onChangeCB = NULL;

libraries/Matter/src/MatterEndpoints/MatterEnhancedColorLight.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ class MatterEnhancedColorLight : public MatterEndPoint {
9191
bool started = false;
9292
bool onOffState = false; // default initial state is off, but it can be changed by begin(bool)
9393
uint8_t brightnessLevel = 0; // default initial brightness is 0, but it can be changed by begin(bool, uint8_t)
94-
espHsvColor_t colorHSV = {0}; // default initial color HSV is black, but it can be changed by begin(bool, uint8_t, espHsvColor_t)
94+
espHsvColor_t colorHSV = {0, 0, 0}; // default initial color HSV is black, but it can be changed by begin(bool, uint8_t, espHsvColor_t)
9595
uint16_t colorTemperatureLevel = 0; // default initial color temperature is 0, but it can be changed by begin(bool, uint8_t, espHsvColor_t, uint16_t)
9696
EndPointOnOffCB _onChangeOnOffCB = NULL;
9797
EndPointBrightnessCB _onChangeBrightnessCB = NULL;

libraries/Network/src/NetworkClient.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@
2323
#include <lwip/netdb.h>
2424
#include <errno.h>
2525

26-
#define IN6_IS_ADDR_V4MAPPED(a) ((((__const uint32_t *)(a))[0] == 0) && (((__const uint32_t *)(a))[1] == 0) && (((__const uint32_t *)(a))[2] == htonl(0xffff)))
26+
// It is already defined in IDF as:
27+
//#define IN6_IS_ADDR_V4MAPPED(a) ip6_addr_isipv4mappedipv6((ip6_addr_t*)(a))
28+
//#define ip6_addr_isipv4mappedipv6(ip6addr) (((ip6addr)->addr[0] == 0) && ((ip6addr)->addr[1] == 0) && (((ip6addr)->addr[2]) == PP_HTONL(0x0000FFFFUL)))
29+
// Keeping as a memory of the change.
30+
//#define _IN6_IS_ADDR_V4MAPPED(a) ((((__const uint32_t *)(a))[0] == 0) && (((__const uint32_t *)(a))[1] == 0) && (((__const uint32_t *)(a))[2] == htonl(0xffff)))
2731

2832
#define WIFI_CLIENT_DEF_CONN_TIMEOUT_MS (3000)
2933
#define WIFI_CLIENT_MAX_WRITE_RETRY (10)

0 commit comments

Comments
 (0)