-
-
Notifications
You must be signed in to change notification settings - Fork 204
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for DHCP hostname #921
Conversation
The compiler errors arise from the fact that a call to Ethernet.begin(nullptr) is ambiguous now: /home/runner/work/ArduinoCore-mbed/ArduinoCore-mbed/libraries/Ethernet/examples/UdpNtpClient/UdpNtpClient.ino:143:29: error: call of overloaded 'begin(std::nullptr_t)' is ambiguous
if (Ethernet.begin(nullptr) == 0) {
^
In file included from /home/runner/.arduino15/packages/arduino/hardware/mbed/3.3.0/libraries/Ethernet/src/PortentaEthernet.h:3:0,
from /home/runner/work/ArduinoCore-mbed/ArduinoCore-mbed/libraries/Ethernet/examples/UdpNtpClient/UdpNtpClient.ino:22:
/home/runner/.arduino15/packages/arduino/hardware/mbed/3.3.0/libraries/Ethernet/src/Ethernet.h:65:7: note: candidate: int arduino::EthernetClass::begin(uint8_t*, long unsigned int, long unsigned int)
int begin(uint8_t *mac = nullptr, unsigned long timeout = 60000, unsigned long responseTimeout = 4000);
^~~~~
/home/runner/.arduino15/packages/arduino/hardware/mbed/3.3.0/libraries/Ethernet/src/Ethernet.h:66:7: note: candidate: int arduino::EthernetClass::begin(const char*)
int begin(const char* hostname);
^~~~~ I suppose to make sure no code is broken the If someone has a more elegant solution please let me know. |
…t char* hostname) method.
Hi @Channel59 thank you so much for your contribution! |
Recently someone pointed me to this PR on the mbed-os repo: ARMmbed/mbed-os#15506.
The patches to make these changes are included in this pull request and so the credits for these patches full go to https://github.com/guilhermerc.
It enables the use of a hostname when DHCP is used to obtain an IP address.
Subsequently, the Ethernet.cpp and Ethernet.h are adjusted to allow the hostname to be set:
Either usingEthernet.begin("desired-hostname");
or using a somewhat more Arduino-like api:
Ethernet.setHostname("desired-hostname"); Ethernet.begin();
Before this compiles,
libmbed.a
should be recompiled on https://github.com/ARMmbed/mbed-os/tree/latest which will also patch some of the header files that are required to compile the arduino program.The code seems to work correctly with the opta. Any testing / refinements are more than welcome.
I do not have a wifi enabled device, so I cannot test it, but with these patches applied, a small change to Wifi.h and Wifi.cpp could add support for Wifi as well.