Correct connection sequence to maximize chances of e.g.: getting connected :)

Aleksander Morgado aleksander at aleksander.es
Tue Apr 28 15:21:36 UTC 2020


Hey!

> So, due to some issues I will have to rewrite my code from scratch anyway. And so this time I am doing it with a different use-case in mind.
>
> I should monitor incoming and outgoing voice calls for a modem. How may I manage objects lifetime, assuming ModemManager and the modem may disappear from underneath at any time?
>
> Answer I found:
> GTasks: I may use them to construct piece by piece the needed context and proceed chaining async operations.
>

I see the GTask as a way to run an async operation that may or may not
involve one or more async operations run one after another. In your
case, you could setup one GTask to manage "each modem found in the
system", and do everything needed under that GTask, as you say. Not
exactly the real purpose of the GTask, but you can definitely do that.

> So, when I see MM appear in the bus I may start a GTask to construct all the needed context to start monitoring calls. but I want to do it for every modem in the system, maybe more than one.
> Or, better, I would do it in general fashion.
> How do I track MMModems and MMVoice objects in this case, since I need to keep them around to receive their GSignals?

You could have a GObject that tracks all the modem/voice objects
reported by the MMManager and keep them e.g. in a list, and just then
remove them if the MMManager reports the device is gone.

> GTasks should help me manage the destruction of objects I am using temporarily, but how about objects I need to keep until a given modem physically disconnects and/or MM is closed for some reason?
>

You need to keep track of the interface objects yourself, e.g. inside
another GObject of your own for example, and then if the device is
reported as going away, get those interface objects removed.

-- 
Aleksander
https://aleksander.es


More information about the ModemManager-devel mailing list