~binli/ubuntu/vivid/modemmanager/lp1441095

« back to all changes in this revision

Viewing changes to plugins/novatel/mm-broadband-bearer-novatel-lte.c

  • Committer: Package Import Robot
  • Author(s): Michael Biebl, Guido Günther, Michael Biebl
  • Date: 2014-06-25 02:23:09 UTC
  • mfrom: (20.2.2 sid)
  • Revision ID: package-import@ubuntu.com-20140625022309-43papaenj5ikbx3y
Tags: 1.2.0-1
[ Guido Günther ]
* New upstream version 1.2.0 (Closes: #731851)
* Update patches
* Install locale files
* Require newer libqmi
* Update symbols file
* Ship gobject introspection data
* Ship vala bindings

[ Michael Biebl ]
* Use canonical URI for Vcs-Git
* Use gir dh addon
* Update extendend package description (Closes: #744180)

Show diffs side-by-side

added added

removed removed

Lines of Context:
114
114
    return g_strrstr (str, "QMI State: DISCONNECTED") || g_strrstr (str, "QMI State: QMI_WDS_PKT_DATA_DISCONNECTED");
115
115
}
116
116
 
 
117
static gboolean
 
118
is_qmistatus_call_failed (const gchar *str)
 
119
{
 
120
    str = mm_strip_tag (str, QMISTATUS_TAG);
 
121
 
 
122
    return (g_strrstr (str, "QMI_RESULT_FAILURE:QMI_ERR_CALL_FAILED") != NULL);
 
123
}
 
124
 
117
125
static void
118
126
poll_connection_ready (MMBaseModem *modem,
119
127
                       GAsyncResult *res,
130
138
    }
131
139
 
132
140
    if (is_qmistatus_disconnected (result)) {
133
 
        mm_bearer_report_disconnection (MM_BEARER (bearer));
 
141
        mm_bearer_report_connection_status (MM_BEARER (bearer), MM_BEARER_CONNECTION_STATUS_DISCONNECTED);
134
142
        g_source_remove (bearer->priv->connection_poller);
135
143
        bearer->priv->connection_poller = 0;
136
144
    }
165
173
    gchar *normalized_result;
166
174
    GError *error = NULL;
167
175
 
168
 
    result = mm_base_modem_at_command_finish (MM_BASE_MODEM (ctx->modem),
169
 
                                              res,
170
 
                                              &error);
 
176
    result = mm_base_modem_at_command_full_finish (modem, res, &error);
171
177
    if (!result) {
172
178
        mm_warn ("QMI connection status failed: %s", error->message);
173
179
        if (!g_error_matches (error, MM_MOBILE_EQUIPMENT_ERROR, MM_MOBILE_EQUIPMENT_ERROR_UNKNOWN)) {
193
199
        g_object_unref (config);
194
200
        detailed_connect_context_complete_and_free (ctx);
195
201
        return;
 
202
    } else if (is_qmistatus_call_failed (result)) {
 
203
        /* Don't retry if the call failed */
 
204
        ctx->retries = 0;
196
205
    }
197
206
 
198
207
    mm_dbg ("Error: '%s'", result);
 
208
 
 
209
    if (g_cancellable_is_cancelled (ctx->cancellable)) {
 
210
        g_simple_async_result_set_error (ctx->result,
 
211
                                         MM_CORE_ERROR,
 
212
                                         MM_CORE_ERROR_CANCELLED,
 
213
                                         "Connection setup operation has been cancelled");
 
214
        detailed_connect_context_complete_and_free (ctx);
 
215
        return;
 
216
    }
 
217
 
199
218
    if (ctx->retries > 0) {
200
219
        ctx->retries--;
201
220
        mm_dbg ("Retrying status check in a second. %d retries left.",
218
237
static gboolean
219
238
connect_3gpp_qmistatus (DetailedConnectContext *ctx)
220
239
{
221
 
    mm_base_modem_at_command (
 
240
    mm_base_modem_at_command_full (
222
241
        ctx->modem,
 
242
        ctx->primary,
223
243
        "$NWQMISTATUS",
224
244
        3, /* timeout */
225
245
        FALSE, /* allow_cached */
 
246
        FALSE, /* is_raw */
 
247
        ctx->cancellable,
226
248
        (GAsyncReadyCallback)connect_3gpp_qmistatus_ready, /* callback */
227
249
        ctx); /* user_data */
228
250
 
237
259
    const gchar *result;
238
260
    GError *error = NULL;
239
261
 
240
 
    result = mm_base_modem_at_command_finish (MM_BASE_MODEM (modem),
241
 
                                              res,
242
 
                                              &error);
 
262
    result = mm_base_modem_at_command_full_finish (modem, res, &error);
243
263
    if (!result) {
244
264
        mm_warn ("QMI connection failed: %s", error->message);
245
265
        g_simple_async_result_take_error (ctx->result, error);
271
291
    g_free (apn);
272
292
    g_free (user);
273
293
    g_free (password);
274
 
    mm_base_modem_at_command (
 
294
    mm_base_modem_at_command_full (
275
295
        ctx->modem,
 
296
        ctx->primary,
276
297
        command,
277
298
        10, /* timeout */
278
299
        FALSE, /* allow_cached */
 
300
        FALSE, /* is_raw */
 
301
        ctx->cancellable,
279
302
        (GAsyncReadyCallback)connect_3gpp_qmiconnect_ready,
280
303
        ctx); /* user_data */
281
304
    g_free (command);
304
327
    ctx->retries = 60;
305
328
 
306
329
    /* Get a 'net' data port */
307
 
    ctx->data = mm_base_modem_get_best_data_port (MM_BASE_MODEM (modem),
308
 
                                                  MM_PORT_TYPE_NET);
 
330
    ctx->data = mm_base_modem_get_best_data_port (ctx->modem, MM_PORT_TYPE_NET);
309
331
    if (!ctx->data) {
310
332
        g_simple_async_result_set_error (
311
333
            ctx->result,
326
348
    MMBroadbandBearer *self;
327
349
    MMBaseModem *modem;
328
350
    MMAtSerialPort *primary;
329
 
    MMAtSerialPort *secondary;
330
351
    MMPort *data;
331
352
    GSimpleAsyncResult *result;
332
353
    gint retries;
336
357
detailed_disconnect_context_new (MMBroadbandBearer *self,
337
358
                                 MMBroadbandModem *modem,
338
359
                                 MMAtSerialPort *primary,
339
 
                                 MMAtSerialPort *secondary,
340
360
                                 MMPort *data,
341
361
                                 GAsyncReadyCallback callback,
342
362
                                 gpointer user_data)
347
367
    ctx->self = g_object_ref (self);
348
368
    ctx->modem = MM_BASE_MODEM (g_object_ref (modem));
349
369
    ctx->primary = g_object_ref (primary);
350
 
    ctx->secondary = (secondary ? g_object_ref (secondary) : NULL);
351
370
    ctx->data = g_object_ref (data);
352
371
    ctx->result = g_simple_async_result_new (G_OBJECT (self),
353
372
                                             callback,
363
382
    g_simple_async_result_complete_in_idle (ctx->result);
364
383
    g_object_unref (ctx->result);
365
384
    g_object_unref (ctx->data);
366
 
    if (ctx->secondary)
367
 
        g_object_unref (ctx->secondary);
368
385
    g_object_unref (ctx->primary);
369
386
    g_object_unref (ctx->modem);
370
387
    g_object_unref (ctx->self);
390
407
    GError *error = NULL;
391
408
    gboolean is_connected = FALSE;
392
409
 
393
 
    result = mm_base_modem_at_command_finish (MM_BASE_MODEM (modem),
394
 
                                              res,
395
 
                                              &error);
 
410
    result = mm_base_modem_at_command_full_finish (modem, res, &error);
396
411
    if (result) {
397
412
        mm_dbg ("QMI connection status: %s", result);
398
413
        if (is_qmistatus_disconnected (result)) {
438
453
static gboolean
439
454
disconnect_3gpp_qmistatus (DetailedDisconnectContext *ctx)
440
455
{
441
 
    mm_base_modem_at_command (
 
456
    mm_base_modem_at_command_full (
442
457
        ctx->modem,
 
458
        ctx->primary,
443
459
        "$NWQMISTATUS",
444
460
        3, /* timeout */
445
461
        FALSE, /* allow_cached */
446
 
        (GAsyncReadyCallback)disconnect_3gpp_status_ready, /* callback */
 
462
        FALSE, /* is_raw */
 
463
        NULL, /* cancellable */
 
464
        (GAsyncReadyCallback)disconnect_3gpp_status_ready,
447
465
        ctx); /* user_data */
448
 
 
449
466
    return FALSE;
450
467
}
451
468
 
457
474
{
458
475
    GError *error = NULL;
459
476
 
460
 
    mm_base_modem_at_command_finish (MM_BASE_MODEM (modem),
461
 
                                     res,
462
 
                                     &error);
 
477
    mm_base_modem_at_command_full_finish (modem, res, &error);
463
478
    if (error) {
464
479
        mm_dbg("Disconnection error: %s", error->message);
465
480
        g_error_free (error);
486
501
        bearer->priv->connection_poller = 0;
487
502
    }
488
503
 
489
 
    ctx = detailed_disconnect_context_new (self, modem, primary, secondary,
490
 
                                           data, callback, user_data);
 
504
    ctx = detailed_disconnect_context_new (self, modem, primary, data, callback, user_data);
491
505
 
492
 
    mm_base_modem_at_command (
 
506
    mm_base_modem_at_command_full (
493
507
        ctx->modem,
 
508
        ctx->primary,
494
509
        "$NWQMIDISCONNECT",
495
510
        10, /* timeout */
496
511
        FALSE, /* allow_cached */
 
512
        FALSE, /* is_raw */
 
513
        NULL, /* cancellable */
497
514
        (GAsyncReadyCallback)disconnect_3gpp_check_status,
498
515
        ctx); /* user_data */
499
516
}