tobof / openhab-addons

The next-generation open Home Automation Bus (openHAB)
Eclipse Public License 2.0
39 stars 30 forks source link

Reverse ethernet conection: Ethernet Nodes/Gateways connecting to controller #100

Open gnalbandian opened 6 years ago

gnalbandian commented 6 years ago

Not an issue, just a RFC.

I have some ethernet gateways in my home acting as nodes. The are regular gateways (ESP) with sensors on them, but without any radio, just wifi.

Sometimes a node (or gateway in this case is the same) gets rebooted and I have to wait for the networkConecctionChecker to acknoledge that the conecction to the node has gone offline to try to reconnect. Time varies depending of the settings defined at .things.

Would be nicer to have the binding listening on some port for incoming connections from the nodes? In this way, almost at the same time the node boots up it will reconnect with the controller.

Let me know what you think.

tobof commented 6 years ago

I haven't worked with client connections from ethernet gateways yet, but I suppose this could be implemented.

gerritv commented 6 years ago

The binding could listen in on the DHCP reports already coming in to OH2? This could then remind the binding to reconnect if it thought it was still connected. An example message from the log, (this example is on reboot of a ESP8266 gw): [work.internal.dhcp.DHCPListenService] - DHCP request for unknown address: 192.168.0.120

gnalbandian commented 6 years ago

Not the best approach. DHCP server are optional in networks. And even thought it’s almost certain you have a DHCP server in almost every other network you come across, maybe you prefer having your gateways with fixed ip. Then you wouldn’t detect DHCP request from them.

gerritv commented 6 years ago

I can't imagine a network without a DHCP server but regardless, you don't need a DHCP server to send out a DHCP request. The MySensors GW code sends out a DHCP request even if you specify a Fixed IP address. Doesn't make sense but just tested it using ESP8266Ethernet GW with Static IP configured.

tobof commented 6 years ago

DHCPListenService is part of the network binding. Using this within our binding would lead to a dependency. The network binding would need to be installed together with the MySensors binding.

I don't see a reason, why a GW with a static IP should send a DHCP request and if it does so by mistake I would not rely on it. :smile:

gnalbandian commented 6 years ago

@gerritv that's not usual. MySensors binding has no reason to send a DHCP request. That's beyond it's intended function. Dynamic Host Configuration Protocol main function is to assign network configurations to hosts. If you have all your host statically configured in your network, there is no need for a DHCP server.

This feature has to be approach as mentioned in the first post. We need to create a serverSocket and listen for incoming connections. I'm out of time, but ASAP I'll get into this. If there is someone also interested in the development it would be nice to join our work.

gerritv commented 6 years ago

I won't disagree that the DHCP request from the ESP8266 gw is spurious, I will see why and suggest a fix to MySensors.

I might be interested in helping. How do you have your node/gw's configured?