Programmatically enable/disable 3G


This is part 1 of a pair of posts about my project to put together a cheap-(the AR300M)-and-dirty-(my programming) monitoring solution.

When I detect problems on my netework, I want to notify via email and boxcar. But when the internet-connection itself is down, these messages don’t get out, so I want to fire up the 3G temporarily. The 3G modem would be connected all the time to the USB.

What is the way to enable and disable the 3G connection via a shell command or anything else that I can trigger from the shell or python?

And what are the commands to monitor the 3G connection (is it connected, to which carrier is it connected, what is the RSSI -or similar connection-strength metric- etc.)?

thanks a lot


Hi Simon, this depends on which modem you use. You have to use AT command to get the carrier info etc.

To disable/enable 3G modem using script is possible and not difficult.

Method 1: first set up modem connection then modify the UCI to disable/enable it. e.g. uci set network.modem.disabled=1; uci commit network , then you need to restart network: /etc/init.d/network restart

Method 2: use gpio to control the power of modem directly. The GPIO is mounted as LED in the system, find /sys/class/leds/xxx:usbpow/brightness, you can write 0 or 1 to it to enable or disable modem. echo 0 > /sys/class/leds/xxx:usbpow/brightness

Method 3: use ifconfig to enable disable the modem interface. e.g. ifconfig 3g-modem down, ifconfig 3g-modem up

1 Like