Re: [RFC] Bumping minimum glib2 required version to 2.48

2020-01-11 Thread Ben Chan
+1.  That also unlocks the use of g_assert_true, g_assert_false,
g_assert_cmpmem, etc

On Fri, Jan 10, 2020 at 9:52 AM Aleksander Morgado 
wrote:

> Hey!
>
>
>> > I'm thinking in bumping the minimum glib2 required version from 2.36
>> > to 2.48 in all libmbim, libqmi and ModemManager, in order to be able
>> > to start using e.g. G_DECLARE_FINAL_TYPE(),
>> > G_DECLARE_DERIVABLE_TYPE(), g_autoptr() and such.
>> >
>> > GLib 2.48.0 was released on Mar 22nd 2016.
>>
>> Works for me, and all the OS versions I care a bunch about (Fedora,
>> RHEL) have 2.48 for a long time.
>>
>> I assume this lets us get rid of the autoptr hacks I put in a while
>> back?
>>
>
> Yes :)
>
>> ___
> libqmi-devel mailing list
> libqmi-de...@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/libqmi-devel
>
___
ModemManager-devel mailing list
ModemManager-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel


Re: Where are you using ModemManager?

2019-04-05 Thread Ben Chan
Chrome OS uses ModemManager + libmbim + libqmi for its cellular
connectivity stack and pretty much tracks the upstream master branches
-- it's still on my TODO to upstream our remaining local patches :)

Since Chromebook Pixel 2013 (LTE model), all Chromebooks with a
built-in modem uses ModemManager. And since late 2014, we've been
dropping AT in favor of MBIM or QMI.

 Speaking as a developer, I really appreciate the openness and
responsiveness of ModemManager maintainers :)


On Mon, Mar 25, 2019 at 10:14 AM Aleksander Morgado
 wrote:
>
> Hey!
>
> If you or your company are using ModemManager in a professional
> product, would you mind sharing your experience in the mailing list?
>
> Even generic descriptions would be appreciated, but if you can share
> also platform details that would be great. Of course, only asking for
> information that can be published, please don't break any NDA :D
>
> --
> Aleksander
> https://aleksander.es
> ___
> ModemManager-devel mailing list
> ModemManager-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel
___
ModemManager-devel mailing list
ModemManager-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel

Re: Problems compiling with clang (3.8.21)

2019-04-03 Thread Ben Chan
Could you try these patches?

https://gitlab.freedesktop.org/mobile-broadband/libmbim/merge_requests/8
https://gitlab.freedesktop.org/mobile-broadband/libqmi/merge_requests/35
https://gitlab.freedesktop.org/mobile-broadband/ModemManager/merge_requests/88

Thanks,
Ben


On Tue, Apr 2, 2019 at 10:42 PM Torsten Hilbrich
 wrote:
>
> On 02.04.19 17:02, Dan Williams wrote:
> > I think -Wno-unused-but-set-variable is actually a mistake and it
> > should be "-Wunused-but-set-variable". But that causes build errors
> > that we should fix.
> >
> > Does clang support -Wunused-but-set-variable?
>
> No.
>
> >
> > Also, does making this change in m4/compiler_warnings.m4 of
> > ModemManager sources help?
> >
> > -   CFLAGS="$CFLAGS $option"
> > +   CFLAGS="$CFLAGS $option -Werror"
>
> This did the job of correctly checking which option is supported:
>
> ...
> checking whether gcc understands -Wunused-but-set-variable... no
> ...
>
> It seems clang is failing on unknown warning options only when using -Werror.
>
> This modification of adding -Werror was sufficient for ModemManager. For 
> libmbim and libqmi the additional option "-Wno-unused-function" was also 
> required, otherwise clang would report errors like:
>
> qmi-ctl.c:352:1: error: unused function 'qmi_message_result_validate' 
> [-Werror,-Wunused-function]
> qmi_message_result_validate (
> ^
> 1 error generated.
>
> or
>
> mbim-basic-connect.c:89:1: error: unused function 
> '_mbim_message_read_mbim_pin_desc_struct_array' [-Werror,-Wunused-function]
> _mbim_message_read_mbim_pin_desc_struct_array (
> ^
>
> Torsten
>
> ___
> ModemManager-devel mailing list
> ModemManager-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel
___
ModemManager-devel mailing list
ModemManager-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel

Re: Problems compiling with clang (3.8.21)

2019-04-02 Thread Ben Chan
autoconf seems to set GCC = yes for clang.  I believe clang supports
Wunused-variable instead of Wunused-but-set-variable. We could use the
former, which is also supported by gcc.   For other unsupported options, we
can work around with -Wno-unknown-warning-option or -Xclang-only=

On Tue, Apr 2, 2019 at 8:02 AM Dan Williams  wrote:

> On Tue, 2019-04-02 at 15:34 +0200, Torsten Hilbrich wrote:
> > Hello,
> >
> > I tried to compile libmbim (1.16.0), libqmi (1.20.0) and ModemManager
> > (1.8.0) with clang and got strange results.
> >
> > I set the environment variables CC=clang and CXX=clang++ and ran the
> > autogen.sh, configure, and make steps.
> >
> > Then the configure noticed that clang was used and checked for the
> > supported warning options:
> >
> > CC='clang'
> > configure:3408: checking for gcc
> > configure:3435: result: clang
> > ...
> > configure:17644: checking whether gcc understands -Wno-unused-but-
> > set-variable
> > configure:17657: clang -c -Wall -std=gnu89 -g -O2 -Wmissing-
> > declarations -Wmissing-prototypes -Wdeclaration-after-statement
> > -Wstrict-prototypes -Wno-unused-parameter -Wno-sign-compare -Wno-
> > deprecated-declarations -Wno-unused-but-set-variable  conftest.c >&5
> > warning: unknown warning option '-Wno-unused-but-set-variable'; did
> > you mean '-Wno-unused-const-variable'? [-Wunknown-warning-option]
> > 1 warning generated.
> > configure:17657: $? = 0
> > configure:17666: result: yes
>
> I think -Wno-unused-but-set-variable is actually a mistake and it
> should be "-Wunused-but-set-variable". But that causes build errors
> that we should fix.
>
> Does clang support -Wunused-but-set-variable?
>
> Also, does making this change in m4/compiler_warnings.m4 of
> ModemManager sources help?
>
> -   CFLAGS="$CFLAGS $option"
> +   CFLAGS="$CFLAGS $option -Werror"
>
> Dan
>
> >
> > However, when compiling the code I got the following error messages:
> >
> > make[4]: Entering directory
> > '/build/client/clang/freedesktop/modemmanager/work/modemmanager/libqc
> > dm/src'
> >   CC   libqcdm_la-com.lo
> > error: unknown warning option '-Wno-unused-but-set-variable'; did you
> > mean '-Wno-unused-const-variable'?
> >   [-Werror,-Wunknown-warning-option]
> > Makefile:516: recipe for target 'libqcdm_la-com.lo' failed
> > make[4]: *** [libqcdm_la-com.lo] Error 1
> >
> > I assume that checking in configure is done without -Werror, but
> > compilation at least in libqdcdm is done with -Werror.
> >
> >
> > It this a known problem? Are fixes welcome to support compilation
> > with clang?
> >
> > The same problem happened in libmbim and libqmi.
> >
> > With regards,
> >
> >   Torsten Hilbrich
> >
> >
> > ___
> > ModemManager-devel mailing list
> > ModemManager-devel@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel
>
> ___
> ModemManager-devel mailing list
> ModemManager-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel
___
ModemManager-devel mailing list
ModemManager-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel

Re: How other applications use the ports that occupied by MM

2019-03-21 Thread Ben Chan
On Thu, Mar 21, 2019 at 9:25 AM Aleksander Morgado
 wrote:
>
> >
> > Yeah, mixed feelings from me too. I guess before we do that, can we ask
> > what commands people want to use? I'd rather it not be used a short
> > circuit for stuff that could be fixed in MM or implemented fairly
> > easily for a device. That's my only reservation, that having it may
> > reduce the incentive to fix/enhance MM itself.
>
> Speaking here as a user, I've been in the need of running AT commands
> sometimes as well, e.g.:
>  * To enable/disable istp traces in Intel-XMM based devices.
>  * To query the status of totally unrelated things, e.g. audio profile
> settings, for which we will probably never have MM APIs.
>  * To query the status of routes configured inside the modem, e.g
> AT+UIPROUTE in the TOBY-L4.
>  * To query device-reported temperature, although for that I could
> envision a "temperature" interface or something like that.
>  * For module certification purposes, or e.g. to show the current
> status of the modem to people who "speak the AT protocol" but who
> don't necessarily understand how MM or mmcli work.
>
> Sometimes I've also seen people running mmcli --command for things
> that would break the MM flow, e.g. running CFUN=4 and CFUN=1 manually
> via --command, and that really messes up all the MM logic indeed, but
> that is honestly the same mess that could happen after running qmicli
> set operation mode offline/reset manually.
>
> As long as the user understands that the API should be exclusively for
> "reading state", all should be good... "should".

I also have mixed feelings (probably more negatives than positives)
about that. It comes handy for debugging and manual queries as you
said, but opens up the possibility for other applications to misuse or
abuse it. For modems that expose a single AT port or have an AT port
for both modem and non-modem (e.g. GPS) functionalities, I'd imagine
how problematic it could be.  I guess we could use D-Bus policy to
restrict who can use Modem.Command, but that may not be granular
enough. A compile-time configuration, as you suggested, would be
great.  On a related note, I really hope and look forward to one day
when we only need the generic MM plugin with MBIM / QMI support to
support any modem :)

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

commit 1093c124b4cb introduced a hard dependency on libqmi

2019-03-12 Thread Ben Chan
The following commit introduced a hard dependency on libqmi for the dell
plugin:

commit 1093c124b4cb "dell,dw5821e: use DMS extension method to load
properly formatted firmware version"

so ModemManager fails to build under --without-qmi.  Aleksander, we should
probably extend the gitlab CI to test out a few configurations (e.g.
--without-mbim, --without-udev, etc)

Ben
___
ModemManager-devel mailing list
ModemManager-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel

[PATCH 1/1] altair-lte: use mm_autoptr instead of g_autoptr

2018-12-12 Thread Ben Chan
commit 397faef3c5ce ("mm-common-helpers: add mm_autoptr helpers for
GRegex and GMatchInfo") introduces mm_autoptr(), which implements
g_autoptr() that isn't available before glib 2.44. This patch fixes the
code to consistently uses mm_autoptr().
---
 plugins/altair/mm-modem-helpers-altair-lte.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/plugins/altair/mm-modem-helpers-altair-lte.c 
b/plugins/altair/mm-modem-helpers-altair-lte.c
index bb247d75..09c6f18f 100644
--- a/plugins/altair/mm-modem-helpers-altair-lte.c
+++ b/plugins/altair/mm-modem-helpers-altair-lte.c
@@ -71,8 +71,8 @@ gchar *
 mm_altair_parse_ceer_response (const gchar *response,
GError **error)
 {
-g_autoptr(GRegex) r = NULL;
-g_autoptr(GMatchInfo) match_info = NULL;
+mm_autoptr(GRegex) r = NULL;
+mm_autoptr(GMatchInfo) match_info = NULL;
 gchar *ceer_response = NULL;
 
 
@@ -136,8 +136,8 @@ mm_altair_parse_cid (const gchar *response, GError **error)
 MMPco *
 mm_altair_parse_vendor_pco_info (const gchar *pco_info, GError **error)
 {
-g_autoptr(GRegex) regex = NULL;
-g_autoptr(GMatchInfo) match_info = NULL;
+mm_autoptr(GRegex) regex = NULL;
+mm_autoptr(GMatchInfo) match_info = NULL;
 MMPco *pco = NULL;
 gint num_matches;
 
-- 
2.20.0.405.gbc1bbc6f85-goog

___
ModemManager-devel mailing list
ModemManager-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel


Re: Planning to add a PCIe(not in USB protocol) device

2018-12-10 Thread Ben Chan
I wonder why MBIM-enumerated-over-PCIe (L860) is preferred over
MBIM-over-USB3 (L850). Perhaps the theoretical achievable data rate
over PCIe?

Despite the MBIM enumeration, having a vendor specific host interface
does feel going backward as Bjørn said.  IMHO, the industry should
really move towards standard interface protocols like MBIM instead of
legacy protocols like AT, or worse, proprietary protocols.  On
Chromium OS, we don't even install the fibocom plugin but simply rely
on the generic plugin with MBIM to support L850 :)

- Ben

On Mon, Dec 10, 2018 at 6:25 PM 王道之  wrote:
>
> Hey Aleksander
>  The device is basic on the Intel 7560 chip, or L860 in fibocom that 
> difference the L850 with PCIe in MBIM protocol.
>  I am not sure there need a PCIe lib or yet, as now I can use lspci found 
> the device, and there is a net port with the drive offered by Intel. And the 
> drive would be open source later time.
>  You add the device L850 of Fibocom in the ModemManager early time, and 
> now the Fibocom want to add the L860 by itself, and I work for Fibocom. So I 
> am going to add a PCIe L860 in the ModemManager.
> As I planned, I am going to add the L860 in the plugin, then init the 
> device ports(this may need a lib?), then init the modem with AT commd.
>  About the L860 there is a net port, divided in several ports by VLAN id. 
> Here is some description:
>  The host driver maps each channel exposed by the modem to an interface 
> for application to exercise communication over such channels. For network 
> devices, each IP session  (0  to 7) is mapped to INM network interfaces (INM0 
> to INM7). Thus "/PCIE/IOSM/IPS/0" will be mapped to INM0, "/PCIE/IOSM/IPS/1" 
> will be mapped to "/PCIE/IOSM/IPS/1" and so on. Similarly, 
> "/PCIE/IOSM/CTRL/0" is mapped to RPC device, "/PCIE/IOSM/TRACE/0" to trace, 
> "/PCIE/IOSM/CTRL/0" and "/PCIE/IOSM/CTRL/2" to IAT devices and so  on. These  
> are  internals to PCIe communication and are transparent  to user-space 
> application.
>
> The IOSM host driver exposes the interfaces as a VLAN devices (except  for  
> flashing  device). Following table lists the interfaces  exposed  by  the 
> host driver. Please  note  that,  not every interface is supported by the 
> modem. The host driver allows opening of  an  interface only if it is 
> supported on the modem side.
>
>
> Cheers!
>
> Quincy Chen
>
>
> Aleksander Morgado  于2018年12月10日周一 下午4:54写道:
>>
>> Hey,
>>
>> > I am going to add a PCIe not in USB protocol modem device in the 
>> > Modemmanager. In order to better integrate into the current architecture 
>> > of Modemmanager, any development advice?
>> > As I planned, I am going to add the new PCIe device in the plugins 
>> > folder,but I am not sure where to add the PCIe lib just like the libqmi or 
>> > the libmbim.
>> > By the way, I found the comment  Nozomi, Card-Bus PCI (not USB)  at 
>> > the device "Option GT 3G+ EMEA" in the supported devices list , Is  that 
>> > mean the device use the PCI protocol? If in that way, I can refer to when 
>> > I develop.
>> >
>>
>> Is this PCIe library a new one that you're writing?
>> What device is this?
>>
>> Cheers!
>>
>> --
>> Aleksander
>> https://aleksander.es
>
> ___
> ModemManager-devel mailing list
> ModemManager-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel
___
ModemManager-devel mailing list
ModemManager-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel


[PATCH 1/1] cli,output: include string.h for strlen()

2018-11-29 Thread Ben Chan
This patch fixes the following compiler warning:

mmcli-output.c:783:19: error: implicitly declaring library function 'strlen' 
with type 'unsigned long (const char *)' 
[-Werror,-Wimplicit-function-declaration]
aux = strlen 
(section_infos[field_infos[item_l->field].section].name);
  ^
---
 cli/mmcli-output.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/cli/mmcli-output.c b/cli/mmcli-output.c
index 245aeed1..ac7dc333 100644
--- a/cli/mmcli-output.c
+++ b/cli/mmcli-output.c
@@ -19,6 +19,7 @@
  */
 
 #include 
+#include 
 
 #include 
 #include "mm-common-helpers.h"
-- 
2.20.0.rc0.387.gc7a69e6b6c-goog

___
ModemManager-devel mailing list
ModemManager-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel


[PATCH 1/1] cli, call: fix incorrect string conversion of MMCallStateReason enum

2018-11-29 Thread Ben Chan
This patch fixes the following issue with string conversion of a 
MMCallStateReason enum:

mmcli-call.c:160:88: error: implicit conversion from enumeration type 
'MMCallStateReason' to different enumeration type 'MMCallState' 
[-Werror,-Wenum-conversion]
mmcli_output_string (MMC_F_CALL_PROPERTIES_STATE_REASON, 
mm_call_state_get_string (mm_call_get_state_reason (call)));
 
  ^~~
---
 cli/mmcli-call.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/cli/mmcli-call.c b/cli/mmcli-call.c
index d4930285..a871dbc0 100644
--- a/cli/mmcli-call.c
+++ b/cli/mmcli-call.c
@@ -157,7 +157,7 @@ print_call_info (MMCall *call)
 mmcli_output_string (MMC_F_CALL_PROPERTIES_NUMBER,   
mm_call_get_number (call));
 mmcli_output_string (MMC_F_CALL_PROPERTIES_DIRECTION,
mm_call_direction_get_string (mm_call_get_direction (call)));
 mmcli_output_string (MMC_F_CALL_PROPERTIES_STATE,
mm_call_state_get_string (mm_call_get_state (call)));
-mmcli_output_string (MMC_F_CALL_PROPERTIES_STATE_REASON, 
mm_call_state_get_string (mm_call_get_state_reason (call)));
+mmcli_output_string (MMC_F_CALL_PROPERTIES_STATE_REASON, 
mm_call_state_reason_get_string (mm_call_get_state_reason (call)));
 mmcli_output_string (MMC_F_CALL_PROPERTIES_AUDIO_PORT,   
mm_call_get_audio_port (call));
 
 if (audio_format) {
-- 
2.20.0.rc0.387.gc7a69e6b6c-goog

___
ModemManager-devel mailing list
ModemManager-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel


Re: Automatic APN

2018-11-15 Thread Ben Chan
On Thu, Nov 15, 2018 at 12:46 AM Aleksander Morgado
 wrote:
>
> Hey,
>
> > My engineering team has been looking at implementing automatic APN 
> > detection and I wanted to reach out and see if anyone has thoughts on 
> > where(MM/NM) or if this would belong.
> >
> > We're looking at using the Android APN/carrier lookup table via MCC/MNC & 
> > IMEI.
> > https://android.googlesource.com/device/sample/+/master/etc/apns-full-conf.xml
> >
> > We've got to do it, I'd like it to go open-source if it can be done without 
> > too much hackyness. Thoughts?
>
> We already have our own database here:
> https://gitlab.gnome.org/GNOME/mobile-broadband-provider-info/blob/master/serviceproviders.xml
>
> This database is used e.g. when creating a new network connection for
> a modem via NetworkManager, it allows the user to select which APN to
> use based on the SIM card MCCMNC. Beware, not IMEI, that would be very
> wrong!!!
>
> We don't have an "automatic" selection procedure, because multiple APN
> configurations may match the same MCCMNC, so which one would you use?

There are definitely edge cases, such as MVNOs, where MCCMNC isn't
sufficient for determining the right APN. Other signals like IMSI,
EFspn, EFgid need to be taken into account. Unfortunately, MNOs/MVNOs
tend to choose different approaches. As MNOs merge and split over
time, APNs may change over time.

It'd be much simpler if they all go with one common default APN.
There is another annoying bit, APN authentication, where in many cases
the username and password are just known values and really serve no
purposes :(
___
ModemManager-devel mailing list
ModemManager-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel


[PATCH] tests: use memcmp() instead of g_assert_cmpmem() for now

2018-11-07 Thread Ben Chan
g_assert_cmpmem() isn't available until glib 2.46, while the minimum
glib version required by ModemManager is 2.36. This patch replaces the
uses of g_assert_cmpmem() with memcmp() instead.
---
 libmm-glib/tests/test-pco.c  | 3 +--
 plugins/altair/tests/test-modem-helpers-altair-lte.c | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/libmm-glib/tests/test-pco.c b/libmm-glib/tests/test-pco.c
index c25606fc..086ce3ba 100644
--- a/libmm-glib/tests/test-pco.c
+++ b/libmm-glib/tests/test-pco.c
@@ -76,8 +76,7 @@ test_pco_list_add (void)
 pco_data = mm_pco_get_data (pco, _data_size);
 g_assert (pco_data != NULL);
 g_assert_cmpuint (pco_data_size, ==, expected_pco->pco_data_size);
-g_assert_cmpmem (pco_data, pco_data_size,
- expected_pco->pco_data, expected_pco->pco_data_size);
+g_assert_cmpint (memcmp (pco_data, expected_pco->pco_data, 
pco_data_size), ==, 0);
 }
 
 mm_pco_list_free (list);
diff --git a/plugins/altair/tests/test-modem-helpers-altair-lte.c 
b/plugins/altair/tests/test-modem-helpers-altair-lte.c
index ec25e5f8..da9eaf32 100644
--- a/plugins/altair/tests/test-modem-helpers-altair-lte.c
+++ b/plugins/altair/tests/test-modem-helpers-altair-lte.c
@@ -164,8 +164,7 @@ test_parse_vendor_pco_info (void)
 pco_data = mm_pco_get_data (pco, _data_size);
 g_assert (pco_data != NULL);
 g_assert_cmpuint (pco_data_size, ==, good_pco_infos[i].pco_data_size);
-g_assert_cmpmem (pco_data, pco_data_size,
- good_pco_infos[i].pco_data, 
good_pco_infos[i].pco_data_size);
+g_assert_cmpint (memcmp (pco_data, good_pco_infos[i].pco_data, 
pco_data_size), ==, 0);
 g_object_unref (pco);
 }
 
-- 
2.19.1.930.g4563a0d9d0-goog

___
ModemManager-devel mailing list
ModemManager-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel


g_assert_cmpmem and glib 2.46

2018-11-06 Thread Ben Chan
Hi Aleksander and Dan,

The PCO patches I submitted earlier on used g_assert_cmpmem(), which I
just realized that it is available in glib 2.46 or later.
ModemManager requires glib 2.36 or later.   Given that glib 2.45 was
released about 3 years ago, I wonder if it's time to bump the minimum
glib version. Otherwise, I can update the code not to use
g_assert_cmpmem(). WDYT?

Thanks,
Ben
___
ModemManager-devel mailing list
ModemManager-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel


[PATCH] broadband-modem-mbim: update ms-basic-connect-extensions naming

2018-11-06 Thread Ben Chan
libmbim 1.17.4 (commit 3eeaa4248b98 "ms-basic-connect-extensions: rename
service") added a MS prefix to the Basic Connectivity Extensions
service. This patch updates the MMBroadbandModemMbim code accordingly.
---
 configure.ac  |  2 +-
 src/mm-broadband-modem-mbim.c | 22 +++---
 2 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/configure.ac b/configure.ac
index f6623eab..964cb523 100644
--- a/configure.ac
+++ b/configure.ac
@@ -317,7 +317,7 @@ 
dnl-
 dnl MBIM support (enabled by default)
 dnl
 
-LIBMBIM_VERSION=1.17.3
+LIBMBIM_VERSION=1.17.4
 
 AC_ARG_WITH(mbim, AS_HELP_STRING([--without-mbim], [Build without MBIM 
support]), [], [with_mbim=yes])
 AM_CONDITIONAL(WITH_MBIM, test "x$with_mbim" = "xyes")
diff --git a/src/mm-broadband-modem-mbim.c b/src/mm-broadband-modem-mbim.c
index 8f95e60e..4f92a7c0 100644
--- a/src/mm-broadband-modem-mbim.c
+++ b/src/mm-broadband-modem-mbim.c
@@ -2009,9 +2009,9 @@ query_device_services_ready (MbimDevice   *device,
 service = mbim_uuid_to_service 
(_services[i]->device_service_id);
 
 switch (service) {
-case MBIM_SERVICE_BASIC_CONNECT_EXTENSIONS:
+case MBIM_SERVICE_MS_BASIC_CONNECT_EXTENSIONS:
 for (j = 0; j < device_services[i]->cids_count; j++) {
-if (device_services[i]->cids[j] == 
MBIM_CID_BASIC_CONNECT_EXTENSIONS_PCO) {
+if (device_services[i]->cids[j] == 
MBIM_CID_MS_BASIC_CONNECT_EXTENSIONS_PCO) {
 mm_dbg ("PCO is supported");
 self->priv->is_pco_supported = TRUE;
 break;
@@ -2754,7 +2754,7 @@ sms_notification (MMBroadbandModemMbim *self,
 }
 
 static void
-basic_connect_extensions_notification_pco (MMBroadbandModemMbim *self,
+ms_basic_connect_extensions_notification_pco (MMBroadbandModemMbim *self,
MbimMessage *notification)
 {
 MbimPcoValue *pco_value;
@@ -2762,7 +2762,7 @@ basic_connect_extensions_notification_pco 
(MMBroadbandModemMbim *self,
 gchar *pco_data_hex;
 MMPco *pco;
 
-if (!mbim_message_basic_connect_extensions_pco_notification_parse (
+if (!mbim_message_ms_basic_connect_extensions_pco_notification_parse (
 notification,
 _value,
 )) {
@@ -2796,13 +2796,13 @@ basic_connect_extensions_notification_pco 
(MMBroadbandModemMbim *self,
 }
 
 static void
-basic_connect_extensions_notification (MMBroadbandModemMbim *self,
+ms_basic_connect_extensions_notification (MMBroadbandModemMbim *self,
MbimMessage *notification)
 {
 switch (mbim_message_indicate_status_get_cid (notification)) {
-case MBIM_CID_BASIC_CONNECT_EXTENSIONS_PCO:
+case MBIM_CID_MS_BASIC_CONNECT_EXTENSIONS_PCO:
 if (self->priv->setup_flags & PROCESS_NOTIFICATION_FLAG_PCO)
-basic_connect_extensions_notification_pco (self, notification);
+ms_basic_connect_extensions_notification_pco (self, notification);
 break;
 default:
 /* Ignore */
@@ -2846,8 +2846,8 @@ device_notification_cb (MbimDevice *device,
 case MBIM_SERVICE_BASIC_CONNECT:
 basic_connect_notification (self, notification);
 break;
-case MBIM_SERVICE_BASIC_CONNECT_EXTENSIONS:
-basic_connect_extensions_notification (self, notification);
+case MBIM_SERVICE_MS_BASIC_CONNECT_EXTENSIONS:
+ms_basic_connect_extensions_notification (self, notification);
 break;
 case MBIM_SERVICE_SMS:
 sms_notification (self, notification);
@@ -3083,10 +3083,10 @@ common_enable_disable_unsolicited_events 
(MMBroadbandModemMbim *self,
 /* Basic connect extensions service */
 if (self->priv->enable_flags & PROCESS_NOTIFICATION_FLAG_PCO) {
 entries[n_entries] = g_new (MbimEventEntry, 1);
-memcpy (&(entries[n_entries]->device_service_id), 
MBIM_UUID_BASIC_CONNECT_EXTENSIONS, sizeof (MbimUuid));
+memcpy (&(entries[n_entries]->device_service_id), 
MBIM_UUID_MS_BASIC_CONNECT_EXTENSIONS, sizeof (MbimUuid));
 entries[n_entries]->cids_count = 1;
 entries[n_entries]->cids = g_new0 (guint32, 1);
-entries[n_entries]->cids[0] = MBIM_CID_BASIC_CONNECT_EXTENSIONS_PCO;
+entries[n_entries]->cids[0] = MBIM_CID_MS_BASIC_CONNECT_EXTENSIONS_PCO;
 n_entries++;
 }
 
-- 
2.19.1.930.g4563a0d9d0-goog

___
ModemManager-devel mailing list
ModemManager-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel


[PATCH 2/2] libqcdm: remove useless checks on always true condition

2018-10-27 Thread Ben Chan
result.c: In function ‘qcdm_result_add_u8_array’:
result.c:338:36: error: comparison of unsigned expression >= 0 is always true 
[-Werror=type-limits]
 qcdm_return_if_fail (array_len >= 0);

result.c: In function ‘qcdm_result_add_u16_array’:
result.c:418:36: error: comparison of unsigned expression >= 0 is always true 
[-Werror=type-limits]
 qcdm_return_if_fail (array_len >= 0);
^
---
 libqcdm/src/result.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/libqcdm/src/result.c b/libqcdm/src/result.c
index 83c61804..65f6c6a5 100644
--- a/libqcdm/src/result.c
+++ b/libqcdm/src/result.c
@@ -335,7 +335,6 @@ qcdm_result_add_u8_array (QcdmResult *r,
 qcdm_return_if_fail (r->refcount > 0);
 qcdm_return_if_fail (key != NULL);
 qcdm_return_if_fail (array != NULL);
-qcdm_return_if_fail (array_len >= 0);
 
 v = val_new_u8_array (key, array, array_len);
 qcdm_return_if_fail (v != NULL);
@@ -415,7 +414,6 @@ qcdm_result_add_u16_array (QcdmResult *r,
 qcdm_return_if_fail (r->refcount > 0);
 qcdm_return_if_fail (key != NULL);
 qcdm_return_if_fail (array != NULL);
-qcdm_return_if_fail (array_len >= 0);
 
 v = val_new_u16_array (key, array, array_len);
 qcdm_return_if_fail (v != NULL);
-- 
2.19.1.568.g152ad8e336-goog

___
ModemManager-devel mailing list
ModemManager-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel


[PATCH 1/2] modem-helpers: remove useless checks on always true condition

2018-10-27 Thread Ben Chan
mm-modem-helpers.c:3075:31: error: comparison of unsigned expression >= 0 is 
always true [-Werror=type-limits]
 g_return_val_if_fail (idx >= 0, NULL);
   ^
---
 src/mm-modem-helpers.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/src/mm-modem-helpers.c b/src/mm-modem-helpers.c
index 87e3754a..1da47a98 100644
--- a/src/mm-modem-helpers.c
+++ b/src/mm-modem-helpers.c
@@ -3072,7 +3072,6 @@ cind_response_new (const gchar *desc, guint idx, gint 
min, gint max)
 gchar *p;
 
 g_return_val_if_fail (desc != NULL, NULL);
-g_return_val_if_fail (idx >= 0, NULL);
 
 r = g_malloc0 (sizeof (MM3gppCindResponse));
 
-- 
2.19.1.568.g152ad8e336-goog

___
ModemManager-devel mailing list
ModemManager-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel


[PATCH] build: ignore generated ChangeLog

2018-10-26 Thread Ben Chan
---
 .gitignore | 1 +
 1 file changed, 1 insertion(+)

diff --git a/.gitignore b/.gitignore
index 94023506..9846a32f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -27,6 +27,7 @@ Makefile.in
 /libtool
 /TAGS
 /ABOUT-NLS
+/ChangeLog
 
 /include/ModemManager-version.h
 /include/ModemManager-names.h
-- 
2.19.1.568.g152ad8e336-goog

___
ModemManager-devel mailing list
ModemManager-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel


Re: [PATCH] ublox: fix username and password passed to +UAUTHREQ

2018-10-26 Thread Ben Chan
On Fri, Oct 26, 2018 at 2:22 PM Dan Williams  wrote:
>
> On Fri, 2018-10-26 at 10:59 -0700, Ben Chan wrote:
> > ---
> >  plugins/ublox/mm-broadband-bearer-ublox.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
>
> LGTM
>

Pushed to master. Thanks!
___
ModemManager-devel mailing list
ModemManager-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel


Re: [BUG] TOBY-L210: Bearer's user and password are swapped in +UAUTHREQ command

2018-10-26 Thread Ben Chan
Based on a few AT command reference found on u-blox website, it does
seem like the username and password passed to +UAUTHREQ are swapped in
ModemManager.  I don't have any u-blox modem to verify, but you can
try this patch:

https://lists.freedesktop.org/archives/modemmanager-devel/2018-October/006803.html

On Fri, Oct 26, 2018 at 10:48 AM Baryshnikov, Maxim (Digiteq
Automotive)  wrote:
>
> Hello everyone,
>
> I would like to report a small bug into bearer’s connection on 
> TOBY-L210. Here follows the information about my hardware (from mmcli):
>
>
>
> root@zynq7:~# ModemManager --version
>
>
>
> ModemManager 1.8.2
>
> Copyright (C) 2008-2017 The ModemManager authors
>
> License GPLv2+: GNU GPL version 2 or later 
> 
>
> This is free software: you are free to change and redistribute it.
>
> There is NO WARRANTY, to the extent permitted by law.
>
>
>
> root@zynq7:~# mmcli -m 0
>
>
>
> /org/freedesktop/ModemManager1/Modem/0 (device id 
> '9be611a4f382a582972f20fa86efbaa8f6b02918')
>
>   -
>
>   Hardware |   manufacturer: 'u-blox'
>
>|  model: 'TOBY-L210'
>
>|   revision: '15.63'
>
>|   H/W revision: 'unknown'
>
>|  supported: 'gsm-umts, lte'
>
>|current: 'gsm-umts, lte'
>
>|   equipment id: ''
>
>   -
>
>   System   | device: 
> '/sys/devices/soc0/amba/e0002000.usb/ci_hdrc.0/usb1/1-1/1-1.2'
>
>|drivers: 'cdc_acm, cdc_ether'
>
>| plugin: 'u-blox'
>
>|   primary port: 'ttyACM1'
>
>|  ports: 'ttyACM1 (at), ttyACM0 (at), wwan0 (net), 
> ttyACM2 (at)'
>
>   -
>
>   Numbers  |   own : 'unknown'
>
>   -
>
>   Status   |   lock: 'none'
>
>   | unlock retries: 'sim-pin (3), sim-pin2 (3), sim-puk (10), 
> sim-puk2 (10)'
>
>|  state: 'enabled'
>
>|power state: 'on'
>
>|access tech: 'unknown'
>
>| signal quality: '40' (recent)
>
>   -
>
>   Modes|  supported: 'allowed: 2g; preferred: none
>
>|  allowed: 2g, 3g; preferred: none
>
>|  allowed: 2g, 3g; preferred: 2g
>
>|  allowed: 2g, 3g; preferred: 3g
>
>|  allowed: 3g; preferred: none
>
>|  allowed: 4g; preferred: none
>
>|  allowed: 2g, 3g, 4g; preferred: none
>
>|  allowed: 2g, 3g, 4g; preferred: 2g
>
>|  allowed: 2g, 3g, 4g; preferred: 3g
>
>|  allowed: 2g, 3g, 4g; preferred: 4g
>
>|  allowed: 2g, 4g; preferred: none
>
>|  allowed: 2g, 4g; preferred: 2g
>
>|  allowed: 2g, 4g; preferred: 4g
>
>|  allowed: 3g, 4g; preferred: none
>
>|  allowed: 3g, 4g; preferred: 3g
>
>|  allowed: 3g, 4g; preferred: 4g'
>
>|current: 'allowed: 2g, 3g, 4g; preferred: 4g'
>
>   -
>
>   Bands|  supported: 'egsm, dcs, pcs, g850, utran-1, utran-3, 
> utran-4, utran-6, utran-5, utran-8, utran-2, utran-7, eutran-1, eutran-2, 
> eutran-3, eutran-4, eutran-5, eutran-7, eutran-8, eutran-11, eutran-13, 
> eutran-17, eutran-20, utran-11'
>
>|current: 'egsm, dcs, pcs, g850, utran-3, utran-5, 
> utran-8, utran-2, eutran-2, eutran-3, eutran-5, eutran-8'
>
>   -
>
>   IP   |  supported: 'ipv4, ipv6, ipv4v6'
>
>   -
>
>   3GPP |   imei: ''
>
>|  enabled locks: 'none'
>
>|operator id: 'unknown'
>
>|  operator name: 'unknown'
>
>|   subscription: 'unknown'
>
>|   registration: 'unknown'
>
>|EPS UE mode: 'csps-2'
>
>   -
>
>   SIM  |   path: '/org/freedesktop/ModemManager1/SIM/0'
>
>
>
>   -
>
>   Bearers  |  paths: 'none'
>
>
>
> While it is in a router mode and uses ethernet-over-usb interface, I’ve 
> noticed that when I connect to the bearer, the credentials are swapped in
> AT+UAUTHREQ command. The order of user and password is not correct, at least 
> in accordance with TOBY-L2 AT commands manual. You could see it in the log 
> below.
>
>
>
> Oct 26 17:13:19 zynq7 ModemManager[10016]:  (ttyACM1) device open 
> count is 2 (open)
>
> Oct 26 17:13:19 zynq7 ModemManager[10016]:  (ttyACM1): --> 
> 'AT+CIND?'
>
> Oct 26 17:13:19 zynq7 ModemManager[10016]:  (ttyACM1): <-- 
> '+CIND: 5,2,0,0,0,0,1,0,1,0,0,1'
>
> Oct 26 17:13:19 zynq7 ModemManager[10016]:  

[PATCH] ublox: fix username and password passed to +UAUTHREQ

2018-10-26 Thread Ben Chan
---
 plugins/ublox/mm-broadband-bearer-ublox.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/plugins/ublox/mm-broadband-bearer-ublox.c 
b/plugins/ublox/mm-broadband-bearer-ublox.c
index 1adcaa26..76f307c8 100644
--- a/plugins/ublox/mm-broadband-bearer-ublox.c
+++ b/plugins/ublox/mm-broadband-bearer-ublox.c
@@ -457,8 +457,8 @@ out:
 cmd = g_strdup_printf ("+UAUTHREQ=%u,%u,%s,%s",
ctx->cid,
ublox_auth,
-   quoted_password,
-   quoted_user);
+   quoted_user,
+   quoted_password);
 
 g_free (quoted_user);
 g_free (quoted_password);
-- 
2.19.1.568.g152ad8e336-goog

___
ModemManager-devel mailing list
ModemManager-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel


[review] Use QMI UIM service to read ICCID and IMSI when needed

2018-10-22 Thread Ben Chan
https://gitlab.freedesktop.org/mobile-broadband/ModemManager/merge_requests/48

This set of patches extends MMSimQmi to use the QMI_UIM_READ_TRANSPARENT to
read ICCID and IMSI when the deprecated QMI_DMS_UIM_GET_ICCID /
QMI_DMS_UIM_GET_IMSI commands aren't available on newer QMI modems.

###

Hi Aleksander and Dan,

Do you have a few QMI modems to try out these patches?

Thanks,
Ben
___
ModemManager-devel mailing list
ModemManager-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel


[PATCH] sierra: remove unused 'self' variable in scact_periodic_query_ready()

2018-10-20 Thread Ben Chan
---
 plugins/sierra/mm-broadband-bearer-sierra.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/plugins/sierra/mm-broadband-bearer-sierra.c 
b/plugins/sierra/mm-broadband-bearer-sierra.c
index 1943d1ac..3a881498 100644
--- a/plugins/sierra/mm-broadband-bearer-sierra.c
+++ b/plugins/sierra/mm-broadband-bearer-sierra.c
@@ -69,7 +69,6 @@ scact_periodic_query_ready (MMBaseModem  *modem,
 GAsyncResult *res,
 GTask*task)
 {
-MMBroadbandBearer*self;
 const gchar  *response;
 GError   *error = NULL;
 GList*pdp_active_list = NULL;
@@ -77,7 +76,6 @@ scact_periodic_query_ready (MMBaseModem  *modem,
 MMBearerConnectionStatus  status = MM_BEARER_CONNECTION_STATUS_UNKNOWN;
 guint cid;
 
-self = MM_BROADBAND_BEARER (g_task_get_source_object (task));
 cid = GPOINTER_TO_UINT (g_task_get_task_data (task));
 
 response = mm_base_modem_at_command_finish (modem, res, );
-- 
2.19.1.568.g152ad8e336-goog

___
ModemManager-devel mailing list
ModemManager-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel


[PATCH] broadband-bearer: remove unused 'self' variables

2018-10-20 Thread Ben Chan
---
 src/mm-broadband-bearer.c | 5 -
 1 file changed, 5 deletions(-)

diff --git a/src/mm-broadband-bearer.c b/src/mm-broadband-bearer.c
index 1b13921a..b5692d43 100644
--- a/src/mm-broadband-bearer.c
+++ b/src/mm-broadband-bearer.c
@@ -1410,11 +1410,8 @@ data_flash_cdma_ready (MMPortSerial *data,
GAsyncResult *res,
GTask *task)
 {
-MMBroadbandBearer *self;
 GError *error = NULL;
 
-self = g_task_get_source_object (task);
-
 mm_port_serial_flash_finish (data, res, );
 
 /* We kept the serial port open during connection, now we close that open
@@ -1540,11 +1537,9 @@ data_flash_3gpp_ready (MMPortSerial *data,
GAsyncResult *res,
GTask *task)
 {
-MMBroadbandBearer *self;
 DetailedDisconnectContext *ctx;
 GError *error = NULL;
 
-self = g_task_get_source_object (task);
 ctx = g_task_get_task_data (task);
 
 mm_port_serial_flash_finish (data, res, );
-- 
2.19.1.568.g152ad8e336-goog

___
ModemManager-devel mailing list
ModemManager-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel


[PATCH] xmm: remove unused 'priv' variable in xact_query_bands_ready()

2018-10-20 Thread Ben Chan
---
 plugins/xmm/mm-shared-xmm.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/plugins/xmm/mm-shared-xmm.c b/plugins/xmm/mm-shared-xmm.c
index fcddee10..cbc7c7b4 100644
--- a/plugins/xmm/mm-shared-xmm.c
+++ b/plugins/xmm/mm-shared-xmm.c
@@ -297,11 +297,8 @@ xact_query_bands_ready (MMBaseModem  *self,
 {
 const gchar *response;
 GError  *error = NULL;
-Private *priv;
 GArray  *result = NULL;
 
-priv = get_private (MM_SHARED_XMM (self));
-
 response = mm_base_modem_at_command_finish (self, res, );
 if (!response ||
 !mm_xmm_parse_xact_query_response (response, NULL, , ))
-- 
2.19.1.568.g152ad8e336-goog

___
ModemManager-devel mailing list
ModemManager-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel


[PATCH] base-call: remove unused 'self' variables

2018-10-20 Thread Ben Chan
---
 src/mm-base-call.c | 9 -
 1 file changed, 9 deletions(-)

diff --git a/src/mm-base-call.c b/src/mm-base-call.c
index c128b601..79d296d9 100644
--- a/src/mm-base-call.c
+++ b/src/mm-base-call.c
@@ -875,12 +875,9 @@ call_start_ready (MMBaseModem *modem,
   GAsyncResult *res,
   GTask *task)
 {
-MMBaseCall *self;
 GError *error = NULL;
 const gchar *response = NULL;
 
-self = g_task_get_source_object (task);
-
 response = mm_base_modem_at_command_finish (modem, res, );
 
 /* check response for error */
@@ -931,12 +928,9 @@ call_accept_ready (MMBaseModem  *modem,
GAsyncResult *res,
GTask*task)
 {
-MMBaseCall  *self;
 GError  *error = NULL;
 const gchar *response;
 
-self = g_task_get_source_object (task);
-
 response = mm_base_modem_at_command_finish (modem, res, );
 
 /* check response for error */
@@ -983,11 +977,8 @@ call_hangup_ready (MMBaseModem  *modem,
GAsyncResult *res,
GTask*task)
 {
-MMBaseCall *self;
 GError *error = NULL;
 
-self = g_task_get_source_object (task);
-
 mm_base_modem_at_command_finish (modem, res, );
 
 if (error)
-- 
2.19.1.568.g152ad8e336-goog

___
ModemManager-devel mailing list
ModemManager-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel


[review] Deprecate SubscriptionState property from Modem3gpp interface

2018-10-18 Thread Ben Chan
https://gitlab.freedesktop.org/mobile-broadband/ModemManager/merge_requests/47
___
ModemManager-devel mailing list
ModemManager-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel


[PATCH 2/3] core: remove unnecessary NULL checks for g_match_info_free()

2018-10-18 Thread Ben Chan
g_match_info_free() already check if the given pointer is NULL and does
nothing on a NULL pointer.
---
 .../cinterion/mm-modem-helpers-cinterion.c| 12 --
 plugins/huawei/mm-modem-helpers-huawei.c  | 21 ++--
 plugins/mbm/mm-modem-helpers-mbm.c|  3 +--
 plugins/mtk/mm-broadband-modem-mtk.c  | 13 --
 plugins/novatel/mm-broadband-modem-novatel.c  |  3 +--
 plugins/sierra/mm-broadband-modem-sierra.c|  6 ++---
 plugins/sierra/mm-modem-helpers-sierra.c  |  3 +--
 plugins/ublox/mm-modem-helpers-ublox.c| 24 +++
 plugins/wavecom/mm-broadband-modem-wavecom.c  |  3 +--
 plugins/xmm/mm-modem-helpers-xmm.c| 10 +++-
 plugins/zte/mm-broadband-modem-zte.c  |  3 +--
 src/mm-modem-helpers.c| 24 ++-
 12 files changed, 40 insertions(+), 85 deletions(-)

diff --git a/plugins/cinterion/mm-modem-helpers-cinterion.c 
b/plugins/cinterion/mm-modem-helpers-cinterion.c
index 86cea6c1..2afd11a4 100644
--- a/plugins/cinterion/mm-modem-helpers-cinterion.c
+++ b/plugins/cinterion/mm-modem-helpers-cinterion.c
@@ -147,8 +147,7 @@ mm_cinterion_parse_scfg_test (const gchar *response,
 g_free (maxbandstr);
 }
 
-if (match_info)
-g_match_info_free (match_info);
+g_match_info_free (match_info);
 g_regex_unref (r);
 
 if (!bands)
@@ -234,8 +233,7 @@ mm_cinterion_parse_scfg_response (const gchar *response,
 g_free (currentstr);
 }
 
-if (match_info)
-g_match_info_free (match_info);
+g_match_info_free (match_info);
 g_regex_unref (r);
 
 if (!bands)
@@ -341,8 +339,7 @@ mm_cinterion_parse_cnmi_test (const gchar *response,
 
 out:
 
-if (match_info)
-g_match_info_free (match_info);
+g_match_info_free (match_info);
 g_regex_unref (r);
 
 if (inner_error) {
@@ -457,8 +454,7 @@ mm_cinterion_parse_sind_response (const gchar *response,
 } else
 errors++;
 
-if (match_info)
-g_match_info_free (match_info);
+g_match_info_free (match_info);
 g_regex_unref (r);
 
 if (errors > 0) {
diff --git a/plugins/huawei/mm-modem-helpers-huawei.c 
b/plugins/huawei/mm-modem-helpers-huawei.c
index 2aac3d60..70de4f54 100644
--- a/plugins/huawei/mm-modem-helpers-huawei.c
+++ b/plugins/huawei/mm-modem-helpers-huawei.c
@@ -257,8 +257,7 @@ mm_huawei_parse_dhcp_response (const char *reply,
 }
 }
 
-if (match_info)
-g_match_info_free (match_info);
+g_match_info_free (match_info);
 g_regex_unref (r);
 return matched;
 }
@@ -324,8 +323,7 @@ mm_huawei_parse_sysinfo_response (const char *reply,
 }
 }
 
-if (match_info)
-g_match_info_free (match_info);
+g_match_info_free (match_info);
 g_regex_unref (r);
 return matched;
 }
@@ -389,8 +387,7 @@ mm_huawei_parse_sysinfoex_response (const char *reply,
 mm_get_uint_from_match_info (match_info, 8, out_sys_submode);
 }
 
-if (match_info)
-g_match_info_free (match_info);
+g_match_info_free (match_info);
 g_regex_unref (r);
 return matched;
 }
@@ -1257,8 +1254,7 @@ gboolean mm_huawei_parse_nwtime_response (const gchar 
*response,
 }
 }
 
-if (match_info)
-g_match_info_free (match_info);
+g_match_info_free (match_info);
 g_regex_unref (r);
 
 return ret;
@@ -1329,8 +1325,7 @@ gboolean mm_huawei_parse_time_response (const gchar 
*response,
 }
 }
 
-if (match_info)
-g_match_info_free (match_info);
+g_match_info_free (match_info);
 g_regex_unref (r);
 
 return ret;
@@ -1400,8 +1395,7 @@ mm_huawei_parse_hcsq_response (const gchar *response,
 ret = TRUE;
 
 done:
-if (match_info)
-g_match_info_free (match_info);
+g_match_info_free (match_info);
 g_regex_unref (r);
 
 return ret;
@@ -1463,8 +1457,7 @@ mm_huawei_parse_cvoice_response (const gchar  *response,
 }
 }
 
-if (match_info)
-g_match_info_free (match_info);
+g_match_info_free (match_info);
 g_regex_unref (r);
 
 return ret;
diff --git a/plugins/mbm/mm-modem-helpers-mbm.c 
b/plugins/mbm/mm-modem-helpers-mbm.c
index ca024ddb..18656e57 100644
--- a/plugins/mbm/mm-modem-helpers-mbm.c
+++ b/plugins/mbm/mm-modem-helpers-mbm.c
@@ -159,8 +159,7 @@ mm_mbm_parse_e2ipcfg_response (const gchar *response,
 }
 
 done:
-if (match_info)
-g_match_info_free (match_info);
+g_match_info_free (match_info);
 g_regex_unref (r);
 return !!*ip_config;
 }
diff --git a/plugins/mtk/mm-broadband-modem-mtk.c 
b/plugins/mtk/mm-broadband-modem-mtk.c
index 475a63ac..0f8aaf79 100644
--- a/plugins/mtk/mm-broadband-modem-mtk.c
+++ b/plugins/mtk/mm-broadband-modem-mtk.c
@@ -122,8 +122,7 @@ load_unlock_retries_ready (MMBaseModem *self,
 }
 g_object_unref (task);
 
-if (match_info)
-g_match_info_free (match_info);
+g_match_info_free (match_info);
 

[PATCH 1/3] core: remove unnecessary NULL checks for g_free()

2018-10-18 Thread Ben Chan
g_free() already check if the given pointer is NULL and does nothing on
a NULL pointer.
---
 libmm-glib/mm-location-gps-raw.c | 3 +--
 src/mm-base-sms.c| 6 ++
 src/mm-broadband-bearer.c| 3 +--
 3 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/libmm-glib/mm-location-gps-raw.c b/libmm-glib/mm-location-gps-raw.c
index 5241ba7c..4cfe7f08 100644
--- a/libmm-glib/mm-location-gps-raw.c
+++ b/libmm-glib/mm-location-gps-raw.c
@@ -217,8 +217,7 @@ mm_location_gps_raw_add_trace (MMLocationGpsRaw *self,
 
 if (g_regex_match (self->priv->gga_regex, trace, 0, _info)) {
 /* UTC time */
-if (self->priv->utc_time)
-g_free (self->priv->utc_time);
+g_free (self->priv->utc_time);
 self->priv->utc_time = g_match_info_fetch (match_info, 1);
 
 /* Latitude */
diff --git a/src/mm-base-sms.c b/src/mm-base-sms.c
index f9c16013..e117bef7 100644
--- a/src/mm-base-sms.c
+++ b/src/mm-base-sms.c
@@ -215,10 +215,8 @@ generate_3gpp_submit_pdus (MMBaseSms *self,
 }
 
 /* Free array (not contents, which were taken for the part) */
-if (split_text)
-g_free (split_text);
-if (split_data)
-g_free (split_data);
+g_free (split_text);
+g_free (split_data);
 
 /* Set additional multipart specific properties */
 if (n_parts > 1) {
diff --git a/src/mm-broadband-bearer.c b/src/mm-broadband-bearer.c
index bf02c13a..1b13921a 100644
--- a/src/mm-broadband-bearer.c
+++ b/src/mm-broadband-bearer.c
@@ -1376,8 +1376,7 @@ detailed_disconnect_finish (MMBroadbandBearer *self,
 static void
 detailed_disconnect_context_free (DetailedDisconnectContext *ctx)
 {
-if (ctx->cgact_command)
-g_free (ctx->cgact_command);
+g_free (ctx->cgact_command);
 g_object_unref (ctx->data);
 g_object_unref (ctx->primary);
 if (ctx->secondary)
-- 
2.19.1.568.g152ad8e336-goog

___
ModemManager-devel mailing list
ModemManager-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel


[PATCH 3/3] core: use g_clear_pointer() to avoid explicitly checking and resetting pointers

2018-10-18 Thread Ben Chan
---
 src/mm-base-sms.c | 10 ++
 src/mm-broadband-modem-mbim.c | 10 ++
 2 files changed, 4 insertions(+), 16 deletions(-)

diff --git a/src/mm-base-sms.c b/src/mm-base-sms.c
index e117bef7..25a02617 100644
--- a/src/mm-base-sms.c
+++ b/src/mm-base-sms.c
@@ -939,10 +939,7 @@ sms_store_next_part (GTask *task)
 return;
 }
 
-if (ctx->msg_data) {
-g_free (ctx->msg_data);
-ctx->msg_data = NULL;
-}
+g_clear_pointer (>msg_data, g_free);
 
 if (!sms_get_store_or_send_command ((MMSmsPart *)ctx->current->data,
 ctx->use_pdu_mode,
@@ -1218,10 +1215,7 @@ sms_send_next_part (GTask *task)
 
 /* Generic send */
 
-if (ctx->msg_data) {
-g_free (ctx->msg_data);
-ctx->msg_data = NULL;
-}
+g_clear_pointer (>msg_data, g_free);
 
 if (!sms_get_store_or_send_command ((MMSmsPart *)ctx->current->data,
 ctx->use_pdu_mode,
diff --git a/src/mm-broadband-modem-mbim.c b/src/mm-broadband-modem-mbim.c
index fa5389cf..8f95e60e 100644
--- a/src/mm-broadband-modem-mbim.c
+++ b/src/mm-broadband-modem-mbim.c
@@ -2421,14 +2421,8 @@ update_registration_info (MMBroadbandModemMbim *self,
 self->priv->current_operator_name = operator_name_take;
 }
 } else {
-if (self->priv->current_operator_id) {
-g_free (self->priv->current_operator_id);
-self->priv->current_operator_id = NULL;
-}
-if (self->priv->current_operator_name) {
-g_free (self->priv->current_operator_name);
-self->priv->current_operator_name = NULL;
-}
+g_clear_pointer (>priv->current_operator_id, g_free);
+g_clear_pointer (>priv->current_operator_name, g_free);
 g_free (operator_id_take);
 g_free (operator_name_take);
 }
-- 
2.19.1.568.g152ad8e336-goog

___
ModemManager-devel mailing list
ModemManager-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel


[PATCH] modem-helpers-qmi: include string.h for memset()

2018-10-16 Thread Ben Chan
This patch fixes the following compiler warning:

mm-modem-helpers-qmi.c:568:5: error: implicitly declaring library function 
'memset' with type 'void *(void *, int, unsigned int)' 
[-Werror,-Wimplicit-function-declaration]
memset (extended_qmi_lte_bands, 0, extended_qmi_lte_bands_size * sizeof 
(guint64));
^
---
 src/mm-modem-helpers-qmi.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/mm-modem-helpers-qmi.c b/src/mm-modem-helpers-qmi.c
index e48d2eb7..e5e3243c 100644
--- a/src/mm-modem-helpers-qmi.c
+++ b/src/mm-modem-helpers-qmi.c
@@ -14,6 +14,8 @@
  * Copyright (C) 2018 Aleksander Morgado 
  */
 
+#include 
+
 #include 
 #include 
 
-- 
2.19.1.331.ge82ca0e54c-goog

___
ModemManager-devel mailing list
ModemManager-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel


Re: [PATCH] sim-qmi: avoid unnecessary MM_SIM_QMI() call on MMSimQmi object

2018-10-16 Thread Ben Chan
On Tue, Oct 16, 2018 at 9:42 AM Dan Williams  wrote:

> On Wed, 2018-10-10 at 23:11 -0700, Ben Chan wrote:
> > ---
> >  src/mm-sim-qmi.c | 12 ++--
> >  1 file changed, 6 insertions(+), 6 deletions(-)
>
> LGTM
>
>
Pushed to git master. Thanks!
___
ModemManager-devel mailing list
ModemManager-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel


[PATCH] sim-qmi: avoid unnecessary MM_SIM_QMI() call on MMSimQmi object

2018-10-11 Thread Ben Chan
---
 src/mm-sim-qmi.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/mm-sim-qmi.c b/src/mm-sim-qmi.c
index 725e073e..e8c0afef 100644
--- a/src/mm-sim-qmi.c
+++ b/src/mm-sim-qmi.c
@@ -449,7 +449,7 @@ uim_verify_pin (MMSimQmi *self,
 QmiClient *client = NULL;
 
 if (!ensure_qmi_client (task,
-MM_SIM_QMI (self),
+self,
 QMI_SERVICE_UIM, ))
 return;
 
@@ -504,7 +504,7 @@ dms_uim_verify_pin (MMSimQmi *self,
 QmiClient *client = NULL;
 
 if (!ensure_qmi_client (NULL,
-MM_SIM_QMI (self),
+self,
 QMI_SERVICE_DMS, )) {
 /* Very unlikely that this will ever happen, but anyway, try with
  * UIM service instead */
@@ -605,7 +605,7 @@ uim_unblock_pin (MMSimQmi *self,
 UnblockPinContext *ctx;
 
 if (!ensure_qmi_client (task,
-MM_SIM_QMI (self),
+self,
 QMI_SERVICE_UIM, ))
 return;
 
@@ -664,7 +664,7 @@ dms_uim_unblock_pin (MMSimQmi *self,
 UnblockPinContext *ctx;
 
 if (!ensure_qmi_client (NULL,
-MM_SIM_QMI (self),
+self,
 QMI_SERVICE_DMS, )) {
 /* Very unlikely that this will ever happen, but anyway, try with
  * UIM service instead */
@@ -772,7 +772,7 @@ uim_change_pin (MMSimQmi *self,
 ChangePinContext *ctx;
 
 if (!ensure_qmi_client (task,
-MM_SIM_QMI (self),
+self,
 QMI_SERVICE_UIM, ))
 return;
 
@@ -831,7 +831,7 @@ dms_uim_change_pin (MMSimQmi *self,
 ChangePinContext *ctx;
 
 if (!ensure_qmi_client (NULL,
-MM_SIM_QMI (self),
+self,
 QMI_SERVICE_DMS, )) {
 /* Very unlikely that this will ever happen, but anyway, try with
  * UIM service instead */
-- 
2.19.0.605.g01d371f741-goog

___
ModemManager-devel mailing list
ModemManager-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel


[PATCH] base-modem: remove explicit GDestroyNotify cast on g_object_unref

2018-10-05 Thread Ben Chan
g_object_unref is in form of  `void (*)(gpointer)`, which matches the
GDestroyNotify signature. An explicit GDestroyNotify cast on
g_object_unref is thus not needed.
---
 src/mm-base-modem.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/mm-base-modem.c b/src/mm-base-modem.c
index d748b374..8ac52d1b 100644
--- a/src/mm-base-modem.c
+++ b/src/mm-base-modem.c
@@ -379,7 +379,7 @@ disable_ready (MMBaseModem  *self,
 }
 g_clear_error ();
 
-g_list_free_full (disable_tasks, (GDestroyNotify)g_object_unref);
+g_list_free_full (disable_tasks, g_object_unref);
 }
 
 void
@@ -439,7 +439,7 @@ enable_ready (MMBaseModem  *self,
 }
 g_clear_error ();
 
-g_list_free_full (enable_tasks, (GDestroyNotify)g_object_unref);
+g_list_free_full (enable_tasks, g_object_unref);
 }
 
 void
-- 
2.19.0.605.g01d371f741-goog

___
ModemManager-devel mailing list
ModemManager-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel


[PATCH 2/2] port-serial: port mm_port_serial_flash to use GTask

2018-09-27 Thread Ben Chan
---
 src/mm-port-serial.c | 92 +---
 1 file changed, 44 insertions(+), 48 deletions(-)

diff --git a/src/mm-port-serial.c b/src/mm-port-serial.c
index c4fee187..41a5fc27 100644
--- a/src/mm-port-serial.c
+++ b/src/mm-port-serial.c
@@ -111,7 +111,7 @@ struct _MMPortSerialPrivate {
 
 guint connected_id;
 
-gpointer flash_ctx;
+GTask *flash_task;
 GTask *reopen_task;
 };
 
@@ -1690,20 +1690,15 @@ set_speed (MMPortSerial *self, speed_t speed, GError 
**error)
 /* Flash */
 
 typedef struct {
-GSimpleAsyncResult *result;
-MMPortSerial *self;
 speed_t current_speed;
 guint flash_id;
 } FlashContext;
 
 static void
-flash_context_complete_and_free (FlashContext *ctx)
+flash_context_free (FlashContext *ctx)
 {
 if (ctx->flash_id)
 g_source_remove (ctx->flash_id);
-g_simple_async_result_complete_in_idle (ctx->result);
-g_object_unref (ctx->result);
-g_object_unref (ctx->self);
 g_slice_free (FlashContext, ctx);
 }
 
@@ -1712,44 +1707,46 @@ mm_port_serial_flash_finish (MMPortSerial *port,
  GAsyncResult *res,
  GError **error)
 {
-return !g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT 
(res), error);
+return g_task_propagate_boolean (G_TASK (res), error);
 }
 
 void
 mm_port_serial_flash_cancel (MMPortSerial *self)
 {
-FlashContext *ctx;
+GTask *task;
 
-if (!self->priv->flash_ctx)
+if (!self->priv->flash_task)
 return;
 
-/* Recover context */
-ctx = (FlashContext *)self->priv->flash_ctx;
-self->priv->flash_ctx = NULL;
+/* Recover task */
+task = self->priv->flash_task;
+self->priv->flash_task = NULL;
 
-g_simple_async_result_set_error (ctx->result,
- MM_CORE_ERROR,
- MM_CORE_ERROR_CANCELLED,
- "Flash cancelled");
-flash_context_complete_and_free (ctx);
+g_task_return_new_error (task,
+ MM_CORE_ERROR,
+ MM_CORE_ERROR_CANCELLED,
+ "Flash cancelled");
+g_object_unref (task);
 }
 
 static gboolean
 flash_do (MMPortSerial *self)
 {
+GTask *task;
 FlashContext *ctx;
 GError *error = NULL;
 
-/* Recover context */
-g_assert (self->priv->flash_ctx != NULL);
-ctx = (FlashContext *)self->priv->flash_ctx;
-self->priv->flash_ctx = NULL;
+/* Recover task */
+g_assert (self->priv->flash_task != NULL);
+task = self->priv->flash_task;
+self->priv->flash_task = NULL;
 
+ctx = g_task_get_task_data (task);
 ctx->flash_id = 0;
 
 if (self->priv->flash_ok && mm_port_get_subsys (MM_PORT (self)) == 
MM_PORT_SUBSYS_TTY) {
 if (ctx->current_speed) {
-if (!set_speed (ctx->self, ctx->current_speed, ))
+if (!set_speed (self, ctx->current_speed, ))
 g_assert (error);
 } else {
 error = g_error_new_literal (MM_SERIAL_ERROR,
@@ -1759,10 +1756,10 @@ flash_do (MMPortSerial *self)
 }
 
 if (error)
-g_simple_async_result_take_error (ctx->result, error);
+g_task_return_error (task, error);
 else
-g_simple_async_result_set_op_res_gboolean (ctx->result, TRUE);
-flash_context_complete_and_free (ctx);
+g_task_return_boolean (task, TRUE);
+g_object_unref (task);
 
 return G_SOURCE_REMOVE;
 }
@@ -1775,6 +1772,7 @@ mm_port_serial_flash (MMPortSerial *self,
   gpointer user_data)
 {
 FlashContext *ctx;
+GTask *task;
 GError *error = NULL;
 gboolean success;
 
@@ -1782,33 +1780,31 @@ mm_port_serial_flash (MMPortSerial *self,
 
 /* Setup context */
 ctx = g_slice_new0 (FlashContext);
-ctx->self = g_object_ref (self);
-ctx->result = g_simple_async_result_new (G_OBJECT (self),
- callback,
- user_data,
- mm_port_serial_flash);
+
+task = g_task_new (self, NULL, callback, user_data);
+g_task_set_task_data (task, ctx, (GDestroyNotify)flash_context_free);
 
 if (!mm_port_serial_is_open (self)) {
-g_simple_async_result_set_error (ctx->result,
- MM_SERIAL_ERROR,
- MM_SERIAL_ERROR_NOT_OPEN,
- "The serial port is not open.");
-flash_context_complete_and_free (ctx);
+g_task_return_new_error (task,
+ MM_SERIAL_ERROR,
+ MM_SERIAL_ERROR_NOT_OPEN,
+ "The serial port is not open.");
+g_object_unref (task);
 return;
 }
 
-if (self->priv->flash_ctx) {
-g_simple_async_result_set_error (ctx->result,
- 

[PATCH 1/2] port-serial: port mm_port_serial_reopen to use GTask

2018-09-27 Thread Ben Chan
---
 src/mm-port-serial.c | 84 +---
 1 file changed, 40 insertions(+), 44 deletions(-)

diff --git a/src/mm-port-serial.c b/src/mm-port-serial.c
index 38d4e477..c4fee187 100644
--- a/src/mm-port-serial.c
+++ b/src/mm-port-serial.c
@@ -112,7 +112,7 @@ struct _MMPortSerialPrivate {
 guint connected_id;
 
 gpointer flash_ctx;
-gpointer reopen_ctx;
+GTask *reopen_task;
 };
 
 /*/
@@ -1166,7 +1166,7 @@ mm_port_serial_open (MMPortSerial *self, GError **error)
 return FALSE;
 }
 
-if (self->priv->reopen_ctx) {
+if (self->priv->reopen_task) {
 g_set_error (error,
  MM_SERIAL_ERROR,
  MM_SERIAL_ERROR_OPEN_FAILED,
@@ -1516,20 +1516,15 @@ port_serial_close_force (MMPortSerial *self)
 /* Reopen */
 
 typedef struct {
-MMPortSerial *self;
-GSimpleAsyncResult *result;
 guint initial_open_count;
 guint reopen_id;
 } ReopenContext;
 
 static void
-reopen_context_complete_and_free (ReopenContext *ctx)
+reopen_context_free (ReopenContext *ctx)
 {
 if (ctx->reopen_id)
 g_source_remove (ctx->reopen_id);
-g_simple_async_result_complete_in_idle (ctx->result);
-g_object_unref (ctx->result);
-g_object_unref (ctx->self);
 g_slice_free (ReopenContext, ctx);
 }
 
@@ -1538,54 +1533,56 @@ mm_port_serial_reopen_finish (MMPortSerial *port,
   GAsyncResult *res,
   GError **error)
 {
-return !g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT 
(res), error);
+return g_task_propagate_boolean (G_TASK (res), error);
 }
 
 static void
 port_serial_reopen_cancel (MMPortSerial *self)
 {
-ReopenContext *ctx;
+GTask *task;
 
-if (!self->priv->reopen_ctx)
+if (!self->priv->reopen_task)
 return;
 
-/* Recover context */
-ctx = (ReopenContext *)self->priv->reopen_ctx;
-self->priv->reopen_ctx = NULL;
+/* Recover task */
+task = self->priv->reopen_task;
+self->priv->reopen_task = NULL;
 
-g_simple_async_result_set_error (ctx->result,
- MM_CORE_ERROR,
- MM_CORE_ERROR_CANCELLED,
- "Reopen cancelled");
-reopen_context_complete_and_free (ctx);
+g_task_return_new_error (task,
+ MM_CORE_ERROR,
+ MM_CORE_ERROR_CANCELLED,
+ "Reopen cancelled");
+g_object_unref (task);
 }
 
 static gboolean
 reopen_do (MMPortSerial *self)
 {
+GTask *task;
 ReopenContext *ctx;
 GError *error = NULL;
 guint i;
 
-/* Recover context */
-g_assert (self->priv->reopen_ctx != NULL);
-ctx = (ReopenContext *)self->priv->reopen_ctx;
-self->priv->reopen_ctx = NULL;
+/* Recover task */
+g_assert (self->priv->reopen_task != NULL);
+task = self->priv->reopen_task;
+self->priv->reopen_task = NULL;
 
+ctx = g_task_get_task_data (task);
 ctx->reopen_id = 0;
 
 for (i = 0; i < ctx->initial_open_count; i++) {
-if (!mm_port_serial_open (ctx->self, )) {
+if (!mm_port_serial_open (self, )) {
 g_prefix_error (, "Couldn't reopen port (%u): ", i);
 break;
 }
 }
 
 if (error)
-g_simple_async_result_take_error (ctx->result, error);
+g_task_return_error (task, error);
 else
-g_simple_async_result_set_op_res_gboolean (ctx->result, TRUE);
-reopen_context_complete_and_free (ctx);
+g_task_return_boolean (task, TRUE);
+g_object_unref (task);
 
 return G_SOURCE_REMOVE;
 }
@@ -1597,35 +1594,34 @@ mm_port_serial_reopen (MMPortSerial *self,
gpointer user_data)
 {
 ReopenContext *ctx;
+GTask *task;
 guint i;
 
 g_return_if_fail (MM_IS_PORT_SERIAL (self));
 
 /* Setup context */
 ctx = g_slice_new0 (ReopenContext);
-ctx->self = g_object_ref (self);
-ctx->result = g_simple_async_result_new (G_OBJECT (self),
- callback,
- user_data,
- mm_port_serial_reopen);
 ctx->initial_open_count = self->priv->open_count;
 
+task = g_task_new (self, NULL, callback, user_data);
+g_task_set_task_data (task, ctx, (GDestroyNotify)reopen_context_free);
+
 if (self->priv->forced_close) {
-g_simple_async_result_set_error (ctx->result,
- MM_CORE_ERROR,
- MM_CORE_ERROR_FAILED,
- "Serial port has been forced close.");
-reopen_context_complete_and_free (ctx);
+g_task_return_new_error (task,
+ MM_CORE_ERROR,
+ 

[review] Port remaining code in MMBroadbandModem to use GTask

2018-08-30 Thread Ben Chan
https://gitlab.freedesktop.org/mobile-broadband/ModemManager/merge_requests/36
___
ModemManager-devel mailing list
ModemManager-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel


[PATCH] test, modem-helpers: remove unnecessary NULL check for g_free()

2018-08-28 Thread Ben Chan
g_free() handles a NULL pointer properly, so there is no need to have a
NULL check before calling g_free().
---
 src/tests/test-modem-helpers.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/src/tests/test-modem-helpers.c b/src/tests/test-modem-helpers.c
index 483b56f5..4a044c68 100644
--- a/src/tests/test-modem-helpers.c
+++ b/src/tests/test-modem-helpers.c
@@ -3265,8 +3265,7 @@ test_cclk_response (void)
 g_assert (mm_network_timezone_get_leap_seconds (tz) == 
MM_NETWORK_TIMEZONE_LEAP_SECONDS_UNKNOWN);
 }
 
-if (iso8601)
-g_free (iso8601);
+g_free (iso8601);
 
 if (tz)
 g_object_unref (tz);
-- 
2.19.0.rc0.228.g281dcd1b4d0-goog

___
ModemManager-devel mailing list
ModemManager-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel


Re: [review] New 'Pco' property in Modem3gpp interface

2018-08-27 Thread Ben Chan
On Mon, Aug 27, 2018 at 6:31 AM Aleksander Morgado 
wrote:

> Hey Ben,
>
> >
> > See
> https://gitlab.freedesktop.org/mobile-broadband/ModemManager/merge_requests/27
> >
> > This MR adds a 'Pco' property to the Modem3gpp interface for reporting
> > raw PCO values received from the network as we discussed in
> >
> https://lists.freedesktop.org/archives/modemmanager-devel/2018-July/006514.html
> .
> > The current implementation supports MBIM modems that implement the
> > MBIM_CID_PCO notification.  A subsequent MR will migrate the
> > altair-lte plugin to make use of the 'Pco' property, which will then
> > allow us to deprecate the SubscriptionState property in Modem3gpp
> > interface.
> >
>
> These warnings happen now when building master, could you take a look
> at them? They look just like some missing G-I annotation tags
>
>   GISCAN   ModemManager-1.0.gir
> mm-modem-3gpp.c:311: Warning: ModemManager: mm_modem_3gpp_get_pco:
> return value: Missing (element-type) annotation
> mm-pco.h:64: Warning: ModemManager: mm_pco_list_free: argument
> pco_list: Missing (element-type) annotation
> mm-pco.h:65: Warning: ModemManager: mm_pco_list_add: argument
> pco_list: Missing (element-type) annotation
> mm-pco.h:65: Warning: ModemManager: mm_pco_list_add: return value:
> Missing (element-type) annotation
> mm-pco.h:76: Warning: ModemManager: mm_pco_from_variant: return value:
> Missing (transfer) annotation
>   GICOMP   ModemManager-1.0.gir
>

Aleksander, could you try this patch and see if it fixes the issue? Thanks.

https://lists.freedesktop.org/archives/modemmanager-devel/2018-August/006624.html


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


[PATCH] libmm-glib,pco: add missing documentation for MMPco

2018-08-27 Thread Ben Chan
---
 libmm-glib/mm-modem-3gpp.c |  2 +-
 libmm-glib/mm-pco.c| 25 +
 2 files changed, 26 insertions(+), 1 deletion(-)

diff --git a/libmm-glib/mm-modem-3gpp.c b/libmm-glib/mm-modem-3gpp.c
index 360aaef6..80746f98 100644
--- a/libmm-glib/mm-modem-3gpp.c
+++ b/libmm-glib/mm-modem-3gpp.c
@@ -308,7 +308,7 @@ mm_modem_3gpp_get_eps_ue_mode_operation (MMModem3gpp *self)
  * The caller is responsible for freeing the returned #GList with
  * mm_pco_list_free().
  *
- * Returns: (transfer full): A list of #MMPco.
+ * Returns: (element-type ModemManager.Pco) (transfer full): A list of #MMPco.
  */
 GList *
 mm_modem_3gpp_get_pco (MMModem3gpp *self)
diff --git a/libmm-glib/mm-pco.c b/libmm-glib/mm-pco.c
index 7ee347b0..0afa1b4b 100644
--- a/libmm-glib/mm-pco.c
+++ b/libmm-glib/mm-pco.c
@@ -193,6 +193,14 @@ mm_pco_from_variant (GVariant *variant,
 
 /*/
 
+/**
+ * mm_pco_to_variant:
+ * @self: a #MMPco.
+ *
+ * Gets a GVariant representation with signature "(ubay)" of @self.
+ *
+ * Returns: (transfer full): A #GVariant representation of the #MMPco object. 
The returned value should be freed with g_variant_unref().
+ */
 GVariant *
 mm_pco_to_variant (MMPco *self)
 {
@@ -224,12 +232,29 @@ mm_pco_to_variant (MMPco *self)
 
 /*/
 
+/**
+ * mm_pco_list_free:
+ * @pco_list (element-type ModemManager.Pco): a #GList of #MMPco.
+ *
+ * Frees all of the memory used by a #GList of #MMPco.
+ */
 void
 mm_pco_list_free (GList *pco_list)
 {
 g_list_free_full (pco_list, g_object_unref);
 }
 
+/**
+ * mm_pco_list_add:
+ * @pco_list (element-type ModemManager.Pco): a #GList of #MMPco.
+ * @pco:: a #MMPco to add to the given list.
+ *
+ * Adds a #MMPco to a given PCO list. #MMPco objects stored in the order of
+ * their session ID. An existing PCO with the same session ID is overwritten
+ * with the new value.
+ *
+ * Returns: (element-type ModemManager.Pco): the new start of an updated or 
newly allocated #GList of #MMPco.
+ */
 GList *
 mm_pco_list_add (GList *pco_list,
  MMPco *pco)
-- 
2.19.0.rc0.228.g281dcd1b4d0-goog

___
ModemManager-devel mailing list
ModemManager-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel


[PATCH] mbim: fix inconsistency in WITH_QMI guards

2018-08-22 Thread Ben Chan
---
 src/mm-broadband-modem-mbim.c | 4 ++--
 src/mm-port-mbim.c| 4 ++--
 src/mm-port-mbim.h| 2 +-
 src/mm-port-probe.c   | 2 +-
 4 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/mm-broadband-modem-mbim.c b/src/mm-broadband-modem-mbim.c
index eb9e723b..5460fd46 100644
--- a/src/mm-broadband-modem-mbim.c
+++ b/src/mm-broadband-modem-mbim.c
@@ -1895,7 +1895,7 @@ initialization_started (MMBroadbandModem*self,
 return;
 }
 
-#if WITH_QMI && QMI_MBIM_QMUX_SUPPORTED
+#if defined WITH_QMI && QMI_MBIM_QMUX_SUPPORTED
 /* Setup services to open */
 ctx->qmi_services[0] = QMI_SERVICE_DMS;
 ctx->qmi_services[1] = QMI_SERVICE_PDS;
@@ -1905,7 +1905,7 @@ initialization_started (MMBroadbandModem*self,
 
 /* Now open our MBIM port */
 mm_port_mbim_open (ctx->mbim,
-#if WITH_QMI && QMI_MBIM_QMUX_SUPPORTED
+#if defined WITH_QMI && QMI_MBIM_QMUX_SUPPORTED
TRUE, /* With QMI over MBIM support if available */
 #endif
NULL,
diff --git a/src/mm-port-mbim.c b/src/mm-port-mbim.c
index cd6d9f22..11c61116 100644
--- a/src/mm-port-mbim.c
+++ b/src/mm-port-mbim.c
@@ -302,7 +302,7 @@ mbim_device_new_ready (GObject  *unused,
 
 void
 mm_port_mbim_open (MMPortMbim  *self,
-#if WITH_QMI && QMI_MBIM_QMUX_SUPPORTED
+#if defined WITH_QMI && QMI_MBIM_QMUX_SUPPORTED
gboolean try_qmi_over_mbim,
 #endif
GCancellable*cancellable,
@@ -335,7 +335,7 @@ mm_port_mbim_open (MMPortMbim  *self,
 fullpath = g_strdup_printf ("/dev/%s", mm_port_get_device (MM_PORT 
(self)));
 file = g_file_new_for_path (fullpath);
 
-#if WITH_QMI && QMI_MBIM_QMUX_SUPPORTED
+#if defined WITH_QMI && QMI_MBIM_QMUX_SUPPORTED
 /* If we want to try QMI over MBIM, store the GFile as task data */
 if (try_qmi_over_mbim)
 g_task_set_task_data (task, g_object_ref (file), g_object_unref);
diff --git a/src/mm-port-mbim.h b/src/mm-port-mbim.h
index f2606ea7..3bd20e48 100644
--- a/src/mm-port-mbim.h
+++ b/src/mm-port-mbim.h
@@ -55,7 +55,7 @@ GType mm_port_mbim_get_type (void);
 MMPortMbim *mm_port_mbim_new (const gchar *name);
 
 void mm_port_mbim_open (MMPortMbim *self,
-#if WITH_QMI && QMI_MBIM_QMUX_SUPPORTED
+#if defined WITH_QMI && QMI_MBIM_QMUX_SUPPORTED
 gboolean try_qmi_over_mbim,
 #endif
 GCancellable *cancellable,
diff --git a/src/mm-port-probe.c b/src/mm-port-probe.c
index 961964f9..e89ecafa 100644
--- a/src/mm-port-probe.c
+++ b/src/mm-port-probe.c
@@ -584,7 +584,7 @@ wdm_probe_mbim (MMPortProbe *self)
 /* Create a port and try to open it */
 ctx->mbim_port = mm_port_mbim_new (mm_kernel_device_get_name 
(self->priv->port));
 mm_port_mbim_open (ctx->mbim_port,
-#if WITH_QMI
+#if defined WITH_QMI
FALSE, /* Don't check QMI over MBIM support at this 
stage */
 #endif
NULL,
-- 
2.18.0.1017.ga543ac7ca45-goog

___
ModemManager-devel mailing list
ModemManager-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel


[PATCH] broadband-modem-mbim: add missing guard for shared_qmi_init()

2018-08-21 Thread Ben Chan
Fixes: 9e42a19742de55cf5c0ba4d68069c1845e9392e6
---
 src/mm-broadband-modem-mbim.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/src/mm-broadband-modem-mbim.c b/src/mm-broadband-modem-mbim.c
index 1559ab5b..eb9e723b 100644
--- a/src/mm-broadband-modem-mbim.c
+++ b/src/mm-broadband-modem-mbim.c
@@ -4634,6 +4634,8 @@ iface_modem_signal_init (MMIfaceModemSignal *iface)
 iface->load_values_finish = modem_signal_load_values_finish;
 }
 
+#if defined WITH_QMI && QMI_MBIM_QMUX_SUPPORTED
+
 static MMIfaceModemLocation *
 peek_parent_location_interface (MMSharedQmi *self)
 {
@@ -4647,6 +4649,8 @@ shared_qmi_init (MMSharedQmi *iface)
 iface->peek_parent_location_interface = peek_parent_location_interface;
 }
 
+#endif
+
 static void
 mm_broadband_modem_mbim_class_init (MMBroadbandModemMbimClass *klass)
 {
-- 
2.18.0.1017.ga543ac7ca45-goog

___
ModemManager-devel mailing list
ModemManager-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel


[PATCH] port-mbim: add missing guard for try_qmi_over_mbim in mm_port_mbim_open()

2018-08-21 Thread Ben Chan
Fixes: c0cc694c67d9e71f200fb23e20473cc9b31d9ec0
---
 src/mm-port-mbim.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/mm-port-mbim.c b/src/mm-port-mbim.c
index f48ebd8f..cd6d9f22 100644
--- a/src/mm-port-mbim.c
+++ b/src/mm-port-mbim.c
@@ -335,9 +335,11 @@ mm_port_mbim_open (MMPortMbim  *self,
 fullpath = g_strdup_printf ("/dev/%s", mm_port_get_device (MM_PORT 
(self)));
 file = g_file_new_for_path (fullpath);
 
+#if WITH_QMI && QMI_MBIM_QMUX_SUPPORTED
 /* If we want to try QMI over MBIM, store the GFile as task data */
 if (try_qmi_over_mbim)
 g_task_set_task_data (task, g_object_ref (file), g_object_unref);
+#endif
 
 self->priv->in_progress = TRUE;
 mbim_device_new (file,
-- 
2.18.0.1017.ga543ac7ca45-goog

___
ModemManager-devel mailing list
ModemManager-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel


[PATCH] xmm: include string.h for strlen()

2018-08-21 Thread Ben Chan
This patch fixes the following compiler warning:

xmm/mm-modem-helpers-xmm.c:388:38: error: implicitly declaring library function 
'strlen' with type 'unsigned long (const char *)' 
[-Werror,-Wimplicit-function-declaration]
g_regex_match_full (r, response, strlen (response), 0, 0, _info, 
_error);
 ^
---
 plugins/xmm/mm-modem-helpers-xmm.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/plugins/xmm/mm-modem-helpers-xmm.c 
b/plugins/xmm/mm-modem-helpers-xmm.c
index a8ede4cf..1c2280af 100644
--- a/plugins/xmm/mm-modem-helpers-xmm.c
+++ b/plugins/xmm/mm-modem-helpers-xmm.c
@@ -13,6 +13,8 @@
  * Copyright (C) 2018 Aleksander Morgado 
  */
 
+#include 
+
 #include "mm-log.h"
 #include "mm-modem-helpers.h"
 #include "mm-modem-helpers-xmm.h"
-- 
2.18.0.1017.ga543ac7ca45-goog

___
ModemManager-devel mailing list
ModemManager-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel


[PATCH] shared-qmi: include string.h for memset()

2018-08-21 Thread Ben Chan
This patch fixes the following compiler warning:

mm-shared-qmi.c:447:9: error: implicitly declaring library function 'memset' 
with type 'void *(void *, int, unsigned long)' 
[-Werror,-Wimplicit-function-declaration]
memset (buf, 0, sizeof (buf));
^
---
 src/mm-shared-qmi.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/mm-shared-qmi.c b/src/mm-shared-qmi.c
index 25fc29a1..dd08d7fd 100644
--- a/src/mm-shared-qmi.c
+++ b/src/mm-shared-qmi.c
@@ -14,6 +14,7 @@
  */
 
 #include 
+#include 
 #include 
 
 #include 
-- 
2.18.0.865.gffc8e1a3cd6-goog

___
ModemManager-devel mailing list
ModemManager-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel


Re: [PATCH] libmm-glib: add MMPco for handling raw PCO data

2018-08-14 Thread Ben Chan
On Tue, Aug 14, 2018 at 12:48 AM Aleksander Morgado
 wrote:
>
> Hey,
>
> >
> > Before submitting further patches, I just want to make sure the MMPco
> > gobject implemented in this patch is what you're looking for. MMPco will
> > be mostly kept in GList (unless you prefer another gobject).
> >
> > If this is the right API to be in libmm-glib, I'll submit a few
> > follow-up patches to integrate the rest of the PCO support. Otherwise, I
> > can move it to src/ instead.
> >
>
> It looks good to me. We should probably wait to have all remaining
> patches ready before integrating this one, though. How about you
> re-suggest this one in a MR along with the remainining ones?

Here you go: 
https://lists.freedesktop.org/archives/modemmanager-devel/2018-August/006577.html.
  Please use the updated version of this patch in the MR instead.

>
> Cheers!
___
ModemManager-devel mailing list
ModemManager-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel


[review] New 'Pco' property in Modem3gpp interface

2018-08-14 Thread Ben Chan
Hi Aleksander and Dan,

See 
https://gitlab.freedesktop.org/mobile-broadband/ModemManager/merge_requests/27

This MR adds a 'Pco' property to the Modem3gpp interface for reporting
raw PCO values received from the network as we discussed in
https://lists.freedesktop.org/archives/modemmanager-devel/2018-July/006514.html.
The current implementation supports MBIM modems that implement the
MBIM_CID_PCO notification.  A subsequent MR will migrate the
altair-lte plugin to make use of the 'Pco' property, which will then
allow us to deprecate the SubscriptionState property in Modem3gpp
interface.

Comments are welcome!

For minor issues, please feel free to submit additional cleanup patches.

Thanks,
Ben
___
ModemManager-devel mailing list
ModemManager-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel


[PATCH] libmm-glib: add MMPco for handling raw PCO data

2018-08-14 Thread Ben Chan
---
Hi Aleksander,

Before submitting further patches, I just want to make sure the MMPco
gobject implemented in this patch is what you're looking for. MMPco will
be mostly kept in GList (unless you prefer another gobject).

If this is the right API to be in libmm-glib, I'll submit a few
follow-up patches to integrate the rest of the PCO support. Otherwise, I
can move it to src/ instead.

Thanks,
Ben


 docs/reference/libmm-glib/libmm-glib-docs.xml |   4 +
 .../libmm-glib/libmm-glib-sections.txt|  28 ++
 libmm-glib/Makefile.am|   3 +
 libmm-glib/libmm-glib.h   |   1 +
 libmm-glib/mm-pco.c   | 256 ++
 libmm-glib/mm-pco.h   |  85 ++
 6 files changed, 377 insertions(+)
 create mode 100644 libmm-glib/mm-pco.c
 create mode 100644 libmm-glib/mm-pco.h

diff --git a/docs/reference/libmm-glib/libmm-glib-docs.xml 
b/docs/reference/libmm-glib/libmm-glib-docs.xml
index 4b0a564c..80b3ce57 100644
--- a/docs/reference/libmm-glib/libmm-glib-docs.xml
+++ b/docs/reference/libmm-glib/libmm-glib-docs.xml
@@ -129,6 +129,10 @@
 Voice support
 
   
+  
+PCO support
+
+  
 
 
 
diff --git a/docs/reference/libmm-glib/libmm-glib-sections.txt 
b/docs/reference/libmm-glib/libmm-glib-sections.txt
index bfa57f1c..01a5de27 100644
--- a/docs/reference/libmm-glib/libmm-glib-sections.txt
+++ b/docs/reference/libmm-glib/libmm-glib-sections.txt
@@ -1308,6 +1308,34 @@ MM_TYPE_CALL_PROPERTIES
 mm_call_properties_get_type
 
 
+
+mm-pco
+MMPco
+MMPco
+
+mm_pco_new
+
+mm_pco_get_session_id
+mm_pco_is_complete
+mm_pco_get_data
+
+mm_pco_from_variant
+mm_pco_to_variant
+mm_pco_set_session_id
+mm_pco_set_complete
+mm_pco_set_data
+
+MMPcoClass
+MMPcoPrivate
+MM_IS_PCO
+MM_IS_PCO_CLASS
+MM_PCO
+MM_PCO_CLASS
+MM_PCO_GET_CLASS
+MM_TYPE_PCO
+mm_pco_get_type
+
+
 
 mm-enums-types
 Flags and Enumerations
diff --git a/libmm-glib/Makefile.am b/libmm-glib/Makefile.am
index 7d554ad0..4c890592 100644
--- a/libmm-glib/Makefile.am
+++ b/libmm-glib/Makefile.am
@@ -83,6 +83,8 @@ libmm_glib_la_SOURCES = \
mm-signal.c \
mm-kernel-event-properties.h \
mm-kernel-event-properties.c \
+   mm-pco.h \
+   mm-pco.c \
$(NULL)
 
 libmm_glib_la_CPPFLAGS = \
@@ -152,6 +154,7 @@ include_HEADERS = \
mm-cdma-manual-activation-properties.h \
mm-signal.h \
mm-kernel-event-properties.h \
+   mm-pco.h \
$(NULL)
 
 CLEANFILES =
diff --git a/libmm-glib/libmm-glib.h b/libmm-glib/libmm-glib.h
index 81175ca9..d45a6b12 100644
--- a/libmm-glib/libmm-glib.h
+++ b/libmm-glib/libmm-glib.h
@@ -78,6 +78,7 @@
 #include 
 #include 
 #include 
+#include 
 
 /* generated */
 #include 
diff --git a/libmm-glib/mm-pco.c b/libmm-glib/mm-pco.c
new file mode 100644
index ..21390b84
--- /dev/null
+++ b/libmm-glib/mm-pco.c
@@ -0,0 +1,256 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details:
+ *
+ * Copyright 2018 Google LLC.
+ */
+
+#include 
+#include 
+
+#include "mm-enums-types.h"
+#include "mm-errors-types.h"
+#include "mm-common-helpers.h"
+#include "mm-pco.h"
+
+/**
+ * SECTION: mm-pco
+ * @title: MMPco
+ * @short_description: Helper object to handle 3GPP PCO.
+ *
+ * The #MMPco is an object handling the raw 3GPP Protocol Configuration Options
+ * (PCO) that the modem has received from the network.
+ *
+ * This object is retrieved with either mm_modem_3gpp_get_pco() or
+ * mm_modem_3gpp_get_pco_sync().
+ */
+
+G_DEFINE_TYPE (MMPco, mm_pco, G_TYPE_OBJECT);
+
+struct _MMPcoPrivate {
+/* Session ID, signature 'u' */
+guint32 session_id;
+/* Flag indicating if the PCO data is complete or partial, signature 'b' */
+gboolean is_complete;
+/* Raw PCO data, signature 'ay' */
+GBytes *data;
+};
+
+/*/
+
+static GBytes *
+_g_variant_get_bytes (GVariant *variant)
+{
+GByteArray *byte_array;
+guint num_bytes;
+GVariantIter iter;
+GVariant *value;
+
+g_assert (g_variant_is_of_type (variant, G_VARIANT_TYPE ("ay")));
+
+num_bytes = g_variant_n_children (variant);
+if (num_bytes == 0)
+return NULL;
+
+byte_array = g_byte_array_sized_new (num_bytes);
+
+g_variant_iter_init (, variant);
+while (g_variant_iter_loop (, "y", )) {
+guint8 byte;
+
+byte = g_variant_get_byte 

[PATCH] broadband-modem: initialize 'tac' in registration_status_check_ready()

2018-08-09 Thread Ben Chan
mm-broadband-modem.c:4395:13: error: variable 'tac' is used uninitialized 
whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]
if (act == MM_MODEM_ACCESS_TECHNOLOGY_LTE) {
^
mm-broadband-modem.c:4407:75: note: uninitialized use occurs here
mm_iface_modem_3gpp_update_location (MM_IFACE_MODEM_3GPP (self), lac, tac, 
cid);
  ^~~
mm-broadband-modem.c:4395:9: note: remove the 'if' if its condition is always 
true
if (act == MM_MODEM_ACCESS_TECHNOLOGY_LTE) {
^~~
mm-broadband-modem.c:4380:9: error: variable 'tac' is used uninitialized 
whenever 'if' condition is true [-Werror,-Wsometimes-uninitialized]
if (cgreg) {
^
mm-broadband-modem.c:4407:75: note: uninitialized use occurs here
mm_iface_modem_3gpp_update_location (MM_IFACE_MODEM_3GPP (self), lac, tac, 
cid);
  ^~~
mm-broadband-modem.c:4380:5: note: remove the 'if' if its condition is always 
false
if (cgreg) {
^~~~
mm-broadband-modem.c:4280:15: note: initialize the variable 'tac' to silence 
this warning
gulong tac;
  ^
   = 0
---
 src/mm-broadband-modem.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/mm-broadband-modem.c b/src/mm-broadband-modem.c
index a685e407..d1afba4d 100644
--- a/src/mm-broadband-modem.c
+++ b/src/mm-broadband-modem.c
@@ -4344,6 +4344,7 @@ registration_status_check_ready (MMBroadbandModem *self,
 cereg = FALSE;
 state = MM_MODEM_3GPP_REGISTRATION_STATE_UNKNOWN;
 act = MM_MODEM_ACCESS_TECHNOLOGY_UNKNOWN;
+tac = 0;
 lac = 0;
 cid = 0;
 parsed = mm_3gpp_parse_creg_response (match_info,
-- 
2.18.0.597.ga71716f1ad-goog

___
ModemManager-devel mailing list
ModemManager-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel


[PATCH] build: require libmbim 1.17.3

2018-08-08 Thread Ben Chan
libmbim 1.17.3 adds the support for MBIM_CID_PCO, which is used by
commit d68078b2ce0f ("broadband-modem-mbim: check if modem implements
MBIM_CID_PCO").
---
 configure.ac | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index f400eb54..7fa4f60d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -317,7 +317,7 @@ 
dnl-
 dnl MBIM support (enabled by default)
 dnl
 
-LIBMBIM_VERSION=1.17.1
+LIBMBIM_VERSION=1.17.3
 
 AC_ARG_WITH(mbim, AS_HELP_STRING([--without-mbim], [Build without MBIM 
support]), [], [with_mbim=yes])
 AM_CONDITIONAL(WITH_MBIM, test "x$with_mbim" = "xyes")
-- 
2.18.0.597.ga71716f1ad-goog

___
ModemManager-devel mailing list
ModemManager-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel


Re: [review v2] New 'fibocom' plugin (with a new Intel XMM modem class)

2018-08-08 Thread Ben Chan
On Wed, Aug 8, 2018 at 5:30 AM Aleksander Morgado
 wrote:
>
> Hey all,
>
> I've now pushed an updated MR to suggest the Fibocom plugin, this time
> including a new "Icera-like" Intel XMM chipset detection. If the modem
> is found to be based on Intel XMM, supporting the "AT+X.." commands,
> then we will use them for things like mode switching. This updated MR
> includes mode/band selection as well as additional power related
> operations like "off" or "reset".
>
> The new XMM-specific operations are implemented in a "MMSharedXmm"
> interface, which is used by both the MMBroadbandXmm and
> MMBroadbandMbimXmm objects.
>
> https://gitlab.freedesktop.org/mobile-broadband/ModemManager/merge_requests/12
>
> Comments?

IIRC, Huawei ME936 is based on Intel XMM7160, but implements a
different set of AT commands that align mostly with other Huawei
modems. If you have such a modem, you may want to check if those AT+X*
commands exist and behave as expected.  I may be able to find one to
test and will let you know.


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


[PATCH 1/2] broadband-modem-mbim: check if modem implements MBIM_CID_PCO

2018-08-07 Thread Ben Chan
Being a part of a series that adds PCO support for MBIM modems that
implement the MBIM_CID_PCO extension, this patch issues a
MBIM_CID_DEVICE_SERVICES query during the modem initialization to check
if a modem implements MBIM_CID_PCO. If the modem does, ModemManager will
subscribe to MBIM_CID_PCO notifications to get PCO updates.
---
 src/mm-broadband-modem-mbim.c | 83 ++-
 1 file changed, 81 insertions(+), 2 deletions(-)

diff --git a/src/mm-broadband-modem-mbim.c b/src/mm-broadband-modem-mbim.c
index 7a62fa46..eab833f6 100644
--- a/src/mm-broadband-modem-mbim.c
+++ b/src/mm-broadband-modem-mbim.c
@@ -81,6 +81,7 @@ struct _MMBroadbandModemMbimPrivate {
 guint notification_id;
 ProcessNotificationFlag setup_flags;
 ProcessNotificationFlag enable_flags;
+gboolean is_pco_supported;
 
 /* 3GPP registration helpers */
 gchar *current_operator_id;
@@ -1737,6 +1738,84 @@ parent_initialization_started (GTask *task)
 task);
 }
 
+static void
+query_device_services_ready (MbimDevice   *device,
+ GAsyncResult *res,
+ GTask*task)
+{
+MMBroadbandModemMbim *self;
+MbimMessage *response;
+GError *error = NULL;
+MbimDeviceServiceElement **device_services;
+guint32 device_services_count;
+
+self = g_task_get_source_object (task);
+self->priv->is_pco_supported = FALSE;
+
+response = mbim_device_command_finish (device, res, );
+if (response &&
+mbim_message_response_get_result (response, 
MBIM_MESSAGE_TYPE_COMMAND_DONE, ) &&
+mbim_message_device_services_response_parse (
+response,
+_services_count,
+NULL, /* max_dss_sessions */
+_services,
+)) {
+guint32 i;
+
+for (i = 0; i < device_services_count; i++) {
+MbimService service;
+guint32 j;
+
+service = mbim_uuid_to_service 
(_services[i]->device_service_id);
+if (service != MBIM_SERVICE_BASIC_CONNECT_EXTENSIONS)
+continue;
+
+for (j = 0; j < device_services[i]->cids_count; j++) {
+if (device_services[i]->cids[j] == 
MBIM_CID_BASIC_CONNECT_EXTENSIONS_PCO) {
+mm_dbg ("PCO is supported");
+self->priv->is_pco_supported = TRUE;
+break;
+}
+}
+
+break;
+}
+mbim_device_service_element_array_free (device_services);
+} else {
+/* Ignore error */
+mm_warn ("Couldn't query device services: %s", error->message);
+g_error_free (error);
+}
+
+if (response)
+mbim_message_unref (response);
+
+parent_initialization_started (task);
+}
+
+static void
+query_device_services (GTask *task)
+{
+InitializationStartedContext *ctx;
+MbimMessage *message;
+MbimDevice *device;
+
+ctx = g_task_get_task_data (task);
+device = mm_port_mbim_peek_device (ctx->mbim);
+g_assert (device);
+
+mm_dbg ("querying device services...");
+message = mbim_message_device_services_query_new (NULL);
+mbim_device_command (device,
+ message,
+ 10,
+ NULL,
+ (GAsyncReadyCallback)query_device_services_ready,
+ task);
+mbim_message_unref (message);
+}
+
 static void
 mbim_device_removed_cb (MbimDevice *device,
 MMBroadbandModemMbim *self)
@@ -1806,7 +1885,7 @@ mbim_port_open_ready (MMPortMbim *mbim,
  * initialization */
 self = MM_BROADBAND_MODEM_MBIM (g_task_get_source_object (task));
 track_mbim_device_removed (self, mbim);
-parent_initialization_started (task);
+query_device_services (task);
 }
 
 static void
@@ -1837,7 +1916,7 @@ initialization_started (MMBroadbandModem *self,
 /* Nothing to be done, just connect to a signal and launch parent's
  * callback */
 track_mbim_device_removed (MM_BROADBAND_MODEM_MBIM (self), ctx->mbim);
-parent_initialization_started (task);
+query_device_services (task);
 return;
 }
 
-- 
2.18.0.597.ga71716f1ad-goog

___
ModemManager-devel mailing list
ModemManager-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel


[PATCH 2/2] broadband-modem-mbim: subscribe to MBIM_CID_PCO notifications

2018-08-07 Thread Ben Chan
This patch changes MMBroadbandModem to subscribe to MBIM_CID_PCO
notifications if the modem supports that.
---
 src/mm-broadband-modem-mbim.c | 76 ---
 1 file changed, 71 insertions(+), 5 deletions(-)

diff --git a/src/mm-broadband-modem-mbim.c b/src/mm-broadband-modem-mbim.c
index eab833f6..79c2726f 100644
--- a/src/mm-broadband-modem-mbim.c
+++ b/src/mm-broadband-modem-mbim.c
@@ -65,6 +65,7 @@ typedef enum {
 PROCESS_NOTIFICATION_FLAG_CONNECT  = 1 << 3,
 PROCESS_NOTIFICATION_FLAG_SUBSCRIBER_INFO  = 1 << 4,
 PROCESS_NOTIFICATION_FLAG_PACKET_SERVICE   = 1 << 5,
+PROCESS_NOTIFICATION_FLAG_PCO  = 1 << 6,
 } ProcessNotificationFlag;
 
 struct _MMBroadbandModemMbimPrivate {
@@ -2484,6 +2485,48 @@ sms_notification (MMBroadbandModemMbim *self,
 }
 }
 
+static void
+basic_connect_extensions_notification_pco (MMBroadbandModemMbim *self,
+   MbimMessage *notification)
+{
+MbimPcoValue *pco_value;
+GError *error = NULL;
+gchar *pco_data_hex;
+
+if (!mbim_message_basic_connect_extensions_pco_notification_parse (
+notification,
+_value,
+)) {
+mm_warn ("Couldn't parse PCO notification: %s", error->message);
+g_error_free (error);
+return;
+}
+
+pco_data_hex = mm_utils_bin2hexstr (pco_value->pco_data_buffer, 
pco_value->pco_data_size);
+mm_dbg ("Received PCO: session ID=%u type=%s size=%u data=%s",
+ pco_value->session_id,
+ mbim_pco_type_get_string (pco_value->pco_data_type),
+ pco_value->pco_data_size,
+ pco_data_hex);
+g_free (pco_data_hex);
+mbim_pco_value_free (pco_value);
+}
+
+static void
+basic_connect_extensions_notification (MMBroadbandModemMbim *self,
+   MbimMessage *notification)
+{
+switch (mbim_message_indicate_status_get_cid (notification)) {
+case MBIM_CID_BASIC_CONNECT_EXTENSIONS_PCO:
+if (self->priv->setup_flags & PROCESS_NOTIFICATION_FLAG_PCO)
+basic_connect_extensions_notification_pco (self, notification);
+break;
+default:
+/* Ignore */
+break;
+}
+}
+
 static void
 device_notification_cb (MbimDevice *device,
 MbimMessage *notification,
@@ -2501,6 +2544,9 @@ device_notification_cb (MbimDevice *device,
 case MBIM_SERVICE_BASIC_CONNECT:
 basic_connect_notification (self, notification);
 break;
+case MBIM_SERVICE_BASIC_CONNECT_EXTENSIONS:
+basic_connect_extensions_notification (self, notification);
+break;
 case MBIM_SERVICE_SMS:
 sms_notification (self, notification);
 break;
@@ -2518,13 +2564,14 @@ common_setup_cleanup_unsolicited_events_sync 
(MMBroadbandModemMbim *self,
 if (!device)
 return;
 
-mm_dbg ("Supported notifications: signal (%s), registration (%s), sms 
(%s), connect (%s), subscriber (%s), packet (%s)",
+mm_dbg ("Supported notifications: signal (%s), registration (%s), sms 
(%s), connect (%s), subscriber (%s), packet (%s), pco (%s)",
 self->priv->setup_flags & PROCESS_NOTIFICATION_FLAG_SIGNAL_QUALITY 
? "yes" : "no",
 self->priv->setup_flags & 
PROCESS_NOTIFICATION_FLAG_REGISTRATION_UPDATES ? "yes" : "no",
 self->priv->setup_flags & PROCESS_NOTIFICATION_FLAG_SMS_READ ? 
"yes" : "no",
 self->priv->setup_flags & PROCESS_NOTIFICATION_FLAG_CONNECT ? 
"yes" : "no",
 self->priv->setup_flags & 
PROCESS_NOTIFICATION_FLAG_SUBSCRIBER_INFO ? "yes" : "no",
-self->priv->setup_flags & PROCESS_NOTIFICATION_FLAG_PACKET_SERVICE 
? "yes" : "no");
+self->priv->setup_flags & PROCESS_NOTIFICATION_FLAG_PACKET_SERVICE 
? "yes" : "no",
+self->priv->setup_flags & PROCESS_NOTIFICATION_FLAG_PCO ? "yes" : 
"no");
 
 if (setup) {
 /* Don't re-enable it if already there */
@@ -2600,6 +2647,8 @@ cleanup_unsolicited_events_3gpp (MMIfaceModem3gpp *_self,
 if (is_sim_hot_swap_configured)
 self->priv->setup_flags &= ~PROCESS_NOTIFICATION_FLAG_SUBSCRIBER_INFO;
 self->priv->setup_flags &= ~PROCESS_NOTIFICATION_FLAG_PACKET_SERVICE;
+if (self->priv->is_pco_supported)
+self->priv->setup_flags &= ~PROCESS_NOTIFICATION_FLAG_PCO;
 common_setup_cleanup_unsolicited_events (self, FALSE, callback, user_data);
 }
 
@@ -2614,6 +2663,8 @@ setup_unsolicited_events_3gpp (MMIfaceModem3gpp *_self,
 self->priv->setup_flags |= PROCESS_NOTIFICATION_FLAG_CONNECT;
 self->priv->setup_flags |= PROCESS_NOTIFICATION_FLAG_SUBSCRIBER_INFO;
 self->priv->setup_flags |= PROCESS_NOTIFICATION_FLAG_PACKET_SERVICE;
+if (self->priv->is_pco_supported)
+self->priv->setup_flags |= PROCESS_NOTIFICATION_FLAG_PCO;
 common_setup_cleanup_unsolicited_events (self, TRUE, callback, user_data);
 }
 
@@ -2688,15 +2739,16 @@ 

Re: [RFC] Deprecate SubscriptionState?

2018-08-07 Thread Ben Chan
On Tue, Aug 7, 2018 at 7:22 AM Dan Williams  wrote:
>
> On Tue, 2018-08-07 at 01:07 +0200, Aleksander Morgado wrote:
> > Hey,
> >
> > Why raw PCO data in hex string? Why not directly the binary data?
> > e.g.
> > "ay" instead of "s". The signature could be then "a(iay)"
>
> Yeah I'd vote for byte array eg "a(iay)" (eg array of struct of integer
> + byte array).
>

Sounds good. We will need to indicate whether the received PCO is
partial or complete, so I'll go with something like an array of struct
of (uint32 + boolean + byte array),  i.e. a(ubay).

I'm planning to do the following:
1. introduce the new Pco property under Modem3gpp interface
2. set it up for modems supporting MBIM_CID_PCO
3. migrate the altair-lte plugin to use the Pco property
4. migrate Chromium OS to use the Pco property instead of the
SubscriptionState property
5. remove the SubscriptionState property from Modem3gpp -- this is an
MM API break, so a version bump will be needed

Does that sound like a plan?

> Dan
___
ModemManager-devel mailing list
ModemManager-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel


Re: [RFC] Deprecate SubscriptionState?

2018-07-30 Thread Ben Chan
Hi Aleksander,

I'm actually wiring up SubscriptionState for some MBIM modems that
support MBIM_CID_PCO (which just landed in libmbim), and about to send
over some patches. It's true that the PCO of interest is the
Verizon-specific PCO, which is used for several use cases (e.g. the
SIM is unprovisioned / no active subscription, the account runs out of
data allowance, etc). It's also true that some modems only
support/expose Verizon-specific PCO, which is likely due to
certification requirements from Verizon. The MBIM_CID_PCO document
from Microsoft also uses Verizon PCO as an example :-|

We went with the SubscriptionState property mostly because the Altair
modem only reports a portion of the PCO (e.g. FF00 130184xx). I'm
testing another MBIM modem which exposes raw PCO info, which is tied
to an active connection (i.e. MBIM_CID_PCO SessionId is tied to
MBIM_CID_CONNECT SessionId) and are updated over time via MBIM_CID_PCO
notifications.

I guess we could depreciate the SubscriptionState property and let
ModemManger simply forward PCO notifications to other clients. What
D-Bus interface are you considering?  For the Altair modem, we may
need to cheat a little bit by repackaging the partial PCO info into a
valid PCO structure.

Thanks,
Ben

On Sat, Jul 28, 2018 at 1:43 PM Aleksander Morgado
 wrote:
>
> Hey Dan, Ben & all,
>
> The SubscriptionState property was originally thought to expose the
> state of the subscription with the operator. It has been implemented
> only in the Altair LTE plugin, and the current implementation is based
> on two main things:
>  * Verizon-specific logic that allows knowing the subscription state
> based on the PCO info.
>  * Registration check errors, e.g. to say that the SIM is
> unprovisioned when the registration fails.
>
> I'm not sure any of the previous two things are very robust. The
> Verizon-specific parsing will only work for Verizon, and the
> registration check errors may be caused by multiple different root
> causes. To me it looks like the Altair LTE plugin is trying to do more
> than it's supposed to do. It would be much better if we exposed the
> raw PCO info received, and let upper layers process that if needed
> with operator-specific logic.
>
> What do you all think?
> Should we deprecate the SubscriptionState property?
> Should we expose the raw PCO info?



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


Re: [review] New 'fibocom' plugin

2018-07-19 Thread Ben Chan
On Thu, Jul 19, 2018 at 12:45 PM Aleksander Morgado
 wrote:
>
> On Thu, Jul 19, 2018 at 9:23 PM, Dan Williams  wrote:
> > On Thu, 2018-07-19 at 21:10 +0200, Aleksander Morgado wrote:
> >> > On Chrome OS, we simply use ID_MM_PORT_IGNORE to ignore all AT
> >> > ports
> >> > on the L850-GL module (e.g.
> >> > https://chromium.googlesource.com/chromiumos/overlays/chromiumos-ov
> >> > erlay/+/master/net-misc/modemmanager-next/files/77-mm-fibocom-port-
> >> > types.rules).
> >> >
> >> > The modem is functional with just MBIM and supported via the
> >> > generic
> >> > plugin, which is the approach we took on Chrome OS. IMHO, there is
> >> > little added benefit with a new modem plugin. More importantly, AT
> >> > probing takes quite some time, and I observed it often took 7
> >> > seconds.
> >> > We've been trying hard for some time to move everything to purely
> >> > MBIM
> >> > or QMI :)
> >> >
> >>
> >> I'm going to extend this plugin in the following weeks with more
> >> features that will require the use of the AT port, e.g. GPS location
> >> and such. I agree that probing is a bit slow right now, but that is
> >> just because the DIAG port goes first through a series of AT probing
> >> steps which are not needed. For devices with fixed layouts like this
> >> one, adding udev tags to specify port types isn't bad IMO, and we
> >> should probably do that for the DIAG port (i.e. flag it as "not AT"
> >> for example).
> >
> > Agreed; ideally we can begin to restrict which ports we bother probing
> > for DIAG, since with QMI and MBIM DIAG is much less useful these days.
> >

IIRC, I initially blacklisted two out of the three AT ports, but
initial AT probing still took seconds to complete (and seconds matter
a lot on Chrome OS as we're pretty sensitive to the overall time from
boot to connect), which drove me into blacklisting all AT ports. For
functionality that isn't implemented by standard MBIM command set,
we've pushing for MBIM extensions -- actually, you'll expect a few
related patches from me soon :-)

Regarding your patches, I think they won't interfere with our AT
blacklist on this modem. In the worst case, we can simply skip
installing the fibocom plugin, which should allow us to gracefully
fall back to the generic plugin and use only MBIM.
>
> You may know this better than me; are all DIAG ports from all qualcomm
> modems ever of the same class/subclass/protocol? i.e. Cls=ff(vend.)
> Sub=ff Prot=ff
> In other words, should we bother probing QCDM for ports that are not ff/ff/ff?
>
> --
> Aleksander
> https://aleksander.es
___
ModemManager-devel mailing list
ModemManager-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel


Re: [review] New 'fibocom' plugin

2018-07-19 Thread Ben Chan
Hi Aleksander,

On Chrome OS, we simply use ID_MM_PORT_IGNORE to ignore all AT ports
on the L850-GL module (e.g.
https://chromium.googlesource.com/chromiumos/overlays/chromiumos-overlay/+/master/net-misc/modemmanager-next/files/77-mm-fibocom-port-types.rules).

The modem is functional with just MBIM and supported via the generic
plugin, which is the approach we took on Chrome OS. IMHO, there is
little added benefit with a new modem plugin. More importantly, AT
probing takes quite some time, and I observed it often took 7 seconds.
We've been trying hard for some time to move everything to purely MBIM
or QMI :)

WDYT?

Thanks,
Ben


On Thu, Jul 19, 2018 at 7:09 AM Aleksander Morgado
 wrote:
>
> Hey all,
>
> See this MR introducing a new Fibocom plugin, which right now just
> maps support for AT/MBIM based devices.
>
> https://gitlab.freedesktop.org/mobile-broadband/ModemManager/merge_requests/12
>
> Tested with the L850-GL module (MBIM+2 AT ports+Intel trace port), and
> explicitly blacklisted the Intel trace port.
>
> Comments welcome
>
> --
> Aleksander
> https://aleksander.es
> ___
> ModemManager-devel mailing list
> ModemManager-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel
___
ModemManager-devel mailing list
ModemManager-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel


[PATCH] modem-helpers-mbim: map more MbimNwError to MMMobileEquipmentError

2018-06-01 Thread Ben Chan
Commit X in libmim ("libmbim-glib: add additional cause codes to
MbimNwError") added additional cause codes to MbimNwError. This patch
maps some of those MbimNwError to MMMobileEquipmentError.

This patch requires libmbim >= 1.7.0
---
Hi Dan / Aleksander,

This is the follow-up MM patch for the corresponding libmbim patch:
https://lists.freedesktop.org/archives/libmbim-devel/2018-June/000993.html

Once the libmbim patch is committed, could you help adjust the commit
hash above in the commit message before committing this patch?

Thanks,
Ben


 configure.ac|  2 +-
 src/mm-modem-helpers-mbim.c | 28 
 2 files changed, 29 insertions(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index 9bf26ed2..ef104d34 100644
--- a/configure.ac
+++ b/configure.ac
@@ -317,7 +317,7 @@ 
dnl-
 dnl MBIM support (enabled by default)
 dnl
 
-LIBMBIM_VERSION=1.16.0
+LIBMBIM_VERSION=1.17.0
 
 AC_ARG_WITH(mbim, AS_HELP_STRING([--without-mbim], [Build without MBIM 
support]), [], [with_mbim=yes])
 AM_CONDITIONAL(WITH_MBIM, test "x$with_mbim" = "xyes")
diff --git a/src/mm-modem-helpers-mbim.c b/src/mm-modem-helpers-mbim.c
index 36d55023..0da5588f 100644
--- a/src/mm-modem-helpers-mbim.c
+++ b/src/mm-modem-helpers-mbim.c
@@ -239,10 +239,30 @@ mm_mobile_equipment_error_from_mbim_nw_error (MbimNwError 
nw_error)
 return g_error_new (MM_MOBILE_EQUIPMENT_ERROR,
 
MM_MOBILE_EQUIPMENT_ERROR_GPRS_USER_AUTHENTICATION_FAILED,
 "Not authorized for this CSG");
+case MBIM_NW_ERROR_INSUFFICIENT_RESOURCES:
+return g_error_new (MM_MOBILE_EQUIPMENT_ERROR,
+
MM_MOBILE_EQUIPMENT_ERROR_GPRS_INSUFFICIENT_RESOURCES,
+"Insufficient resources");
 case MBIM_NW_ERROR_MISSING_OR_UNKNOWN_APN:
 return g_error_new (MM_MOBILE_EQUIPMENT_ERROR,
 
MM_MOBILE_EQUIPMENT_ERROR_GPRS_MISSING_OR_UNKNOWN_APN,
 "Missing or unknown APN");
+case MBIM_NW_ERROR_UNKNOWN_PDP_ADDRESS_OR_TYPE:
+return g_error_new (MM_MOBILE_EQUIPMENT_ERROR,
+
MM_MOBILE_EQUIPMENT_ERROR_GPRS_UNKNOWN_PDP_ADDRESS_OR_TYPE,
+"Unknown PDP address or type");
+case MBIM_NW_ERROR_USER_AUTHENTICATION_FAILED:
+return g_error_new (MM_MOBILE_EQUIPMENT_ERROR,
+
MM_MOBILE_EQUIPMENT_ERROR_GPRS_USER_AUTHENTICATION_FAILED,
+"User authentication failed");
+case MBIM_NW_ERROR_ACTIVATION_REJECTED_BY_GGSN_OR_GW:
+return g_error_new (MM_MOBILE_EQUIPMENT_ERROR,
+
MM_MOBILE_EQUIPMENT_ERROR_GPRS_ACTIVATION_REJECTED_BY_GGSN_OR_GW,
+"Activation rejected by GGSN or GW");
+case MBIM_NW_ERROR_ACTIVATION_REJECTED_UNSPECIFIED:
+return g_error_new (MM_MOBILE_EQUIPMENT_ERROR,
+
MM_MOBILE_EQUIPMENT_ERROR_GPRS_ACTIVATION_REJECTED_UNSPECIFIED,
+"Activation rejected; unspecified");
 case MBIM_NW_ERROR_SERVICE_OPTION_NOT_SUPPORTED:
 return g_error_new (MM_MOBILE_EQUIPMENT_ERROR,
 
MM_MOBILE_EQUIPMENT_ERROR_GPRS_SERVICE_OPTION_NOT_SUPPORTED,
@@ -255,6 +275,14 @@ mm_mobile_equipment_error_from_mbim_nw_error (MbimNwError 
nw_error)
 return g_error_new (MM_MOBILE_EQUIPMENT_ERROR,
 
MM_MOBILE_EQUIPMENT_ERROR_GPRS_SERVICE_OPTION_OUT_OF_ORDER,
 "Service option temporarily out of order");
+case MBIM_NW_ERROR_MAXIMUM_NUMBER_OF_PDP_CONTEXTS_REACHED:
+return g_error_new (MM_MOBILE_EQUIPMENT_ERROR,
+
MM_MOBILE_EQUIPMENT_ERROR_GPRS_MAXIMUM_NUMBER_OF_PDP_CONTEXTS_REACHED,
+"Maximum number of PDP contexts reached");
+case MBIM_NW_ERROR_REQUESTED_APN_NOT_SUPPORTED_IN_CURRENT_RAT_AND_PLMN:
+return g_error_new (MM_MOBILE_EQUIPMENT_ERROR,
+
MM_MOBILE_EQUIPMENT_ERROR_GPRS_REQUESTED_APN_NOT_SUPPORTED,
+"Requested APN not supported");
 default:
 return g_error_new (MM_MOBILE_EQUIPMENT_ERROR,
 MM_MOBILE_EQUIPMENT_ERROR_GPRS_UNKNOWN,
-- 
2.17.1.1185.g55be947832-goog

___
ModemManager-devel mailing list
ModemManager-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel


[review] https://github.com/cbchan/ModemManager/tree/gtask-broadband-modem-qmi

2018-05-10 Thread Ben Chan
This branch contains a series of patches that port the remaining code in
MMBroadbandQmi to use GTask:

https://github.com/linux-mobile-broadband/ModemManager/compare/master...cbchan:gtask-broadband-modem-qmi
___
ModemManager-devel mailing list
ModemManager-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel


Re: ModemManager SMS PIN DEBUG QUESTION

2018-05-03 Thread Ben Chan
On Thu, May 3, 2018 at 9:19 AM 刘其峰 <li...@fibocom.com> wrote:

> Hi Ben:
> root@fibocom:~# mmcli -L
>
> Found 1 modems:
> /org/freedesktop/ModemManager1/Modem/1 [Generic] MBIM [2CB7:0007]
>
>
> root@fibocom:~# mmcli -m 1
>
> /org/freedesktop/ModemManager1/Modem/1 (device id
> 'd226995fe1daf60db0ec2e492cbcb0e37f3bef03')
>   -
>   Hardware |   manufacturer: 'Generic'
>|  model: 'MBIM [2CB7:0007]'
>|   revision: '18500.5001.00.01.17.65'
>|  supported: 'gsm-umts, lte'
>|current: 'gsm-umts, lte'
>|   equipment id: '863059020075042'
>   -
>   System   | device:
> '/sys/devices/pci:00/:00:14.0/usb3/3-8'
>|drivers: 'cdc_mbim, cdc_acm'
>| plugin: 'Generic'
>|   primary port: 'cdc-wdm0'
>|  ports: 'cdc-wdm0 (mbim), wwp0s20u8 (net), ttyACM0
> (at), ttyACM2 (at)'
>   -
>   Numbers  |   own : '10086'
>   -
>   Status   |   lock: 'none'
>| unlock retries: 'sim-pin2 (3)'
>|  state: 'connected'
>|power state: 'on'
>|access tech: 'lte'
>| signal quality: '0' (cached)
>   -
>   Modes|  supported: 'allowed: 3g, 4g; preferred: none'
>|current: 'allowed: 3g, 4g; preferred: none'
>   -
>   Bands|  supported: 'unknown'
>|current: 'unknown'
>   -
>   IP   |  supported: 'ipv4, ipv6, ipv4v6'
>   -
>   3GPP |   imei: '863059020075042'
>|  enabled locks: 'fixed-dialing'
>|operator id: '46001'
>|  operator name: '00'
>|   subscription: 'unknown'
>|   registration: 'home'
>   -
>   SIM  |   path: '/org/freedesktop/ModemManager1/SIM/1'
>
>   -
>   Bearers  |  paths: '/org/freedesktop/ModemManager1/Bearer/1'
>
> root@fibocom:~# mmcli -m 1
> --messaging-create-sms="number=13760527596,text=Hello"
> Successfully created new SMS:
> /org/freedesktop/ModemManager1/SMS/10 (unknown)
> root@fibocom:~# mmcli --send
> error: no SMS was specified
> root@fibocom:~# mmcli -m 1 --send
> error: no SMS was specified
> root@fibocom:~# mmcli -m 1 --send=10
> error: no SMS was specified
> root@fibocom:~#
>
> Hi Ben,
>I follow your suggestion, but the last step '--send' show 'error: no
> SMS was specified'
>
>

Try `mmcli -s 10 --send` instead

https://www.freedesktop.org/software/ModemManager/man/1.0.0/mmcli.8.html
has some more examples


>
> -- Original --
> *From: * "Ben Chan"<benc...@chromium.org>;
> *Date: * Thu, May 3, 2018 11:58 PM
> *To: * "LiuQiFeng"<li...@fibocom.com>;
> *Cc: * "modemmanager-devel"<modemmanager-devel@lists.freedesktop.org>;
> *Subject: * Re: ModemManager SMS PIN DEBUG QUESTION
>
> On Thu, May 3, 2018 at 8:35 AM 刘其峰 <li...@fibocom.com> wrote:
>
> > Hi ModemManager Team,
> > I'm a software developer from china, i have some question about SMS
> and PIN api.
>
> > I had see usage about mmcli and it had some api about pin and sms.
> > but i don't know how to use this api, can you give us some help about
> mmcli ?
>
> > ght@fibocom:~$ mmcli -L
>
> > Found 1 modems:
> >  /org/freedesktop/ModemManager1/Modem/2 [Fibocom] L850 LTE
> > Module","L850
> > ght@fibocom:~$ mmcli -m 2 --pin=1234
> > error: no sim was specified
>
> > ght@fibocom:~$ mmcli -s 2 --pin=1234
> > error: no sim was specified
>
> You need to specify "-i " to specify the SIM object, e.g. -i 2
>
> > ght@fibocom:~$ mmcli -s 2 --send="123456"
>
> Are you trying to send a SMS here?
>
> Looks like SMS/2 object doesn't exist, you can list the existing SMS
> objects using `mmcli -m 2 --messaging-list-sms`
>
> To create a SMS object, you can do something like `mmcli -m2
> --messaging-create-sms="number=1234567890,text=Hello"`
>
> Once the SMS object is created, you can send it with mmcli --send
>
>
> > error: couldn't find SMS at '/org/freedesktop/ModemManager1/SMS/2': 'not
> > found in any modem'
> > ght@fibocom:~$
>
> > ght@fibocom:~$ mmcli -i 2
> > SIM '/org/freedesktop/ModemManager1/SIM/2'
> >--

Re: ModemManager SMS PIN DEBUG QUESTION

2018-05-03 Thread Ben Chan
On Thu, May 3, 2018 at 8:35 AM 刘其峰  wrote:

> Hi ModemManager Team,
> I'm a software developer from china, i have some question about SMS
and PIN api.

> I had see usage about mmcli and it had some api about pin and sms.
> but i don't know how to use this api, can you give us some help about
mmcli ?

> ght@fibocom:~$ mmcli -L

> Found 1 modems:
>  /org/freedesktop/ModemManager1/Modem/2 [Fibocom] L850 LTE
> Module","L850
> ght@fibocom:~$ mmcli -m 2 --pin=1234
> error: no sim was specified

> ght@fibocom:~$ mmcli -s 2 --pin=1234
> error: no sim was specified

You need to specify "-i " to specify the SIM object, e.g. -i 2

> ght@fibocom:~$ mmcli -s 2 --send="123456"

Are you trying to send a SMS here?

Looks like SMS/2 object doesn't exist, you can list the existing SMS
objects using `mmcli -m 2 --messaging-list-sms`

To create a SMS object, you can do something like `mmcli -m2
--messaging-create-sms="number=1234567890,text=Hello"`

Once the SMS object is created, you can send it with mmcli --send


> error: couldn't find SMS at '/org/freedesktop/ModemManager1/SMS/2': 'not
> found in any modem'
> ght@fibocom:~$

> ght@fibocom:~$ mmcli -i 2
> SIM '/org/freedesktop/ModemManager1/SIM/2'
>-
>Properties |  imsi : '460015646534044'
>   |id : '89860117801059844938'
>   |   operator id : '46001'
>   | operator name : 'unknown'
> ght@fibocom:~$

> ___
> ModemManager-devel mailing list
> ModemManager-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel
___
ModemManager-devel mailing list
ModemManager-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel


[PATCH] broadband-modem-qmi: fix memory leak in dms_set_operating_mode_ready

2018-04-28 Thread Ben Chan
---
 src/mm-broadband-modem-qmi.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/mm-broadband-modem-qmi.c b/src/mm-broadband-modem-qmi.c
index d87c39aa..898906c8 100644
--- a/src/mm-broadband-modem-qmi.c
+++ b/src/mm-broadband-modem-qmi.c
@@ -3140,6 +3140,8 @@ dms_set_operating_mode_ready (QmiClientDms *client,
 return;
 }
 
+qmi_message_dms_set_operating_mode_output_unref (output);
+
 /* Good! we're done, go to last step */
 ctx->step = SET_OPERATING_MODE_STEP_LAST;
 set_operating_mode_context_step (ctx);
-- 
2.17.0.441.gb46fe60e1d-goog

___
ModemManager-devel mailing list
ModemManager-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel


[PATCH] iface-modem: allow initial signal check after the modem is re-enabled

2018-04-24 Thread Ben Chan
Commit 708b00ae3 "modem: allow periodic signal check to be disabled"
added a "iface-modem-periodic-signal-check-disabled" property in
MMIfaceModem/MMBroadbandModem to indicate if the periodic signal check
should be disabled. If the property is set to TRUE, the
signal_quality_polling_supported field of SignalCheckContext is set to
FALSE, which is sticky across modem disable/enable operations. However,
that is undesirable as we would like to issue an initial signal check to
refresh the signal quality value after the modem is re-enabled from a
state when the RF may have been previously turned off.
---
 src/mm-iface-modem.c | 13 +
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/src/mm-iface-modem.c b/src/mm-iface-modem.c
index b1224428..11bdf1f6 100644
--- a/src/mm-iface-modem.c
+++ b/src/mm-iface-modem.c
@@ -1222,6 +1222,7 @@ signal_quality_check_ready (MMIfaceModem *self,
 static void
 peridic_signal_check_step (MMIfaceModem *self)
 {
+gboolean periodic_signal_check_disabled = FALSE;
 SignalCheckContext *ctx;
 
 ctx = get_signal_check_context (self);
@@ -1284,17 +1285,12 @@ peridic_signal_check_step (MMIfaceModem *self)
 initial_check_done = ((signal_quality_ready && 
access_technology_ready) ||
   (--ctx->initial_retries == 0));
 if (initial_check_done) {
-gboolean periodic_signal_check_disabled = FALSE;
-
+/* After the initial check is done, check if periodic signal
+ * check is disabled. */
 g_object_get (self,
   MM_IFACE_MODEM_PERIODIC_SIGNAL_CHECK_DISABLED,
   _signal_check_disabled,
   NULL);
-/* If periodic signal check is disabled, treat it as
- * unsupported after the initial check is done. */
-if (periodic_signal_check_disabled)
-ctx->signal_quality_polling_supported = FALSE;
-
 ctx->interval = SIGNAL_CHECK_TIMEOUT_SEC;
 }
 }
@@ -1302,7 +1298,8 @@ peridic_signal_check_step (MMIfaceModem *self)
 /* If both tasks are unsupported, implicitly disable. Do NOT clear the
  * values, because if we're told they are unsupported it may be that
  * they're really updated via unsolicited messages. */
-if (!ctx->access_technology_polling_supported && 
!ctx->signal_quality_polling_supported) {
+if (!ctx->access_technology_polling_supported &&
+(!ctx->signal_quality_polling_supported || 
periodic_signal_check_disabled)) {
 mm_dbg ("Periodic signal and access technologies checks not 
supported");
 periodic_signal_check_disable (self, FALSE);
 return;
-- 
2.17.0.484.g0c8726318c-goog

___
ModemManager-devel mailing list
ModemManager-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel


Re: Initial signal quality query on MBIM modems

2018-04-23 Thread Ben Chan
On Sat, Jan 6, 2018 at 9:58 AM Aleksander Morgado 
wrote:


> That idea looks good to me, yes. If that property is set, MM would
> just run one signal update query. You could reuse the same polling
> logic and just exit polling early as soon as the first successful poll
> happens.

> As for why QMI has both polling and unsolicited indications, I'm not
> sure, don't recall why that was done. Probably to handle devices which
> wouldn't report signal updates properly via indications or something,
> but not sure. The last similar thing I recall is the Netgear AC341U
> not properly reporting network-initiated disconnections via
> unsolicited messages, and we tag that one explicitly so that polling
> for connection status is performed.


Here're the patches:

https://lists.freedesktop.org/archives/modemmanager-devel/2018-April/006308.html
https://lists.freedesktop.org/archives/modemmanager-devel/2018-April/006309.html

Thanks,
Ben
___
ModemManager-devel mailing list
ModemManager-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel


[PATCH 1/2] modem: allow periodic signal check to be disabled

2018-04-23 Thread Ben Chan
ModemManager decides to disable periodic signal check if either
load_signal_quality is not implemented or load_signal_quality returns an
unsupported error. However, in some cases, we want to use
load_signal_quality to query the initial signal quality but rely on
unsolicited signal quality updates from the modem afterwards without
periodically polling for signal quality. To support that, this patch
introduces a property in MMIfaceModem/MMBroadbandModem to indicate if
the periodic signal check should be disabled.
---
 src/mm-broadband-modem.c | 14 
 src/mm-iface-modem.c | 47 
 src/mm-iface-modem.h |  1 +
 3 files changed, 48 insertions(+), 14 deletions(-)

diff --git a/src/mm-broadband-modem.c b/src/mm-broadband-modem.c
index dfb0425b..b21c2491 100644
--- a/src/mm-broadband-modem.c
+++ b/src/mm-broadband-modem.c
@@ -117,6 +117,7 @@ enum {
 PROP_MODEM_SIMPLE_STATUS,
 PROP_MODEM_SIM_HOT_SWAP_SUPPORTED,
 PROP_MODEM_SIM_HOT_SWAP_CONFIGURED,
+PROP_MODEM_PERIODIC_SIGNAL_CHECK_DISABLED,
 PROP_FLOW_CONTROL,
 PROP_LAST
 };
@@ -136,6 +137,7 @@ struct _MMBroadbandModemPrivate {
 gboolean modem_init_run;
 gboolean sim_hot_swap_supported;
 gboolean sim_hot_swap_configured;
+gboolean periodic_signal_check_disabled;
 
 /*<--- Modem interface --->*/
 /* Properties */
@@ -10809,6 +10811,9 @@ set_property (GObject *object,
 case PROP_MODEM_SIM_HOT_SWAP_CONFIGURED:
 self->priv->sim_hot_swap_configured = g_value_get_boolean (value);
 break;
+case PROP_MODEM_PERIODIC_SIGNAL_CHECK_DISABLED:
+self->priv->periodic_signal_check_disabled = g_value_get_boolean 
(value);
+break;
 default:
 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
 break;
@@ -10917,6 +10922,9 @@ get_property (GObject *object,
 case PROP_MODEM_SIM_HOT_SWAP_CONFIGURED:
 g_value_set_boolean (value, self->priv->sim_hot_swap_configured);
 break;
+case PROP_MODEM_PERIODIC_SIGNAL_CHECK_DISABLED:
+g_value_set_boolean (value, 
self->priv->periodic_signal_check_disabled);
+break;
 case PROP_FLOW_CONTROL:
 g_value_set_flags (value, self->priv->flow_control);
 break;
@@ -10949,6 +10957,7 @@ mm_broadband_modem_init (MMBroadbandModem *self)
 self->priv->current_sms_mem1_storage = MM_SMS_STORAGE_UNKNOWN;
 self->priv->current_sms_mem2_storage = MM_SMS_STORAGE_UNKNOWN;
 self->priv->sim_hot_swap_supported = FALSE;
+self->priv->periodic_signal_check_disabled = FALSE;
 self->priv->modem_cmer_enable_mode = MM_3GPP_CMER_MODE_NONE;
 self->priv->modem_cmer_disable_mode = MM_3GPP_CMER_MODE_NONE;
 self->priv->modem_cmer_ind = MM_3GPP_CMER_IND_NONE;
@@ -11430,6 +11439,11 @@ mm_broadband_modem_class_init (MMBroadbandModemClass 
*klass)
 g_object_class_override_property (object_class,
   PROP_MODEM_SIM_HOT_SWAP_CONFIGURED,
   MM_IFACE_MODEM_SIM_HOT_SWAP_CONFIGURED);
+
+g_object_class_override_property (object_class,
+  
PROP_MODEM_PERIODIC_SIGNAL_CHECK_DISABLED,
+  
MM_IFACE_MODEM_PERIODIC_SIGNAL_CHECK_DISABLED);
+
 properties[PROP_FLOW_CONTROL] =
 g_param_spec_flags (MM_BROADBAND_MODEM_FLOW_CONTROL,
 "Flow control",
diff --git a/src/mm-iface-modem.c b/src/mm-iface-modem.c
index 06441e22..b1224428 100644
--- a/src/mm-iface-modem.c
+++ b/src/mm-iface-modem.c
@@ -1263,15 +1263,6 @@ peridic_signal_check_step (MMIfaceModem *self)
 return;
 }
 
-/* If both tasks are unsupported, implicitly disable. Do NOT clear the
- * values, because if we're told they are unsupported it may be that
- * they're really updated via unsolicited messages. */
-if (!ctx->access_technology_polling_supported && 
!ctx->signal_quality_polling_supported) {
-mm_dbg ("Periodic signal checks not supported");
-periodic_signal_check_disable (self, FALSE);
-return;
-}
-
 /* Schedule when we poll next time.
  * Initially we poll at a higher frequency until we get valid signal
  * quality and access technology values. As soon as we get them, OR if
@@ -1280,6 +1271,7 @@ peridic_signal_check_step (MMIfaceModem *self)
 if (ctx->interval == SIGNAL_CHECK_INITIAL_TIMEOUT_SEC) {
 gboolean signal_quality_ready;
 gboolean access_technology_ready;
+gboolean initial_check_done;
 
 /* Signal quality is ready if unsupported or if we got a valid
  * value reported */
@@ -1289,15 +1281,33 @@ peridic_signal_check_step (MMIfaceModem *self)
 access_technology_ready = 
(!ctx->access_technology_polling_supported ||
((ctx->access_technologies & 

[PATCH 2/2] broadband-modem-mbim: implement initial signal quality loading

2018-04-23 Thread Ben Chan
ModemManager currently relies on unsolicited MBIM_CID_SIGNAL_STATE
notifications to obtain signal quality updates, and it doesn't query the
initial signal quality. It's been observed that some MBIM modems issue a
MBIM_CID_SIGNAL_STATE notification only when there is a notable change
in RSSI. The signal quality may remain at 0 for quite some time. It's
more noticeable when simply restarting ModemManager after the modem has
been initialized and enabled once.

We could simply enable periodic signal check on an MBIM modem, but
that's less ideal as it may unnecessarily wake the modem up from USB
selective suspend (unless we use a much longer polling period).

To address the issue, this patch adds the implementation of
load_signal_quality to MMBroadbandModemMbim so that the signal quality
is initially polled via a solicited MBIM_CID_SIGNAL_STATE query. To
avoid the periodic signal check, we set the
MM_IFACE_MODEM_PERIODIC_SIGNAL_CHECK_DISABLED property to TRUE for
MMBroadbandModemMbim.
---
 src/mm-broadband-modem-mbim.c | 80 ++-
 1 file changed, 78 insertions(+), 2 deletions(-)

diff --git a/src/mm-broadband-modem-mbim.c b/src/mm-broadband-modem-mbim.c
index d6562088..09e1ffb7 100644
--- a/src/mm-broadband-modem-mbim.c
+++ b/src/mm-broadband-modem-mbim.c
@@ -1433,6 +1433,79 @@ modem_power_down (MMIfaceModem *self,
 mbim_message_unref (message);
 }
 
+/*/
+/* Signal quality loading (Modem interface) */
+
+static guint
+modem_load_signal_quality_finish (MMIfaceModem *self,
+  GAsyncResult *res,
+  GError **error)
+{
+gssize value;
+
+value = g_task_propagate_int (G_TASK (res), error);
+return value < 0 ? 0 : value;
+}
+
+static void
+signal_state_query_ready (MbimDevice *device,
+  GAsyncResult *res,
+  GTask *task)
+{
+MbimMessage *response;
+GError *error = NULL;
+guint32 rssi;
+
+response = mbim_device_command_finish (device, res, );
+if (response &&
+mbim_message_response_get_result (response, 
MBIM_MESSAGE_TYPE_COMMAND_DONE, ) &&
+mbim_message_signal_state_response_parse (
+response,
+,
+NULL, /* error_rate */
+NULL, /* signal_strength_interval */
+NULL, /* rssi_threshold */
+NULL, /* error_rate_threshold */
+)) {
+guint32 quality;
+
+/* Normalize the quality. 99 means unknown, we default it to 0 */
+quality = CLAMP (rssi == 99 ? 0 : rssi, 0, 31) * 100 / 31;
+
+g_task_return_int (task, quality);
+} else
+g_task_return_error (task, error);
+
+g_object_unref (task);
+
+if (response)
+mbim_message_unref (response);
+}
+
+static void
+modem_load_signal_quality (MMIfaceModem *self,
+   GAsyncReadyCallback callback,
+   gpointer user_data)
+{
+MbimDevice *device;
+MbimMessage *message;
+GTask *task;
+
+if (!peek_device (self, , callback, user_data))
+return;
+
+task = g_task_new (self, NULL, callback, user_data);
+
+message = mbim_message_signal_state_query_new (NULL);
+mbim_device_command (device,
+ message,
+ 10,
+ NULL,
+ (GAsyncReadyCallback)signal_state_query_ready,
+ task);
+mbim_message_unref (message);
+}
+
 /*/
 /* Create Bearer (Modem interface) */
 
@@ -3305,6 +3378,7 @@ mm_broadband_modem_mbim_new (const gchar *device,
  MM_BASE_MODEM_PRODUCT_ID, product_id,
  MM_IFACE_MODEM_SIM_HOT_SWAP_SUPPORTED, TRUE,
  MM_IFACE_MODEM_SIM_HOT_SWAP_CONFIGURED, FALSE,
+ MM_IFACE_MODEM_PERIODIC_SIGNAL_CHECK_DISABLED, TRUE,
  NULL);
 }
 
@@ -3379,6 +3453,10 @@ iface_modem_init (MMIfaceModem *iface)
 iface->load_supported_ip_families = modem_load_supported_ip_families;
 iface->load_supported_ip_families_finish = 
modem_load_supported_ip_families_finish;
 
+/* Additional actions */
+iface->load_signal_quality = modem_load_signal_quality;
+iface->load_signal_quality_finish = modem_load_signal_quality_finish;
+
 /* Unneeded things */
 iface->modem_after_power_up = NULL;
 iface->modem_after_power_up_finish = NULL;
@@ -3388,8 +3466,6 @@ iface_modem_init (MMIfaceModem *iface)
 iface->setup_flow_control_finish = NULL;
 iface->setup_charset = NULL;
 iface->setup_charset_finish = NULL;
-iface->load_signal_quality = NULL;
-iface->load_signal_quality_finish = NULL;
 iface->load_access_technologies = NULL;
 iface->load_access_technologies_finish = NULL;
 
-- 

[PATCH] broadband-modem: remove unused GError field in SetupRegistrationChecksContext

2018-02-05 Thread Ben Chan
---
 src/mm-broadband-modem.c | 64 ++--
 1 file changed, 29 insertions(+), 35 deletions(-)

diff --git a/src/mm-broadband-modem.c b/src/mm-broadband-modem.c
index ecefcf28..41abceab 100644
--- a/src/mm-broadband-modem.c
+++ b/src/mm-broadband-modem.c
@@ -8146,7 +8146,6 @@ typedef struct {
 typedef struct {
 MMBroadbandModem *self;
 GSimpleAsyncResult *result;
-GError *error;
 gboolean has_qcdm_port;
 gboolean has_sprint_commands;
 } SetupRegistrationChecksContext;
@@ -8154,44 +8153,39 @@ typedef struct {
 static void
 setup_registration_checks_context_complete_and_free 
(SetupRegistrationChecksContext *ctx)
 {
-if (ctx->error)
-g_simple_async_result_take_error (ctx->result, ctx->error);
-else {
-SetupRegistrationChecksResults *results;
-
-results = g_new0 (SetupRegistrationChecksResults, 1);
-
-/* Skip QCDM steps if no QCDM port */
-if (!ctx->has_qcdm_port) {
-mm_dbg ("Will skip all QCDM-based registration checks");
-results->skip_qcdm_call_manager_step = TRUE;
-results->skip_qcdm_hdr_step = TRUE;
-}
+SetupRegistrationChecksResults *results;
 
-if (MM_IFACE_MODEM_CDMA_GET_INTERFACE 
(ctx->self)->get_detailed_registration_state ==
-modem_cdma_get_detailed_registration_state) {
-/* Skip CDMA1x Serving System check if we have Sprint specific
- * commands AND if the default detailed registration checker
- * is the generic one. Implementations knowing that their
- * CSS response is undesired, should either setup NULL callbacks
- * for the specific step, or subclass this setup and return
- * FALSE themselves. */
-if (ctx->has_sprint_commands) {
-mm_dbg ("Will skip CDMA1x Serving System check, "
-"we do have Sprint commands");
-results->skip_at_cdma1x_serving_system_step = TRUE;
-} else {
-/* If there aren't Sprint specific commands, and the detailed
- * registration state getter wasn't subclassed, skip the step 
*/
-mm_dbg ("Will skip generic detailed registration check, we "
-"don't have Sprint commands");
-results->skip_detailed_registration_state = TRUE;
-}
+results = g_new0 (SetupRegistrationChecksResults, 1);
+
+/* Skip QCDM steps if no QCDM port */
+if (!ctx->has_qcdm_port) {
+mm_dbg ("Will skip all QCDM-based registration checks");
+results->skip_qcdm_call_manager_step = TRUE;
+results->skip_qcdm_hdr_step = TRUE;
+}
+
+if (MM_IFACE_MODEM_CDMA_GET_INTERFACE 
(ctx->self)->get_detailed_registration_state ==
+modem_cdma_get_detailed_registration_state) {
+/* Skip CDMA1x Serving System check if we have Sprint specific
+ * commands AND if the default detailed registration checker
+ * is the generic one. Implementations knowing that their
+ * CSS response is undesired, should either setup NULL callbacks
+ * for the specific step, or subclass this setup and return
+ * FALSE themselves. */
+if (ctx->has_sprint_commands) {
+mm_dbg ("Will skip CDMA1x Serving System check, "
+"we do have Sprint commands");
+results->skip_at_cdma1x_serving_system_step = TRUE;
+} else {
+/* If there aren't Sprint specific commands, and the detailed
+ * registration state getter wasn't subclassed, skip the step */
+mm_dbg ("Will skip generic detailed registration check, we "
+"don't have Sprint commands");
+results->skip_detailed_registration_state = TRUE;
 }
-
-g_simple_async_result_set_op_res_gpointer (ctx->result, results, 
g_free);
 }
 
+g_simple_async_result_set_op_res_gpointer (ctx->result, results, g_free);
 g_simple_async_result_complete_in_idle (ctx->result);
 g_object_unref (ctx->result);
 g_object_unref (ctx->self);
-- 
2.16.0.rc1.238.g530d649a79-goog

___
ModemManager-devel mailing list
ModemManager-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel


Re: [PATCH 1/3] bearer-mbim: remove a unnecessary MbimMessage variable

2018-02-03 Thread Ben Chan
All lgtm. Thanks Dan!


On Fri, Feb 2, 2018 at 7:46 AM Dan Williams <d...@redhat.com> wrote:

> On Wed, 2018-01-31 at 21:57 -0800, Ben Chan wrote:
> > ---
> >  src/mm-bearer-mbim.c | 1 -
> >  1 file changed, 1 deletion(-)
>
> All three pushed to git master and mm-1-6.  The backport to 1.6
> required undoing the GTask stuff, so maybe take a quick look and see if
> it all looks OK to you?
>
> Thanks!
>
> Dan
>
>
> > diff --git a/src/mm-bearer-mbim.c b/src/mm-bearer-mbim.c
> > index 949edfbe..4535018b 100644
> > --- a/src/mm-bearer-mbim.c
> > +++ b/src/mm-bearer-mbim.c
> > @@ -830,7 +830,6 @@ connect_context_step (GTask *task)
> >  return;
> >
> >  case CONNECT_STEP_ENSURE_DISCONNECTED: {
> > -MbimMessage *message;
> >  GError *error = NULL;
> >
> >  message = (mbim_message_connect_set_new (
>
___
ModemManager-devel mailing list
ModemManager-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel


Issue observed on Huawei ME936 since commit 0c7f3380a

2018-01-31 Thread Ben Chan
I've been debugging an issue with Huawei ME936 (in MBIM mode). The issue is
observed since commit 0c7f3380a ("bearer-mbim: ensure session is
disconnected before trying to connect").

>From what I observe, the first connection attempt on ME936 always times out
when MMBearerMbim issues a MBIM_CID_CONNECT
(MBIMActivationCommandDeactivate) command to force deactivating a session
that hasn't yet been activated. But as MMBearerMbim currently ignores that
error, it proceeds to issue MBIM_CID_CONNECT
(MBIMActivationCommandActivate) command, which then also fails. For some
unknown reason (mostly like a firmware bug), the modem takes more than 30s
(i.e. the current timeout) to deactivate a session that hasn't been
activated once.

Increasing the timeout would address the issue, but I'm not too happy to
wait 30-40s for a unnecessary operation. So I thought I could query the
activation state of the session before trying to deactivate it.
Unfortunately, the modem always reports a "unknown" activation state if the
session hasn't been activated once (well, most likely yet another firmware
bug).

As the chance of getting a firmware fix seems slim, I try to address that
in ModemManger / libmbim with the following patches:

---

modemmanager-devel:
https://lists.freedesktop.org/archives/modemmanager-devel/2018-February/006167.html
https://lists.freedesktop.org/archives/modemmanager-devel/2018-February/006165.html
https://lists.freedesktop.org/archives/modemmanager-devel/2018-February/006166.html

libmbim-devel:
https://lists.freedesktop.org/archives/libmbim-devel/2018-February/000985.html
https://lists.freedesktop.org/archives/libmbim-devel/2018-February/000986.html

---

Thanks,
Ben
___
ModemManager-devel mailing list
ModemManager-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel


[PATCH 2/3] bearer-mbim: increase timeout for deactivating IP session to 60s

2018-01-31 Thread Ben Chan
Since commit 0c7f3380a ("bearer-mbim: ensure session is disconnected
before trying to connect"), MMBearerMbim always issues a
MBIM_CID_CONNECT (MBIMActivationCommandDeactivate) command before a
MBIM_CID_CONNECT (MBIMActivationCommandActivate) command during a
connection attempt. That is to ensure that an IP session is actually
deactivated before we try to activate a new IP session.

Unfortunately, it's been observed on Huawei ME936 that it takes more
than 30s for the modem to respond to a MBIM_CID_CONNECT
(MBIMActivationCommandDeactivate) command when trying to deactivate a
session that hasn't been activated.

When the signal is weak, it's also possible that a modem takes more than
30s to deactivate an IP session during a disconnection attempt.

This patch increases the timeout for deactivating an IP session from 30s
to 60s in both connection and disconnection attempt.
---
 src/mm-bearer-mbim.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/mm-bearer-mbim.c b/src/mm-bearer-mbim.c
index 4535018b..f7c721b6 100644
--- a/src/mm-bearer-mbim.c
+++ b/src/mm-bearer-mbim.c
@@ -851,7 +851,7 @@ connect_context_step (GTask *task)
 
 mbim_device_command (ctx->device,
  message,
- 30,
+ 60,
  NULL,
  (GAsyncReadyCallback)ensure_disconnected_ready,
  task);
@@ -1254,7 +1254,7 @@ disconnect_context_step (GTask *task)
 
 mbim_device_command (ctx->device,
  message,
- 30,
+ 60,
  NULL,
  (GAsyncReadyCallback)disconnect_set_ready,
  task);
-- 
2.16.0.rc1.238.g530d649a79-goog

___
ModemManager-devel mailing list
ModemManager-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel


[PATCH 3/3] bearer-mbim: check if IP session is activated before deactivating it

2018-01-31 Thread Ben Chan
It may be undesirable to issue a MBIM_CID_CONNECT
(MBIMActivationCommandDeactivate) command to deactivate an IP session
when the session isn't activated. For instance, it's been observed on
Huawei ME936 that it takes more than 30s for the modem to deactivate a
not-yet-activated session. This patch modifies MMBearerMbim to query if
a session is activated before trying to deactivate the session during a
connection attempt.
---
 src/mm-bearer-mbim.c | 75 
 1 file changed, 75 insertions(+)

diff --git a/src/mm-bearer-mbim.c b/src/mm-bearer-mbim.c
index f7c721b6..652f6825 100644
--- a/src/mm-bearer-mbim.c
+++ b/src/mm-bearer-mbim.c
@@ -211,6 +211,7 @@ typedef enum {
 CONNECT_STEP_FIRST,
 CONNECT_STEP_PACKET_SERVICE,
 CONNECT_STEP_PROVISIONED_CONTEXTS,
+CONNECT_STEP_CHECK_DISCONNECTED,
 CONNECT_STEP_ENSURE_DISCONNECTED,
 CONNECT_STEP_CONNECT,
 CONNECT_STEP_IP_CONFIGURATION,
@@ -644,6 +645,53 @@ ensure_disconnected_ready (MbimDevice   *device,
 connect_context_step (task);
 }
 
+static void
+check_disconnected_ready (MbimDevice   *device,
+  GAsyncResult *res,
+  GTask*task)
+{
+ConnectContext *ctx;
+GError *error = NULL;
+MbimMessage *response;
+guint32 session_id;
+MbimActivationState activation_state;
+
+ctx = g_task_get_task_data (task);
+
+response = mbim_device_command_finish (device, res, );
+if (response &&
+mbim_message_response_get_result (response, 
MBIM_MESSAGE_TYPE_COMMAND_DONE, ) &&
+mbim_message_connect_response_parse (
+response,
+_id,
+_state,
+NULL, /* voice_call_state */
+NULL, /* ip_type */
+NULL, /* context_type */
+NULL, /* nw_error */
+)) {
+mm_dbg ("Session ID '%u': %s", session_id, 
mbim_activation_state_get_string (activation_state));
+} else
+activation_state = MBIM_ACTIVATION_STATE_UNKNOWN;
+
+if (response)
+mbim_message_unref (response);
+
+/* Some modem (e.g. Huawei ME936) reports MBIM_ACTIVATION_STATE_UNKNOWN
+ * when being queried for the activation state before an IP session has
+ * been activated once. Here we expect a modem would at least tell the
+ * truth when the session has been activated, so we proceed to deactivate
+ * the session only the modem indicates the session has been activated or
+ * is being activated.
+ */
+if (activation_state == MBIM_ACTIVATION_STATE_ACTIVATED || 
activation_state == MBIM_ACTIVATION_STATE_ACTIVATING)
+ctx->step = CONNECT_STEP_ENSURE_DISCONNECTED;
+else
+ctx->step = CONNECT_STEP_CONNECT;
+
+connect_context_step (task);
+}
+
 static void
 provisioned_contexts_query_ready (MbimDevice *device,
   GAsyncResult *res,
@@ -829,6 +877,33 @@ connect_context_step (GTask *task)
 mbim_message_unref (message);
 return;
 
+case CONNECT_STEP_CHECK_DISCONNECTED: {
+GError *error = NULL;
+
+message = (mbim_message_connect_query_new (
+   self->priv->session_id,
+   MBIM_ACTIVATION_STATE_UNKNOWN,
+   MBIM_VOICE_CALL_STATE_NONE,
+   MBIM_CONTEXT_IP_TYPE_DEFAULT,
+   mbim_uuid_from_context_type 
(MBIM_CONTEXT_TYPE_INTERNET),
+   0,
+   ));
+if (!message) {
+g_task_return_error (task, error);
+g_object_unref (task);
+return;
+}
+
+mbim_device_command (ctx->device,
+ message,
+ 10,
+ NULL,
+ (GAsyncReadyCallback)check_disconnected_ready,
+ task);
+mbim_message_unref (message);
+return;
+}
+
 case CONNECT_STEP_ENSURE_DISCONNECTED: {
 GError *error = NULL;
 
-- 
2.16.0.rc1.238.g530d649a79-goog

___
ModemManager-devel mailing list
ModemManager-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel


[PATCH 1/3] bearer-mbim: remove a unnecessary MbimMessage variable

2018-01-31 Thread Ben Chan
---
 src/mm-bearer-mbim.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/src/mm-bearer-mbim.c b/src/mm-bearer-mbim.c
index 949edfbe..4535018b 100644
--- a/src/mm-bearer-mbim.c
+++ b/src/mm-bearer-mbim.c
@@ -830,7 +830,6 @@ connect_context_step (GTask *task)
 return;
 
 case CONNECT_STEP_ENSURE_DISCONNECTED: {
-MbimMessage *message;
 GError *error = NULL;
 
 message = (mbim_message_connect_set_new (
-- 
2.16.0.rc1.238.g530d649a79-goog

___
ModemManager-devel mailing list
ModemManager-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel


[PATCH] huawei: handle optional 0x prefix on hex numbers in ^DHCP response

2018-01-26 Thread Ben Chan
On Huawei ME936, the hex numbers in the response to AT^DHCP contain the 0x 
prefix, e.g.

  AT^DHCP?

  ^DHCP: 
0xda7d0e0a,0xff00,0xdb7d0e0a,0xdb7d0e0a,0x01261aac,0x,1,5000

This patch updates mm_huawei_parse_dhcp_response() to handle the
optional 0x prefix.
---
 plugins/huawei/mm-modem-helpers-huawei.c | 2 +-
 plugins/huawei/tests/test-modem-helpers-huawei.c | 6 ++
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/plugins/huawei/mm-modem-helpers-huawei.c 
b/plugins/huawei/mm-modem-helpers-huawei.c
index fde1c791..e92552ed 100644
--- a/plugins/huawei/mm-modem-helpers-huawei.c
+++ b/plugins/huawei/mm-modem-helpers-huawei.c
@@ -230,7 +230,7 @@ mm_huawei_parse_dhcp_response (const char *reply,
  * actually 10.10.1.1.
  */
 
-r = g_regex_new 
("\\^DHCP:\\s*([0-9a-fA-F]+),([0-9a-fA-F]+),([0-9a-fA-F]+),([0-9a-fA-F]+),([0-9a-fA-F]+),([0-9a-fA-F]+),.*$",
 0, 0, NULL);
+r = g_regex_new 
("\\^DHCP:\\s*(?:0[xX])?([0-9a-fA-F]+),(?:0[xX])?([0-9a-fA-F]+),(?:0[xX])?([0-9a-fA-F]+),(?:0[xX])?([0-9a-fA-F]+),(?:0[xX])?([0-9a-fA-F]+),(?:0[xX])?([0-9a-fA-F]+),.*$",
 0, 0, NULL);
 g_assert (r != NULL);
 
 matched = g_regex_match_full (r, reply, -1, 0, 0, _info, 
_error);
diff --git a/plugins/huawei/tests/test-modem-helpers-huawei.c 
b/plugins/huawei/tests/test-modem-helpers-huawei.c
index 46c90f44..70c40db2 100644
--- a/plugins/huawei/tests/test-modem-helpers-huawei.c
+++ b/plugins/huawei/tests/test-modem-helpers-huawei.c
@@ -154,10 +154,16 @@ typedef struct {
 static const DhcpTest dhcp_tests[] = {
 { 
"^DHCP:a3ec5c64,f8ff,a1ec5c64,a1ec5c64,2200b10a,74bba80a,236800,236800\r\n",
   "100.92.236.163", 29, "100.92.236.161", "10.177.0.34", "10.168.187.116" 
},
+{ 
"^DHCP:0xa3ec5c64,0xf8ff,0xa1ec5c64,0xa1ec5c64,0x2200b10a,0x74bba80a,236800,236800\r\n",
+  "100.92.236.163", 29, "100.92.236.161", "10.177.0.34", "10.168.187.116" 
},
 { "^DHCP: 1010A0A,FCFF,2010A0A,2010A0A,0,0,15000,15000\r\n",
   "10.10.1.1", 30, "10.10.1.2", "0.0.0.0", "0.0.0.0" },
 { "^DHCP: 
CCDB080A,F8FF,C9DB080A,C9DB080A,E67B59C0,E77B59C0,85600,85600\r\n",
   "10.8.219.204", 29, "10.8.219.201", "192.89.123.230", "192.89.123.231" },
+{ "^DHCP: 
0xCCDB080A,0xF8FF,0xC9DB080A,0xC9DB080A,0xE67B59C0,0xE77B59C0,85600,85600\r\n",
+  "10.8.219.204", 29, "10.8.219.201", "192.89.123.230", "192.89.123.231" },
+{ "^DHCP: 
0XCCDB080A,0XF8FF,0XC9DB080A,0XC9DB080A,0XE67B59C0,0XE77B59C0,85600,85600\r\n",
+  "10.8.219.204", 29, "10.8.219.201", "192.89.123.230", "192.89.123.231" },
 { NULL }
 };
 
-- 
2.16.0.rc1.238.g530d649a79-goog

___
ModemManager-devel mailing list
ModemManager-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel


[PATCH] iface-modem-3gpp: ignore initial registration check result when appropriate

2018-01-12 Thread Ben Chan
When a modem is being enabled, an initial registration check is
scheduled to determine the current registration state and access
technology. The initial registration check is performed asynchronously
and may not complete before the modem state is transitioned to
'enabled'. When the modem is disabled shortly afterwards, the
registration state is transitioned to 'unknown' and the modem state is
transitioned to 'disabled'. But the completion of the initial
registration check after that can transition the registration state and
modem state to a wrong state. This patch addresses the issue by ignoring
a registration state update if the modem isn't already enabled or being
enabled.
---
 src/mm-iface-modem-3gpp.c | 18 ++
 1 file changed, 18 insertions(+)

diff --git a/src/mm-iface-modem-3gpp.c b/src/mm-iface-modem-3gpp.c
index e1a61ced..f5abc092 100644
--- a/src/mm-iface-modem-3gpp.c
+++ b/src/mm-iface-modem-3gpp.c
@@ -1205,10 +1205,28 @@ update_registration_state (MMIfaceModem3gpp *self,
 new_state == MM_MODEM_3GPP_REGISTRATION_STATE_ROAMING_SMS_ONLY ||
 new_state == MM_MODEM_3GPP_REGISTRATION_STATE_HOME_CSFB_NOT_PREFERRED 
||
 new_state == 
MM_MODEM_3GPP_REGISTRATION_STATE_ROAMING_CSFB_NOT_PREFERRED) {
+MMModemState modem_state;
+
 /* If already reloading registration info, skip it */
 if (ctx->reloading_registration_info)
 return;
 
+/* If the modem isn't already enabled or being enabled, this
+ * registration state update is due to a previously scheduled
+ * initial registration check when the modem was being enabled.
+ * We need to ignore it as otherwise it may cause an incorrect
+ * transition of the registration state and modem state when the
+ * modem is being disabled. */
+modem_state = MM_MODEM_STATE_UNKNOWN;
+g_object_get (self,
+  MM_IFACE_MODEM_STATE, _state,
+  NULL);
+if (modem_state < MM_MODEM_STATE_ENABLING) {
+mm_dbg ("Modem %s: 3GPP Registration state change ignored as modem 
isn't enabled",
+g_dbus_object_get_object_path (G_DBUS_OBJECT (self)));
+return;
+}
+
 mm_info ("Modem %s: 3GPP Registration state changed (%s -> 
registering)",
  g_dbus_object_get_object_path (G_DBUS_OBJECT (self)),
  mm_modem_3gpp_registration_state_get_string (old_state));
-- 
2.16.0.rc1.238.g530d649a79-goog

___
ModemManager-devel mailing list
ModemManager-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel


Incorrect modem state transition due to previous initial registration check

2018-01-12 Thread Ben Chan
Hi Aleksander,

I observed the following issue when trying to disable the modem shortly
after it was enabled by ModemManager. In the last step of enabling the
Modem3gpp interface, the code scheduled an initial registration state check
and then proceeded to completion. While the initial registration check was
executing asynchronously, the modem was going through the disabling
sequence. If the initial registration check completed during or after the
disabling sequence, the modem and registration state were incorrectly
transitioned to a wrong state.  Assuming it may not always be possible to
cancel an ongoing registration checks, one solution is to ignore the
registration check result if modem state < ENABLING. Does it sound
reasonable?

Thanks,
Ben

---

Here's an example log that demonstrates the issue:

### modem was being disabled

2018-01-10T13:14:25.071293+08:00 INFO ModemManager[1485]:   Modem
/org/freedesktop/ModemManager1/Modem/0: state changed (registered ->
disabling)
2018-01-10T13:14:25.071565+08:00 DEBUG ModemManager[1485]:  Modem
has messaging capabilities, disabling the Messaging interface...
2018-01-10T13:14:25.073144+08:00 DEBUG ModemManager[1485]:  Modem
has 3GPP capabilities, disabling the Modem 3GPP interface...
2018-01-10T13:14:25.073170+08:00 DEBUG ModemManager[1485]:  Periodic
3GPP registration checks disabled
...

### modem registration state was set to unknown

2018-01-10T13:14:25.075148+08:00 INFO ModemManager[1485]:   Modem
/org/freedesktop/ModemManager1/Modem/0: 3GPP Registration state changed
(home -> unknown)
2018-01-10T13:14:25.075269+08:00 DEBUG ModemManager[1485]:  Bearer
not allowed to connect, not registered in 3GPP network
2018-01-10T13:14:25.075315+08:00 DEBUG ModemManager[1485]:  Modem
/org/freedesktop/ModemManager1/Modem/0: access technology changed (lte ->
unknown)

### modem state was transitioned to 'disabled'

2018-01-10T13:14:25.075654+08:00 INFO ModemManager[1485]:   Modem
/org/freedesktop/ModemManager1/Modem/0: state changed (disabling ->
disabled)

### Previously scheduled initial registration check completed and returned
the registration state

2018-01-10T13:14:25.078755+08:00 DEBUG ModemManager[1485]: [/dev/cdc-wdm0]
Received message...#012>> RAW:#012>>   length = 120#012>>
data   =
03:00:00:80:78:00:00:00:7C:2D:00:00:01:00:00:00:00:00:00:00:A2:89:CC:33:BC:BB:8B:4F:B6:B0:13:3E:C2:AA:E6:DF:09:00:00:00:00:00:00:00:48:00:00:00:00:00:00:00:03:00:00:00:01:00:00:00:20:00:00:00:01:00:00:00:30:00:00:00:0A:00:00:00:3C:00:00:00:0C:00:00:00:00:00:00:00:00:00:00:00:02:00:00:00:34:00:36:00:30:00:30:00:31:00:00:00:30:00:30:00:30:00:30:00:30:00:30:00
2018-01-10T13:14:25.078796+08:00 DEBUG ModemManager[1485]: [/dev/cdc-wdm0]
Received message (translated)...#012>> Header:#012>>   length
  = 120#012>>   type= command-done (0x8003)#012>>
transaction = 11644#012>> Fragment header:#012>>   total   =
1#012>>   current = 0#012>> Contents:#012>>   status error =
'None' (0x)#012>>   service  = 'basic-connect'
(a289cc33-bcbb-8b4f-b6b0-133ec2aae6df)#012>>   cid  =
'register-state' (0x0009)

### modem registration was (potentially incorrectly) transitioned from
'unknown' to 'registering'

2018-01-10T13:14:25.078877+08:00 INFO ModemManager[1485]:   Modem
/org/freedesktop/ModemManager1/Modem/0: 3GPP Registration state changed
(unknown -> registering)
2018-01-10T13:14:25.078967+08:00 DEBUG ModemManager[1485]:  Modem
/org/freedesktop/ModemManager1/Modem/0: access technology changed (unknown
-> lte)
2018-01-10T13:14:25.078988+08:00 DEBUG ModemManager[1485]:  Initial
3GPP registration checks finished
2018-01-10T13:14:25.079392+08:00 INFO ModemManager[1485]:   Modem
/org/freedesktop/ModemManager1/Modem/0: 3GPP Registration state changed
(registering -> home)

### modem state was incorrectly transitioned from 'disabled' back to
'registered'

2018-01-10T13:14:25.079456+08:00 INFO ModemManager[1485]:   Modem
/org/freedesktop/ModemManager1/Modem/0: state changed (disabled ->
registered)
___
ModemManager-devel mailing list
ModemManager-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel


Re: Initial signal quality query on MBIM modems

2018-01-05 Thread Ben Chan
On Fri, Jan 5, 2018 at 7:33 AM Dan Williams <d...@redhat.com> wrote:

> On Fri, 2018-01-05 at 06:57 +0000, Ben Chan wrote:
> > Hi Aleksander and Dan
> >
> > ModemManager currently relies on unsolicited MBIM_CID_SIGNAL_STATE
> > notification to obtain signal quality updates, and it doesn't query
> > the
> > initial signal quality. I've observed that some MBIM modems issue a
> > MBIM_CID_SIGNAL_STATE
> > notification only when there is a notable change in RSSI. The signal
> > quality may remain at 0 for quite some time. It's more noticeable
> > when
> > simply restarting ModemManager after the modem has been initialized
> > and
> > enabled once.
> >
> > We could simply enable periodic signal quality polling on an MBIM
> > modem,
> > but that's less ideal as it may unnecessarily wake the modem up from
> > USB
> > selective suspend (unless we use a much longer polling period).
> >
> > I'm thinking about letting ModemManager issue an initial
> > MBIM_CID_SIGNAL_STATE query when it enables MBIM_CID_SIGNAL_STATE
> > notification.  Does that sound reasonable to you. If so, I'll submit
> > a
> > patch.
>
> Sounds OK to me.
>

On a related question, it seems like QMI uses both periodic polling and
unsolicited indication for signal strength updates. Is that intentional?
 If we decide that it's best to handle signal updates over unsolicited
notifications for MBIM and QMI modems, perhaps we could bake the logic in
MMIfaceModem instead.  Currently, MMIfaceModem skips periodic updates if
the load_signal_quality function pointer is NULL or if load_signal_quality
returns UNSUPPORTED. Neither addresses the case where we want to call
load_signal_quality to load the initial signal quality but skip further
periodic polling.  I guess we could use a
MM_IFACE_MODEM_PERIODIC_SIGNAL_UPDATES_DESIRED property to indicate such an
intention?


>
> Dan
>
___
ModemManager-devel mailing list
ModemManager-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel


Initial signal quality query on MBIM modems

2018-01-04 Thread Ben Chan
Hi Aleksander and Dan

ModemManager currently relies on unsolicited MBIM_CID_SIGNAL_STATE
notification to obtain signal quality updates, and it doesn't query the
initial signal quality. I've observed that some MBIM modems issue a
MBIM_CID_SIGNAL_STATE
notification only when there is a notable change in RSSI. The signal
quality may remain at 0 for quite some time. It's more noticeable when
simply restarting ModemManager after the modem has been initialized and
enabled once.

We could simply enable periodic signal quality polling on an MBIM modem,
but that's less ideal as it may unnecessarily wake the modem up from USB
selective suspend (unless we use a much longer polling period).

I'm thinking about letting ModemManager issue an initial
MBIM_CID_SIGNAL_STATE query when it enables MBIM_CID_SIGNAL_STATE
notification.  Does that sound reasonable to you. If so, I'll submit a
patch.

Thanks,
Ben
___
ModemManager-devel mailing list
ModemManager-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel


[PATCH] sms-part-3gpp: decode Unicode SMS with non-BMP code points

2017-12-15 Thread Ben Chan
Depsite 3GPP TS 23.038 specifies that Unicode SMS messages are encoded in
UCS-2, UTF-16 encoding is commonly used instead on many modern platforms to
allow encoding code points that fall outside the Basic Multilingual Plane
(BMP), such as Emoji. Most of the UCS-2 code points are identical to their
equivalent UTF-16 code points.  In UTF-16, non-BMP code points are encoded in a
pair of surrogate code points (i.e. a high surrogate in 0xD800..0xDBFF,
followed by a low surrogate in 0xDC00..0xDFFF). An isolated surrogate code
point has no general interpretation in UTF-16, but could be a valid (though
unmapped) code point in UCS-2.

This patch modifies the 3GPP SMS decoding to first try UTF-16BE and then fall
back to UCS-2BE on failure. If both fail, an empty string is returned
instead of a NULL pointer.
---
Hi Aleksander and Dan,

I found that ModemManager failed to decode SMS with Emoji and thus researched
into SMS encoding used by modern mobile platforms. It seems like UTF-16BE is
used in practice instead of UCS-2 as specified by the 3GPP spec. It seems like
we can practically use UTF-16BE for most cases as most of the UCS-2 code points
are identical to their equivalent UTF-16 code points. The UCS-2 fallback is
mostly to handle isolated surrogate code points, which should be rare given
that they don't seem to map to a "character" in UCS-2. Given that the 3GPP spec
assumes UCS-2BE, I also assume UTF-16BE by default as I haven't observed any
byte order mark (BOM) in SMS so far.

That said, I've only tested with some modems and US carriers. If you've some
spare cycle, could you try sending SMS with Emoji and other unicode characters
to your modems with your local carrier and see if MM correctly decodes the SMS
with / without this patch.

Thanks,
Ben


 src/mm-sms-part-3gpp.c | 24 ++--
 1 file changed, 22 insertions(+), 2 deletions(-)

diff --git a/src/mm-sms-part-3gpp.c b/src/mm-sms-part-3gpp.c
index 0b59b247..f7beaf61 100644
--- a/src/mm-sms-part-3gpp.c
+++ b/src/mm-sms-part-3gpp.c
@@ -247,8 +247,28 @@ sms_decode_text (const guint8 *text, int len, 
MMSmsEncoding encoding, int bit_of
 mm_dbg ("   Got UTF-8 text: '%s'", utf8);
 g_free (unpacked);
 } else if (encoding == MM_SMS_ENCODING_UCS2) {
-mm_dbg ("Converting SMS part text from UCS-2BE to UTF8...");
-utf8 = g_convert ((char *) text, len, "UTF8", "UCS-2BE", NULL, NULL, 
NULL);
+/* Depsite 3GPP TS 23.038 specifies that Unicode SMS messages are
+ * encoded in UCS-2, UTF-16 encoding is commonly used instead on many
+ * modern platforms to allow encoding code points that fall outside the
+ * Basic Multilingual Plane (BMP), such as Emoji. Most of the UCS-2
+ * code points are identical to their equivalent UTF-16 code points.
+ * In UTF-16, non-BMP code points are encoded in a pair of surrogate
+ * code points (i.e. a high surrogate in 0xD800..0xDBFF, followed by a
+ * low surrogate in 0xDC00..0xDFFF). An isolated surrogate code point
+ * has no general interpretation in UTF-16, but could be a valid
+ * (though unmapped) code point in UCS-2. Here we first try to decode
+ * the SMS message in UTF-16BE, and if that fails, fall back to decode
+ * in UCS-2BE.
+ */
+mm_dbg ("Converting SMS part text from UTF16BE to UTF8...");
+utf8 = g_convert ((const gchar *) text, len, "UTF8", "UTF16BE", NULL, 
NULL, NULL);
+if (!utf8) {
+mm_dbg ("Converting SMS part text from UCS-2BE to UTF8...");
+utf8 = g_convert ((const gchar *) text, len, "UTF8", "UCS-2BE", 
NULL, NULL, NULL);
+}
+if (!utf8)
+utf8 = g_strdup ("");
+
 mm_dbg ("   Got UTF-8 text: '%s'", utf8);
 } else {
 g_warn_if_reached ();
-- 
2.15.1.504.g5279b80103-goog

___
ModemManager-devel mailing list
ModemManager-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel


Re: Roadmap for next stable 1.8?

2017-11-03 Thread Ben Chan
The new device filter policies mechanism may be nice to include, and would
benefit from some testing in the field.


On Fri, Nov 3, 2017 at 11:42 AM Dan Williams  wrote:

> On Fri, 2017-11-03 at 09:55 +0100, Aleksander Morgado wrote:
> > Hey,
> >
> > It's been already a while since we released 1.6.0, and there are a
> > lot
> > of things in git master that haven't been released yet, so maybe it's
> > time for a 1.8.0 release.
> >
> > I see two big pending things that could get finished before doing
> > 1.8.0, which is the GTask migration and especially the new device
> > filter policies. Actually, the GTask migration itself isn't that
> > critical for a stable release, just a good thing to have, but we're
> > so
> > close to be fully migrated that it probably makes sense.
> >
> > The one big thing that may not get to 1.8.0 on time could be the
> > Infineon plugin... or maybe we could include what we have and fix it
> > properly for 1.8.x stable updates.
> >
> > What does everyone think?
>
> Sounds good; might be nice to get QMI LOC support but I don't think we
> need to block on that.  Slowly working on it but not sure when I'd have
> enough to get a position fix.
>
> Dan
>
___
ModemManager-devel mailing list
ModemManager-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel


[PATCH] sms-cdma-part: fix tautological-constant-compare compiler warning

2017-10-25 Thread Ben Chan
From: "Luis A. Lozano" 

This patch fixes the following compiler warning issued by clang:

  mm-sms-part-cdma.c:301:46: mcomparison 'guint8' (aka 'unsigned char') <= 255 
is always true
  [-Werror,-Wtautological-constant-compare]
---
 src/mm-sms-part-cdma.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/mm-sms-part-cdma.c b/src/mm-sms-part-cdma.c
index 167eda83..5379c58b 100644
--- a/src/mm-sms-part-cdma.c
+++ b/src/mm-sms-part-cdma.c
@@ -298,7 +298,7 @@ cause_code_to_delivery_state (guint8 error_class,
 else if (cause_code == 101)
 /* 101 reserved */
 delivery_state += CAUSE_CODE_GENERAL_PROBLEM_OTHER;
-else if (cause_code >= 108 && cause_code <= 255)
+else if (cause_code >= 108) /* cause_code <= 255 is always true */
 /* 108 to 223 reserved, treat as CAUSE_CODE_GENERAL_PROBLEM_OTHER
  * 224 to 255 reserved for TIA/EIA-41 extension, otherwise treat as 
CAUSE_CODE_GENERAL_PROBLEM_OTHER */
 delivery_state += CAUSE_CODE_GENERAL_PROBLEM_OTHER;
-- 
2.15.0.rc2.357.g7e34df9404-goog

___
ModemManager-devel mailing list
ModemManager-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel


[PATCH] novatel: port load_supported_modes to use GTask

2017-10-20 Thread Ben Chan
---
 plugins/novatel/mm-broadband-modem-novatel.c | 22 +++---
 1 file changed, 7 insertions(+), 15 deletions(-)

diff --git a/plugins/novatel/mm-broadband-modem-novatel.c 
b/plugins/novatel/mm-broadband-modem-novatel.c
index 6fd0c478..fdb4ba52 100644
--- a/plugins/novatel/mm-broadband-modem-novatel.c
+++ b/plugins/novatel/mm-broadband-modem-novatel.c
@@ -58,16 +58,13 @@ load_supported_modes_finish (MMIfaceModem *self,
  GAsyncResult *res,
  GError **error)
 {
-if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), 
error))
-return NULL;
-
-return g_array_ref (g_simple_async_result_get_op_res_gpointer 
(G_SIMPLE_ASYNC_RESULT (res)));
+return g_task_propagate_pointer (G_TASK (res), error);
 }
 
 static void
 parent_load_supported_modes_ready (MMIfaceModem *self,
GAsyncResult *res,
-   GSimpleAsyncResult *simple)
+   GTask *task)
 {
 GError *error = NULL;
 GArray *all;
@@ -77,9 +74,8 @@ parent_load_supported_modes_ready (MMIfaceModem *self,
 
 all = iface_modem_parent->load_supported_modes_finish (self, res, );
 if (!all) {
-g_simple_async_result_take_error (simple, error);
-g_simple_async_result_complete (simple);
-g_object_unref (simple);
+g_task_return_error (task, error);
+g_object_unref (task);
 return;
 }
 
@@ -112,9 +108,8 @@ parent_load_supported_modes_ready (MMIfaceModem *self,
 g_array_unref (all);
 g_array_unref (combinations);
 
-g_simple_async_result_set_op_res_gpointer (simple, filtered, 
(GDestroyNotify) g_array_unref);
-g_simple_async_result_complete (simple);
-g_object_unref (simple);
+g_task_return_pointer (task, filtered, (GDestroyNotify) g_array_unref);
+g_object_unref (task);
 }
 
 static void
@@ -126,10 +121,7 @@ load_supported_modes (MMIfaceModem *self,
 iface_modem_parent->load_supported_modes (
 MM_IFACE_MODEM (self),
 (GAsyncReadyCallback)parent_load_supported_modes_ready,
-g_simple_async_result_new (G_OBJECT (self),
-   callback,
-   user_data,
-   load_supported_modes));
+g_task_new (self, NULL, callback, user_data));
 }
 
 /*/
-- 
2.15.0.rc0.271.g36b669edcc-goog

___
ModemManager-devel mailing list
ModemManager-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel


[PATCH] anydata: port get_detailed_registration_state to use GTask

2017-10-20 Thread Ben Chan
---
 plugins/anydata/mm-broadband-modem-anydata.c | 91 +++-
 1 file changed, 35 insertions(+), 56 deletions(-)

diff --git a/plugins/anydata/mm-broadband-modem-anydata.c 
b/plugins/anydata/mm-broadband-modem-anydata.c
index 4b579da1..a4acaf27 100644
--- a/plugins/anydata/mm-broadband-modem-anydata.c
+++ b/plugins/anydata/mm-broadband-modem-anydata.c
@@ -47,34 +47,6 @@ typedef struct {
 MMModemCdmaRegistrationState detailed_evdo_state;
 } DetailedRegistrationStateResults;
 
-typedef struct {
-MMBroadbandModem *self;
-GSimpleAsyncResult *result;
-MMModemCdmaRegistrationState cdma1x_state;
-MMModemCdmaRegistrationState evdo_state;
-GError *error;
-} DetailedRegistrationStateContext;
-
-static void
-detailed_registration_state_context_complete_and_free 
(DetailedRegistrationStateContext *ctx)
-{
-if (ctx->error)
-g_simple_async_result_take_error (ctx->result, ctx->error);
-else {
-DetailedRegistrationStateResults *results;
-
-results = g_new (DetailedRegistrationStateResults, 1);
-results->detailed_cdma1x_state = ctx->cdma1x_state;
-results->detailed_evdo_state = ctx->evdo_state;
-g_simple_async_result_set_op_res_gpointer (ctx->result, results, 
g_free);
-}
-
-g_simple_async_result_complete (ctx->result);
-g_object_unref (ctx->result);
-g_object_unref (ctx->self);
-g_free (ctx);
-}
-
 static gboolean
 get_detailed_registration_state_finish (MMIfaceModemCdma *self,
 GAsyncResult *res,
@@ -84,31 +56,36 @@ get_detailed_registration_state_finish (MMIfaceModemCdma 
*self,
 {
 DetailedRegistrationStateResults *results;
 
-if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), 
error))
+results = g_task_propagate_pointer (G_TASK (res), error);
+if (!results)
 return FALSE;
 
-results = g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT 
(res));
 *detailed_cdma1x_state = results->detailed_cdma1x_state;
 *detailed_evdo_state = results->detailed_evdo_state;
+g_free (results);
 return TRUE;
 }
 
 static void
 hstate_ready (MMIfaceModemCdma *self,
   GAsyncResult *res,
-  DetailedRegistrationStateContext *ctx)
+  GTask *task)
 {
+DetailedRegistrationStateResults *results;
 GError *error = NULL;
 const gchar *response;
 GRegex *r;
 GMatchInfo *match_info;
 
+results = g_task_get_task_data (task);
+
 response = mm_base_modem_at_command_finish (MM_BASE_MODEM (self), res, 
);
 if (error) {
 /* Leave superclass' reg state alone if AT*HSTATE isn't supported */
 g_error_free (error);
-/* Result is set here when completing */
-detailed_registration_state_context_complete_and_free (ctx);
+
+g_task_return_pointer (task, g_memdup (results, sizeof (*results)), 
g_free);
+g_object_unref (task);
 return;
 }
 
@@ -135,11 +112,11 @@ hstate_ready (MMIfaceModemCdma *self,
  * It may be that IDLE actually means NO SERVICE too; not sure.
  */
 if (dbm > -105)
-ctx->evdo_state = 
MM_MODEM_CDMA_REGISTRATION_STATE_REGISTERED;
+results->detailed_evdo_state = 
MM_MODEM_CDMA_REGISTRATION_STATE_REGISTERED;
 break;
 case 4:  /* ACCESS */
 case 5:  /* CONNECT */
-ctx->evdo_state = MM_MODEM_CDMA_REGISTRATION_STATE_REGISTERED;
+results->detailed_evdo_state = 
MM_MODEM_CDMA_REGISTRATION_STATE_REGISTERED;
 break;
 default:
 mm_warn ("ANYDATA: unknown *STATE (%d); assuming no service.", 
val);
@@ -155,25 +132,29 @@ hstate_ready (MMIfaceModemCdma *self,
 g_match_info_free (match_info);
 g_regex_unref (r);
 
-/* Result is set here when completing */
-detailed_registration_state_context_complete_and_free (ctx);
+g_task_return_pointer (task, g_memdup (results, sizeof (*results)), 
g_free);
+g_object_unref (task);
 }
 
 static void
 state_ready (MMIfaceModemCdma *self,
  GAsyncResult *res,
- DetailedRegistrationStateContext *ctx)
+ GTask *task)
 {
+DetailedRegistrationStateResults *results;
+GError *error = NULL;
 const gchar *response;
 GRegex *r;
 GMatchInfo *match_info;
 
-response = mm_base_modem_at_command_finish (MM_BASE_MODEM (self), res, 
>error);
-if (ctx->error) {
-detailed_registration_state_context_complete_and_free (ctx);
+response = mm_base_modem_at_command_finish (MM_BASE_MODEM (self), res, 
);
+if (error) {
+g_task_return_error (task, error);
+g_object_unref (task);
 return;
 }
 
+results = g_task_get_task_data (task);
 response = mm_strip_tag (response, "*STATE:");
 
 /* Format is ",,..." */
@@ -197,12 +178,12 @@ state_ready 

[PATCH] anydata: remove unused 'port' field in DetailedRegistrationStateContext

2017-10-06 Thread Ben Chan
The 'port' field in DetailedRegistrationStateContext is initialized to
NULL but never updated or used.

When detailed_registration_state_context_complete_and_free() calls
g_object_unref() on the NULL 'port' field, an assertion is raised.
---
 plugins/anydata/mm-broadband-modem-anydata.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/plugins/anydata/mm-broadband-modem-anydata.c 
b/plugins/anydata/mm-broadband-modem-anydata.c
index 4a1da0f9..4b579da1 100644
--- a/plugins/anydata/mm-broadband-modem-anydata.c
+++ b/plugins/anydata/mm-broadband-modem-anydata.c
@@ -50,7 +50,6 @@ typedef struct {
 typedef struct {
 MMBroadbandModem *self;
 GSimpleAsyncResult *result;
-MMPortSerialAt *port;
 MMModemCdmaRegistrationState cdma1x_state;
 MMModemCdmaRegistrationState evdo_state;
 GError *error;
@@ -71,7 +70,6 @@ detailed_registration_state_context_complete_and_free 
(DetailedRegistrationState
 }
 
 g_simple_async_result_complete (ctx->result);
-g_object_unref (ctx->port);
 g_object_unref (ctx->result);
 g_object_unref (ctx->self);
 g_free (ctx);
-- 
2.14.2.920.gcf0c67979c-goog

___
ModemManager-devel mailing list
ModemManager-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel


[PATCH 1/2] wavecom: fix memory leak

2017-10-06 Thread Ben Chan
---
 plugins/wavecom/mm-broadband-modem-wavecom.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/plugins/wavecom/mm-broadband-modem-wavecom.c 
b/plugins/wavecom/mm-broadband-modem-wavecom.c
index 94115408..5da6c232 100644
--- a/plugins/wavecom/mm-broadband-modem-wavecom.c
+++ b/plugins/wavecom/mm-broadband-modem-wavecom.c
@@ -305,13 +305,14 @@ wwsm_read_ready (MMBaseModem  *self,
 }
 }
 
-if (result->allowed == MM_MODEM_MODE_NONE)
+if (result->allowed == MM_MODEM_MODE_NONE) {
 g_task_return_new_error (task,
  MM_CORE_ERROR,
  MM_CORE_ERROR_FAILED,
  "Unknown wireless data service reply: '%s'",
  response);
-else
+g_free (result);
+} else
 g_task_return_pointer (task, result, g_free);
 g_object_unref (task);
 
-- 
2.14.2.920.gcf0c67979c-goog

___
ModemManager-devel mailing list
ModemManager-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel


[PATCH 2/2] simtech: fix memory leak

2017-10-06 Thread Ben Chan
---
 plugins/simtech/mm-broadband-modem-simtech.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/plugins/simtech/mm-broadband-modem-simtech.c 
b/plugins/simtech/mm-broadband-modem-simtech.c
index 45cc5542..c511629e 100644
--- a/plugins/simtech/mm-broadband-modem-simtech.c
+++ b/plugins/simtech/mm-broadband-modem-simtech.c
@@ -565,6 +565,7 @@ cnmp_query_ready (MMBroadbandModemSimtech *self,
 "Unknown acquisition order preference: '%d'",
 ctx->acqord);
 g_object_unref (task);
+g_free (result);
 return;
 }
 break;
@@ -589,6 +590,7 @@ cnmp_query_ready (MMBroadbandModemSimtech *self,
 "Unknown mode preference: '%d'",
 ctx->modepref);
 g_object_unref (task);
+g_free (result);
 return;
 }
 
-- 
2.14.2.920.gcf0c67979c-goog

___
ModemManager-devel mailing list
ModemManager-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel


[PATCH] novatel-lte: implement load_unlock_retries

2017-10-06 Thread Ben Chan
This patch implements load_unlock_retries() for the Novatel LTE modem by
using the AT$NWPINR? command to query the number of retries left for
entering PIN1 or PIN2.

Ported from the original patch by Arman Uguray :
https://chromium-review.googlesource.com/c/58118
---
 plugins/novatel/mm-broadband-modem-novatel-lte.c | 65 
 1 file changed, 65 insertions(+)

diff --git a/plugins/novatel/mm-broadband-modem-novatel-lte.c 
b/plugins/novatel/mm-broadband-modem-novatel-lte.c
index 38f7e7e7..7b6396d1 100644
--- a/plugins/novatel/mm-broadband-modem-novatel-lte.c
+++ b/plugins/novatel/mm-broadband-modem-novatel-lte.c
@@ -399,6 +399,69 @@ load_current_bands (MMIfaceModem *self,
 g_task_new (self, NULL, callback, user_data));
 }
 
+/*/
+/* Load unlock retries (Modem interface) */
+
+static MMUnlockRetries *
+load_unlock_retries_finish (MMIfaceModem *self,
+GAsyncResult *res,
+GError **error)
+{
+return g_task_propagate_pointer (G_TASK (res), error);
+}
+
+static void
+load_unlock_retries_ready (MMBaseModem *self,
+   GAsyncResult *res,
+   GTask *task)
+{
+const gchar *response;
+GError *error = NULL;
+gint pin_num, pin_value;
+int scan_count;
+
+response = mm_base_modem_at_command_finish (MM_BASE_MODEM (self), res, 
);
+if (!response) {
+mm_dbg ("Couldn't query unlock retries: '%s'", error->message);
+g_task_return_error (task, error);
+g_object_unref (task);
+return;
+}
+
+response = mm_strip_tag (response, "$NWPINR:");
+
+scan_count = sscanf (response, "PIN%d, %d", _num, _value);
+if (scan_count != 2 || (pin_num != 1 && pin_num != 2)) {
+g_task_return_new_error (task,
+ MM_CORE_ERROR,
+ MM_CORE_ERROR_FAILED,
+ "Invalid unlock retries response: '%s'",
+ response);
+} else {
+MMUnlockRetries *retries;
+
+retries = mm_unlock_retries_new ();
+mm_unlock_retries_set (retries,
+   pin_num == 1 ? MM_MODEM_LOCK_SIM_PIN : 
MM_MODEM_LOCK_SIM_PIN2,
+   pin_value);
+g_task_return_pointer (task, retries, g_object_unref);
+}
+g_object_unref (task);
+}
+
+static void
+load_unlock_retries (MMIfaceModem *self,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+mm_base_modem_at_command (MM_BASE_MODEM (self),
+  "$NWPINR?",
+  20,
+  FALSE,
+  (GAsyncReadyCallback)load_unlock_retries_ready,
+  g_task_new (self, NULL, callback, user_data));
+}
+
 /*/
 /* Load access technologies (Modem interface) */
 
@@ -616,6 +679,8 @@ iface_modem_init (MMIfaceModem *iface)
 iface->load_supported_bands_finish = load_supported_bands_finish;
 iface->load_current_bands = load_current_bands;
 iface->load_current_bands_finish = load_current_bands_finish;
+iface->load_unlock_retries = load_unlock_retries;
+iface->load_unlock_retries_finish = load_unlock_retries_finish;
 /* No support for setting bands, as it destabilizes the modem. */
 iface->load_access_technologies = load_access_technologies;
 iface->load_access_technologies_finish = load_access_technologies_finish;
-- 
2.14.2.920.gcf0c67979c-goog

___
ModemManager-devel mailing list
ModemManager-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel


Re: [rfc] Propagate manufacturer information from MMKernelDevice to MMBroadbandModem

2017-10-04 Thread Ben Chan
On Wed, Oct 4, 2017 at 4:51 AM, Bjørn Mork <bj...@mork.no> wrote:
> Ben Chan <benc...@chromium.org> writes:
>
>> * The few MBIM modems I have report the correct manufacturer through
>> the manufacturer string descriptor, but I suspect some MBIM modems
>> don't.
>
> FWIW, this is true for all the MBIM modems I've used so far too.  Few
> vendors manage to write their name in a consistent way, but I guess that
> is the same regardless of the source.
>

Hi Bjørn, thanks for checking and providing the list :)

> bjorn@miraculix:/var/tmp/usb$ for f in `grep -l 'CDC MBIM' */lsusb.txt`;
do echo -n "$f: "; grep Manu $f; done
> 0bdb:1926/lsusb.txt:   iManufacturer   1 Lenovo
> 1199:68a2/lsusb.txt:   iManufacturer   4 Sierra Wireless,
Incorporated
> 1199:9041/lsusb.txt:   iManufacturer   1 Sierra Wireless,
Incorporated
> 1199:9079/lsusb.txt:   iManufacturer   1 Sierra Wireless,
Incorporated
> 1199:a001/lsusb.txt:   iManufacturer   1 Sierra Wireless Inc.
> 12d1:1446/lsusb.txt:   iManufacturer   4 Huawei Technologies
> 12d1:157d/lsusb.txt:   iManufacturer   1 HUAWEI_MOBILE
> 12d1:15bb/lsusb.txt:   iManufacturer   6 Huawei Technologies Co.,
Ltd.
> 2001:7d01/lsusb.txt:   iManufacturer   9 D-Link,Inc
> 258d:e000/lsusb.txt:   iManufacturer   1 Sequans Communications
>
> What's the "correct" manufacturer, BTW?  Looking over this list, I note
> that the OEM and chipset vendors Ericsson, Intel, Qualcomm and Mediatek
> are all anonymous here.

Yeah, it's hard to tell which one is more "correct".  It's really up to the
OEMs to specify the appropriate USB vendor ID and manufacturer string
descriptor. Some may specify the chipset vendor and some may choose the
module vendor.  Some OEMs simply "rebrand" existing modules with a new
sticker on the modules but keep vendor ID and manufacturer string unchanged.

>
> The USB vendor ID gives a slightly different list, but not necessarily
> more correct:
>
> bjorn@miraculix:/var/tmp/usb$ for f in `grep -l 'CDC MBIM' */lsusb.txt`;
do echo -n "$f: "; grep idVend $f; done
> 0bdb:1926/lsusb.txt:   idVendor   0x0bdb Ericsson Business Mobile
Networks BV
> 1199:68a2/lsusb.txt:   idVendor   0x1199 Sierra Wireless, Inc.
> 1199:9041/lsusb.txt:   idVendor   0x1199 Sierra Wireless, Inc.
> 1199:9079/lsusb.txt:   idVendor   0x1199 Sierra Wireless, Inc.
> 1199:a001/lsusb.txt:   idVendor   0x1199 Sierra Wireless, Inc.
> 12d1:1446/lsusb.txt:   idVendor   0x12d1 Huawei Technologies Co.,
Ltd.
> 12d1:157d/lsusb.txt:   idVendor   0x12d1 Huawei Technologies Co.,
Ltd.
> 12d1:15bb/lsusb.txt:   idVendor   0x12d1 Huawei Technologies Co.,
Ltd.
> 2001:7d01/lsusb.txt:   idVendor   0x2001 D-Link Corp.
> 258d:e000/lsusb.txt:   idVendor   0x258d
>
>
> Bjørn
___
ModemManager-devel mailing list
ModemManager-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel


Re: [rfc] Propagate manufacturer information from MMKernelDevice to MMBroadbandModem

2017-10-04 Thread Ben Chan
On Wed, Oct 4, 2017 at 12:46 AM, Aleksander Morgado
 wrote:
> Hey,
>
>>
>> Unlike AT or QMI, MBIM doesn't define a standard command to query
>> manufacturer information. But the manufacturer information can often
>> be inferred from the USB vendor ID or retrieved through the
>> Manufacturer string descriptor at the USB level.
>>
>> MMBroadbandModemMbim currently uses the plugin name as the
>> manufacturer, which may not be very useful if the generic plugin is
>> used. I wonder if it makes sense to let MMBroadbandModemMbim make use
>> of the manufacturer information, if available, from MMKernelDevice.
>> Obviously, modem vendors would like us to report a proper manufacturer
>> name than 'Generic' :)
>>
>> I've put together a few patches that plumb up the logic, which you
>> check it out from this github branch:
>> https://github.com/cbchan/ModemManager/commits/mbim-manufacturer.
>> I'd like to hear your thoughts on this approach before creating a pull
>> request. In particular,
>>
>
> I personally find the idea ok.
>
>> * The few MBIM modems I have report the correct manufacturer through
>> the manufacturer string descriptor, but I suspect some MBIM modems
>> don't.
>>
>
> And the fallback back to plugin name is ok in that case.
>
>> *  I find the propagation (i.e. MMKernelDevice -> MMDevice -> MMPlugin
>> -> MMBaseModem -> MMBroadbandModemMbim) a bit involved and convoluted.
>> Perhaps there is simpler way to do that?
>>
>
> I believe you only need the API in MMKernelDevice, and then just:
>
> manufacturer = g_strdup (
> mm_kernel_device_get_physdev_manufacturer (
> mm_port_peek_kernel_device (
> MM_PORT (mm_base_modem_peek_port_mbim (MM_BASE_MODEM (self);
>
> (or something along those lines)

Thanks Aleksander. That works like a charm.

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


Re: [review] https://github.com/aleksander0m/ModemManager/tree/gtask-plugins-simtech

2017-10-04 Thread Ben Chan
On Fri, Sep 22, 2017 at 5:05 AM, Aleksander Morgado
 wrote:
> Hey,
>
> The following branch includes several commits to port the simtech
> plugin to GTask:
> https://github.com/aleksander0m/ModemManager/tree/gtask-plugins-simtech

lgtm w/ one nit

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


Re: [review] https://github.com/aleksander0m/ModemManager/tree/gtask-plugins-thuraya

2017-10-04 Thread Ben Chan
On Fri, Sep 22, 2017 at 5:09 AM, Aleksander Morgado
 wrote:
> Hey,
>
> The following branch includes several commits to port the Thuraya
> plugin to GTask
> https://github.com/aleksander0m/ModemManager/tree/gtask-plugins-thuraya

lgtm

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


Re: [review] https://github.com/aleksander0m/ModemManager/tree/gtask-plugins-dell

2017-10-04 Thread Ben Chan
On Fri, Sep 22, 2017 at 5:04 AM, Aleksander Morgado
 wrote:
> Hey,
>
> This branch contains a single patch to port the Dell plugin to GTask:
> https://github.com/aleksander0m/ModemManager/tree/gtask-plugins-dell

lgtm

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


Re: [review] https://github.com/aleksander0m/ModemManager/tree/gtask-plugins-via

2017-10-04 Thread Ben Chan
On Fri, Sep 22, 2017 at 5:11 AM, Aleksander Morgado
 wrote:
> Hey,
>
> The following branch contains a couple of patches to port the Via
> plugin to GTask
> https://github.com/aleksander0m/ModemManager/tree/gtask-plugins-via

lgtm w/ some questions

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


Re: [review] https://github.com/aleksander0m/ModemManager/tree/gtask-plugins-altair

2017-10-04 Thread Ben Chan
On Fri, Sep 22, 2017 at 5:08 AM, Aleksander Morgado
 wrote:
> Hey,
>
> This branch includes a commit to fully port the Altair plugin to GTask
> https://github.com/aleksander0m/ModemManager/tree/gtask-plugins-altair

lgtm

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


[rfc] Propagate manufacturer information from MMKernelDevice to MMBroadbandModem

2017-10-04 Thread Ben Chan
Hi Aleksander and Dan,

Unlike AT or QMI, MBIM doesn't define a standard command to query
manufacturer information. But the manufacturer information can often
be inferred from the USB vendor ID or retrieved through the
Manufacturer string descriptor at the USB level.

MMBroadbandModemMbim currently uses the plugin name as the
manufacturer, which may not be very useful if the generic plugin is
used. I wonder if it makes sense to let MMBroadbandModemMbim make use
of the manufacturer information, if available, from MMKernelDevice.
Obviously, modem vendors would like us to report a proper manufacturer
name than 'Generic' :)

I've put together a few patches that plumb up the logic, which you
check it out from this github branch:
https://github.com/cbchan/ModemManager/commits/mbim-manufacturer.
I'd like to hear your thoughts on this approach before creating a pull
request. In particular,

* The few MBIM modems I have report the correct manufacturer through
the manufacturer string descriptor, but I suspect some MBIM modems
don't.

*  I find the propagation (i.e. MMKernelDevice -> MMDevice -> MMPlugin
-> MMBaseModem -> MMBroadbandModemMbim) a bit involved and convoluted.
Perhaps there is simpler way to do that?

Thanks,
Ben
___
ModemManager-devel mailing list
ModemManager-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel


[review] https://github.com/cbchan/ModemManager/tree/gtask-plugins-mtk

2017-09-21 Thread Ben Chan
This branch contains a series of patches that port the mtk plugin to use GTask:

https://github.com/linux-mobile-broadband/ModemManager/compare/master...cbchan:gtask-plugins-mtk
___
ModemManager-devel mailing list
ModemManager-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel


[review] https://github.com/cbchan/ModemManager/tree/gtask-plugins-hso

2017-09-19 Thread Ben Chan
This branch contains a series of patches that port the hso plugin to use GTask:

https://github.com/linux-mobile-broadband/ModemManager/compare/master...cbchan:gtask-plugins-hso
___
ModemManager-devel mailing list
ModemManager-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel


Re: [review] https://github.com/cbchan/ModemManager/tree/sim-mbim-unlock-retries

2017-09-18 Thread Ben Chan
On Tue, Sep 19, 2017 at 12:01 AM, Aleksander Morgado
 wrote:
>>
>> I overlooked one thing when I revised the patches based on Dan's
>> suggestion,  and also missed that in my testing :-(
>>
>> MMSimMbim:update_modem_unlock_retries() calls
>> mm_iface_modem_update_unlock_retries() to report remaining attempts
>> PIN1.  That won't affect MMBroadbandModemMbimPriv::sim_pin_retries. My
>> original approach was to handle all MMUnlockRetries updates via
>> MMIfaceModem.
>>
>> If we prefer caching PIN1 retries in MMBroadbandModemMbim,
>> MMBroadbandModemMbim needs to provide a method (e.g.
>> mm_broadband_modem_mbm_set_sim_pin_retries) for MMSimMbim to propagate
>> the information.  Would you prefer that or should I go back to my
>> original approach?
>>
>
> Probably better to go with the old approach I think; I wouldn't like
> MMIfaceModem code to call MMBroadbandModemMbim APIs.

Uploaded two patches that change the code to use the original
approach.  Dan, let me know if you've any concern or would like to
propose a different approach. I can adjust the patches accordingly.
Aleksander, I've done some basic tests on my SIMs.  Thanks.

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


[PATCH 2/2] broadband-modem-mbim: fix preservation logic for PIN1 unlock retries

2017-09-18 Thread Ben Chan
This patches fixes commit 334273979 "broadband-modem-mbim: preserve
unlock retries for PIN1 when appropriate", which doesn't correctly
propagate the unlock retries information for PIN1 observed from
responses to MBIM_CID_PIN set operations (see commit eb9ec1b61
"sim-mbim: update unlock retries information after PIN operations").
---
 src/mm-broadband-modem-mbim.c | 29 +
 1 file changed, 13 insertions(+), 16 deletions(-)

diff --git a/src/mm-broadband-modem-mbim.c b/src/mm-broadband-modem-mbim.c
index 93a61085..aaa3e1cc 100644
--- a/src/mm-broadband-modem-mbim.c
+++ b/src/mm-broadband-modem-mbim.c
@@ -93,9 +93,6 @@ struct _MMBroadbandModemMbimPrivate {
 
 /* For notifying when the mbim-proxy connection is dead */
 gulong mbim_device_removed_id;
-
-/* Previously observed SIM-PIN remaining retries */
-guint sim_pin_retries;
 };
 
 /*/
@@ -713,7 +710,7 @@ pin_query_unlock_retries_ready (MbimDevice *device,
 NULL,
 _attempts,
 )) {
-MMBroadbandModemMbim *self;
+MMIfaceModem *self;
 MMModemLock lock;
 MMUnlockRetries *retries;
 
@@ -737,22 +734,24 @@ pin_query_unlock_retries_ready (MbimDevice *device,
  * PIN1. Here we thus carry over any existing information on PIN1 from
  * MMIfaceModem's MMUnlockRetries if the MBIM_CID_PIN query reports
  * something other than PIN1. */
-if (lock != MM_MODEM_LOCK_SIM_PIN &&
-self->priv->sim_pin_retries != MM_UNLOCK_RETRIES_UNKNOWN) {
-mm_unlock_retries_set (retries,
-   MM_MODEM_LOCK_SIM_PIN,
-   self->priv->sim_pin_retries);
+if (lock != MM_MODEM_LOCK_SIM_PIN) {
+MMUnlockRetries *previous_retries;
+guint previous_sim_pin_retries;
+
+previous_retries = mm_iface_modem_get_unlock_retries (self);
+previous_sim_pin_retries = mm_unlock_retries_get (previous_retries,
+  
MM_MODEM_LOCK_SIM_PIN);
+if (previous_sim_pin_retries != MM_UNLOCK_RETRIES_UNKNOWN) {
+mm_unlock_retries_set (retries,
+   MM_MODEM_LOCK_SIM_PIN,
+   previous_sim_pin_retries);
+}
 }
 
 /* According to the MBIM specification, RemainingAttempts is set to
  * 0x if the device does not support this information. */
 if (remaining_attempts != G_MAXUINT32)
 mm_unlock_retries_set (retries, lock, remaining_attempts);
-else
-remaining_attempts = MM_UNLOCK_RETRIES_UNKNOWN;
-
-if (lock == MM_MODEM_LOCK_SIM_PIN)
-self->priv->sim_pin_retries = remaining_attempts;
 
 g_task_return_pointer (task, retries, g_object_unref);
 } else
@@ -3274,8 +3273,6 @@ mm_broadband_modem_mbim_init (MMBroadbandModemMbim *self)
 self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
   MM_TYPE_BROADBAND_MODEM_MBIM,
   MMBroadbandModemMbimPrivate);
-
-self->priv->sim_pin_retries = MM_UNLOCK_RETRIES_UNKNOWN;
 }
 
 static void
-- 
2.14.1.690.gbb1197296e-goog

___
ModemManager-devel mailing list
ModemManager-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel


[PATCH 1/2] iface-modem: add mm_iface_modem_get_unlock_retries helper

2017-09-18 Thread Ben Chan
This patch adds a mm_iface_modem_get_unlock_retries helper for getting
the current MMUnlockRetries value of a MMIfaceModem object, which later
allows us to partially update (e.g. a specific MMModemLock) the
MMUnlockRetries value of a MMIfaceModem object.
---
 src/mm-iface-modem.c | 21 +
 src/mm-iface-modem.h |  2 ++
 2 files changed, 23 insertions(+)

diff --git a/src/mm-iface-modem.c b/src/mm-iface-modem.c
index e21d5aeb..cc4d6991 100644
--- a/src/mm-iface-modem.c
+++ b/src/mm-iface-modem.c
@@ -2926,6 +2926,27 @@ set_lock_status (MMIfaceModem *self,
 }
 }
 
+MMUnlockRetries *
+mm_iface_modem_get_unlock_retries (MMIfaceModem *self)
+{
+MmGdbusModem *skeleton = NULL;
+MMUnlockRetries *unlock_retries;
+
+g_object_get (self,
+  MM_IFACE_MODEM_DBUS_SKELETON, ,
+  NULL);
+if (skeleton) {
+GVariant *dictionary;
+
+dictionary = mm_gdbus_modem_get_unlock_retries (skeleton);
+unlock_retries = mm_unlock_retries_new_from_dictionary (dictionary);
+g_object_unref (skeleton);
+} else
+unlock_retries = mm_unlock_retries_new ();
+
+return unlock_retries;
+}
+
 void
 mm_iface_modem_update_unlock_retries (MMIfaceModem *self,
   MMUnlockRetries *unlock_retries)
diff --git a/src/mm-iface-modem.h b/src/mm-iface-modem.h
index af039b3b..1a154b48 100644
--- a/src/mm-iface-modem.h
+++ b/src/mm-iface-modem.h
@@ -414,6 +414,8 @@ MMModemLock mm_iface_modem_update_lock_info_finish 
(MMIfaceModem *self,
 GAsyncResult *res,
 GError **error);
 
+MMUnlockRetries *mm_iface_modem_get_unlock_retries (MMIfaceModem *self);
+
 void mm_iface_modem_update_unlock_retries (MMIfaceModem *self,
MMUnlockRetries *unlock_retries);
 
-- 
2.14.1.690.gbb1197296e-goog

___
ModemManager-devel mailing list
ModemManager-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel


Re: [review] https://github.com/cbchan/ModemManager/tree/modem-hardware-revision

2017-09-18 Thread Ben Chan
Please note that I use GSimpleAsyncResult instead of GTask in the
patch that modifies MMBroadbandModemQmi in order to minimize the
changes (as I don't want to touch ensure_qmi_client related code). The
GTask migration will be done in another branch:
https://github.com/cbchan/ModemManager/tree/gtask-broadband-modem-qmi

On Mon, Sep 18, 2017 at 11:13 PM, Ben Chan <benc...@chromium.org> wrote:
> Similar to firmware revision, hardware revision is useful information
> for identifying characteristics about a modem module. Both MBIM and
> QMI provides API to query hardware revision from the modem. This
> series of patch add support of loading and reporting hardware revision
> through the Modem interface.
>
> https://github.com/linux-mobile-broadband/ModemManager/compare/master...cbchan:modem-hardware-revision
___
ModemManager-devel mailing list
ModemManager-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel


[review] https://github.com/cbchan/ModemManager/tree/modem-hardware-revision

2017-09-18 Thread Ben Chan
Similar to firmware revision, hardware revision is useful information
for identifying characteristics about a modem module. Both MBIM and
QMI provides API to query hardware revision from the modem. This
series of patch add support of loading and reporting hardware revision
through the Modem interface.

https://github.com/linux-mobile-broadband/ModemManager/compare/master...cbchan:modem-hardware-revision
___
ModemManager-devel mailing list
ModemManager-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel


  1   2   3   >