Android device connected via “adb tcp” disconnects after a while

I wrote a shell script to control the Android battery level (using adb) and charge the device if the battery level is below the threshold value. I run adb in tcp mode (port 5555). My host machine and device are connected to a Wi-Fi network. To charge, I keep my device connected via a USB cutter to turn on / off the power of the device.

The problem I encountered is that adb shuts down after a while. I have support in my script that saves the device’s connection status. If the device is disconnected, the script reconnects to the device (adb connect). But sometimes the device turns off, and it also does not work. My script is not working at this time.

I saved “Keep Wi-Fi during sleep” to “Always” on my device. Advanced Wi-Fi settings.

Is this a problem with my network or do I need to change some settings on an Android device that I don’t know about?

+4
source share

All Articles