ADB command to restart modem connection on MR200 OpenWrt

I've installed OpenWrt on Tp-Link MR200, everything seems to work just fine apart from rebooting the router via the UI, where all of the modem settings(android OS), configurable via 192.168.225.1/login.html seems to reset and clears off any settings set.

Trying to find an alternative modem connection restart, i figured out the following :
The modem is connected and controlled by the OpenWrt via adb-modemenable package.

i tried to use a ADB command to restart the mobile connection, but i'm not quite familiar with adb commands.

I tried the following different adb commands via ssh and yield the following :

root@OpenWrt:~# adb devices -l
List of devices attached
593add8c067c device usb:1-1

when i issued adb reboot, i wasn't able to reattach the USB mobile device :

root@OpenWrt:~# adb reboot
root@OpenWrt:~# adb devices -l
List of devices attached

root@OpenWrt:~#

Tired the adb kill-server, and this is what happens :

root@OpenWrt:~# adb kill-server
root@OpenWrt:~# adb devices -l

  • daemon not running. starting it now on port 5037 *
  • daemon started successfully *
    List of devices attached

root@OpenWrt:~#

The only way to get the modem to reattach, was to issue a reboot command for the whole router, where my modem settings doesn't survive and reset to default.

P.S switching off the router from the power supply mains and switching it back on seems to keep the modem settings but doing so renders the automated connection ping script useless.

Please any help towards this matter will be highly appreciated.

Please don't double post.

Sure, I just thought that it’s a different approach, and might help others with adb commands.

Here is the content of the /etc/init.d/adb-enablemodem file

#!/bin/sh /etc/rc.common

START=99

adb_exec() {
adb -s "$serial" shell "( $1 ) >/dev/null 2>&1"'; printf "\nEXIT_CODE: %i\n" $?' | head -c 64 | grep -qx 'EXIT_CODE: 0\r?'
}

enablemodem_do() {
logger -t adb-enablemodem 'INFO: waiting for device'
adb wait-for-device
serial="$(adb get-serialno)"

vendor_id="$(adb -s "$serial" shell 'uci get product.usb.vid' | head -c 16 | tr -d '\r\n')"
product_id="$(adb -s "$serial" shell 'uci get product.usb.pid' | head -c 16 | tr -d '\r\n')"

case "$vendor_id:$product_id" in
"0x2357:0x000D") # TP-LINK LTE MODULE
case "$1" in
start)
if adb_exec '
chmod +x /WEBSERVER/www/cgi-bin/*
fds="$(ls /proc/$$/fd | grep -v "[1]$")"
for fd in $fds; do
eval "exec $fd>&-"
done
start-stop-daemon -x httpd -S -- -h /WEBSERVER/www/
'; then
logger -t adb-enablemodem 'INFO: httpd on modem started'
else
logger -t adb-enablemodem 'ERROR: failed to start httpd on modem'
fi
option_newid='/sys/bus/usb-serial/drivers/option1/new_id'
if [ -e "$option_newid" ]; then
printf '%s %s' "$vendor_id" "$product_id" > "$option_newid"
fi
;;
stop)
if adb_exec 'start-stop-daemon -x httpd -K'; then
logger -t adb-enablemodem 'INFO: httpd on modem stopped'
else
logger -t adb-enablemodem 'ERROR: failed to stop httpd on modem'
fi
;;
esac
;;
*)
logger -t adb-enablemodem "ERROR: unknown device $vendor_id:$product_id"
;;
esac
}

start() {
( enablemodem_do start ) &
}

stop() {
( enablemodem_do stop ) &
}

restart() {
( enablemodem_do stop; enablemodem_do start ) &
}


  1. 012 ↩︎

These are the packages installed onto my OpenWrt installation :

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.