Mobile modem connection restart after power failure

Hi,

After successful IPFire deployment I made the last test.
I tested if it will work after the power supply failure.
And found a problem.
It seems mobile modems do work but only after connecting into running system, means after system was started and while it has non-interrupted power.
Once it loose power supply, modems never start on next boot, so router will not reconnect internet on power supply failure.
Technically, on fresh start kernel/driver do not recognise modems as serial devices but as drives only. But if you remove it and put it back, while IPFire/kernel is running, drivers load as for modem.
Could be it’s the USB ids problem - but same modems worked for years in ASUS router and it was bulletproof config.
Tested using 2 Huawei modems.

Simple usb_switchmode -J solved driver/mode problem but now I need help to resolve two issues:

  1. earlier then ‘rc.local’ call to change modem mode.
  2. command to properly call system Dial Profile to established a connection ASAP after modem mode change.

Here a little script to solve above problem.
Change USB modem IDs to your needs!

Code partially based on this forum ideas.

#!/bin/bash

# repair ppp folders!
mkdir /var/run/pppd/ &>/dev/null
mkdir /var/run/pppd/lock &>/dev/null

# Define the IP address to check
ip_address="1.1.1.1"

#It's highly important to give original startup a change to connect first.
sleep 60


# Ping the IP address with a single packet and suppress output
ping -c 1 -q "$ip_address" > /dev/null

# Check the exit status of the ping command
if [ $? -eq 0 ]; then
    echo "Internet connected ..." | logger -t wan-check
else
    echo "Internet not connected! Switching modem and reconnecting" | logger -t wan-check

    usb_modeswitch -J -v 2222 -p 2222
    #(( sleep 2 ; /etc/rc.d/init.d/networking/red stop ; sleep 2; /etc/rc.d/init.d/networking/red start) & disown )
    (( sleep 2 ; /usr/local/bin/connscheduler reconnect ) & disown )
    #(( sleep 600 ; /etc/init.d/networking restart ) & disown )

fi[
1 Like