Implementing USB network card type switch
I want to implement mechanics when you can specify using udev rules (and possibly D-Bus API) target USB network type (sometimes called USB composition) so ModemManager can switch it by itself.
For example, Quectel modules often uses command AT+QCFG="usbnet",x
to switch between QMI, RNDIS, MBIM, ... USB network card types (AT commands manual). Telit uses AT#USBCFG=x
to do the same thing (AT commands manual). SIMCom uses AT+CUSBPIDSWITCH=xxxx,1,1
to do it. I think that other modules also have similar commands.
If you have a lot of hardware that uses modems you will face with problem with switching modem to the correct mode when you insert new modems to the hardware (by default they can come from the supplier in different modes). You can do it in separate program that listen for new modems on D-Bus and switches it to the target mode, however it requires ModemManager running in debug mode (so you can execute AT commands) and require knowledge about modem manufacturer and correct AT commands in this script. I think that better to have this logic right in the ModemManager.
I have made a draft that implements this logic in ModemManager. I have tested it with RM520N-GL and it works fine. Now I want to merge it to the upstream, but I don't have that much experience neither in glib development nor ModemManager development.
So before creating new PR with this feature I'd like to ask several questions:
- I've created 3 new steps in MMBroadbandModem initialization (get current USB net card type, set new if required and reboot), but not sure that it is right way to do this logic. Is there any other logic that requires configuring something in modem and rebooting it?
- I didn't see any way to plugins that implement MMBroadbandModem/MMBaseModem reboot logic, though this is pretty common command for all modems. Maybe I just didn't notice it?
- AT commands execution and reading can lead to some unsolicited messages from modem to mix with AT command response (especially during modem boot). Is there any common way to remove from the response all messages that isn't response for the command?