-
Hello, |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 6 replies
-
did you see the example of the W5500lwIP library? for DNS this could help #8076 |
Beta Was this translation helpful? Give feedback.
-
Do you mean "Ethernet Library" which is a driver + a library (I suppose that module = hardware) ? There are two drivers in this repository. The legacy Ethernet library (that is a submodule pointing to https://github.com/arduino-libraries/Ethernet.git) and the other one compatible with lwIP.
The two drivers are not inter-operable. It's one or the other. |
Beta Was this translation helpful? Give feedback.
-
I'm having a hard time with this.. I'm trying to see what's under, but i really can't understand why i can't call a simple WiFi.hostByName() (always error -5), but i can call directly the dns_gethostbyname() THAT IS USED BY THE FIRST! Simpler script (the problem is just dns, the udp part is not needed): #include <ESP8266WiFi.h>
#include <SPI.h>
#include <W5500lwIP.h>
#include "lwip/dns.h"
byte mac[] = {0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x02};
const char dnsHostOne[] = "google.com"; // time.nist.gov NTP server
const char dnsHostTwo[] = "google.us"; // time.nist.gov NTP server
const char dnsHostThree[] = "google.co.uk"; // time.nist.gov NTP server
Wiznet5500lwIP eth(D1);
ip_addr_t ip_Addr;
void dns_found_cb(const char *name, const ip_addr_t *ipaddr, void *callback_arg)
{
Serial.print("Name ");
Serial.println(name);
Serial.print("ip ");
Serial.println(ip4addr_ntoa(ipaddr));
}
void setup() {
WiFi.mode(WIFI_OFF);
// Open serial communications and wait for port to open:
Serial.begin(115200);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}
SPI.begin();
SPI.setBitOrder(MSBFIRST);
SPI.setDataMode(SPI_MODE0);
SPI.setFrequency(4000000);
eth.setDefault(); // use ethernet for default route
eth.setHostname("TEST"); //THIS ALWAYS FAILS
int present = eth.begin(mac);
if (!present) {
Serial.println("no ethernet hardware present");
while(1);
}
Serial.print("connecting ethernet");
while (!eth.connected()) {
Serial.print(".");
delay(100);
}
Serial.println("Connected");
}
void loop() {
Serial.println("Starting First.");
while ( dns_gethostbyname(dnsHostOne, &ip_Addr, dns_found_cb, NULL ) != ERR_OK ){
delay(1);
}
Serial.print("First over: ");
Serial.println(ip4addr_ntoa(&ip_Addr));
Serial.println("Starting Second.");
while ( dns_gethostbyname_addrtype(dnsHostTwo, &ip_Addr, dns_found_cb, NULL, LWIP_DNS_ADDRTYPE_DEFAULT ) != ERR_OK ){
delay(1);
}
Serial.print("Second over: ");
Serial.println(ip4addr_ntoa(&ip_Addr));
IPAddress tempAddress;
Serial.println("Direct lookup: ");
WiFi.hostByName(dnsHostThree, tempAddress);
Serial.println(ip4addr_ntoa(tempAddress));
delay(5000);
} Debug info (well.. all i could get) (and setting hostname is always impossible for me..)
Using platformio with upstream version of esp8266 arduino core Any hint? How can i debug this further? |
Beta Was this translation helpful? Give feedback.
-
Hello, void wifi_dns_found_callback(const char *name, const ip_addr_t *ipaddr, void *callback_arg)
{
(void) name;
if (!_dns_lookup_pending) {
return;
}
if(ipaddr) {
(*reinterpret_cast<IPAddress*>(callback_arg)) = IPAddress(ipaddr);
_dns_lookup_pending = false;
}
esp_schedule(); // break delay in hostByName
} Btw yes, thank you a lot, this solves the issue! Edit: ok, i found the PR you were referring to, it's perfect :) |
Beta Was this translation helpful? Give feedback.
Do you mean "Ethernet Library" which is a driver + a library (I suppose that module = hardware) ?
There are two drivers in this repository. The legacy Ethernet library (that is a submodule pointing to https://github.com/arduino-libraries/Ethernet.git) and the other one compatible with lwIP.
With the first, esp8266 specific network goodies are not available.
With the second, which appeared in release 3.0.0, everything works just like with the WiFi interface (dhcp, ntp, webserver, webclient, mdns, etc and of course
WiFiClient
,WiFiClientSecure
andWiFiUdp
classes). This driver-library is at early stage and some adjustments may be needed as @JAndrassy…