modemmanager: add setting for allowed and preferred mode
Signed-off-by: Florian Eckert <fe@dev.tdt.de>
This commit is contained in:
parent
5fa043000f
commit
015106346c
2 changed files with 79 additions and 3 deletions
|
@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
|
|||
|
||||
PKG_NAME:=modemmanager
|
||||
PKG_SOURCE_VERSION:=1.20.6
|
||||
PKG_RELEASE:=10
|
||||
PKG_RELEASE:=11
|
||||
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_URL:=https://gitlab.freedesktop.org/mobile-broadband/ModemManager.git
|
||||
|
|
|
@ -340,6 +340,8 @@ proto_modemmanager_init_config() {
|
|||
proto_config_add_string 'allowedauth:list(string)'
|
||||
proto_config_add_string username
|
||||
proto_config_add_string password
|
||||
proto_config_add_string allowedmode
|
||||
proto_config_add_string preferredmode
|
||||
proto_config_add_string pincode
|
||||
proto_config_add_string iptype
|
||||
proto_config_add_string plmn
|
||||
|
@ -358,18 +360,65 @@ append_param() {
|
|||
connectargs="${connectargs}${param}"
|
||||
}
|
||||
|
||||
modemmanager_set_allowed_mode() {
|
||||
local device="$1"
|
||||
local interface="$2"
|
||||
local allowedmode="$3"
|
||||
|
||||
echo "setting allowed mode to '${allowedmode}'"
|
||||
mmcli --modem="${device}" --set-allowed-modes="${allowedmode}" || {
|
||||
proto_notify_error "${interface}" MM_INVALID_ALLOWED_MODES_LIST
|
||||
proto_block_restart "${interface}"
|
||||
return 1
|
||||
}
|
||||
}
|
||||
|
||||
modemmanager_set_preferred_mode() {
|
||||
local device="$1"
|
||||
local interface="$2"
|
||||
local allowedmode="$3"
|
||||
local preferredmode="$4"
|
||||
|
||||
[ -z "${preferredmode}" ] && {
|
||||
echo "no preferred mode configured"
|
||||
proto_notify_error "${interface}" MM_NO_PREFERRED_MODE_CONFIGURED
|
||||
proto_block_restart "${interface}"
|
||||
return 1
|
||||
}
|
||||
|
||||
[ -z "${allowedmode}" ] && {
|
||||
echo "no allowed mode configured"
|
||||
proto_notify_error "${interface}" MM_NO_ALLOWED_MODE_CONFIGURED
|
||||
proto_block_restart "${interface}"
|
||||
return 1
|
||||
}
|
||||
|
||||
echo "setting preferred mode to '${preferredmode}' (${allowedmode})"
|
||||
mmcli --modem="${device}" \
|
||||
--set-preferred-mode="${preferredmode}" \
|
||||
--set-allowed-modes="${allowedmode}" || {
|
||||
proto_notify_error "${interface}" MM_FAILED_SETTING_PREFERRED_MODE
|
||||
proto_block_restart "${interface}"
|
||||
return 1
|
||||
}
|
||||
}
|
||||
|
||||
proto_modemmanager_setup() {
|
||||
local interface="$1"
|
||||
|
||||
local modempath modemstatus bearercount bearerpath connectargs bearerstatus beareriface
|
||||
local bearermethod_ipv4 bearermethod_ipv6 auth cliauth
|
||||
local operatorname operatorid registration accesstech signalquality
|
||||
local allowedmode preferredmode
|
||||
|
||||
local device apn allowedauth username password pincode iptype plmn metric signalrate allow_roaming
|
||||
local device apn allowedauth username password pincode
|
||||
local iptype plmn metric signalrate allow_roaming
|
||||
|
||||
local address prefix gateway mtu dns1 dns2
|
||||
|
||||
json_get_vars device apn allowedauth username password pincode iptype plmn metric signalrate allow_roaming
|
||||
json_get_vars device apn allowedauth username password
|
||||
json_get_vars pincode iptype plmn metric signalrate allow_roaming
|
||||
json_get_vars allowedmode preferredmode
|
||||
|
||||
# validate sysfs path given in config
|
||||
[ -n "${device}" ] || {
|
||||
|
@ -390,6 +439,33 @@ proto_modemmanager_setup() {
|
|||
}
|
||||
echo "modem available at ${modempath}"
|
||||
|
||||
[ -z "${allowedmode}" ] || {
|
||||
case "$allowedmode" in
|
||||
"2g")
|
||||
modemmanager_set_allowed_mode "$device" \
|
||||
"$interface" "2g"
|
||||
;;
|
||||
"3g")
|
||||
modemmanager_set_allowed_mode "$device" \
|
||||
"$interface" "3g"
|
||||
;;
|
||||
"4g")
|
||||
modemmanager_set_allowed_mode "$device" \
|
||||
"$interface" "4g"
|
||||
;;
|
||||
"5g")
|
||||
modemmanager_set_allowed_mode "$device" \
|
||||
"$interface" "5g"
|
||||
;;
|
||||
*)
|
||||
modemmanager_set_preferred_mode "$device" \
|
||||
"$interface" "${allowedmode}" "${preferredmode}"
|
||||
;;
|
||||
esac
|
||||
# check error for allowed_mode and preferred_mode function call
|
||||
[ "$?" -ne "0" ] && return 1
|
||||
}
|
||||
|
||||
# always cleanup before attempting a new connection, just in case
|
||||
modemmanager_cleanup_connection "${modemstatus}"
|
||||
|
||||
|
|
Loading…
Reference in a new issue