2

I have a rooted Google Pixel 4a and an IoT device which I connect to over WiFi. This WiFi network does not have internet connectivity and simply serves as a way to control the IoT device. I have a termux process (it is run within an Ubuntu chroot jail) with which I want to be able to get information from the IoT device (over WiFi) and then POST it to a server (over LTE). I have tried so hard to get this to work. I'm fairly sure this should be possible with root access but I've exhausted my options at this point. Here's what I've tried:

  • Connecting to WiFi normally. Doesn't work because even though Android knows the WiFi has no connectivity, it still attempts to connect through it. To be clear, I have mobile data always on and I'm able to ping through LTE interfaces while connected to my IoT WiFi. It baffles me why Android doesn't direct traffic to LTE for non local IPs when it knows WiFi is down. This functionality should come out of the box in my opinion.

  • Changing the routing tables. This doesn't work since the LTE interface being used tends to change names at seemingly random times so the entries must be kept up to date. I can't seem to bind processes to interfaces from the command line either (but you can from the ConnectivityManager), as far as I'm aware. This is the disadvantage of circumventing the system commands for these things and directly modifying them. I am not notified of any changes or any other things going on and stuff simply stops working.

  • Assigning my IoT network a static IP with no gateway. This works on Apple phones but not on Android. It still attempts to access the network through the WiFi even with a 0.0.0.0 gateway.

  • Bypassing the GUI WiFi connection system to try to connect to WiFi from the terminal. This involves turning WiFi off, then using iwconfig to link it to the right network so Android still thinks it's in LTE only mode. Doesn't work because wlan0 interface doesn't permit this action on Android, even with sudo (couldn't figure out how to give myself permission to do so).

  • [PENDING] I'm trying to see if I can build a wrapper app that runs this process from inside it. Then, using the ConnectivityManager, I can bind the process to use the LTE interface. Then, I run a second process which is piped into the first which handles all communication with the IoT device, and I bind it to use WiFi. I'm not sure whether this strategy works but it seems very hacky. Also, I'd prefer a more elegant solution.

  • Looking at the Android source to find out how ConnectivityManager's bind process to network interface works and if there is an equivalent instruction for the command line. I have not found anything yet.

If any of you has insight on new strategies or has suggestions on how to fix my approaches to any of the above, let me know! Thanks in advance for your help!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.