Closed smuellener closed 6 years ago
The function setCustomHostname is in DHCP and in Ethernet classes. There should only one function in the Ethernet class.
@sstaub We can not use just one function in Ethernet class, as the hostname is used in dhcp.cpp as well. We would need to change the design of dhcp.cpp considerably. Therefore, we decided to use both functions. With this design nothing changes for any current implementation so there will be no possibility of code breakage.
Example: Use any example using dhcp and use the following two lines instead of only Ethernet.begin():
Ethernet.setCustomHostname("foo");
Ethernet.begin(mac);
The idea itself is good but we need to find a better and simpler way without doubling functions and allocating memory for the hostname twice. I will do it in the version2 of the library, planned next month.
Memory is only allocated once in Ethernet (dhcp.cpp is then using a pointer). But I agree with you. Rewriting the dhcp part can lead to a nicer solution. Do you want to do this or should we provide another solution?
If you find a better solution you are welcome. One point I found is that you allocate memory even when you don't use the setter. I'm on a large cleanup the library, so be patient.
If you are working on a cleanup, I‘d better wait. But let me know if you need some help (please do share your current status on a feature branch in that case though, so we can work in the same direction). I hope we can agree on a way to integrate the hostname (especially in the dhcp scenario). I‘m sure, others would profit as well from this.
Please retest.
Can you make a small example?