Commit Graph

5733 Commits

Author SHA1 Message Date
Dan Williams
fb65cba607 qcdm: add qcdm_cmd_control_new() to set operating mode 2012-09-27 10:55:20 -05:00
Aleksander Morgado
1b5804895f build: use $PKG_CONFIG
The build system sets up this variable for us, so use it rather than
hardcoding "pkg-config" which might be the wrong one.

Equivalent to the one done by
    Mike Frysinger <vapier@gentoo.org>
in libqmi.
2012-09-24 04:36:38 +02:00
Ben Chan
717b16b5b6 broadband-modem: increase timeout for ATZ
Some modem like Novatel LTE can take up to 5 seconds to complete the ATZ
command. Increase the timeout for ATZ from 3 seconds to 6 seconds.
2012-09-22 14:55:50 +02:00
Ben Chan
e60207d6ab broadband-modem: disconnect bearers only if the bearer list still exists
This patch fixes a crash when MMBroadbandModem tries to access an
already cleared bearer list during the disabling steps.

Thread 0 *CRASHED* ( SIGSEGV @ 0x00000000 )

0x7f6eed4c40a3   [ModemManager]             - mm-bearer-list.c:259       mm_bearer_list_disconnect_all_bearers
0x7f6eed4cd6f8   [ModemManager]             - mm-iface-modem.c:1216      handle_enable_auth_ready
0x7f6eed332676   [libgio-2.0.so.0.3000.2]   - gsimpleasyncresult.c:749   g_simple_async_result_complete
0x7f6eed4c5750   [ModemManager]             - mm-base-modem.c:1015       authorize_ready
0x7f6eed332676   [libgio-2.0.so.0.3000.2]   - gsimpleasyncresult.c:749   g_simple_async_result_complete
0x7f6eed332788   [libgio-2.0.so.0.3000.2]   - gsimpleasyncresult.c:761   complete_in_idle_cb
0x7f6eecf36f44   [libglib-2.0.so.0.3000.2]  - gmain.c:2441               g_main_context_dispatch
0x7f6eecf37597   [libglib-2.0.so.0.3000.2]  - gmain.c:3089               g_main_context_iterate
0x7f6eecf37b51   [libglib-2.0.so.0.3000.2]  - gmain.c:3297               g_main_loop_run
0x7f6eed4b5ad1   [ModemManager]             - main.c:150                 main
0x7f6eec95141c   [libc-2.15.so]             - libc-start.c:234           __libc_start_main
0x7f6eed4b55e8   [ModemManager]             + 0x0001a5e8
2012-09-22 14:55:42 +02:00
Ben Chan
6124022ab3 modem-helpers: handle the case when operator name is "Unknown"
Some modems report "Unknown" as the operator name when failed to obtain
the actual value:

    --> 'AT+COPS=3,0;+COPS?<CR>'
    <-- '<CR><LF>+COPS: 0,0,"Unknown",0<CR><LF><CR><LF>OK<CR><LF>'

This patch prevents "Unknown" from being treated as a valid operator name.
2012-09-20 12:02:06 -05:00
Aleksander Morgado
6995300ecd huawei: if port replies to AT^GETPORTMODE, port is AT
Just skips the additional check for AT support in the port.
2012-09-19 10:37:31 +02:00
Aleksander Morgado
c4b5293669 device: if failed to get VID/PID in first port, try the next one
Don't rely only in the first grabbed port to get VID/PID. Some modems, e.g.
Huawei E367, won't report a proper VID in the cdc-wdm port, which is the first
one probed.
2012-09-19 10:18:44 +02:00
Aleksander Morgado
ee099fcd08 plugin-manager: never suggest the Generic plugin to others
Some modems, e.g. Huawei E367, will probe first the QMI port and for some reason
it doesn't report a proper VID/PID so the Generic plugin is the one finally
accepting that port. When we probe the AT ports afterwards we already got the
Generic plugin as suggestion, and we end up not grabbing the proper primary and
secondary ports as we skipped the AT^GETPORTMODE reply.

So, from now on the Generic plugin is never suggested to other probes; except
for the case where we need the suggestion to finish a probing task which was
'deferred until suggested'.

Also, the device-level plugin can now be overwritten, if and only if, the
previously set plugin was the Generic one.
2012-09-19 10:18:38 +02:00
Aleksander Morgado
a6faae3260 broadband-modem: skip +CGMM: prefix when loading device model
Some devices, e.g. ZTE MF820D, seem to prefix the `AT+CGMM?' response with the
`+CGMM:' string, resulting in the following model string being loaded:

   model: '+CGMM: "MF820D"'

Avoid this by:
 1) Removing the expected prefixes.
 2) Unquoting the resulting string.

Reported by: Marius Kotsbak <marius.kotsbak@gmail.com>
2012-09-19 07:42:47 +02:00
Marius B. Kotsbak
d2353e01ff sierra: use +CFUN=4 for powering down GSM modems 2012-09-18 16:27:09 -05:00
Aleksander Morgado
b65bc50777 qmi-port: plug memleak
Ensure we clear all allocated client objects when disposing the port.
2012-09-18 19:10:05 +02:00
Aleksander Morgado
127900b67b broadband-modem-qmi: plug memleak, always need to unref() input containers 2012-09-18 19:09:57 +02:00
Aleksander Morgado
48bb20d018 libmm-common,gps-nmea: skip duplicate traces in sequence 2012-09-18 13:57:25 +02:00
Aleksander Morgado
598799a61c broadband-modem-qmi: request NMEA trace indications 2012-09-18 13:15:35 +02:00
Aleksander Morgado
48d8bf4164 broadband-modem-qmi: listen to "PDS Event Report" indications 2012-09-18 13:15:35 +02:00
Aleksander Morgado
b43c5933d8 broadband-modem-qmi: enable/disable GPS location gathering 2012-09-18 13:15:35 +02:00
Aleksander Morgado
4babcbe30e broadband-modem-qmi: new common method to peek a QMI client 2012-09-18 13:15:34 +02:00
Aleksander Morgado
0e40bb7b11 broadband-modem-qmi: check support for GPS location capabilities 2012-09-18 10:59:49 +02:00
Aleksander Morgado
6284737249 sms: don't allow more than 255 parts 2012-09-14 13:12:02 +02:00
Aleksander Morgado
d5e57dd8eb sms: fix error message string when failing to parse input text 2012-09-14 13:11:33 +02:00
Aleksander Morgado
d30ec8f5a6 cli: minor text output fixes 2012-09-14 11:57:36 +02:00
Aleksander Morgado
2c1ce492ce sms: don't try the generic SMS method if we got a timeout error 2012-09-14 07:05:26 +02:00
Aleksander Morgado
e212f6b6ed sms: create SMS parts only when storing or sending
When a user creates an SMS object, we will expose all its properties in DBus
properly, but we will not create the internal list of SMS parts.

The list of SMS parts will be created when the SMS is stored or sent, whatever
comes first. When the message is sent and it was previously stored, the list of
parts is not re-created.

If the message requires multiple parts, the multipart reference is computed as
follows:
 * If the SMS was not stored and is being sent, we just use a random number.
 * If the SMS is being stored, we will use a multipart reference which is not
   being used already in another SMS to the same destination.
2012-09-14 07:05:26 +02:00
Aleksander Morgado
2da9474d0c test: new tester for the messaging capabilities of a modem, using `mmcli'
Usage:
  mmcli-test-sms [MODEM INDEX] [all|ucs2|gsm7|data] [NUMBER]"

If [NUMBER] is not given, a dummy number will be used and NO SMS will be sent.

If you give a proper [NUMBER], we will try to send the SMS.
2012-09-14 07:05:26 +02:00
Aleksander Morgado
4196ef1a86 sms: don't try to delete parts if SMS not stored 2012-09-14 07:05:26 +02:00
Aleksander Morgado
8612667776 sms,sms-qmi: update timeout when sending an SMS to 30s 2012-09-14 07:05:26 +02:00
Aleksander Morgado
f6832d72cf cli: new `--create-file-with-data' action for SMS objects
This new action allows creating a new file with the binary data stored in the
SMS, if any.

E.g.:

$> sudo mmcli -s 7 \
              --create-file-with-data=output.txt

This action can only be run on SMS object with binary data.
2012-09-14 07:05:26 +02:00
Aleksander Morgado
0156279749 cli: new `--messaging-create-sms-with-data' switch
This switch can be run along with the `--messaging-create-sms' action, in order
to include in the SMS the data as given in the file specified by the new switch.

E.g.:

$> sudo mmcli -m 0 \
              --messaging-create-sms="number='1234567890'" \
              --messaging-create-sms-with-data=file.txt

In this case, the SMS properties string cannot contain a 'text' field.
2012-09-14 07:05:26 +02:00
Aleksander Morgado
1304a628f8 sms-part: include user data, if passed, when building the PDU 2012-09-14 07:05:26 +02:00
Aleksander Morgado
8e6a603578 libmm-glib: provide accessors for the 'Data' property in the SMS interface 2012-09-14 07:05:26 +02:00
Aleksander Morgado
a66f971a7c libmm-common: added common utils from core
Moved the utils to play with binary to hex strings into libmm-common.
2012-09-14 07:05:26 +02:00
Aleksander Morgado
fbe01c8d6a sms: 'Text' and 'Data' will never be given at the same time
When receiving an SMS, if the encoding is either GSM7 or UCS2, we will treat the
contents of the SMS as text; and if the encoding is either 8BIT or unknown, we
will just dump the contents of the SMS as data.

When creating an SMS, the user is not allowed to give both text and data, only
one can be given. We will use by default 8BIT when data is given, and guess the
best encoding if text is given.

Note that it's still possible to have SMS with neither text nor data, as in
delivery status reports.

This commit also handles the split of the input data in order to make it fit
into singlepart or multipart messages.
2012-09-14 07:05:26 +02:00
Aleksander Morgado
15be01d4fa sms: fix error return when a mandatory parameter missing in dictionary 2012-09-14 07:05:26 +02:00
Aleksander Morgado
baf3ed0c64 sms-part: don't keep track of the whole TP-DCS value
We already retrieve the bits we use from it, class and encoding.
2012-09-14 07:05:25 +02:00
Aleksander Morgado
64f728b375 sms-part: read message class only if TP-DCS available 2012-09-14 07:05:25 +02:00
Aleksander Morgado
815decb034 broadband-modem: properly avoid duplicate CMTI indications
We will look for the part being notified in the CMTI indication directly in the
list of processed parts; and if we have it there already we won't re-process it.

Still, we may get several CMTI indications for the same part one after the
other, so it may still happen that the second CMTI comes *before* we have parsed
and created the part in the SMS list. For that case, the SMS list will reject
taking the part if there is already a part with the same storage+index already
processed.

This fix removes the `known_sms_parts' hash table, which was being handled
incorrectly.

This should fix https://bugzilla.gnome.org/show_bug.cgi?id=675175
2012-09-14 07:05:25 +02:00
Aleksander Morgado
8cbf3b7826 broadband-modem: fix SMS list object type 2012-09-14 07:05:25 +02:00
Aleksander Morgado
91b324ed40 broadband-modem: select and lock proper storage when reading CMTI indications 2012-09-14 07:05:25 +02:00
Aleksander Morgado
f6147e0d6b cli: print new SMS properties in SMS status report 2012-09-14 07:05:25 +02:00
Aleksander Morgado
744b9fba67 libmm-glib: added methods to retrieve new SMS properties 2012-09-14 07:05:25 +02:00
Aleksander Morgado
1111bfa806 api: new `DeliveryState' property in the SMS interface
Given only for STATUS REPORT SMS messages.
2012-09-14 07:05:25 +02:00
Aleksander Morgado
bdf0f9484b sms: allow parts with neither text nor data only in Status Report PDUs 2012-09-14 07:05:25 +02:00
Aleksander Morgado
83ab63138c sms: fix double free when parsing PDUs
If we get an error when telling the SMS list to take the new PDU, the caller is
the one responsible for freeing the part, so avoid doing it twice.

Relevant valgrind log:
==7287== Invalid read of size 8
==7287==    at 0x437CE1: mm_sms_part_free (mm-sms-part.c:344)
==7287==    by 0x454D11: mm_iface_modem_messaging_take_part (mm-iface-modem-messaging.c:359)
==7287==    by 0x461234: cds_received (mm-broadband-modem.c:4626)
==7287==    by 0x48A305: parse_unsolicited (mm-at-serial-port.c:256)
==7287==    by 0x48723D: parse_response (mm-serial-port.c:731)
==7287==    by 0x48759B: data_available (mm-serial-port.c:801)
==7287==    by 0x36ADC47694: g_main_context_dispatch (in /usr/lib64/libglib-2.0.so.0.3200.4)
==7287==    by 0x36ADC479C7: ??? (in /usr/lib64/libglib-2.0.so.0.3200.4)
==7287==    by 0x36ADC47DC1: g_main_loop_run (in /usr/lib64/libglib-2.0.so.0.3200.4)
==7287==    by 0x421398: main (main.c:150)
==7287==  Address 0x9840b78 is 24 bytes inside a block of size 104 free'd
==7287==    at 0x4A079AE: free (vg_replace_malloc.c:427)
==7287==    by 0x36ADC4D37E: g_free (in /usr/lib64/libglib-2.0.so.0.3200.4)
==7287==    by 0x36ADC61CCE: g_slice_free1 (in /usr/lib64/libglib-2.0.so.0.3200.4)
==7287==    by 0x437D5A: mm_sms_part_free (mm-sms-part.c:351)
==7287==    by 0x36ADC449EC: g_list_foreach (in /usr/lib64/libglib-2.0.so.0.3200.4)
==7287==    by 0x36ADC44A0A: g_list_free_full (in /usr/lib64/libglib-2.0.so.0.3200.4)
==7287==    by 0x43D8A1: finalize (mm-sms.c:1629)
==7287==    by 0x36AE8145DA: g_object_unref (in /usr/lib64/libgobject-2.0.so.0.3200.4)
==7287==    by 0x43CD52: mm_sms_singlepart_new (mm-sms.c:1376)
==7287==    by 0x43E223: take_singlepart (mm-sms-list.c:236)
==7287==    by 0x43E60D: mm_sms_list_take_part (mm-sms-list.c:338)
==7287==    by 0x454CC7: mm_iface_modem_messaging_take_part (mm-iface-modem-messaging.c:353)
2012-09-14 07:05:25 +02:00
Aleksander Morgado
2871e3e821 sms-part: don't read out of the pdu buffer
... or Valgrind will complain:

==4834== Invalid read of size 1
==4834==    at 0x43904C: mm_sms_part_new_from_binary_pdu (mm-sms-part.c:783)
==4834==    by 0x4382C9: mm_sms_part_new_from_pdu (mm-sms-part.c:485)
==4834==    by 0x461D85: sms_pdu_part_list_ready (mm-broadband-modem.c:5004)
==4834==    by 0x3161A6CFB6: g_simple_async_result_complete (in /usr/lib64/libgio-2.0.so.0.3200.4)
==4834==    by 0x432F82: at_command_parse_response (mm-base-modem-at.c:490)
==4834==    by 0x489F96: handle_response (mm-at-serial-port.c:161)
==4834==    by 0x486D0A: mm_serial_port_got_response (mm-serial-port.c:588)
==4834==    by 0x48758B: data_available (mm-serial-port.c:804)
==4834==    by 0x36ADC47694: g_main_context_dispatch (in /usr/lib64/libglib-2.0.so.0.3200.4)
==4834==    by 0x36ADC479C7: ??? (in /usr/lib64/libglib-2.0.so.0.3200.4)
==4834==    by 0x36ADC47DC1: g_main_loop_run (in /usr/lib64/libglib-2.0.so.0.3200.4)
==4834==    by 0x421398: main (main.c:150)
==4834==  Address 0x927e489 is 0 bytes after a block of size 25 alloc'd
==4834==    at 0x4A06F18: calloc (vg_replace_malloc.c:566)
==4834==    by 0x36ADC4D2C6: g_malloc0 (in /usr/lib64/libglib-2.0.so.0.3200.4)
==4834==    by 0x4844B2: utils_hexstr2bin (mm-utils.c:63)
==4834==    by 0x438284: mm_sms_part_new_from_pdu (mm-sms-part.c:476)
==4834==    by 0x461D85: sms_pdu_part_list_ready (mm-broadband-modem.c:5004)
==4834==    by 0x3161A6CFB6: g_simple_async_result_complete (in /usr/lib64/libgio-2.0.so.0.3200.4)
==4834==    by 0x432F82: at_command_parse_response (mm-base-modem-at.c:490)
==4834==    by 0x489F96: handle_response (mm-at-serial-port.c:161)
==4834==    by 0x486D0A: mm_serial_port_got_response (mm-serial-port.c:588)
==4834==    by 0x48758B: data_available (mm-serial-port.c:804)
==4834==    by 0x36ADC47694: g_main_context_dispatch (in /usr/lib64/libglib-2.0.so.0.3200.4)
==4834==    by 0x36ADC479C7: ??? (in /usr/lib64/libglib-2.0.so.0.3200.4)
2012-09-14 07:05:25 +02:00
Aleksander Morgado
2b01c93c57 api: make read-only all SMS properties for now
We don't support yet modifying these properties on the fly (e.g. we would need
to re-construct the internal PDU list when the text changes).
2012-09-14 07:05:25 +02:00
Aleksander Morgado
628f7e41a4 sms-list: don't look for duplicate parts if index is unknown 2012-09-14 07:05:25 +02:00
Aleksander Morgado
4f1991e2ba api: new `MessageReference' property in the SMS interface
Message reference allows to match a sent SMS with its corresponding delivery
report, if requested.
2012-09-14 07:05:25 +02:00
Aleksander Morgado
320984a4a0 api: new `DischargeTimestamp' property for Status Report SMS messages 2012-09-14 07:05:25 +02:00
Aleksander Morgado
f1a73a5719 sms-part: always treat TP-DCS as a bitmask 2012-09-14 07:05:25 +02:00
Aleksander Morgado
6c7766afed sms-part: always treat TP-MTI as a bitmask 2012-09-14 07:05:24 +02:00