Install usbreset:
opkg update
opkg install usbreset
launch usbreset to check dongle ID:
usbreset
example:
root@OpenWrt:~# usbreset
Usage:
usbreset PPPP:VVVV - reset by product and vendor id
usbreset BBB/DDD - reset by bus and device number
usbreset "Product" - reset by product name
Devices:
Number 001/002 ID 05e3:0608 USB2.0 Hub
Number 001/005 ID 12d1:1001 HUAWEI Mobile
create script:
nano /root/check-gsm.sh
#!/bin/bash
# check dongle status, reset dongle and restart asterisk if not ready
#
checkifok=`/usr/sbin/asterisk -rx "dongle show devices" | grep -wc Free`
if [[ $checkifok == 0 ]]; then
/bin/echo "Dongle not ready" >/dev/null 2>&1
/bin/sleep 3
/usr/bin/usbreset 12d1:1001
/bin/sleep 2
/etc/init.d/asterisk restart
else
/bin/echo "Dongle OK" >/dev/null 2>&1
fi
# eof
give the right permisisons to the above script:
chmod 755 /root/check-gsm.sh
add this to root crontabs:
# check dongle status every 5 minutes and restart asterisk if not ready
*/5 * * * * /root/check-gsm.sh