Cellular Signal Strength Threshold Test
Goal
To periodically check the cellular signal strength of the cellular modem in the 63xx-series router, and reset the cellular connection if the signal strength is below a specified threshold percentage.
Background
Cellular connections can grow stale over time, due to various environmental factors such as the modem sticking to a particular LTE band, the modem switching from one nearby cellular tower to another, or bandwidth saturation from other cellular devices in the area. Restarting the cellular connection when this occurs allows the modem to re-register with the nearby cellular towers and networks, perform PRL updates, receive OTA updates, and various other improvements that could result in improved signal strength and bandwidth.
The following script, when setup in the configuration profile as shown below, will check the cellular signal strength once every 20 minutes, regardless of whether the cellular modem has an Internet connection or not. If the signal strength falls below the specified threshold percentage four times in a row, then the script will automatically reset the cellular modem inside the 63xx-series router, and start its cellular connection process over again. The default threshold percentage is 20%, and can be adjusted by changing the signal_threshold_percentage variable in the script below.
Config Setup
Minimum firmware: 18.4.54
Create a new custom script under System -> Scheduled tasks -> custom scripts, and enter in the following. Adjust the Interval to 20m, or the desired interval you would like this script to run.
#!/bin/sh # Check the signal strength of the modem. If it's below the specified percentage, # mark it as a failure. Keep a count of failed signal strength thresholds. If # the signal is below the threshold for four consecutive checks, then reset the modem. # Adjustable settings signal_threshold_percentage='20' fail_count_file='/tmp/custom_signal_test_fail_count.txt' fail_count_limit='4' # number of concurrent failures that occur before resetting modem test_failed() { try=$((try+1)) echo "$try" > "$fail_count_file" accns_log w config "custom: signal below threshold ($1 - try $try)" } test_passed() { rm -f "$fail_count_file" try=0 # Note: uncomment the following line if you want to log successful tests #accns_log w config "custom: signal above threshold ($1)" } try=$(cat "$fail_count_file" 2> /dev/null) try=${try:-0} # make sure $try is an integer. set to zero if not case $try in ''|*[!0-9]*) try=0 ;; esac # do the signal strength test current_signal_pct="$(runt get mm.modem.$(modem idx).status.per)" current_signal_pct=${current_signal_pct:-0} if [ "$current_signal_pct" -ge "$signal_threshold_percentage" ]; then test_passed "current=$current_signal_pct~threshold=$signal_threshold_percentage" else test_failed "current=$current_signal_pct~threshold=$signal_threshold_percentage" fi # reset modem if failed count is greater than specified limit if [ "$try" -ge "$fail_count_limit" ]; then # note that we reset the fail count, to give the modem time to reconnect and # improve signal before we reset it again rm -f "$fail_count_file" modem reset fi
NOTE: The threshold for resetting the modem is determined by the script's fail_count_limit multiplied by the Interval set in the device configuration.