Search code examples
androidcameraroutes3g

Can Android route using both 3G and Wifi depending of name resolution failure?


I'm keeping my Samsung tablet always connected to a 360 camera (Ricoh Theta S with OSC API), trying to send 360 images to a custom server autonomously over 3G thanks to a homemade Android app, with no human supervision.

OSC specifications mention that the camera acts as a Wifi access point and devices connect to its ESSID on a local 192.168.0.* network to take pictures. After capturing the picture, Android prioritizes the Wifi in order to reach the server, and asks the camera's DNS to resolve example.com, which inevitably fails.

I must manually disconnect the Wifi interface from the camera to let Android establish the 3G connection and in the end send the iamges on example.com, which requires a manual operation that I don't want.

Problem is that Android's routing behaviour looks binary: 100% Wifi or 100% 3G. While I feel that I need a custom routing table, that would be somehting like : 192.168.0.* over Wifi *.*.*.* over 3G Samsung tablets have an Intelligent network features that can proactively switch between 3G and Wifi when connection is weak, but that does not fix the problem because I assume they make decisions according to the quality of the physical connection. So it does not switch to 3G even if example.com fails to resolve.

What's the next solution to make this autonomous? Disabling and enabling Wifi from the code does not ensure Android will reconnect to the right camera's ESSID afterwards, plus the camera goes to standby after a few minutes of Wifi disconnection.

Does rooting the tablet to modify the way Android prioritizes Wifi or 3G look feasible?


Solution

  • First of all, let me answer your last question.

    Yes, rooting should solve you problem. Any it's the only possible way to use Wi-Fi and cellular networks simultaneously.

    To enable simultaneous connections on rooted device, execute:

    pkill dhcpcd
    svc wifi disable
    svc data enable
    netcfg wlan0 up
    cd /data/misc/wifi/.
    wpa_supplicant -B -Dnl80211 -iwlan0 -c/data/misc/wifi/wpa_supplicant.conf
    dhcpcd wlan0
    

    and define desired routes:

    ip route add x.x.x.x via x.x.x.y