mirror of
https://github.com/Ysurac/openmptcprouter-feeds.git
synced 2025-03-09 15:40:03 +00:00
fix modemmanager
This commit is contained in:
parent
36efe9515d
commit
f0336c7de5
7 changed files with 35 additions and 110 deletions
|
@ -64,7 +64,6 @@ MESON_ARGS += \
|
|||
-Dintrospection=false \
|
||||
-Dman=false \
|
||||
-Dbash_completion=false \
|
||||
-Dbuiltin_plugins=true \
|
||||
-Db_lto=true \
|
||||
-Dmbim=$(if $(CONFIG_MODEMMANAGER_WITH_MBIM),true,false) \
|
||||
-Dqmi=$(if $(CONFIG_MODEMMANAGER_WITH_QMI),true,false) \
|
||||
|
@ -81,8 +80,6 @@ define Build/InstallDev
|
|||
$(INSTALL_DIR) $(1)/usr/lib/pkgconfig
|
||||
$(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/ModemManager.pc $(1)/usr/lib/pkgconfig
|
||||
$(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/mm-glib.pc $(1)/usr/lib/pkgconfig
|
||||
$(INSTALL_DIR) $(1)/usr/share/dbus-1/interfaces
|
||||
$(CP) $(PKG_BUILD_DIR)/introspection/org.freedesktop.ModemManager1.* $(1)/usr/share/dbus-1/interfaces
|
||||
endef
|
||||
|
||||
define Package/modemmanager/install
|
||||
|
@ -99,6 +96,10 @@ define Package/modemmanager/install
|
|||
$(INSTALL_DIR) $(1)/usr/lib
|
||||
$(CP) $(PKG_INSTALL_DIR)/usr/lib/libmm-glib.so.* $(1)/usr/lib
|
||||
|
||||
$(INSTALL_DIR) $(1)/usr/lib/ModemManager
|
||||
$(CP) $(PKG_INSTALL_DIR)/usr/lib/ModemManager/libmm-shared-*.so* $(1)/usr/lib/ModemManager
|
||||
$(CP) $(PKG_INSTALL_DIR)/usr/lib/ModemManager/libmm-plugin-*.so* $(1)/usr/lib/ModemManager
|
||||
|
||||
$(INSTALL_DIR) $(1)/usr/lib/ModemManager/connection.d
|
||||
$(INSTALL_BIN) ./files/10-report-down $(1)/usr/lib/ModemManager/connection.d
|
||||
|
||||
|
@ -109,7 +110,7 @@ define Package/modemmanager/install
|
|||
$(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/share/dbus-1/system-services/org.freedesktop.ModemManager1.service $(1)/usr/share/dbus-1/system-services
|
||||
|
||||
$(INSTALL_DIR) $(1)/usr/share/ModemManager
|
||||
$$(if $$(wildcard $(PKG_INSTALL_DIR)/usr/share/ModemManager/*.conf),$(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/share/ModemManager/*.conf $(1)/usr/share/ModemManager,)
|
||||
$(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/share/ModemManager/*.conf $(1)/usr/share/ModemManager
|
||||
$(INSTALL_DATA) ./files/modemmanager.common $(1)/usr/share/ModemManager
|
||||
|
||||
$(INSTALL_DIR) $(1)/usr/share/ModemManager/fcc-unlock.available.d
|
||||
|
|
|
@ -22,10 +22,8 @@ Once installed, you can configure the 2G/3G/4G modem connections directly in
|
|||
option password 'vodafone'
|
||||
option pincode '7423'
|
||||
option iptype 'ipv4'
|
||||
option plmn '214001'
|
||||
option lowpower '1'
|
||||
option signalrate '30'
|
||||
option allow_roaming '1'
|
||||
|
||||
Only 'device' and 'proto' are mandatory options, the remaining ones are all
|
||||
optional.
|
||||
|
@ -38,7 +36,5 @@ allowing all protocols.
|
|||
The 'iptype' option supports any of these values: 'ipv4', 'ipv6' or 'ipv4v6'.
|
||||
It will default to 'ipv4' if not given.
|
||||
|
||||
The 'plmn' option allows to set the network operator MCCMNC.
|
||||
|
||||
The 'signalrate' option set's the signal refresh rate (in seconds) for the device.
|
||||
You can call signal info with command: mmcli -m 0 --signal-get
|
||||
|
|
11
modemmanager/files/10-report-down
Executable file → Normal file
11
modemmanager/files/10-report-down
Executable file → Normal file
|
@ -29,12 +29,7 @@ MODEM_DEVICE=$(modemmanager_get_field "${MODEM_STATUS}" "modem.generic.device")
|
|||
CFG=$(mm_get_modem_config "${MODEM_DEVICE}")
|
||||
[ -n "${CFG}" ] || exit 3
|
||||
|
||||
IFUP=$(ifstatus "${CFG}" | jsonfilter -e "@.up")
|
||||
|
||||
[ "${IFUP}" = "true" ] && {
|
||||
logger -t "modemmanager" "interface ${CFG} (network device ${INTERFACE}) ${STATE}"
|
||||
proto_init_update $INTERFACE 0
|
||||
proto_send_update $CFG
|
||||
}
|
||||
|
||||
logger -t "modemmanager" "interface ${CFG} (network device ${INTERFACE}) ${STATE}"
|
||||
proto_init_update $INTERFACE 0
|
||||
proto_send_update $CFG
|
||||
exit 0
|
||||
|
|
|
@ -22,7 +22,7 @@ MODEMMANAGER_EVENTS_CACHE="${MODEMMANAGER_RUNDIR}/events.cache"
|
|||
|
||||
mm_log() {
|
||||
local level="$1"; shift
|
||||
logger -p "daemon.${level}" -t "ModemManager[$$]" "hotplug: $*"
|
||||
[ "$(uci -q get openmptcprouter.settings.debug)" = "true" ] && logger -p "daemon.${level}" -t "ModemManager[$$]" "hotplug: $*"
|
||||
}
|
||||
|
||||
################################################################################
|
||||
|
|
4
modemmanager/files/modemmanager.init
Executable file → Normal file
4
modemmanager/files/modemmanager.init
Executable file → Normal file
|
@ -4,8 +4,6 @@
|
|||
USE_PROCD=1
|
||||
START=70
|
||||
|
||||
LOG_LEVEL="INFO"
|
||||
|
||||
start_service() {
|
||||
# Setup ModemManager service
|
||||
#
|
||||
|
@ -23,8 +21,6 @@ start_service() {
|
|||
. /usr/share/ModemManager/modemmanager.common
|
||||
procd_open_instance
|
||||
procd_set_param command /usr/sbin/ModemManager-wrapper
|
||||
procd_append_param command --log-level="$LOG_LEVEL"
|
||||
[ "$LOG_LEVEL" = "DEBUG" ] && procd_append_param command --debug
|
||||
procd_set_param respawn "${respawn_threshold:-3600}" "${respawn_timeout:-5}" "${respawn_retry:-5}"
|
||||
procd_set_param pidfile "${MODEMMANAGER_PID_FILE}"
|
||||
procd_close_instance
|
||||
|
|
95
modemmanager/files/modemmanager.proto
Executable file → Normal file
95
modemmanager/files/modemmanager.proto
Executable file → Normal file
|
@ -323,6 +323,16 @@ modemmanager_connected_method_static_ipv6() {
|
|||
proto_send_update "${interface}"
|
||||
}
|
||||
|
||||
modemmanager_disconnected_method_common() {
|
||||
local interface="$1"
|
||||
|
||||
echo "running disconnection (common)"
|
||||
proto_notify_error "${interface}" MM_DISCONNECT_IN_PROGRESS
|
||||
|
||||
proto_init_update "*" 0
|
||||
proto_send_update "${interface}"
|
||||
}
|
||||
|
||||
proto_modemmanager_init_config() {
|
||||
available=1
|
||||
no_device=1
|
||||
|
@ -331,8 +341,6 @@ 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
|
||||
|
@ -351,65 +359,18 @@ 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
|
||||
local iptype plmn metric signalrate allow_roaming
|
||||
local device apn allowedauth username password pincode iptype plmn metric signalrate allow_roaming
|
||||
|
||||
local address prefix gateway mtu dns1 dns2
|
||||
|
||||
json_get_vars device apn allowedauth username password
|
||||
json_get_vars pincode iptype plmn metric signalrate allow_roaming
|
||||
json_get_vars allowedmode preferredmode
|
||||
json_get_vars device apn allowedauth username password pincode iptype plmn metric signalrate allow_roaming
|
||||
|
||||
# validate sysfs path given in config
|
||||
[ -n "${device}" ] || {
|
||||
|
@ -430,33 +391,6 @@ 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}"
|
||||
|
||||
|
@ -619,6 +553,7 @@ proto_modemmanager_teardown() {
|
|||
|
||||
# disconnection handling only requires special treatment in IPv4/PPP
|
||||
[ "${bearermethod_ipv4}" = "ppp" ] && modemmanager_disconnected_method_ppp_ipv4 "${interface}"
|
||||
modemmanager_disconnected_method_common "${interface}"
|
||||
|
||||
# disconnect
|
||||
mmcli --modem="${device}" --simple-disconnect ||
|
||||
|
@ -626,10 +561,14 @@ proto_modemmanager_teardown() {
|
|||
|
||||
# disable
|
||||
mmcli --modem="${device}" --disable
|
||||
proto_notify_error "${interface}" MM_MODEM_DISABLED
|
||||
|
||||
# low power, only if requested
|
||||
[ "${lowpower:-0}" -lt 1 ] ||
|
||||
mmcli --modem="${device}" --set-power-state-low
|
||||
|
||||
proto_init_update "*" 0
|
||||
proto_send_update "$interface"
|
||||
}
|
||||
|
||||
[ -n "$INCLUDE_ONLY" ] || {
|
||||
|
|
2
modemmanager/files/usr/sbin/ModemManager-wrapper
Normal file → Executable file
2
modemmanager/files/usr/sbin/ModemManager-wrapper
Normal file → Executable file
|
@ -27,8 +27,6 @@ main() {
|
|||
mm_report_events_from_cache
|
||||
|
||||
wait "$CHILD"
|
||||
|
||||
# Set all configured interfaces as unavailable
|
||||
mm_cleanup_interfaces
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue