if you want you can do this (with a 20 second timeout)
uqmi -m -d /dev/cdc-wdm0 -t 20000 --get-data-status
"connected"
show:
uqmi
No device given
Usage: uqmi <options|actions>
Options:
--single, -s: Print output as a single line (for scripts)
--device=NAME, -d NAME: Set device name to NAME (required)
--keep-client-id <name>: Keep Client ID for service <name>
--release-client-id <name>: Release Client ID after exiting
--mbim, -m NAME is an MBIM device with EXT_QMUX support
--timeout, -t response timeout in msecs
Services: dms, nas, pds, wds, wms
Actions:
--get-versions: Get service versions
--set-client-id <name>,<id>: Set Client ID for service <name> to <id>
(implies --keep-client-id)
--get-client-id <name>: Connect and get Client ID for service <name>
(implies --keep-client-id)
--sync: Release all Client IDs
--start-network: Start network connection (use with options below)
--apn <apn>: Use APN
--auth-type pap|chap|both|none: Use network authentication type
--username <name>: Use network username
--password <password>: Use network password
--ip-family <family>: Use ip-family for the connection (ipv4, ipv6, unspecified)
--autoconnect: Enable automatic connect/reconnect
--profile <index>: Use connection profile
--stop-network <pdh>: Stop network connection (use with option below)
--autoconnect: Disable automatic connect/reconnect
--get-data-status: Get current data access status
--set-ip-family <val>: Set ip-family (ipv4, ipv6, unspecified)
--set-autoconnect <val>: Set automatic connect/reconnect (disabled, enabled, paused)
--get-profile-settings <val,#>: Get APN profile settings (3gpp, 3gpp2),#
--get-default-profile <val>: Get default profile number (3gpp, 3gpp2)
--create-profile <val> Create profile (3gpp, 3gpp2)
--apn <apn>: Use APN
--pdp-type ipv4|ipv6|ipv4v6>: Use pdp-type for the connection
--username <name>: Use network username
--password <password>: Use network password
--auth-type pap|chap|both|none: Use network authentication type
--no-roaming false|true To allow roaming, set to false
--modify-profile <val>,# Modify profile number (3gpp, 3gpp2)
--apn <apn>: Use APN
--pdp-type ipv4|ipv6|ipv4v6>: Use pdp-type for the connection
--username <name>: Use network username
--password <password>: Use network password
--auth-type pap|chap|both|none: Use network authentication type
--no-roaming false|true To allow roaming, set to false
--get-current-settings: Get current connection settings
--get-capabilities: List device capabilities
--get-pin-status: Get PIN verification status
--verify-pin1 <pin>: Verify PIN1
--verify-pin2 <pin>: Verify PIN2
--set-pin1-protection <state>: Set PIN1 protection state (disabled, enabled)
--pin <pin>: PIN1 needed to change state
--set-pin2-protection <state>: Set PIN2 protection state (disabled, enabled)
--pin <pin2>: PIN2 needed to change state
--change-pin1: Change PIN1
--pin <old pin>: Current PIN1
--new-pin <new pin>: New pin
--change-pin2: Change PIN2
--pin <old pin>: Current PIN2
--new-pin <new pin>: New pin
--unblock-pin1: Unblock PIN1
--puk <puk>: PUK needed to unblock
--new-pin <new pin>: New pin
--unblock-pin2: Unblock PIN2
--puk <puk>: PUK needed to unblock
--new-pin <new pin>: New pin
--get-iccid: Get the ICCID
--get-imsi: Get International Mobile Subscriber ID
--get-imei: Get International Mobile Equipment ID
--get-msisdn: Get the MSISDN (telephone number)
--reset-dms: Reset the DMS service
--get-device-operating-mode Get the device operating mode
--set-device-operating-mode <m> Set the device operating mode
(modes: online, low_power, factory_test, offline
reset, shutting_down, persistent_low_power,
mode_only_low_power)
--fcc-auth: Set FCC authentication
--uim-verify-pin1 <pin>: Verify PIN1 (new devices)
--uim-verify-pin2 <pin>: Verify PIN2 (new devices)
--uim-get-sim-state: Get current SIM state
--uim-power-off: Power off SIM card
--uim-slot: SIM slot [1-2]
--uim-power-on: Power on SIM card
--uim-slot: SIM slot [1-2]
--set-network-modes <modes>: Set usable network modes (Syntax: <mode1>[,<mode2>,...])
Available modes: all, lte, umts, gsm, cdma, td-scdma, 5gnr
--set-network-preference <mode>: Set preferred network mode to <mode>
Available modes: auto, gsm, wcdma
--set-network-roaming <mode>: Set roaming preference:
Available modes: any, off, only
--network-scan: Initiate network scan
--network-register: Initiate network register
--set-plmn: Register at specified network
--mcc <mcc>: Mobile Country Code (0 - auto)
--mnc <mnc>: Mobile Network Code
--get-plmn: Get preferred network selection info
--get-signal-info: Get signal strength info
--get-serving-system: Get serving system info
--get-system-info: Get system info
--get-lte-cphy-ca-info: Get LTE Cphy CA Info
--get-cell-location-info: Get Cell Location Info
--get-tx-rx-info <radio>: Get TX/RX Info (gsm, umts, lte, 5gnr)
--list-messages: List SMS messages
--storage <mem>: Messages storage (sim (default), me)
--delete-message <id>: Delete SMS message at index <id>
--storage <mem>: Messages storage (sim (default), me)
--get-message <id>: Get SMS message at index <id>
--storage <mem>: Messages storage (sim (default), me)
--get-raw-message <id>: Get SMS raw message contents at index <id>
--storage <mem>: Messages storage (sim (default), me)
--send-message <data>: Send SMS message (use options below)
--send-message-smsc <nr>: SMSC number
--send-message-target <nr>: Destination number (required)
--send-message-flash: Send as Flash SMS
--wda-set-data-format <type>: Set data format (type: 802.3|raw-ip)
--wda-get-data-format: Get data format
From personal experience I still notice some disconnections with both QMI and MBIM and ECM
log:
Mon Oct 14 21:52:01 2024 user.notice root: exec /root/wan2_connect: lost connection detected exec ifdown wan; ifup wan
Tue Oct 15 09:51:00 2024 user.notice root: exec /root/wan2_connect: lost connection detected exec ifdown wan; ifup wan
Tue Oct 15 21:46:01 2024 user.notice root: exec /root/wan2_connect: lost connection detected exec ifdown wan; ifup wan
Wed Oct 16 09:45:01 2024 user.notice root: exec /root/wan2_connect: lost connection detected exec ifdown wan; ifup wan
Wed Oct 16 21:43:01 2024 user.notice root: exec /root/wan2_connect: lost connection detected exec ifdown wan; ifup wan
script (for MBIM):
#!/bin/sh
# from 600 sec form boot not exec
if [ $(awk -F "." '{print $1}' /proc/uptime) -lt "600" ]; then
exit 0
fi
# if proto=mbim then it proceeds otherwise it does nothing
LTEPROTO=$(cat /etc/config/network | grep "proto 'mbim'" | wc -l)
if [ ${LTEPROTO} -eq "1" ]; then
LTESTATUS=$(uqmi -m -d /dev/cdc-wdm0 -t 20000 --get-data-status)
LTEERROR=$?
LTEFIND=$(echo ${LTESTATUS} | grep "\"connected\"" | wc -l)
if [ ${LTEERROR} -ne 0 ]; then
logger "exec /root/wan2_connect: uqmi not response into 20 sec exec ifdown wan; ifup wan"
ifdown wan
ifup wan
exit 0
fi
if [ ${LTEFIND} -eq "0" ]; then
logger "exec /root/wan2_connect: lost connection detected exec ifdown wan; ifup wan"
ifdown wan
ifup wan
#usbreset 2c7c:0512
fi
fi
script (for QMI):
#!/bin/sh
# from 600 sec form boot not exec
if [ $(awk -F "." '{print $1}' /proc/uptime) -lt "600" ]; then
exit 0
fi
# if proto=qmi then it proceeds otherwise it does nothing
LTEPROTO=$(cat /etc/config/network | grep "proto 'qmi'" | wc -l)
if [ ${LTEPROTO} -eq "1" ]; then
LTESTATUS=$(uqmi -d /dev/cdc-wdm0 -t 20000 --get-data-status)
LTEERROR=$?
LTEFIND=$(echo ${LTESTATUS} | grep "\"connected\"" | wc -l)
if [ ${LTEERROR} -ne 0 ]; then
logger "exec /root/wan_connect: uqmi not response into 20 sec exec ifdown wan; ifup wan"
ifdown wan
ifup wan
exit 0
fi
if [ ${LTEFIND} -eq "0" ]; then
logger "exec /root/wan_connect: lost connection detected exec ifdown wan; ifup wan"
ifdown wan
ifup wan
#usbreset 2c7c:0512
fi
fi
ps: I tried both QMI and MBIM and ECM