Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Ethernet and WiFi - fix DNS for static IP#918

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
facchinm merged 1 commit intoarduino:mainfromJAndrassy:net_staticip_dns_fix
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletionlibraries/Ethernet/src/Ethernet.cpp
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -55,11 +55,13 @@ int arduino::EthernetClass::begin(uint8_t *mac, IPAddress ip, IPAddress dns, IPA

eth_if->set_dhcp(false);
eth_if->set_network(_ip, _netmask, _gateway);

auto ret = _begin(mac, timeout, responseTimeout);

char if_name[5];
eth_if->get_interface_name(if_name);
eth_if->add_dns_server(_dnsServer1, if_name);

auto ret = _begin(mac, timeout, responseTimeout);
return ret;
}

Expand Down
10 changes: 6 additions & 4 deletionslibraries/WiFi/src/WiFi.cpp
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -66,16 +66,18 @@ int arduino::WiFiClass::begin(const char* ssid, const char* passphrase, wl_enc_t
wifi_if->set_dhcp(!_useStaticIP);
if (_useStaticIP) {
wifi_if->set_network(_ip, _netmask, _gateway);
char if_name[5];
wifi_if->get_interface_name(if_name);
wifi_if->add_dns_server(_dnsServer2, if_name);
wifi_if->add_dns_server(_dnsServer1, if_name); // pushes dnsServer2 at index 1
}

nsapi_error_t result = wifi_if->connect(ssid, passphrase, _security);

if(result == NSAPI_ERROR_IS_CONNECTED) {
wifi_if->disconnect();
} else
if (_useStaticIP) {
char if_name[5];
wifi_if->get_interface_name(if_name);
wifi_if->add_dns_server(_dnsServer2, if_name);
wifi_if->add_dns_server(_dnsServer1, if_name); // pushes dnsServer2 at index 1
}
_currentNetworkStatus = (result == NSAPI_ERROR_OK && setSSID(ssid)) ? WL_CONNECTED : WL_CONNECT_FAILED;

Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp