Hi...
I have a app running fine on rpi zero 2. It sends data over wlan0 no problems.
However - if I connect a local ethernet connection (via usb0) then my app tries to send data that way instead of over wlan0.
But that's just a local connection and has no internet access.
I altered the route metrics so wlan0 is much lower than usb0 but that didn't fix it.
Ideally I'd like to select the interface to use for internet access programatically - is that possible in b4j?
Dim inet As JavaObject
inet.InitializeNewInstance("java.net.InetSocketAddress", Array("ip.address.of.correct.driver", 0))
socket.As(JavaObject).GetFieldJO("socket").RunMethod("bind", Array(inet))
'socket' should be an initialized and unconnected socket.
Not only the metrics are important when choosing a route. If a lower metric is not enough, you can specify a specific interface for the route. With the command route print you can find the number of the preferred interface, for example 2. Then you can add an IF 2 to the default route at the end.
example route
Change preferred interface:
route CHANGE 192.168.1.0 MASK 255.255.255.0 192.168.1.1 METRIC 2 IF 2