sstaub / Ethernet3

Ethernet library for Arduino and Ethernetshield2 / WIZ550io / WIZ850io / USR-ES1 with Wiznet W5500 chip
Other
76 stars 34 forks source link

Add possibility to register custom hostname at dhcp server #12

Closed smuellener closed 6 years ago

sstaub commented 6 years ago

Can you make a small example?

sstaub commented 6 years ago

The function setCustomHostname is in DHCP and in Ethernet classes. There should only one function in the Ethernet class.

smuellener commented 6 years ago

@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);

sstaub commented 6 years ago

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.

smuellener commented 6 years ago

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?

sstaub commented 6 years ago

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.

smuellener commented 6 years ago

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.

sstaub commented 6 years ago

Please retest.