Unexpected COPS format

Dan Williams dcbw at redhat.com
Fri Mar 17 17:40:55 UTC 2017


On Fri, 2017-03-17 at 16:13 +0000, Colin Helliwell wrote:
> > On 17 March 2017 at 15:02 Colin Helliwell <colin.helliwell at ln-syste
> > ms.com> wrote:
> > 
> > > On 17 March 2017 at 14:16 colin.helliwell at ln-systems.com wrote:
> > > 
> > > I’m reviewing the info fetched on my modems, and one of them is
> > > giving an unusual format for “AT+COPS=3,2;+COPS?” :
> > > 
> > > +COPS: 0,2,"00320033003400310035",0
> > > 
> > > This seems to be some sort of ‘wide char’ hex representation of
> > > “23415” [which is what I’d expect].
> > > 
> > > The modem’s AT spec doesn’t say anything about it coming back in
> > > the form, but I just wondered if it was a format anyone had
> > > encountered elsewhere?
> > 
> > Doing a bit of comparison between them:
> > 
> > BGS2 -
> > [src/mm-broadband-modem.c:3496] modem_3gpp_load_operator_code():
> > loading Operator Code...
> > [src/mm-port-serial-at.c:459] debug_log(): (ttyMux1): -->
> > 'AT+COPS=3,2;+COPS?'
> > [src/mm-port-serial-at.c:459] debug_log(): (ttyMux1): <-- '+COPS:
> > 0,2,"23415"OK'
> > [src/mm-broadband-modem.c:3487]
> > modem_3gpp_load_operator_code_finish(): loaded Operator Code: 23415
> > [src/mm-broadband-modem.c:3539] modem_3gpp_load_operator_name():
> > loading Operator Name...
> > [src/mm-port-serial-at.c:459] debug_log(): (ttyMux1): -->
> > 'AT+COPS=3,0;+COPS?'
> > [src/mm-port-serial-at.c:459] debug_log(): (ttyMux1): <-- '+COPS:
> > 0,0,"vodafone UK"OK'
> > [src/mm-broadband-modem.c:3530]
> > modem_3gpp_load_operator_name_finish(): loaded Operator Name:
> > vodafone UK
> > 
> > EHS5 -
> > 
> > [src/mm-broadband-modem.c:3496] modem_3gpp_load_operator_code():
> > loading Operator Code...
> > [src/mm-port-serial-at.c:459] debug_log(): (ttyMux1): -->
> > 'AT+COPS=3,2;+COPS?'
> > [src/mm-port-serial-at.c:459] debug_log(): (ttyMux1): <-- '+COPS:
> > 0,2,"00320033003400310035",0'
> > [src/mm-port-serial-at.c:459] debug_log(): (ttyMux1): <-- 'OK'
> > [src/mm-broadband-modem.c:3487]
> > modem_3gpp_load_operator_code_finish(): loaded Operator Code:
> > 00320033003400310035
> > [src/mm-iface-modem-3gpp.c:874] parse_mcc_mnc(): Unexpected MCC/MNC
> > string '00320033003400310035'
> > [src/mm-broadband-modem.c:3539] modem_3gpp_load_operator_name():
> > loading Operator Name...
> > [src/mm-port-serial-at.c:459] debug_log(): (ttyMux1): -->
> > 'AT+COPS=3,0;+COPS?'
> > [src/mm-port-serial-at.c:459] debug_log(): (ttyMux1): <-- '+COPS:
> > 0,0,"0076006F006400610066006F006E006500200055004B",0OK'
> > [src/mm-broadband-modem.c:3530]
> > modem_3gpp_load_operator_name_finish(): loaded Operator Name:
> > vodafone UK
> > 
> > I notice that modem_3gpp_load_operator_name_finish() has a
> > 'mm_3gpp_normalize_operator_name()' step; maybe same needed on
> > modem_3gpp_load_operator_code_finish()?
> > 
> 
> As a quick test, utilizing that function appears to work with the
> above case. A neater patch would be to refactor it a bit more
> generically - e.g. "mm_3gpp_normalize_operator_string". Any
> objections/issues (or, more importantly, risk of adverse
> consequences) with me submitting such a patch?

No objections with you submitting a patch; I was looking at doing the
same thing but since you touched it, you can own it! :)

I ended up with something like:

void
mm_3gpp_normalize_operator_id (gchar          **id,
                               MMModemCharset   cur_charset)
{
    g_assert (id);

    /* Some modems return the operator name as a hexadecimal string of the
     * bytes of the operator name as encoded by the current character set.
     */

    if (*id && !mm_3gpp_parse_operator_id (id, NULL, NULL, NULL)) {
        *id = mm_charset_take_and_convert_to_utf8 (*id, cur_charset);
        if (!mm_3gpp_parse_operator_id (id, NULL, NULL, NULL))
            g_clear_pointer (id, g_free);
    }
}

but didn't get as far as writing testcases for it in src/tests/test-
modem-helpers.c.  Testcases would be great, obviously.

Dan


More information about the ModemManager-devel mailing list