Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
arduino-esp32
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
arduino-esp32
Commits
e4a57854
Unverified
Commit
e4a57854
authored
Apr 02, 2024
by
Me No Dev
Committed by
GitHub
Apr 02, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ensure that Static IP configuration for network interfaces is kept until STOP (#9445)
parent
3c1885f8
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
10 additions
and
12 deletions
+10
-12
libraries/Ethernet/src/ETH.cpp
libraries/Ethernet/src/ETH.cpp
+1
-1
libraries/Network/src/NetworkInterface.cpp
libraries/Network/src/NetworkInterface.cpp
+3
-3
libraries/Network/src/NetworkInterface.h
libraries/Network/src/NetworkInterface.h
+1
-0
libraries/WiFi/src/STA.cpp
libraries/WiFi/src/STA.cpp
+3
-3
libraries/WiFi/src/WiFiSTA.cpp
libraries/WiFi/src/WiFiSTA.cpp
+2
-5
No files found.
libraries/Ethernet/src/ETH.cpp
View file @
e4a57854
...
@@ -107,7 +107,7 @@ void ETHClass::_onEthEvent(int32_t event_id, void* event_data){
...
@@ -107,7 +107,7 @@ void ETHClass::_onEthEvent(int32_t event_id, void* event_data){
}
else
if
(
event_id
==
ETHERNET_EVENT_STOP
)
{
}
else
if
(
event_id
==
ETHERNET_EVENT_STOP
)
{
log_v
(
"%s Stopped"
,
desc
());
log_v
(
"%s Stopped"
,
desc
());
arduino_event
.
event_id
=
ARDUINO_EVENT_ETH_STOP
;
arduino_event
.
event_id
=
ARDUINO_EVENT_ETH_STOP
;
clearStatusBits
(
ESP_NETIF_STARTED_BIT
|
ESP_NETIF_CONNECTED_BIT
|
ESP_NETIF_HAS_IP_BIT
|
ESP_NETIF_HAS_LOCAL_IP6_BIT
|
ESP_NETIF_HAS_GLOBAL_IP6_BIT
);
clearStatusBits
(
ESP_NETIF_STARTED_BIT
|
ESP_NETIF_CONNECTED_BIT
|
ESP_NETIF_HAS_IP_BIT
|
ESP_NETIF_HAS_LOCAL_IP6_BIT
|
ESP_NETIF_HAS_GLOBAL_IP6_BIT
|
ESP_NETIF_HAS_STATIC_IP_BIT
);
}
}
if
(
arduino_event
.
event_id
<
ARDUINO_EVENT_MAX
){
if
(
arduino_event
.
event_id
<
ARDUINO_EVENT_MAX
){
...
...
libraries/Network/src/NetworkInterface.cpp
View file @
e4a57854
...
@@ -281,7 +281,7 @@ bool NetworkInterface::connected() const {
...
@@ -281,7 +281,7 @@ bool NetworkInterface::connected() const {
}
}
bool
NetworkInterface
::
hasIP
()
const
{
bool
NetworkInterface
::
hasIP
()
const
{
return
(
getStatusBits
()
&
ESP_NETIF_HAS_IP_BIT
)
!=
0
;
return
(
getStatusBits
()
&
(
ESP_NETIF_HAS_IP_BIT
|
ESP_NETIF_HAS_STATIC_IP_BIT
)
)
!=
0
;
}
}
bool
NetworkInterface
::
hasLinkLocalIPv6
()
const
{
bool
NetworkInterface
::
hasLinkLocalIPv6
()
const
{
...
@@ -451,7 +451,7 @@ bool NetworkInterface::config(IPAddress local_ip, IPAddress gateway, IPAddress s
...
@@ -451,7 +451,7 @@ bool NetworkInterface::config(IPAddress local_ip, IPAddress gateway, IPAddress s
return
false
;
return
false
;
}
}
clearStatusBits
(
ESP_NETIF_HAS_IP_BIT
);
clearStatusBits
(
ESP_NETIF_HAS_IP_BIT
|
ESP_NETIF_HAS_STATIC_IP_BIT
);
// Set IPv4, Netmask, Gateway
// Set IPv4, Netmask, Gateway
err
=
esp_netif_set_ip_info
(
_esp_netif
,
&
info
);
err
=
esp_netif_set_ip_info
(
_esp_netif
,
&
info
);
...
@@ -473,7 +473,7 @@ bool NetworkInterface::config(IPAddress local_ip, IPAddress gateway, IPAddress s
...
@@ -473,7 +473,7 @@ bool NetworkInterface::config(IPAddress local_ip, IPAddress gateway, IPAddress s
return
false
;
return
false
;
}
}
}
else
{
}
else
{
setStatusBits
(
ESP_NETIF_HAS_IP_BIT
);
setStatusBits
(
ESP_NETIF_HAS_
STATIC_
IP_BIT
);
}
}
}
}
...
...
libraries/Network/src/NetworkInterface.h
View file @
e4a57854
...
@@ -27,6 +27,7 @@ static const int ESP_NETIF_HAS_IP_BIT = BIT2;
...
@@ -27,6 +27,7 @@ static const int ESP_NETIF_HAS_IP_BIT = BIT2;
static
const
int
ESP_NETIF_HAS_LOCAL_IP6_BIT
=
BIT3
;
static
const
int
ESP_NETIF_HAS_LOCAL_IP6_BIT
=
BIT3
;
static
const
int
ESP_NETIF_HAS_GLOBAL_IP6_BIT
=
BIT4
;
static
const
int
ESP_NETIF_HAS_GLOBAL_IP6_BIT
=
BIT4
;
static
const
int
ESP_NETIF_WANT_IP6_BIT
=
BIT5
;
static
const
int
ESP_NETIF_WANT_IP6_BIT
=
BIT5
;
static
const
int
ESP_NETIF_HAS_STATIC_IP_BIT
=
BIT6
;
#define ESP_NETIF_ID_ETH ESP_NETIF_ID_ETH0
#define ESP_NETIF_ID_ETH ESP_NETIF_ID_ETH0
...
...
libraries/WiFi/src/STA.cpp
View file @
e4a57854
...
@@ -213,7 +213,7 @@ void STAClass::_onStaEvent(int32_t event_id, void* event_data){
...
@@ -213,7 +213,7 @@ void STAClass::_onStaEvent(int32_t event_id, void* event_data){
}
else
if
(
event_id
==
WIFI_EVENT_STA_STOP
)
{
}
else
if
(
event_id
==
WIFI_EVENT_STA_STOP
)
{
log_v
(
"STA Stopped"
);
log_v
(
"STA Stopped"
);
arduino_event
.
event_id
=
ARDUINO_EVENT_WIFI_STA_STOP
;
arduino_event
.
event_id
=
ARDUINO_EVENT_WIFI_STA_STOP
;
clearStatusBits
(
ESP_NETIF_STARTED_BIT
|
ESP_NETIF_CONNECTED_BIT
|
ESP_NETIF_HAS_IP_BIT
|
ESP_NETIF_HAS_LOCAL_IP6_BIT
|
ESP_NETIF_HAS_GLOBAL_IP6_BIT
);
clearStatusBits
(
ESP_NETIF_STARTED_BIT
|
ESP_NETIF_CONNECTED_BIT
|
ESP_NETIF_HAS_IP_BIT
|
ESP_NETIF_HAS_LOCAL_IP6_BIT
|
ESP_NETIF_HAS_GLOBAL_IP6_BIT
|
ESP_NETIF_HAS_STATIC_IP_BIT
);
}
else
if
(
event_id
==
WIFI_EVENT_STA_AUTHMODE_CHANGE
)
{
}
else
if
(
event_id
==
WIFI_EVENT_STA_AUTHMODE_CHANGE
)
{
#if ARDUHAL_LOG_LEVEL >= ARDUHAL_LOG_LEVEL_VERBOSE
#if ARDUHAL_LOG_LEVEL >= ARDUHAL_LOG_LEVEL_VERBOSE
wifi_event_sta_authmode_change_t
*
event
=
(
wifi_event_sta_authmode_change_t
*
)
event_data
;
wifi_event_sta_authmode_change_t
*
event
=
(
wifi_event_sta_authmode_change_t
*
)
event_data
;
...
@@ -355,7 +355,7 @@ bool STAClass::connect(){
...
@@ -355,7 +355,7 @@ bool STAClass::connect(){
return
false
;
return
false
;
}
}
if
((
getStatusBits
()
&
ESP_NETIF_HAS_IP_BIT
)
==
0
&&
!
config
()){
if
((
getStatusBits
()
&
ESP_NETIF_HAS_
STATIC_
IP_BIT
)
==
0
&&
!
config
()){
log_e
(
"STA failed to configure dynamic IP!"
);
log_e
(
"STA failed to configure dynamic IP!"
);
return
false
;
return
false
;
}
}
...
@@ -426,7 +426,7 @@ bool STAClass::connect(const char* ssid, const char *passphrase, int32_t channel
...
@@ -426,7 +426,7 @@ bool STAClass::connect(const char* ssid, const char *passphrase, int32_t channel
return
false
;
return
false
;
}
}
if
((
getStatusBits
()
&
ESP_NETIF_HAS_IP_BIT
)
==
0
&&
!
config
()){
if
((
getStatusBits
()
&
ESP_NETIF_HAS_
STATIC_
IP_BIT
)
==
0
&&
!
config
()){
log_e
(
"STA failed to configure dynamic IP!"
);
log_e
(
"STA failed to configure dynamic IP!"
);
return
false
;
return
false
;
}
}
...
...
libraries/WiFi/src/WiFiSTA.cpp
View file @
e4a57854
...
@@ -177,7 +177,7 @@ bool WiFiSTAClass::config(IPAddress local_ip, IPAddress gateway, IPAddress subne
...
@@ -177,7 +177,7 @@ bool WiFiSTAClass::config(IPAddress local_ip, IPAddress gateway, IPAddress subne
subnet
=
(
tmp
!=
INADDR_NONE
)
?
tmp
:
IPAddress
(
255
,
255
,
255
,
0
);
subnet
=
(
tmp
!=
INADDR_NONE
)
?
tmp
:
IPAddress
(
255
,
255
,
255
,
0
);
}
}
return
STA
.
config
(
local_ip
,
gateway
,
subnet
,
dns1
,
dns2
);
return
STA
.
begin
()
&&
STA
.
config
(
local_ip
,
gateway
,
subnet
,
dns1
,
dns2
);
}
}
bool
WiFiSTAClass
::
config
(
IPAddress
local_ip
,
IPAddress
dns
)
{
bool
WiFiSTAClass
::
config
(
IPAddress
local_ip
,
IPAddress
dns
)
{
...
@@ -205,10 +205,7 @@ bool WiFiSTAClass::config(IPAddress local_ip, IPAddress dns) {
...
@@ -205,10 +205,7 @@ bool WiFiSTAClass::config(IPAddress local_ip, IPAddress dns) {
*/
*/
bool
WiFiSTAClass
::
setDNS
(
IPAddress
dns1
,
IPAddress
dns2
)
bool
WiFiSTAClass
::
setDNS
(
IPAddress
dns1
,
IPAddress
dns2
)
{
{
if
(
!
STA
.
started
()){
return
STA
.
begin
()
&&
STA
.
dnsIP
(
0
,
dns1
)
&&
STA
.
dnsIP
(
1
,
dns2
);
return
false
;
}
return
STA
.
dnsIP
(
0
,
dns1
)
&&
STA
.
dnsIP
(
1
,
dns2
);
}
}
/**
/**
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment