Scheduled Testing of inactive SIM Slot

Design

Our 63xx-series line of routers provide SIM failover connectivity using the 1002-CM plug-in LTE modem.  

https://accelerated.com/products/1002_cm_lte_modem/ 

However, the 63xx-series routers can only connect with one SIM at a given time.  If both SIM slots of a 1002-CM connected to an Accelerated router are occupied, the user may want to periodically test the connection of that second SIM and report the results of that test and the stats of that modem to aView.

This feature is implemented using a custom script.  See example setup below.  This script will temporarily switch the 63xx-series router to use the secondary SIM slot, syslog to aView whether that SIM is able to establish a cellular connection (PASS/FAIL), send signal strength/connection details for that SIM to aView, perform a speed test, and then switch back to the previous SIM slot.

Config Setup

Minimum firmware: 18.1.29

Create a new custom script under System -> Scheduled tasks -> custom scripts, and enter in the following.   Adjust the Run time to the desired time of day you would like to test the inactive SIM.

# test inactive SIM slot and report pass/fail along with modem stats to aView

run_speed_test() {
  server=$(config get config.aview.speedtest_server)
  if [ "$(expr "$server" : '[0-9]\{1,3\}.[0-9]\{1,3\}.[0-9]\{1,3\}.[0-9]\{1,3\}$')" -eq 0 ]; then
    server=$(resolveip $server)
  fi
  if [ "$server" ]; then
    accns_log speed $(/bin/speedtest $server | tr '\n' '~' | sed 's/~$//')
  else
    accns_log w speed "Speed test failed: invalid server)"
  fi
}

run_speed_test
sim1=$(sim | grep -o '[0-9]*')
sim2=$((1 + (sim1 % 2)))
case "$(runt get modem.sim.$sim2.present)" in
""|true)
    sim $sim2
    sleep 300
    if [ "$(runt get modem.sim.$sim2.present)" != "true" ] || ! modem cli 2>&1 | grep -q "'connected'"; then
          ( sleep 90; event create info config "SIM $sim2 - check FAIL")  &
    else
        event create info config "SIM $sim2 - check PASS"
    fi
    ubus call eventd reset
    trigger event status
    run_speed_test
    sim $sim1
    ;;
*)
    event create info config "SIM $sim2 - no SIM present"
    ;; 
esac