* [PATCH 0/7] Get SID and provider name
@ 2011-11-24 17:46 Philippe Nunes
2011-11-24 17:46 ` [PATCH 1/7] Huaweicdmamodem: remove this specific driver Philippe Nunes
` (6 more replies)
0 siblings, 7 replies; 11+ messages in thread
From: Philippe Nunes @ 2011-11-24 17:46 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 1603 bytes --]
Hi,
The goal of these patch is to:
- Merge the huaweicdmamodem driver with cdmamodem driver.
- Add the serving system entry point in cdmamodem driver
- Retrieve the provider name based on the SID provided by the modem.
Philippe Nunes (7):
Huaweicdmamodem: remove this specific driver
huaweicdmamodem: Merge this driver with cdmamodem driver
cdmamodem: Add CDMA network-registration support
cdma-netreg: Add 'serving_system' entry point to cdma-netreg to get
SID
cdmamodem: Add serving system identifier support
cdma-netreg: Make use of the new driver entry point serving_system
cdma-netreg: Add provider name support
Makefile.am | 13 +-
drivers/cdmamodem/cdmamodem.c | 2 +
drivers/cdmamodem/cdmamodem.h | 2 +
drivers/cdmamodem/network-registration.c | 278 ++++++++++++++++++++++++
drivers/huaweicdmamodem/huaweicdmamodem.c | 45 ----
drivers/huaweicdmamodem/huaweicdmamodem.h | 23 --
drivers/huaweicdmamodem/network-registration.c | 199 -----------------
include/cdma-netreg.h | 7 +
plugins/huaweicdma.c | 5 +-
src/cdma-netreg.c | 55 +++++
10 files changed, 353 insertions(+), 276 deletions(-)
create mode 100644 drivers/cdmamodem/network-registration.c
delete mode 100644 drivers/huaweicdmamodem/huaweicdmamodem.c
delete mode 100644 drivers/huaweicdmamodem/huaweicdmamodem.h
delete mode 100644 drivers/huaweicdmamodem/network-registration.c
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 1/7] Huaweicdmamodem: remove this specific driver
2011-11-24 17:46 [PATCH 0/7] Get SID and provider name Philippe Nunes
@ 2011-11-24 17:46 ` Philippe Nunes
2011-11-24 17:46 ` [PATCH 2/7] huaweicdmamodem: Merge this driver with cdmamodem driver Philippe Nunes
` (5 subsequent siblings)
6 siblings, 0 replies; 11+ messages in thread
From: Philippe Nunes @ 2011-11-24 17:46 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 631 bytes --]
---
Makefile.am | 6 ------
1 files changed, 0 insertions(+), 6 deletions(-)
diff --git a/Makefile.am b/Makefile.am
index 337aeb7..4c3ca84 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -274,12 +274,6 @@ builtin_sources += drivers/cdmamodem/cdmamodem.h \
drivers/cdmamodem/voicecall.c \
drivers/cdmamodem/devinfo.c \
drivers/cdmamodem/connman.c
-
-builtin_modules += huaweicdmamodem
-builtin_sources += drivers/huaweicdmamodem/huaweicdmamodem.h \
- drivers/huaweicdmamodem/huaweicdmamodem.c \
- drivers/huaweicdmamodem/network-registration.c
-
endif
builtin_modules += g1
--
1.7.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 2/7] huaweicdmamodem: Merge this driver with cdmamodem driver
2011-11-24 17:46 [PATCH 0/7] Get SID and provider name Philippe Nunes
2011-11-24 17:46 ` [PATCH 1/7] Huaweicdmamodem: remove this specific driver Philippe Nunes
@ 2011-11-24 17:46 ` Philippe Nunes
2011-11-24 17:46 ` [PATCH 3/7] cdmamodem: Add CDMA network-registration support Philippe Nunes
` (4 subsequent siblings)
6 siblings, 0 replies; 11+ messages in thread
From: Philippe Nunes @ 2011-11-24 17:46 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 8449 bytes --]
---
drivers/huaweicdmamodem/huaweicdmamodem.c | 45 ------
drivers/huaweicdmamodem/huaweicdmamodem.h | 23 ---
drivers/huaweicdmamodem/network-registration.c | 199 ------------------------
3 files changed, 0 insertions(+), 267 deletions(-)
delete mode 100644 drivers/huaweicdmamodem/huaweicdmamodem.c
delete mode 100644 drivers/huaweicdmamodem/huaweicdmamodem.h
delete mode 100644 drivers/huaweicdmamodem/network-registration.c
diff --git a/drivers/huaweicdmamodem/huaweicdmamodem.c b/drivers/huaweicdmamodem/huaweicdmamodem.c
deleted file mode 100644
index 4e9c400..0000000
--- a/drivers/huaweicdmamodem/huaweicdmamodem.c
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- *
- * oFono - Open Source Telephony
- *
- * Copyright (C) 2008-2011 Intel Corporation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#define OFONO_API_SUBJECT_TO_CHANGE
-#include <ofono/plugin.h>
-
-#include "huaweicdmamodem.h"
-
-static int huaweicdmamodem_init(void)
-{
- huaweicdma_netreg_init();
-
- return 0;
-}
-
-static void huaweicdmamodem_exit(void)
-{
- huaweicdma_netreg_exit();
-}
-
-OFONO_PLUGIN_DEFINE(huaweicdmamodem, "Huawei CDMA modem driver", VERSION,
- OFONO_PLUGIN_PRIORITY_DEFAULT,
- huaweicdmamodem_init, huaweicdmamodem_exit)
diff --git a/drivers/huaweicdmamodem/huaweicdmamodem.h b/drivers/huaweicdmamodem/huaweicdmamodem.h
deleted file mode 100644
index 799d3a8..0000000
--- a/drivers/huaweicdmamodem/huaweicdmamodem.h
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- *
- * oFono - Open Source Telephony
- *
- * Copyright (C) 2008-2011 Intel Corporation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- */
-
-extern void huaweicdma_netreg_init(void);
-extern void huaweicdma_netreg_exit(void);
diff --git a/drivers/huaweicdmamodem/network-registration.c b/drivers/huaweicdmamodem/network-registration.c
deleted file mode 100644
index 25c6291..0000000
--- a/drivers/huaweicdmamodem/network-registration.c
+++ /dev/null
@@ -1,199 +0,0 @@
-/*
- *
- * oFono - Open Source Telephony
- *
- * Copyright (C) 2008-2011 Intel Corporation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#define _GNU_SOURCE
-#include <glib.h>
-#include <errno.h>
-
-#include <ofono/log.h>
-#include <ofono/modem.h>
-#include <ofono/cdma-netreg.h>
-
-#include "gatchat.h"
-
-#include "huaweicdmamodem.h"
-
-static const char *sysinfo_prefix[] = { "^SYSINFO:", NULL };
-
-static gboolean parse_sysinfo(GAtResult *result, gint *status)
-{
- GAtResultIter iter;
- gint srv_status;
- gint srv_domain;
- gint roaming_status;
-
- g_at_result_iter_init(&iter, result);
-
- if (!g_at_result_iter_next(&iter, "^SYSINFO:"))
- return FALSE;
-
- if (!g_at_result_iter_next_number(&iter, &srv_status))
- return FALSE;
-
- if (!g_at_result_iter_next_number(&iter, &srv_domain))
- return FALSE;
-
- if (!g_at_result_iter_next_number(&iter, &roaming_status))
- return FALSE;
-
- DBG("%d, %d, %d", srv_status, srv_domain, roaming_status);
-
- switch (srv_status) {
- case 1: /* Restricted service */
- case 2: /* Service valid */
- case 3: /* Restricted region service */
- if (roaming_status)
- *status = CDMA_NETWORK_REGISTRATION_STATUS_ROAMING;
- else
- *status = CDMA_NETWORK_REGISTRATION_STATUS_REGISTERED;
- break;
- case 0: /* No service */
- case 4: /* Not registered */
- default:
- *status = CDMA_NETWORK_REGISTRATION_STATUS_NOT_REGISTERED;
- break;
- }
-
- switch (srv_domain) {
- case 0: /* No service */
- case 255: /* CDMA not supported */
- *status = CDMA_NETWORK_REGISTRATION_STATUS_NOT_REGISTERED;
- break;
- case 1: /* Only CS */
- case 2: /* Only PS */
- case 3: /* CS PS */
- case 4: /* CS registered, PS in searching state */
- break;
- }
-
- return TRUE;
-}
-
-static void sysinfo_cb(gboolean ok, GAtResult *result, gpointer user_data)
-{
- struct ofono_cdma_netreg *netreg = user_data;
- int status;
-
- if (!ok)
- return;
-
- if (parse_sysinfo(result, &status) == FALSE) {
- ofono_error("Invalid SYSINFO values");
- return;
- }
-
- ofono_cdma_netreg_status_notify(netreg, status);
-}
-
-static void mode_notify(GAtResult *result, gpointer user_data)
-{
- struct ofono_cdma_netreg *netreg = user_data;
- GAtChat *chat = ofono_cdma_netreg_get_data(netreg);
-
- g_at_chat_send(chat, "AT^SYSINFO", sysinfo_prefix,
- sysinfo_cb, netreg, NULL);
-}
-
-static void rssilvl_notify(GAtResult *result, gpointer user_data)
-{
- struct ofono_cdma_netreg *netreg = user_data;
- int strength;
- GAtResultIter iter;
-
- g_at_result_iter_init(&iter, result);
-
- if (!g_at_result_iter_next(&iter, "^RSSILVL:"))
- goto error;
-
- if (!g_at_result_iter_next_number(&iter, &strength))
- goto error;
-
- if (strength == 99)
- strength = 100;
-
- ofono_cdma_netreg_strength_notify(netreg, strength);
-
- return;
-
-error:
- ofono_error("Invalid RSSILVL value");
-}
-
-static void probe_cb(gboolean ok, GAtResult *result, gpointer user_data)
-{
- struct ofono_cdma_netreg *netreg = user_data;
- GAtChat *chat = ofono_cdma_netreg_get_data(netreg);
-
- if (!ok) {
- ofono_cdma_netreg_remove(netreg);
- return;
- }
-
- g_at_chat_register(chat, "^MODE:",
- mode_notify, FALSE, netreg, NULL);
-
- g_at_chat_register(chat, "^RSSILVL:",
- rssilvl_notify, FALSE, netreg, NULL);
-
- ofono_cdma_netreg_register(netreg);
-}
-
-static int huaweicdma_netreg_probe(struct ofono_cdma_netreg *netreg,
- unsigned int vendor, void *data)
-{
- GAtChat *chat = g_at_chat_clone(data);
-
- ofono_cdma_netreg_set_data(netreg, chat);
-
- g_at_chat_send(chat, "AT^SYSINFO", sysinfo_prefix,
- probe_cb, netreg, NULL);
-
- return 0;
-}
-
-static void huaweicdma_netreg_remove(struct ofono_cdma_netreg *netreg)
-{
- GAtChat *chat = ofono_cdma_netreg_get_data(netreg);
-
- ofono_cdma_netreg_set_data(netreg, NULL);
-
- g_at_chat_unref(chat);
-}
-
-static struct ofono_cdma_netreg_driver driver = {
- .name = "huaweicdmamodem",
- .probe = huaweicdma_netreg_probe,
- .remove = huaweicdma_netreg_remove,
-};
-
-void huaweicdma_netreg_init(void)
-{
- ofono_cdma_netreg_driver_register(&driver);
-}
-
-void huaweicdma_netreg_exit(void)
-{
- ofono_cdma_netreg_driver_unregister(&driver);
-}
--
1.7.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 3/7] cdmamodem: Add CDMA network-registration support
2011-11-24 17:46 [PATCH 0/7] Get SID and provider name Philippe Nunes
2011-11-24 17:46 ` [PATCH 1/7] Huaweicdmamodem: remove this specific driver Philippe Nunes
2011-11-24 17:46 ` [PATCH 2/7] huaweicdmamodem: Merge this driver with cdmamodem driver Philippe Nunes
@ 2011-11-24 17:46 ` Philippe Nunes
2011-11-24 17:46 ` [PATCH 4/7] cdma-netreg: Add 'serving_system' entry point to cdma-netreg to get SID Philippe Nunes
` (3 subsequent siblings)
6 siblings, 0 replies; 11+ messages in thread
From: Philippe Nunes @ 2011-11-24 17:46 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 7972 bytes --]
---
Makefile.am | 6 +-
drivers/cdmamodem/cdmamodem.c | 2 +
drivers/cdmamodem/cdmamodem.h | 2 +
drivers/cdmamodem/network-registration.c | 201 ++++++++++++++++++++++++++++++
plugins/huaweicdma.c | 5 +-
5 files changed, 213 insertions(+), 3 deletions(-)
create mode 100644 drivers/cdmamodem/network-registration.c
diff --git a/Makefile.am b/Makefile.am
index 4c3ca84..6002eb0 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -269,11 +269,13 @@ endif
if CDMAMODEM
builtin_modules += cdmamodem
-builtin_sources += drivers/cdmamodem/cdmamodem.h \
+builtin_sources += drivers/atmodem/atutil.h \
+ drivers/cdmamodem/cdmamodem.h \
drivers/cdmamodem/cdmamodem.c \
drivers/cdmamodem/voicecall.c \
drivers/cdmamodem/devinfo.c \
- drivers/cdmamodem/connman.c
+ drivers/cdmamodem/connman.c \
+ drivers/cdmamodem/network-registration.c
endif
builtin_modules += g1
diff --git a/drivers/cdmamodem/cdmamodem.c b/drivers/cdmamodem/cdmamodem.c
index 50908e3..1548102 100644
--- a/drivers/cdmamodem/cdmamodem.c
+++ b/drivers/cdmamodem/cdmamodem.c
@@ -37,6 +37,7 @@ static int cdmamodem_init(void)
cdma_voicecall_init();
cdma_devinfo_init();
cdma_connman_init();
+ cdma_netreg_init();
return 0;
}
@@ -46,6 +47,7 @@ static void cdmamodem_exit(void)
cdma_voicecall_exit();
cdma_devinfo_exit();
cdma_connman_exit();
+ cdma_netreg_exit();
}
OFONO_PLUGIN_DEFINE(cdmamodem, "CDMA AT modem driver", VERSION,
diff --git a/drivers/cdmamodem/cdmamodem.h b/drivers/cdmamodem/cdmamodem.h
index 3554705..d496214 100644
--- a/drivers/cdmamodem/cdmamodem.h
+++ b/drivers/cdmamodem/cdmamodem.h
@@ -27,3 +27,5 @@ extern void cdma_devinfo_init(void);
extern void cdma_devinfo_exit(void);
extern void cdma_connman_init(void);
extern void cdma_connman_exit(void);
+extern void cdma_netreg_init(void);
+extern void cdma_netreg_exit(void);
diff --git a/drivers/cdmamodem/network-registration.c b/drivers/cdmamodem/network-registration.c
new file mode 100644
index 0000000..a34db91
--- /dev/null
+++ b/drivers/cdmamodem/network-registration.c
@@ -0,0 +1,201 @@
+/*
+ *
+ * oFono - Open Source Telephony
+ *
+ * Copyright (C) 2008-2011 Intel Corporation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#define _GNU_SOURCE
+#include <glib.h>
+#include <errno.h>
+
+#include <ofono/log.h>
+#include <ofono/modem.h>
+#include <ofono/cdma-netreg.h>
+
+#include "gatchat.h"
+
+#include "cdmamodem.h"
+#include <drivers/atmodem/vendor.h>
+
+static const char *sysinfo_prefix[] = { "^SYSINFO:", NULL };
+
+static gboolean parse_sysinfo(GAtResult *result, gint *status)
+{
+ GAtResultIter iter;
+ gint srv_status;
+ gint srv_domain;
+ gint roaming_status;
+
+ g_at_result_iter_init(&iter, result);
+
+ if (!g_at_result_iter_next(&iter, "^SYSINFO:"))
+ return FALSE;
+
+ if (!g_at_result_iter_next_number(&iter, &srv_status))
+ return FALSE;
+
+ if (!g_at_result_iter_next_number(&iter, &srv_domain))
+ return FALSE;
+
+ if (!g_at_result_iter_next_number(&iter, &roaming_status))
+ return FALSE;
+
+ DBG("%d, %d, %d", srv_status, srv_domain, roaming_status);
+
+ switch (srv_status) {
+ case 1: /* Restricted service */
+ case 2: /* Service valid */
+ case 3: /* Restricted region service */
+ if (roaming_status)
+ *status = CDMA_NETWORK_REGISTRATION_STATUS_ROAMING;
+ else
+ *status = CDMA_NETWORK_REGISTRATION_STATUS_REGISTERED;
+ break;
+ case 0: /* No service */
+ case 4: /* Not registered */
+ default:
+ *status = CDMA_NETWORK_REGISTRATION_STATUS_NOT_REGISTERED;
+ break;
+ }
+
+ switch (srv_domain) {
+ case 0: /* No service */
+ case 255: /* CDMA not supported */
+ *status = CDMA_NETWORK_REGISTRATION_STATUS_NOT_REGISTERED;
+ break;
+ case 1: /* Only CS */
+ case 2: /* Only PS */
+ case 3: /* CS PS */
+ case 4: /* CS registered, PS in searching state */
+ break;
+ }
+
+ return TRUE;
+}
+
+static void sysinfo_cb(gboolean ok, GAtResult *result, gpointer user_data)
+{
+ struct ofono_cdma_netreg *netreg = user_data;
+ int status;
+
+ if (!ok)
+ return;
+
+ if (parse_sysinfo(result, &status) == FALSE) {
+ ofono_error("Invalid SYSINFO values");
+ return;
+ }
+
+ ofono_cdma_netreg_status_notify(netreg, status);
+}
+
+static void mode_notify(GAtResult *result, gpointer user_data)
+{
+ struct ofono_cdma_netreg *netreg = user_data;
+ GAtChat *chat = ofono_cdma_netreg_get_data(netreg);
+
+ g_at_chat_send(chat, "AT^SYSINFO", sysinfo_prefix,
+ sysinfo_cb, netreg, NULL);
+}
+
+static void rssilvl_notify(GAtResult *result, gpointer user_data)
+{
+ struct ofono_cdma_netreg *netreg = user_data;
+ int strength;
+ GAtResultIter iter;
+
+ g_at_result_iter_init(&iter, result);
+
+ if (!g_at_result_iter_next(&iter, "^RSSILVL:"))
+ goto error;
+
+ if (!g_at_result_iter_next_number(&iter, &strength))
+ goto error;
+
+ if (strength == 99)
+ strength = 100;
+
+ ofono_cdma_netreg_strength_notify(netreg, strength);
+
+ return;
+
+error:
+ ofono_error("Invalid RSSILVL value");
+}
+
+static void probe_cb(gboolean ok, GAtResult *result, gpointer user_data)
+{
+ struct ofono_cdma_netreg *netreg = user_data;
+ GAtChat *chat = ofono_cdma_netreg_get_data(netreg);
+
+ if (!ok) {
+ ofono_cdma_netreg_remove(netreg);
+ return;
+ }
+
+ g_at_chat_register(chat, "^MODE:",
+ mode_notify, FALSE, netreg, NULL);
+
+ g_at_chat_register(chat, "^RSSILVL:",
+ rssilvl_notify, FALSE, netreg, NULL);
+
+ ofono_cdma_netreg_register(netreg);
+}
+
+static int cdma_netreg_probe(struct ofono_cdma_netreg *netreg,
+ unsigned int vendor, void *data)
+{
+ GAtChat *chat = g_at_chat_clone(data);
+
+ ofono_cdma_netreg_set_data(netreg, chat);
+
+ if (vendor == OFONO_VENDOR_HUAWEI)
+ g_at_chat_send(chat, "AT^SYSINFO", sysinfo_prefix,
+ probe_cb, netreg, NULL);
+
+ return 0;
+}
+
+static void cdma_netreg_remove(struct ofono_cdma_netreg *netreg)
+{
+ GAtChat *chat = ofono_cdma_netreg_get_data(netreg);
+
+ ofono_cdma_netreg_set_data(netreg, NULL);
+
+ g_at_chat_unref(chat);
+}
+
+static struct ofono_cdma_netreg_driver driver = {
+ .name = "cdmamodem",
+ .probe = cdma_netreg_probe,
+ .remove = cdma_netreg_remove,
+};
+
+void cdma_netreg_init(void)
+{
+ ofono_cdma_netreg_driver_register(&driver);
+}
+
+void cdma_netreg_exit(void)
+{
+ ofono_cdma_netreg_driver_unregister(&driver);
+}
diff --git a/plugins/huaweicdma.c b/plugins/huaweicdma.c
index 4c83114..5618417 100644
--- a/plugins/huaweicdma.c
+++ b/plugins/huaweicdma.c
@@ -38,6 +38,8 @@
#include <ofono/cdma-connman.h>
#include <ofono/log.h>
+#include <drivers/atmodem/vendor.h>
+
struct huaweicdma_data {
GAtChat *modem;
GAtChat *pcui;
@@ -211,7 +213,8 @@ static void huaweicdma_post_online(struct ofono_modem *modem)
DBG("%p", modem);
- ofono_cdma_netreg_create(modem, 0, "huaweicdmamodem", data->modem);
+ ofono_cdma_netreg_create(modem, OFONO_VENDOR_HUAWEI, "cdmamodem",
+ data->modem);
ofono_cdma_connman_create(modem, 0, "cdmamodem", data->modem);
}
--
1.7.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 4/7] cdma-netreg: Add 'serving_system' entry point to cdma-netreg to get SID
2011-11-24 17:46 [PATCH 0/7] Get SID and provider name Philippe Nunes
` (2 preceding siblings ...)
2011-11-24 17:46 ` [PATCH 3/7] cdmamodem: Add CDMA network-registration support Philippe Nunes
@ 2011-11-24 17:46 ` Philippe Nunes
2011-11-24 23:42 ` Denis Kenzior
2011-11-24 17:46 ` [PATCH 5/7] cdmamodem: Add serving system identifier support Philippe Nunes
` (2 subsequent siblings)
6 siblings, 1 reply; 11+ messages in thread
From: Philippe Nunes @ 2011-11-24 17:46 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 904 bytes --]
---
include/cdma-netreg.h | 7 +++++++
1 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/include/cdma-netreg.h b/include/cdma-netreg.h
index 31ed289..529dab5 100644
--- a/include/cdma-netreg.h
+++ b/include/cdma-netreg.h
@@ -36,12 +36,19 @@ enum cdma_netreg_status {
struct ofono_cdma_netreg;
+typedef void (*ofono_cdma_netreg_serving_system_cb_t)(
+ const struct ofono_error *error,
+ const char *sid,
+ void *data);
+
struct ofono_cdma_netreg_driver {
const char *name;
int (*probe)(struct ofono_cdma_netreg *cdma_netreg,
unsigned int vendor,
void *data);
void (*remove)(struct ofono_cdma_netreg *cdma_netreg);
+ void (*serving_system)(struct ofono_cdma_netreg *cdma_netreg,
+ ofono_cdma_netreg_serving_system_cb_t cb, void *data);
};
void ofono_cdma_netreg_status_notify(struct ofono_cdma_netreg *netreg,
--
1.7.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 5/7] cdmamodem: Add serving system identifier support
2011-11-24 17:46 [PATCH 0/7] Get SID and provider name Philippe Nunes
` (3 preceding siblings ...)
2011-11-24 17:46 ` [PATCH 4/7] cdma-netreg: Add 'serving_system' entry point to cdma-netreg to get SID Philippe Nunes
@ 2011-11-24 17:46 ` Philippe Nunes
2011-11-24 17:46 ` [PATCH 6/7] cdma-netreg: Make use of the new driver entry point serving_system Philippe Nunes
2011-11-24 17:46 ` [PATCH 7/7] cdma-netreg: Add provider name support Philippe Nunes
6 siblings, 0 replies; 11+ messages in thread
From: Philippe Nunes @ 2011-11-24 17:46 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 3174 bytes --]
---
drivers/cdmamodem/network-registration.c | 77 ++++++++++++++++++++++++++++++
1 files changed, 77 insertions(+), 0 deletions(-)
diff --git a/drivers/cdmamodem/network-registration.c b/drivers/cdmamodem/network-registration.c
index a34db91..b72295c 100644
--- a/drivers/cdmamodem/network-registration.c
+++ b/drivers/cdmamodem/network-registration.c
@@ -24,6 +24,7 @@
#endif
#define _GNU_SOURCE
+#include <string.h>
#include <glib.h>
#include <errno.h>
@@ -108,6 +109,66 @@ static void sysinfo_cb(gboolean ok, GAtResult *result, gpointer user_data)
ofono_cdma_netreg_status_notify(netreg, status);
}
+static gboolean parse_css(GAtResult *result, const char **sid)
+{
+ GAtResultIter iter;
+ /*
+ * According TIA/EIA/IS-707, CSS query returns <AB>,<SID> but
+ * according TIA/EIA/IS-707-A , it returns <Band_Class>,<Band>,<SID>.
+ * PREV field which has been added afterward is ignored
+ */
+
+ g_at_result_iter_init(&iter, result);
+
+ g_at_result_iter_next(&iter, NULL);
+
+ /* Skip first field since we are not interested in this */
+ if (!g_at_result_iter_skip_next(&iter))
+ return FALSE;
+
+ if (!g_at_result_iter_next_unquoted_string(&iter, sid))
+ return FALSE;
+ /*
+ * As CSS answer may differ according which revision of TIA/EIA/IS-707
+ * the modem is compliant, we need to check if this field is Band or SID
+ */
+ if ((*sid[0] >= 'A' && *sid[0] <= 'F') || (*sid[0] == 'Z'))
+ /* This is the band field, the next field is the SID*/
+ if (!g_at_result_iter_next_unquoted_string(&iter, sid))
+ return FALSE;
+
+ if (!strcmp(*sid, "99999"))
+ /* The mobile station is not registered.*/
+ return FALSE;
+
+ return TRUE;
+}
+
+static void serving_system_cb(gboolean ok, GAtResult *result,
+ gpointer user_data)
+{
+ struct cb_data *cbd = user_data;
+ ofono_cdma_netreg_serving_system_cb_t cb = cbd->cb;
+ struct ofono_error error;
+ const char* sid;
+
+ decode_at_error(&error, g_at_result_final_response(result));
+
+ if (!ok) {
+ cb(&error, NULL, cbd->data);
+ return;
+ }
+
+ if (parse_css(result, &sid) == FALSE) {
+ CALLBACK_WITH_FAILURE(cb, NULL, cbd->data);
+ return;
+ }
+
+ DBG("serving system: SID %s", sid);
+
+ cb(&error, sid, cbd->data);
+}
+
static void mode_notify(GAtResult *result, gpointer user_data)
{
struct ofono_cdma_netreg *netreg = user_data;
@@ -184,10 +245,26 @@ static void cdma_netreg_remove(struct ofono_cdma_netreg *netreg)
g_at_chat_unref(chat);
}
+static void cdma_netreg_serving_system(struct ofono_cdma_netreg *netreg,
+ ofono_cdma_netreg_serving_system_cb_t cb, void *data)
+{
+ GAtChat *chat = ofono_cdma_netreg_get_data(netreg);
+ struct cb_data *cbd = cb_data_new(cb, data);
+
+ if (g_at_chat_send(chat, "AT+CSS=?", NULL, serving_system_cb, cbd,
+ g_free) > 0)
+ return;
+
+ g_free(cbd);
+
+ CALLBACK_WITH_FAILURE(cb, NULL, data);
+}
+
static struct ofono_cdma_netreg_driver driver = {
.name = "cdmamodem",
.probe = cdma_netreg_probe,
.remove = cdma_netreg_remove,
+ .serving_system = cdma_netreg_serving_system,
};
void cdma_netreg_init(void)
--
1.7.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 6/7] cdma-netreg: Make use of the new driver entry point serving_system
2011-11-24 17:46 [PATCH 0/7] Get SID and provider name Philippe Nunes
` (4 preceding siblings ...)
2011-11-24 17:46 ` [PATCH 5/7] cdmamodem: Add serving system identifier support Philippe Nunes
@ 2011-11-24 17:46 ` Philippe Nunes
2011-11-24 23:51 ` Denis Kenzior
2011-11-24 17:46 ` [PATCH 7/7] cdma-netreg: Add provider name support Philippe Nunes
6 siblings, 1 reply; 11+ messages in thread
From: Philippe Nunes @ 2011-11-24 17:46 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 1569 bytes --]
---
src/cdma-netreg.c | 25 +++++++++++++++++++++++++
1 files changed, 25 insertions(+), 0 deletions(-)
diff --git a/src/cdma-netreg.c b/src/cdma-netreg.c
index 739d1ef..222c3b7 100644
--- a/src/cdma-netreg.c
+++ b/src/cdma-netreg.c
@@ -104,6 +104,24 @@ static GDBusSignalTable cdma_netreg_manager_signals[] = {
{ }
};
+static void serving_system_callback(const struct ofono_error *error,
+ const char *sid, void *data)
+{
+ struct ofono_cdma_netreg *cdma_netreg = data;
+
+ if (cdma_netreg->status != CDMA_NETWORK_REGISTRATION_STATUS_REGISTERED
+ && cdma_netreg->status !=
+ CDMA_NETWORK_REGISTRATION_STATUS_ROAMING)
+ return;
+
+ if (error->type != OFONO_ERROR_TYPE_NO_ERROR) {
+ DBG("Error during serving system query");
+ return;
+ }
+
+ DBG("Serving system Identifier: %s", sid);
+}
+
static void set_registration_status(struct ofono_cdma_netreg *cdma_netreg,
enum cdma_netreg_status status)
{
@@ -117,6 +135,13 @@ static void set_registration_status(struct ofono_cdma_netreg *cdma_netreg,
OFONO_CDMA_NETWORK_REGISTRATION_INTERFACE,
"Status", DBUS_TYPE_STRING,
&str_status);
+
+ if (cdma_netreg->status == CDMA_NETWORK_REGISTRATION_STATUS_REGISTERED
+ || cdma_netreg->status ==
+ CDMA_NETWORK_REGISTRATION_STATUS_ROAMING)
+ if (cdma_netreg->driver->serving_system != NULL)
+ cdma_netreg->driver->serving_system(cdma_netreg,
+ serving_system_callback, cdma_netreg);
}
void ofono_cdma_netreg_status_notify(struct ofono_cdma_netreg *cdma_netreg,
--
1.7.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 7/7] cdma-netreg: Add provider name support
2011-11-24 17:46 [PATCH 0/7] Get SID and provider name Philippe Nunes
` (5 preceding siblings ...)
2011-11-24 17:46 ` [PATCH 6/7] cdma-netreg: Make use of the new driver entry point serving_system Philippe Nunes
@ 2011-11-24 17:46 ` Philippe Nunes
2011-11-24 23:55 ` Denis Kenzior
6 siblings, 1 reply; 11+ messages in thread
From: Philippe Nunes @ 2011-11-24 17:46 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 3294 bytes --]
---
Makefile.am | 3 ++-
src/cdma-netreg.c | 30 ++++++++++++++++++++++++++++++
2 files changed, 32 insertions(+), 1 deletions(-)
diff --git a/Makefile.am b/Makefile.am
index 6002eb0..978ac9f 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -275,7 +275,8 @@ builtin_sources += drivers/atmodem/atutil.h \
drivers/cdmamodem/voicecall.c \
drivers/cdmamodem/devinfo.c \
drivers/cdmamodem/connman.c \
- drivers/cdmamodem/network-registration.c
+ drivers/cdmamodem/network-registration.c \
+ plugins/mbpi.c plugins/mbpi.h
endif
builtin_modules += g1
diff --git a/src/cdma-netreg.c b/src/cdma-netreg.c
index 222c3b7..19947ab 100644
--- a/src/cdma-netreg.c
+++ b/src/cdma-netreg.c
@@ -28,6 +28,7 @@
#include <gdbus.h>
#include "ofono.h"
+#include "plugins/mbpi.h"
static GSList *g_drivers;
@@ -38,6 +39,7 @@ struct ofono_cdma_netreg {
const struct ofono_cdma_netreg_driver *driver;
void *driver_data;
struct ofono_atom *atom;
+ char *provider_name;
};
static const char *cdma_netreg_status_to_string(enum cdma_netreg_status status)
@@ -90,6 +92,10 @@ static DBusMessage *network_get_properties(DBusConnection *conn,
&strength);
}
+ if (cdma_netreg->provider_name)
+ ofono_dbus_dict_append(&dict, "Name", DBUS_TYPE_STRING,
+ &cdma_netreg->provider_name);
+
dbus_message_iter_close_container(&iter, &dict);
return reply;
@@ -108,6 +114,9 @@ static void serving_system_callback(const struct ofono_error *error,
const char *sid, void *data)
{
struct ofono_cdma_netreg *cdma_netreg = data;
+ const char *path = __ofono_atom_get_path(cdma_netreg->atom);
+ DBusConnection *conn = ofono_dbus_get_connection();
+ GError *err = NULL;
if (cdma_netreg->status != CDMA_NETWORK_REGISTRATION_STATUS_REGISTERED
&& cdma_netreg->status !=
@@ -120,6 +129,20 @@ static void serving_system_callback(const struct ofono_error *error,
}
DBG("Serving system Identifier: %s", sid);
+
+ g_free(cdma_netreg->provider_name);
+ cdma_netreg->provider_name = NULL;
+ cdma_netreg->provider_name = mbpi_lookup_cdma_provider_name(sid, &err);
+
+ if (cdma_netreg->provider_name)
+ ofono_dbus_signal_property_changed(conn, path,
+ OFONO_CDMA_NETWORK_REGISTRATION_INTERFACE,
+ "Name", DBUS_TYPE_STRING,
+ &cdma_netreg->provider_name);
+ else if (err != NULL) {
+ ofono_error("%s", err->message);
+ g_error_free(err);
+ }
}
static void set_registration_status(struct ofono_cdma_netreg *cdma_netreg,
@@ -136,6 +159,12 @@ static void set_registration_status(struct ofono_cdma_netreg *cdma_netreg,
"Status", DBUS_TYPE_STRING,
&str_status);
+ if (cdma_netreg->status ==
+ CDMA_NETWORK_REGISTRATION_STATUS_NOT_REGISTERED) {
+ g_free(cdma_netreg->provider_name);
+ cdma_netreg->provider_name = NULL;
+ }
+
if (cdma_netreg->status == CDMA_NETWORK_REGISTRATION_STATUS_REGISTERED
|| cdma_netreg->status ==
CDMA_NETWORK_REGISTRATION_STATUS_ROAMING)
@@ -251,6 +280,7 @@ static void cdma_netreg_remove(struct ofono_atom *atom)
if (cdma_netreg->driver && cdma_netreg->driver->remove)
cdma_netreg->driver->remove(cdma_netreg);
+ g_free(cdma_netreg->provider_name);
g_free(cdma_netreg);
}
--
1.7.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH 4/7] cdma-netreg: Add 'serving_system' entry point to cdma-netreg to get SID
2011-11-24 17:46 ` [PATCH 4/7] cdma-netreg: Add 'serving_system' entry point to cdma-netreg to get SID Philippe Nunes
@ 2011-11-24 23:42 ` Denis Kenzior
0 siblings, 0 replies; 11+ messages in thread
From: Denis Kenzior @ 2011-11-24 23:42 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 223 bytes --]
Hi Philippe,
On 11/24/2011 11:46 AM, Philippe Nunes wrote:
> ---
> include/cdma-netreg.h | 7 +++++++
> 1 files changed, 7 insertions(+), 0 deletions(-)
>
Patch has been applied, thanks.
Regards,
-Denis
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 6/7] cdma-netreg: Make use of the new driver entry point serving_system
2011-11-24 17:46 ` [PATCH 6/7] cdma-netreg: Make use of the new driver entry point serving_system Philippe Nunes
@ 2011-11-24 23:51 ` Denis Kenzior
0 siblings, 0 replies; 11+ messages in thread
From: Denis Kenzior @ 2011-11-24 23:51 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 238 bytes --]
Hi Philippe,
On 11/24/2011 11:46 AM, Philippe Nunes wrote:
> ---
> src/cdma-netreg.c | 25 +++++++++++++++++++++++++
> 1 files changed, 25 insertions(+), 0 deletions(-)
>
Patch has been applied, thanks.
Regards,
-Denis
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 7/7] cdma-netreg: Add provider name support
2011-11-24 17:46 ` [PATCH 7/7] cdma-netreg: Add provider name support Philippe Nunes
@ 2011-11-24 23:55 ` Denis Kenzior
0 siblings, 0 replies; 11+ messages in thread
From: Denis Kenzior @ 2011-11-24 23:55 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 4308 bytes --]
Hi Philippe,
On 11/24/2011 11:46 AM, Philippe Nunes wrote:
> ---
> Makefile.am | 3 ++-
> src/cdma-netreg.c | 30 ++++++++++++++++++++++++++++++
> 2 files changed, 32 insertions(+), 1 deletions(-)
>
> diff --git a/Makefile.am b/Makefile.am
> index 6002eb0..978ac9f 100644
> --- a/Makefile.am
> +++ b/Makefile.am
> @@ -275,7 +275,8 @@ builtin_sources += drivers/atmodem/atutil.h \
> drivers/cdmamodem/voicecall.c \
> drivers/cdmamodem/devinfo.c \
> drivers/cdmamodem/connman.c \
> - drivers/cdmamodem/network-registration.c
> + drivers/cdmamodem/network-registration.c \
> + plugins/mbpi.c plugins/mbpi.h
> endif
>
> builtin_modules += g1
> diff --git a/src/cdma-netreg.c b/src/cdma-netreg.c
> index 222c3b7..19947ab 100644
> --- a/src/cdma-netreg.c
> +++ b/src/cdma-netreg.c
> @@ -28,6 +28,7 @@
> #include <gdbus.h>
>
> #include "ofono.h"
> +#include "plugins/mbpi.h"
Don't do this, see below
>
> static GSList *g_drivers;
>
> @@ -38,6 +39,7 @@ struct ofono_cdma_netreg {
> const struct ofono_cdma_netreg_driver *driver;
> void *driver_data;
> struct ofono_atom *atom;
> + char *provider_name;
> };
>
> static const char *cdma_netreg_status_to_string(enum cdma_netreg_status status)
> @@ -90,6 +92,10 @@ static DBusMessage *network_get_properties(DBusConnection *conn,
> &strength);
> }
>
> + if (cdma_netreg->provider_name)
> + ofono_dbus_dict_append(&dict, "Name", DBUS_TYPE_STRING,
> + &cdma_netreg->provider_name);
> +
You might also want to export the SystemIdentifier property here
> dbus_message_iter_close_container(&iter, &dict);
>
> return reply;
> @@ -108,6 +114,9 @@ static void serving_system_callback(const struct ofono_error *error,
> const char *sid, void *data)
> {
> struct ofono_cdma_netreg *cdma_netreg = data;
> + const char *path = __ofono_atom_get_path(cdma_netreg->atom);
> + DBusConnection *conn = ofono_dbus_get_connection();
> + GError *err = NULL;
>
> if (cdma_netreg->status != CDMA_NETWORK_REGISTRATION_STATUS_REGISTERED
> && cdma_netreg->status !=
> @@ -120,6 +129,20 @@ static void serving_system_callback(const struct ofono_error *error,
> }
>
> DBG("Serving system Identifier: %s", sid);
> +
> + g_free(cdma_netreg->provider_name);
> + cdma_netreg->provider_name = NULL;
> + cdma_netreg->provider_name = mbpi_lookup_cdma_provider_name(sid, &err);
Please don't do it this way, this part should be abstracted behind a
provider name lookup plugin, similar to how context provisioning for GSM
is done. Mobile Broadband Provider Info database might not be the only
source of this information, in fact manufacturers might have their own
(better) databases.
> +
> + if (cdma_netreg->provider_name)
> + ofono_dbus_signal_property_changed(conn, path,
> + OFONO_CDMA_NETWORK_REGISTRATION_INTERFACE,
> + "Name", DBUS_TYPE_STRING,
> + &cdma_netreg->provider_name);
> + else if (err != NULL) {
> + ofono_error("%s", err->message);
> + g_error_free(err);
> + }
Are you sure you want to perform the lookup every time? Why don't you
cache the last result and not perform the query if the SID is the same
as the last one obtained. We're highly unlikely to get a different SID
under normal circumstances (e.g. signal loss, etc) so re-querying seems
wasteful.
> }
>
> static void set_registration_status(struct ofono_cdma_netreg *cdma_netreg,
> @@ -136,6 +159,12 @@ static void set_registration_status(struct ofono_cdma_netreg *cdma_netreg,
> "Status", DBUS_TYPE_STRING,
> &str_status);
>
> + if (cdma_netreg->status ==
> + CDMA_NETWORK_REGISTRATION_STATUS_NOT_REGISTERED) {
> + g_free(cdma_netreg->provider_name);
> + cdma_netreg->provider_name = NULL;
See comment above
> + }
> +
> if (cdma_netreg->status == CDMA_NETWORK_REGISTRATION_STATUS_REGISTERED
> || cdma_netreg->status ==
> CDMA_NETWORK_REGISTRATION_STATUS_ROAMING)
> @@ -251,6 +280,7 @@ static void cdma_netreg_remove(struct ofono_atom *atom)
> if (cdma_netreg->driver && cdma_netreg->driver->remove)
> cdma_netreg->driver->remove(cdma_netreg);
>
> + g_free(cdma_netreg->provider_name);
> g_free(cdma_netreg);
> }
>
Regards,
-Denis
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2011-11-24 23:55 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-24 17:46 [PATCH 0/7] Get SID and provider name Philippe Nunes
2011-11-24 17:46 ` [PATCH 1/7] Huaweicdmamodem: remove this specific driver Philippe Nunes
2011-11-24 17:46 ` [PATCH 2/7] huaweicdmamodem: Merge this driver with cdmamodem driver Philippe Nunes
2011-11-24 17:46 ` [PATCH 3/7] cdmamodem: Add CDMA network-registration support Philippe Nunes
2011-11-24 17:46 ` [PATCH 4/7] cdma-netreg: Add 'serving_system' entry point to cdma-netreg to get SID Philippe Nunes
2011-11-24 23:42 ` Denis Kenzior
2011-11-24 17:46 ` [PATCH 5/7] cdmamodem: Add serving system identifier support Philippe Nunes
2011-11-24 17:46 ` [PATCH 6/7] cdma-netreg: Make use of the new driver entry point serving_system Philippe Nunes
2011-11-24 23:51 ` Denis Kenzior
2011-11-24 17:46 ` [PATCH 7/7] cdma-netreg: Add provider name support Philippe Nunes
2011-11-24 23:55 ` Denis Kenzior
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.