How do I edit how do I edit the qmi.sh script to fix it?

Good Day,

As a noob I've been very impressed by how to much detailed knowledge there is on technical details associated with getting a LTE modem to work.

I found some instructions that suggest that I "edit the qmi.sh script to fix it."

Unfortunately, I don't know how to edit the script nor how to find it.

Can someone point me to a tutorial?

Thanks in advance!

Here's the reference BTW

uqmi commands hang

If you type any uqmi command and get no output, you may need to edit the qmi.sh script to fix it.

The file is located in /lib/netifd/proto/qmi.sh

Locate the line that looks like this:

while uqmi -s -d "$device" --get-pin-status | grep '"UIM uninitialized"' > /dev/null; do

On OpenWRT 19.7 it's on line 83. It might be on a different line if you have a newer or older OS version.

Add the following 3 lines before the line above.

uqmi -s -d "$device" --get-pin-status & sleep 3 killall uqmi || echo "UQMI now works fine!"

This fix is currently necessary for SIM7600G-H card.

The instructions are pretty clear: It's in /lib/netifd/proto/qmi.sh. Obviously, this file is on your router, so you have to connect to it via SSH to get command line access. There is the following wiki article about this:

Then you have several options to edit the file, you could even use the described WinSCP to copy the file to your computer, edit it there and copy it back.

2 Likes

Welcome to the community!

Here's the refrence: https://teklager.se/en/knowledge-base/openwrt-4g-wwan-configuration/

1 Like

thank you!

#!/bin/bash

FILE_PATH="/lib/netifd/proto/qmi.sh"
BACKUP_FILE_PATH="${FILE_PATH}.bak"
SEARCH_LINE="while uqmi -s -d \"\$device\" --get-pin-status | grep '\"UIM uninitialized\"' > /dev/null"
INSERT_LINES=("uqmi -s -d \"\$device\" --get-pin-status &" "sleep 3" "killall uqmi || echo \"UQMI now works fine!\"")

# Check if the file exists
if [ ! -f "$FILE_PATH" ]; then
    echo "File not found: $FILE_PATH"
    exit 1
fi

# Create a backup of the original file
cp "$FILE_PATH" "$BACKUP_FILE_PATH"
echo "Backup created at $BACKUP_FILE_PATH"

# Read file and search for the line
LINE_NUMBER=$(grep -n "$SEARCH_LINE" "$FILE_PATH" | cut -d: -f1)

if [ -z "$LINE_NUMBER" ]; then
    echo "Line not found in the file."
    exit 1
fi

# Insert lines before the found line
sed -i "${LINE_NUMBER}i${INSERT_LINES[2]}" "$FILE_PATH"
sed -i "${LINE_NUMBER}i${INSERT_LINES[1]}" "$FILE_PATH"
sed -i "${LINE_NUMBER}i${INSERT_LINES[0]}" "$FILE_PATH"

echo "Lines successfully inserted."