mdlayher / modemmanager

Package modemmanager enables Go programs to control ModemManager and its devices using D-Bus. MIT Licensed.
MIT License
8 stars 2 forks source link

ForEachModem does not work with non-sequential modem indexes #2

Open bluecmd opened 2 months ago

bluecmd commented 2 months ago

Hi,

When using Client.ForEachModem and the first modem index is e.g. 2, the callback is never executed. This seems to be because there is a built-in assumption that the list is sequential. This is only true on boot. If you have a USB modem and plug it in, unplug it, and plug it back in it will likely have an index >1 causing Client.ForEachModem to no longer connect the modem.

bluecmd commented 2 months ago

As for how mmcli -L implements it, it seems to have to do with DBusObjectManager:

https://github.com/linux-mobile-broadband/ModemManager/blob/8934ce865c06df5d9fd405b55798c98fa4b6b1b0/cli/mmcli-manager.c#L370-L378

Sadly, this seems to not be implemented in the library used here for dbus communication: https://github.com/godbus/dbus/issues/57 unless I am missing something