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
70d0d464
Commit
70d0d464
authored
Dec 19, 2017
by
copercini
Committed by
Me No Dev
Dec 19, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Enable static IP via ethernet (#924)
parent
cfbb7300
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
16 deletions
+31
-16
libraries/WiFi/src/ETH.cpp
libraries/WiFi/src/ETH.cpp
+30
-14
libraries/WiFi/src/ETH.h
libraries/WiFi/src/ETH.h
+1
-2
No files found.
libraries/WiFi/src/ETH.cpp
View file @
70d0d464
/*
ETH.h - espre ETH PHY support.
Based on WiFi.h from Ard
io
no WiFi shield library.
Based on WiFi.h from Ard
ui
no WiFi shield library.
Copyright (c) 2011-2014 Arduino. All right reserved.
This library is free software; you can redistribute it and/or
...
...
@@ -110,26 +110,43 @@ bool ETHClass::begin(uint8_t phy_addr, int power, int mdc, int mdio, eth_phy_typ
return
false
;
}
/*
bool
ETHClass
::
config
(
IPAddress
local_ip
,
IPAddress
gateway
,
IPAddress
subnet
,
IPAddress
dns1
,
IPAddress
dns2
)
{
if(!initialized){
esp_err_t
err
=
ESP_OK
;
tcpip_adapter_ip_info_t
info
;
if
(
local_ip
!=
(
uint32_t
)
0x00000000
){
info
.
ip
.
addr
=
static_cast
<
uint32_t
>
(
local_ip
);
info
.
gw
.
addr
=
static_cast
<
uint32_t
>
(
gateway
);
info
.
netmask
.
addr
=
static_cast
<
uint32_t
>
(
subnet
);
}
else
{
info
.
ip
.
addr
=
0
;
info
.
gw
.
addr
=
0
;
info
.
netmask
.
addr
=
0
;
}
err
=
tcpip_adapter_dhcpc_stop
(
TCPIP_ADAPTER_IF_ETH
);
if
(
err
!=
ESP_OK
&&
err
!=
ESP_ERR_TCPIP_ADAPTER_DHCP_ALREADY_STOPPED
){
log_e
(
"DHCP could not be stopped! Error: %d"
,
err
);
return
false
;
}
tcpip_adapter_ip_info_t info;
info.ip.addr = static_cast<uint32_t>(local_ip);
info.gw.addr = static_cast<uint32_t>(gateway);
info.netmask.addr = static_cast<uint32_t>(subnet);
if(!staticIP){
tcpip_adapter_dhcpc_stop(TCPIP_ADAPTER_IF_ETH);
}
if(tcpip_adapter_set_ip_info(TCPIP_ADAPTER_IF_ETH, &info) == ESP_OK) {
err
=
tcpip_adapter_set_ip_info
(
TCPIP_ADAPTER_IF_ETH
,
&
info
);
if
(
err
!=
ERR_OK
){
log_e
(
"STA IP could not be configured! Error: %d"
,
err
);
return
false
;
}
if
(
info
.
ip
.
addr
){
staticIP
=
true
;
}
else
{
return false;
err
=
tcpip_adapter_dhcpc_start
(
TCPIP_ADAPTER_IF_ETH
);
if
(
err
!=
ESP_OK
&&
err
!=
ESP_ERR_TCPIP_ADAPTER_DHCP_ALREADY_STARTED
){
log_w
(
"DHCP could not be started! Error: %d"
,
err
);
return
false
;
}
staticIP
=
false
;
}
ip_addr_t
d
;
d
.
type
=
IPADDR_TYPE_V4
;
...
...
@@ -147,7 +164,6 @@ bool ETHClass::config(IPAddress local_ip, IPAddress gateway, IPAddress subnet, I
return
true
;
}
*/
IPAddress
ETHClass
::
localIP
()
{
...
...
libraries/WiFi/src/ETH.h
View file @
70d0d464
...
...
@@ -62,8 +62,7 @@ class ETHClass {
bool
begin
(
uint8_t
phy_addr
=
ETH_PHY_ADDR
,
int
power
=
ETH_PHY_POWER
,
int
mdc
=
ETH_PHY_MDC
,
int
mdio
=
ETH_PHY_MDIO
,
eth_phy_type_t
type
=
ETH_PHY_TYPE
,
eth_clock_mode_t
clk_mode
=
ETH_CLK_MODE
);
// NOT WORKING YET!
//bool config(IPAddress local_ip, IPAddress gateway, IPAddress subnet, IPAddress dns1 = (uint32_t)0x00000000, IPAddress dns2 = (uint32_t)0x00000000);
bool
config
(
IPAddress
local_ip
,
IPAddress
gateway
,
IPAddress
subnet
,
IPAddress
dns1
=
(
uint32_t
)
0x00000000
,
IPAddress
dns2
=
(
uint32_t
)
0x00000000
);
const
char
*
getHostname
();
bool
setHostname
(
const
char
*
hostname
);
...
...
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