New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
qmi: read sim status problem #9501
Comments
@obsy I still had this on my to-do list. What was your reason for closing the issue now? |
Because I don't know what the issue is. This code working for Askey modem, working for BroadMobi BM806U and not working for my Quectel EC20. I don't know if there is anything wrong with him. If you can, check it with some qmi modem. |
Yes, from this EC20. |
See:
grep Failed is the problem? |
Please try if this patch fixes it then diff --git a/package/network/utils/uqmi/files/lib/netifd/proto/qmi.sh b/package/network/utils/uqmi/files/lib/netifd/proto/qmi.sh
index ad577ea317..8b8ba014ce 100755
--- a/package/network/utils/uqmi/files/lib/netifd/proto/qmi.sh
+++ b/package/network/utils/uqmi/files/lib/netifd/proto/qmi.sh
@@ -105,9 +105,9 @@ proto_qmi_setup() {
}
}
else
- . /usr/share/libubox/jshn.sh
- json_load "$(uqmi -s -d "$device" --get-pin-status)" 2>&1 | grep -q Failed &&
- json_load "$(uqmi -s -d "$device" --uim-get-sim-state)"
+ local pin_json="$(uqmi -s -d "$device" --get-pin-status)"
+ [ "${pin_json:0:1}" = "{" ] || pin_json="$(uqmi -s -d "$device" --uim-get-sim-state)"
+ json_load "$pin_json"
json_get_var pin1_status pin1_status
json_get_var pin1_verify_tries pin1_verify_tries
This should have the desired effect (and we can remove |
Ok. it works. But looks very bad. Maybe like this:
Duplicate, but tests if it's really json. |
How about diff --git a/package/network/utils/uqmi/files/lib/netifd/proto/qmi.sh b/package/network/utils/uqmi/files/lib/netifd/proto/qmi.sh
index ad577ea317..c2c5fc1eca 100755
--- a/package/network/utils/uqmi/files/lib/netifd/proto/qmi.sh
+++ b/package/network/utils/uqmi/files/lib/netifd/proto/qmi.sh
@@ -105,10 +105,12 @@ proto_qmi_setup() {
}
}
else
- . /usr/share/libubox/jshn.sh
- json_load "$(uqmi -s -d "$device" --get-pin-status)" 2>&1 | grep -q Failed &&
- json_load "$(uqmi -s -d "$device" --uim-get-sim-state)"
+ json_load "$(uqmi -s -d "$device" --get-pin-status)"
json_get_var pin1_status pin1_status
+ if [ -z "$pin1_status" ]; then
+ json_load "$(uqmi -s -d "$device" --uim-get-sim-state)"
+ json_get_var pin1_status pin1_status
+ fi
json_get_var pin1_verify_tries pin1_verify_tries
case "$pin1_status" in That would avoid duplicate parsing and also avoid wildly checking for the first character of the replied string... |
Ok. |
Evaluating the return value of 'json_load' didn't work in the intended way resulting in PIN status no longer being read on modems where --get-pin-status doesn't fail. Fix this by trying --get-pin-status first and checking if pin1_status field exists in JSON, and if it doesn't try again with --uim-get-sim-state. Fixes: #9501 Signed-off-by: Daniel Golle <daniel@makrotopia.org>
Evaluating the return value of 'json_load' didn't work in the intended way resulting in PIN status no longer being read on modems where --get-pin-status doesn't fail. Fix this by trying --get-pin-status first and checking if pin1_status field exists in JSON, and if it doesn't try again with --uim-get-sim-state. Fixes: openwrt#9501 Signed-off-by: Daniel Golle <daniel@makrotopia.org>
Evaluating the return value of 'json_load' didn't work in the intended way resulting in PIN status no longer being read on modems where --get-pin-status doesn't fail. Fix this by trying --get-pin-status first and checking if pin1_status field exists in JSON, and if it doesn't try again with --uim-get-sim-state. Fixes: #9501 Signed-off-by: Daniel Golle <daniel@makrotopia.org> (cherry picked from commit ee7cb5e)
Evaluating the return value of 'json_load' didn't work in the intended way resulting in PIN status no longer being read on modems where --get-pin-status doesn't fail. Fix this by trying --get-pin-status first and checking if pin1_status field exists in JSON, and if it doesn't try again with --uim-get-sim-state. Fixes: openwrt#9501 Signed-off-by: Daniel Golle <daniel@makrotopia.org>
81832b3
Reading pin status in this way is wrong, this code return empty values. See debug script:
Tested with Quectel EC20
CC: @dangowrt
The text was updated successfully, but these errors were encountered: