On Fri, Mar 10, 2017 at 7:25 PM, Tom Hayward <t...@harbortronics.com> wrote:
> On Fri, Mar 10, 2017 at 9:25 AM, Tom Hayward <t...@harbortronics.com> wrote:
>> It sounds like I could improve my process by ditching the chatscript,
>> using --simple-connect, then adding a new utility to communicate with
>> the bearer and launch the appropriate type of interface (pppd, dhcp
>> client, or static). Can you point to some example code that shows how
>> to get this information from the bearer object?
>
> I think I've found the relevant interfaces:
>
> https://www.freedesktop.org/software/ModemManager/libmm-glib/latest/MMBearer.html#mm-bearer-get-ipv4-config
> MMBearerIpConfig *
> mm_bearer_get_ipv4_config (MMBearer *self);
>
> https://www.freedesktop.org/software/ModemManager/libmm-glib/latest/MMBearerIpConfig.html#mm-bearer-ip-config-get-method
> MMBearerIpMethod
> mm_bearer_ip_config_get_method (MMBearerIpConfig *self);
>
> Where do I get the MMBearer object?

Each MMModem has a list of MMBearer objects that you can retrieve.
But, more especifically, if you call Simple.Connect() you'll get the
connected bearer object as return value:
https://www.freedesktop.org/software/ModemManager/libmm-glib/1.6.0/MMModemSimple.html#mm-modem-simple-connect
https://www.freedesktop.org/software/ModemManager/libmm-glib/1.6.0/MMModemSimple.html#mm-modem-simple-connect-finish

This would be using libmm-glib directly from a C application.

Of course you could do the same in a python or javascript program, as
libmm-glib is GObject introspectable and it would be very easy to
integrate, see e.g.:
https://cgit.freedesktop.org/ModemManager/ModemManager/tree/examples/modem-watcher-javascript
https://cgit.freedesktop.org/ModemManager/ModemManager/tree/examples/modem-watcher-python

And also, another option, uglier maybe, is to run mmcli commands and
parse mmcli text outputs, as done in the OpenWRT protocol handler
(here you can see all 3 methods being handled)
https://bitbucket.org/aleksander0m/modemmanager-openwrt/src/d694c4c6f92d870885e9f78c6a443d7f74c8254c/modemmanager/files/modemmanager.proto?at=master&fileviewer=file-view-default

-- 
Aleksander
https://aleksander.es
_______________________________________________
ModemManager-devel mailing list
ModemManager-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel

Reply via email to