Modemmanager preconfigure

I am using Modemmanager on a router for a 4G and a 5G module from Sierra. I want to preconfigure the modemmanager interface such that it automatically brings starts the 4G/5G connection when the modem is plugged.

I don't know in advance if the 4G module or the 5G module is plugged - and I don't know in advance to which interface. Normally, I would configure the modemmanager interface to attach to device /dev/cdc-wdm0, but apparently I need to specify the full system path. But this one I guess I don't know in advance.

Any good ideas how to elegantly solve this? Thanks!

# readlink -f /sys/class/usbmisc/cdc-wdm0/device/
/sys/devices/platform/soc/1c1c000.usb/usb4/4-1/4-1.3/4-1.3:1.0

You can create a hotplug script that will get the path and adjust the interface configuration if necessary.

thanks for the great tip. I guess in that script I would need to reload the config and somehow restart the modemmanager as well?

Right, or you can simply not use MM instead.