network: wiznet: zeroconf
Checks
-
I agree to follow the MicroPython Code of Conduct to ensure a safe and respectful space for everyone.
-
I've searched for existing issues regarding this feature, and didn't find any.
Description
Working with boards with a wiznet ethernet interface, sometimes there isn't a DHCP server.
So, in this scenario, the interface is unusable.
It is easy to develop a zeroconf
implementation to auto assign a IP address without DHCP server.
Zeroconf checks if an IP address is in use (by other network peers) doing ARP requests.
Problem: the class WIZNET5K has the method send_ethernet but not a read_ethernet
I have written, pure python, two function:
arp_probe : about 40 lines
zeroconf : 13 lines
At the moment I can send ARP probes but not check the peers replies... so my zeroconf return a (random) IP address that theoretically can collide with other peers.
Are there other boards with a Ethernet interface that could benefit of zeroconf ?
Class WIZNET5K: if I wtore a PR to add read_ethernet, will the maintainers accept it ?
Code Size
I see in [network_wiznet5k.c(https://github.com/micropython/micropython/blob/30a9ccf4caa72c62cb8656a1572518fef34b08a4/extmod/network_wiznet5k.c#L248)
there are the two functions:
- wiznet5k_send_ethernet
- wiznet5k_recv_ethernet
wiznet5k_send_ethernet is already available to Python, see https://github.com/micropython/micropython/issues/15169
I think adding a wrapper also for wiznet5k_recv_ethernet will take few bytes.
Implementation
- I intend to implement this feature and would submit a Pull Request if desirable.
- I hope the MicroPython maintainers or community will implement this feature.
- I would like to Sponsor development of this feature.
network.WIZNET5 : link status; isconnected(): the documentation is incorrect?
Checks
-
I agree to follow the MicroPython Code of Conduct to ensure a safe and respectful space for everyone.
-
I've searched for existing issues regarding this feature, and didn't find any.
Description
On a W5500_EVB_PICO, I see these symbols:
import network
dir(network)
['__class__', '__name__', 'AP_IF', 'STA_IF', 'WIZNET5K', '__dict__', 'country', 'hostname', 'route']
nic = network.WIZNET5K
dir(nic)
['__class__', '__name__', '__bases__', '__dict__', 'active', 'config', 'ifconfig', 'isconnected', 'regs', 'send_ethernet', 'status']
The board is wired to a network switch.
I issue
nic.active(True)
and with Wireshark I see the tcp/ip stack tries to get a lease from a dhcp server.
During this:
nic.isconnected()
False
From the doc
Returns True if the physical Ethernet link is connected and up.
The physical Eth link is running.
Question 1)
is nic.isconnected() not working or is the doc in error?
Polling nic.status(), when it changes from 0 to 2 the nic still isn't configured:
nic.ifconfig()
('0.0.0.0', '0.0.0.0', '0.0.0.0', '0.0.0.0')
I have to poll with nic.isconnected(); when it changes to True the nic has acquired the dhcp lease:
nic.ifconfig()
('192.168.1.2', '255.255.255.0', '192.168.1.1', '9.9.9.9')
Questions:
-
Can you add symbols for the current status() return values ?
-
Can you enhance status() adding the return value STAT_GOT_IP ?
So it is possible to poll just status(), as with WiFi interfaces.
Code Size
No response
Implementation
- I intend to implement this feature and would submit a Pull Request if desirable.
- I hope the MicroPython maintainers or community will implement this feature.
- I would like to Sponsor development of this feature.