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-pico
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-pico
Commits
abd35477
Unverified
Commit
abd35477
authored
Dec 01, 2023
by
Juraj Andrássy
Committed by
GitHub
Dec 01, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WiFi and Ethernet - config static IP auto gw,mask,dns as in Arduino libs (#1862)
parent
9181ec05
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
6 deletions
+26
-6
libraries/WiFi/src/WiFiClass.cpp
libraries/WiFi/src/WiFiClass.cpp
+3
-6
libraries/lwIP_Ethernet/src/LwipIntfDev.h
libraries/lwIP_Ethernet/src/LwipIntfDev.h
+23
-0
No files found.
libraries/WiFi/src/WiFiClass.cpp
View file @
abd35477
...
...
@@ -193,7 +193,7 @@ bool WiFiClass::connected() {
param local_ip: Static ip configuration
*/
void
WiFiClass
::
config
(
IPAddress
local_ip
)
{
ip4_addr_set_u32
(
ip_2_ip4
(
&
_wifi
.
getNetIf
()
->
ip_addr
),
local_ip
.
v4
()
);
_wifi
.
config
(
local_ip
);
}
/* Change Ip configuration settings disabling the dhcp client
...
...
@@ -202,8 +202,7 @@ void WiFiClass::config(IPAddress local_ip) {
param dns_server: IP configuration for DNS server 1
*/
void
WiFiClass
::
config
(
IPAddress
local_ip
,
IPAddress
dns_server
)
{
ip4_addr_set_u32
(
ip_2_ip4
(
&
_wifi
.
getNetIf
()
->
ip_addr
),
local_ip
.
v4
());
dns_setserver
(
0
,
dns_server
);
_wifi
.
config
(
local_ip
,
dns_server
);
}
/* Change Ip configuration settings disabling the dhcp client
...
...
@@ -213,9 +212,7 @@ void WiFiClass::config(IPAddress local_ip, IPAddress dns_server) {
param gateway : Static gateway configuration
*/
void
WiFiClass
::
config
(
IPAddress
local_ip
,
IPAddress
dns_server
,
IPAddress
gateway
)
{
ip4_addr_set_u32
(
ip_2_ip4
(
&
_wifi
.
getNetIf
()
->
ip_addr
),
local_ip
.
v4
());
dns_setserver
(
0
,
dns_server
);
ip4_addr_set_u32
(
ip_2_ip4
(
&
_wifi
.
getNetIf
()
->
gw
),
gateway
.
v4
());
_wifi
.
config
(
local_ip
,
dns_server
,
gateway
);
}
/* Change Ip configuration settings disabling the dhcp client
...
...
libraries/lwIP_Ethernet/src/LwipIntfDev.h
View file @
abd35477
...
...
@@ -61,9 +61,14 @@ public:
memset
(
&
_netif
,
0
,
sizeof
(
_netif
));
}
//The argument order for ESP is not the same as for Arduino. However, there is compatibility code under the hood
//to detect Arduino arg order, and handle it correctly.
bool
config
(
const
IPAddress
&
local_ip
,
const
IPAddress
&
arg1
,
const
IPAddress
&
arg2
,
const
IPAddress
&
arg3
=
IPADDR_NONE
,
const
IPAddress
&
dns2
=
IPADDR_NONE
);
// two and one parameter version. 2nd parameter is DNS like in Arduino. IPv4 only
boolean
config
(
IPAddress
local_ip
,
IPAddress
dns
=
IPADDR_NONE
);
// default mac-address is inferred from esp8266's STA interface
bool
begin
(
const
uint8_t
*
macAddress
=
nullptr
,
const
uint16_t
mtu
=
DEFAULT_MTU
);
...
...
@@ -264,6 +269,24 @@ bool LwipIntfDev<RawDev>::config(const IPAddress& localIP, const IPAddress& gate
}
return
true
;
}
template
<
class
RawDev
>
boolean
LwipIntfDev
<
RawDev
>::
config
(
IPAddress
local_ip
,
IPAddress
dns
)
{
if
(
!
local_ip
.
isSet
())
{
return
config
(
INADDR_ANY
,
INADDR_ANY
,
INADDR_ANY
);
}
if
(
!
local_ip
.
isV4
())
{
return
false
;
}
IPAddress
gw
(
local_ip
);
gw
[
3
]
=
1
;
if
(
!
dns
.
isSet
())
{
dns
=
gw
;
}
return
config
(
local_ip
,
gw
,
IPAddress
(
255
,
255
,
255
,
0
),
dns
);
}
extern
char
wifi_station_hostname
[];
template
<
class
RawDev
>
bool
LwipIntfDev
<
RawDev
>::
begin
(
const
uint8_t
*
macAddress
,
const
uint16_t
mtu
)
{
...
...
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