~bjorn-runaker-se/modemmanager/trunk.mbm

« back to all changes in this revision

Viewing changes to plugins/mm-modem-mbm.c

  • Committer: bjorn
  • Date: 2008-12-02 13:24:57 UTC
  • Revision ID: svn-v3-single1-dHJ1bmsvbGludXgvYXBwL25ldHdvcmtfbWFuYWdlcl92YW5pbGxhL3NyYy9tb2RlbW1hbmFnZXI.:001bfd16-f65b-11dc-971d-77b725aee811:trunk%2Flinux%2Fapp%2Fnetwork_manager_vanilla%2Fsrc%2Fmodemmanager:1068
Delivery of waiting for ENAP event. This solves the case where it do not get IP after connect.

Show diffs side-by-side

added added

removed removed

Lines of Context:
73
73
    int      bModemEnabled;
74
74
    int      bModemEnableRunning;
75
75
    int      register_completed;
 
76
  int       enap_completed;
76
77
    int       bEnap_done;
77
78
    int      bCOPS_register;
78
79
    char    *network_id;
250
251
    mm_serial_queue_command (serial, "+CREG=1", 25, init_do_wait4creg, user_data);
251
252
}
252
253
 
 
254
static void
 
255
init_do_wait4enap_loop (MMSerial *serial, gpointer user_data);
 
256
 
 
257
 
 
258
static void
 
259
check_enap_done (MMSerial *serial,
 
260
                 GString *response,
 
261
                 GError *error,
 
262
                 gpointer user_data)
 
263
{
 
264
    MMCallbackInfo *info = (MMCallbackInfo *) user_data;
 
265
    MMModemMbmPrivate *priv = MM_MODEM_MBM_GET_PRIVATE (info->modem);
 
266
    const char *reply = response->str;
 
267
 
 
268
    priv->enap_completed = 0;
 
269
    
 
270
    if (error)
 
271
        info->error = g_error_copy (error);
 
272
 
 
273
    if (g_str_has_prefix (reply, "*ENAP: ")) {
 
274
        int bEnabled;
 
275
        if (sscanf (reply + 7, "%d", &bEnabled)) {
 
276
            if (bEnabled == 1)
 
277
                priv->enap_completed = 1;
 
278
        }
 
279
    }
 
280
 
 
281
    mm_serial_flash (serial, 1000, init_do_wait4enap_loop, user_data);
 
282
}
 
283
 
 
284
 
 
285
 
 
286
static void
 
287
init_do_wait4enap_loop (MMSerial *serial, gpointer user_data)
 
288
{
 
289
    MMCallbackInfo *info = (MMCallbackInfo *) user_data;
 
290
    MMModemMbmPrivate *priv = MM_MODEM_MBM_GET_PRIVATE(info->modem);
 
291
 
 
292
    GError *error;
 
293
 
 
294
    if (!priv)
 
295
        return;
 
296
 
 
297
    if (!priv->bModemEnabled) {
 
298
        mm_callback_info_schedule (info); /* TODO: is this the best way to free structures */
 
299
        return;
 
300
    }
 
301
 
 
302
    if (!priv->enap_completed) {
 
303
        g_debug("still waiting for enap to complete\n");
 
304
        mm_serial_queue_command (serial, "*enap?", 3, check_enap_done, info);
 
305
 
 
306
    } else {
 
307
        g_debug("registration completed\n");
 
308
        do_register_done (serial, "", NULL, info);
 
309
//        mm_serial_queue_command(serial, "AT*ENAP=1,1", 20, do_register_done, info);
 
310
    }  
 
311
}
 
312
 
 
313
 
253
314
/*
254
315
 * ENAP=1,1 should be done after a successful registration
255
316
 */
271
332
    }
272
333
 
273
334
    sleep(4);
274
 
    mm_serial_queue_command (serial, "*ENAP=1,1", 25, do_register_done, user_data);
 
335
    mm_serial_queue_command (serial, "*ENAP=1,1", 25, check_enap_done, user_data);
275
336
}
276
337
 
277
338
static void
361
422
        } else
362
423
        {
363
424
            
364
 
            mm_serial_queue_command(serial, "AT*ENAP=1,1", 20, do_register_done, info);
 
425
            mm_serial_queue_command(serial, "AT*ENAP=1,1", 20, check_enap_done, info);
365
426
        }
366
427
    }
367
428
}
1068
1129
    priv->bModemEnabled = 0;
1069
1130
    priv->bModemEnableRunning = 0;
1070
1131
    priv->register_completed = 0;
 
1132
    priv->enap_completed = 0;
1071
1133
    priv->bCOPS_register = 0;
1072
1134
    priv->network_id = NULL;
1073
1135
}
1119
1181
    priv->bEnable = 0;
1120
1182
    
1121
1183
    priv->register_completed = 0;
 
1184
    priv->enap_completed = 0;
1122
1185
    priv->bCOPS_register = 0;
1123
1186
    priv->network_id = NULL;
1124
1187
    priv->bEnap_done = 0;
1184
1247
    }
1185
1248
    
1186
1249
    priv->register_completed = 0;
 
1250
    priv->enap_completed = 0;
1187
1251
    priv->bCOPS_register = 0;
1188
1252
    priv->network_id = NULL;
1189
1253
    priv->bEnap_done = 0;