mirror of
https://github.com/Telecominfraproject/wlan-ap.git
synced 2025-10-29 09:32:34 +00:00
modemmanager: Use AT command to set username password for EAP112 LTE
1. For EAP112 LTE module (Quectel EM60 series), when username and password is configured, it is required to update the context with the QICSGP AT command. 2. Use a handler function to check if the AT command is stuck and retry. Fixes: WIFI-14545 Signed-off-by: Sebastian Huang <sebastian_huang@accton.com>
This commit is contained in:
committed by
John Crispin
parent
a488be045c
commit
41a3317661
@@ -36,14 +36,3 @@ start_service() {
|
||||
procd_set_param pidfile "${MODEMMANAGER_PID_FILE}"
|
||||
procd_close_instance
|
||||
}
|
||||
|
||||
reload_service()
|
||||
{
|
||||
stop
|
||||
start
|
||||
}
|
||||
|
||||
service_triggers()
|
||||
{
|
||||
procd_add_reload_trigger network
|
||||
}
|
||||
|
||||
@@ -403,6 +403,101 @@ modemmanager_set_preferred_mode() {
|
||||
}
|
||||
}
|
||||
|
||||
exec_at_command() {
|
||||
local at_command=$1
|
||||
local serial_dev=$2
|
||||
|
||||
local resp_file="/tmp/at_response.txt"
|
||||
local cmd_timeout=1
|
||||
local retry_limit=3
|
||||
local i=0
|
||||
local socat_pid reader_pid
|
||||
|
||||
while [ $i -lt ${retry_limit} ]; do
|
||||
# Flush old data
|
||||
> ${resp_file}
|
||||
|
||||
echo "${at_command}" | socat - /dev/${serial_dev},crnl &
|
||||
socat_pid=$!
|
||||
|
||||
{
|
||||
cat /dev/${serial_dev} > ${resp_file} &
|
||||
reader_pid=$!
|
||||
sleep ${cmd_timeout}
|
||||
kill -9 ${reader_pid} 2>/dev/null
|
||||
}
|
||||
|
||||
kill -9 ${socat_pid} 2>/dev/null
|
||||
|
||||
case $(cat ${resp_file}) in
|
||||
*OK*)
|
||||
echo "AT command executed successfully"
|
||||
break
|
||||
;;
|
||||
*)
|
||||
echo -n "AT command failed or no response"
|
||||
[ -n "$i" ] && echo ", retry $i" || echo
|
||||
;;
|
||||
esac
|
||||
|
||||
let "i++"
|
||||
done
|
||||
|
||||
rm -f ${resp_file}
|
||||
}
|
||||
|
||||
_mm_get_processed_device() {
|
||||
local mm_rundir="/var/run/modemmanager"
|
||||
local mm_sysfs_cache="${mm_rundir}/sysfs.cache"
|
||||
|
||||
awk -v status="processed" '!/^#/ && $0 ~ status {print $1}' "${mm_sysfs_cache}"
|
||||
}
|
||||
|
||||
proto_modemmanager_quectel_setup() {
|
||||
local apn username password pdptype
|
||||
local manufacturer ser_port context_id context_type at_command
|
||||
json_get_vars apn username password pdptype
|
||||
|
||||
local device=$(_mm_get_processed_device)
|
||||
[ -n "${device}" ] || {
|
||||
echo "No processed device"
|
||||
return 1
|
||||
}
|
||||
|
||||
# validate that ModemManager is handling the modem at the sysfs path
|
||||
modemstatus=$(mmcli --modem="${device}" --output-keyvalue)
|
||||
modempath=$(modemmanager_get_field "${modemstatus}" "modem.dbus-path")
|
||||
[ -n "${modempath}" ] || {
|
||||
echo "Device not managed by ModemManager"
|
||||
return 1
|
||||
}
|
||||
echo "modem available at ${modempath}"
|
||||
|
||||
# workaround for Quectel embedded TCP/IP Stack
|
||||
manufacturer=$(modemmanager_get_field "${modemstatus}" "modem.generic.manufacturer")
|
||||
ser_port=$(mmcli --modem="${device}" -K | grep modem.generic.ports | grep tty | awk '{print $3}' | head -n 1)
|
||||
if [ "${manufacturer}" = "Quectel" ]; then
|
||||
echo "setup TCP/IP Context"
|
||||
case "${pdptype}" in
|
||||
ip)
|
||||
context_type=1
|
||||
;;
|
||||
ipv6)
|
||||
context_type=2
|
||||
;;
|
||||
ipv4v6|*)
|
||||
context_type=3
|
||||
;;
|
||||
esac
|
||||
if [ -n "${username}" ] && [ -n "${password}" ]; then
|
||||
at_command="at+qicsgp=1,${context_type},\"${apn}\",\"${username}\",\"${password}\",3"
|
||||
else
|
||||
at_command="at+qicsgp=1,${context_type},\"${apn}\",\"\",\"\",0"
|
||||
fi
|
||||
exec_at_command "${at_command}" "${ser_port}"
|
||||
fi
|
||||
}
|
||||
|
||||
proto_modemmanager_setup() {
|
||||
local interface="$1"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user