From: Forest Bond <[email protected]>
If the device has retained parameters for a previously defined IP
context, is is probed via AT+CGDCONT?.
---
drivers/atmodem/gprs.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 53 insertions(+), 2 deletions(-)
diff --git a/drivers/atmodem/gprs.c b/drivers/atmodem/gprs.c
index 3005867..280ca49 100644
--- a/drivers/atmodem/gprs.c
+++ b/drivers/atmodem/gprs.c
@@ -35,6 +35,7 @@
#include <ofono/log.h>
#include <ofono/modem.h>
#include <ofono/gprs.h>
+#include <ofono/gprs-provision.h>
#include "gatchat.h"
#include "gatresult.h"
@@ -408,6 +409,56 @@ error:
ofono_gprs_remove(gprs);
}
+static void at_cgdcont_read_cb(gboolean ok, GAtResult *result,
+ gpointer user_data)
+{
+ struct ofono_gprs *gprs = user_data;
+ struct gprs_data *gd = ofono_gprs_get_data(gprs);
+ GAtResultIter iter;
+ gint cid;
+ const char *pdp_type;
+ const char *apn;
+ struct ofono_gprs_provision_data *ap;
+ gboolean found = FALSE;
+
+ if (!ok)
+ goto done;
+
+ g_at_result_iter_init(&iter, result);
+
+ while (!found && g_at_result_iter_next(&iter, "+CGDCONT:")) {
+ if (!g_at_result_iter_next_number(&iter, &cid))
+ continue;
+
+ if (!g_at_result_iter_next_string(&iter, &pdp_type))
+ continue;
+
+ if (!g_at_result_iter_next_string(&iter, &apn))
+ continue;
+
+ /* We look for IP PDPs */
+ if (g_str_equal(pdp_type, "IP"))
+ found = TRUE;
+ }
+
+ if (found == FALSE)
+ goto done;
+
+ ap = g_try_new0(struct ofono_gprs_provision_data, 1);
+ if (ap == NULL)
+ goto done;
+
+ ap->type = OFONO_GPRS_CONTEXT_TYPE_INTERNET;
+ ap->proto = OFONO_GPRS_PROTO_IP;
+ ap->apn = g_strdup(apn);
+ ofono_info("Probed AP %s from device", apn);
+ ofono_gprs_set_probed_ap(gprs, ap);
+
+done:
+ g_at_chat_send(gd->chat, "AT+CGREG=?", cgreg_prefix,
+ at_cgreg_test_cb, gprs, NULL);
+}
+
static void at_cgdcont_test_cb(gboolean ok, GAtResult *result,
gpointer user_data)
{
@@ -454,8 +505,8 @@ static void at_cgdcont_test_cb(gboolean ok, GAtResult
*result,
ofono_gprs_set_cid_range(gprs, min, max);
- g_at_chat_send(gd->chat, "AT+CGREG=?", cgreg_prefix,
- at_cgreg_test_cb, gprs, NULL);
+ g_at_chat_send(gd->chat, "AT+CGDCONT?", cgdcont_prefix,
+ at_cgdcont_read_cb, gprs, NULL);
return;
--
1.7.0.4
_______________________________________________
ofono mailing list
[email protected]
http://lists.ofono.org/listinfo/ofono