robertalab-ev3dev
robertalab-ev3dev copied to clipboard
detect local server when using a Point-to-Point conenction
When we are online, check if we can detect a local open roberta server. This would help using p2p-connections like usb/bt. We would e.g. do a mdns discovery on the robot and mdns announcements of local clients.
Ideally we'd just try to connect to
$ ifconfig usb0
usb0 Link encap:Ethernet HWaddr 12:16:53:48:af:38
inet addr:172.16.243.1 Bcast:172.16.243.255 Mask:255.255.255.0
inet6 addr: fe80::1016:53ff:fe48:af38/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:18 errors:0 dropped:0 overruns:0 frame:0
TX packets:77 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:2917 (2.9 KB) TX bytes:10592 (10.5 KB)
$ route -n
Destination Gateway Genmask Flags Metric Ref Use Iface
172.16.243.0 0.0.0.0 255.255.255.0 U 1 0 0 usb0
On the ev3:
$ ifconfig usb0
usb0 Link encap:Ethernet HWaddr 02:16:53:48:af:38
inet addr:172.16.243.50 Bcast:172.16.243.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST DYNAMIC MTU:1500 Metric:1
RX packets:8151 errors:0 dropped:220 overruns:0 frame:0
TX packets:6056 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:2337065 (2.2 MiB) TX bytes:837457 (817.8 KiB)
$ route -n
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 172.16.243.1 0.0.0.0 UG 0 0 0 usb0
172.16.243.0 0.0.0.0 255.255.255.0 U 0 0 0 usb0
172.16.243.1 0.0.0.0 255.255.255.255 UH 0 0 0 usb0
So we could grab the gateway address for usbX or hciX and try to connect to :1999.
First step would be a local python prototype. If that works, we'd need changes in the UI to support a "discovered server" and changes on this module to run a thread an periodically run the discovery (the code from the previously mentioned prototype).