All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] huaweimodem: Add support for radio settings
@ 2010-11-30 18:25 Lucas De Marchi
  2010-11-30 18:35 ` Lucas De Marchi
  0 siblings, 1 reply; 6+ messages in thread
From: Lucas De Marchi @ 2010-11-30 18:25 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 7637 bytes --]

From: Marcel Holtmann <marcel.holtmann@intel.com>

---
 Makefile.am                          |    3 +-
 drivers/huaweimodem/huaweimodem.c    |    2 +
 drivers/huaweimodem/huaweimodem.h    |    3 +
 drivers/huaweimodem/radio-settings.c |  212 ++++++++++++++++++++++++++++++++++
 4 files changed, 219 insertions(+), 1 deletions(-)
 create mode 100644 drivers/huaweimodem/radio-settings.c

diff --git a/Makefile.am b/Makefile.am
index a4c47e8..5d39c23 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -180,7 +180,8 @@ builtin_sources += drivers/atmodem/atutil.h \
 			drivers/huaweimodem/huaweimodem.c \
 			drivers/huaweimodem/voicecall.c \
 			drivers/huaweimodem/audio-settings.c \
-			drivers/huaweimodem/gprs-context.c
+			drivers/huaweimodem/gprs-context.c \
+			drivers/huaweimodem/radio-settings.c
 
 builtin_modules += calypsomodem
 builtin_sources += drivers/atmodem/atutil.h \
diff --git a/drivers/huaweimodem/huaweimodem.c b/drivers/huaweimodem/huaweimodem.c
index c8b6522..8097a9c 100644
--- a/drivers/huaweimodem/huaweimodem.c
+++ b/drivers/huaweimodem/huaweimodem.c
@@ -36,6 +36,7 @@ static int huaweimodem_init(void)
 {
 	huawei_voicecall_init();
 	huawei_audio_settings_init();
+	huawei_radio_settings_init();
 	huawei_gprs_context_init();
 
 	return 0;
@@ -44,6 +45,7 @@ static int huaweimodem_init(void)
 static void huaweimodem_exit(void)
 {
 	huawei_gprs_context_exit();
+	huawei_radio_settings_exit();
 	huawei_audio_settings_exit();
 	huawei_voicecall_exit();
 }
diff --git a/drivers/huaweimodem/huaweimodem.h b/drivers/huaweimodem/huaweimodem.h
index 03d52ef..596aa08 100644
--- a/drivers/huaweimodem/huaweimodem.h
+++ b/drivers/huaweimodem/huaweimodem.h
@@ -27,5 +27,8 @@ extern void huawei_voicecall_exit();
 extern void huawei_audio_settings_init();
 extern void huawei_audio_settings_exit();
 
+extern void huawei_radio_settings_init();
+extern void huawei_radio_settings_exit();
+
 extern void huawei_gprs_context_init();
 extern void huawei_gprs_context_exit();
diff --git a/drivers/huaweimodem/radio-settings.c b/drivers/huaweimodem/radio-settings.c
new file mode 100644
index 0000000..7f0b223
--- /dev/null
+++ b/drivers/huaweimodem/radio-settings.c
@@ -0,0 +1,212 @@
+/*
+ *
+ *  oFono - Open Source Telephony
+ *
+ *  Copyright (C) 2010  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 <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <errno.h>
+
+#include <glib.h>
+
+#include <ofono/log.h>
+#include <ofono/modem.h>
+#include <ofono/radio-settings.h>
+
+#include "gatchat.h"
+#include "gatresult.h"
+
+#include "huaweimodem.h"
+
+static const char *none_prefix[] = { NULL };
+static const char *xrat_prefix[] = { "^SYSCFG:", NULL };
+
+struct radio_settings_data {
+	GAtChat *chat;
+};
+
+static void xrat_query_cb(gboolean ok, GAtResult *result, gpointer user_data)
+{
+	struct cb_data *cbd = user_data;
+	ofono_radio_settings_rat_mode_query_cb_t cb = cbd->cb;
+	enum ofono_radio_access_mode mode;
+	struct ofono_error error;
+	GAtResultIter iter;
+	int value;
+
+	decode_at_error(&error, g_at_result_final_response(result));
+
+	if (!ok) {
+		cb(&error, -1, cbd->data);
+		return;
+	}
+
+	g_at_result_iter_init(&iter, result);
+
+	if (g_at_result_iter_next(&iter, "^SYSCFG:") == FALSE)
+		goto error;
+
+	if (g_at_result_iter_next_number(&iter, &value) == FALSE)
+		goto error;
+
+	switch (value) {
+	case 2:
+		mode = OFONO_RADIO_ACCESS_MODE_ANY;
+		break;
+	case 13:
+		mode = OFONO_RADIO_ACCESS_MODE_GSM;
+		break;
+	case 14:
+		mode = OFONO_RADIO_ACCESS_MODE_UMTS;
+		break;
+	default:
+		CALLBACK_WITH_FAILURE(cb, -1, cbd->data);
+		return;
+	}
+
+	cb(&error, mode, cbd->data);
+
+	return;
+
+error:
+	CALLBACK_WITH_FAILURE(cb, -1, cbd->data);
+}
+
+static void huawei_query_rat_mode(struct ofono_radio_settings *rs,
+				ofono_radio_settings_rat_mode_query_cb_t cb,
+				void *data)
+{
+	struct radio_settings_data *rsd = ofono_radio_settings_get_data(rs);
+	struct cb_data *cbd = cb_data_new(cb, data);
+
+	if (g_at_chat_send(rsd->chat, "AT^SYSCFG?", xrat_prefix,
+					xrat_query_cb, cbd, g_free) == 0) {
+		CALLBACK_WITH_FAILURE(cb, -1, data);
+		g_free(cbd);
+	}
+}
+
+static void xrat_modify_cb(gboolean ok, GAtResult *result, gpointer user_data)
+{
+	struct cb_data *cbd = user_data;
+	ofono_radio_settings_rat_mode_set_cb_t cb = cbd->cb;
+	struct ofono_error error;
+
+	decode_at_error(&error, g_at_result_final_response(result));
+	cb(&error, cbd->data);
+}
+
+static void huawei_set_rat_mode(struct ofono_radio_settings *rs,
+				enum ofono_radio_access_mode mode,
+				ofono_radio_settings_rat_mode_set_cb_t cb,
+				void *data)
+{
+	struct radio_settings_data *rsd = ofono_radio_settings_get_data(rs);
+	struct cb_data *cbd = cb_data_new(cb, data);
+	char buf[40];
+	int value = 2;
+
+	switch (mode) {
+	case OFONO_RADIO_ACCESS_MODE_ANY:
+		value = 2;
+		break;
+	case OFONO_RADIO_ACCESS_MODE_GSM:
+		value = 13;
+		break;
+	case OFONO_RADIO_ACCESS_MODE_UMTS:
+		value = 14;
+		break;
+	case OFONO_RADIO_ACCESS_MODE_LTE:
+		goto error;
+	}
+
+	snprintf(buf, sizeof(buf), "AT^SYSCFG=%u,0,3FFFFFFF,2,4", value);
+
+	if (g_at_chat_send(rsd->chat, buf, none_prefix,
+					xrat_modify_cb, cbd, g_free) > 0)
+		return;
+
+error:
+	CALLBACK_WITH_FAILURE(cb, data);
+	g_free(cbd);
+}
+
+static void xrat_support_cb(gboolean ok, GAtResult *result, gpointer user_data)
+{
+	struct ofono_radio_settings *rs = user_data;
+
+	if (!ok)
+		return;
+
+	ofono_radio_settings_register(rs);
+}
+
+static int huawei_radio_settings_probe(struct ofono_radio_settings *rs,
+					unsigned int vendor, void *data)
+{
+	GAtChat *chat = data;
+	struct radio_settings_data *rsd;
+
+	rsd = g_try_new0(struct radio_settings_data, 1);
+	if (rsd == NULL)
+		return -ENOMEM;
+
+	rsd->chat = g_at_chat_clone(chat);
+
+	ofono_radio_settings_set_data(rs, rsd);
+
+	g_at_chat_send(rsd->chat, "AT^SYSCFG=?", xrat_prefix,
+					xrat_support_cb, rs, NULL);
+
+	return 0;
+}
+
+static void huawei_radio_settings_remove(struct ofono_radio_settings *rs)
+{
+	struct radio_settings_data *rsd = ofono_radio_settings_get_data(rs);
+
+	ofono_radio_settings_set_data(rs, NULL);
+
+	g_at_chat_unref(rsd->chat);
+	g_free(rsd);
+}
+
+static struct ofono_radio_settings_driver driver = {
+	.name			= "huaweimodem",
+	.probe			= huawei_radio_settings_probe,
+	.remove			= huawei_radio_settings_remove,
+	.query_rat_mode		= huawei_query_rat_mode,
+	.set_rat_mode		= huawei_set_rat_mode
+};
+
+void huawei_radio_settings_init()
+{
+	ofono_radio_settings_driver_register(&driver);
+}
+
+void huawei_radio_settings_exit()
+{
+	ofono_radio_settings_driver_unregister(&driver);
+}
-- 
1.7.3.2


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/2] huaweimodem: Add support for radio settings
  2010-11-30 18:25 Lucas De Marchi
@ 2010-11-30 18:35 ` Lucas De Marchi
  0 siblings, 0 replies; 6+ messages in thread
From: Lucas De Marchi @ 2010-11-30 18:35 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 2173 bytes --]

On Tue, Nov 30, 2010 at 4:25 PM, Lucas De Marchi
<lucas.demarchi@profusion.mobi> wrote:
> diff --git a/drivers/huaweimodem/radio-settings.c b/drivers/huaweimodem/radio-settings.c
> new file mode 100644
> index 0000000..7f0b223
> --- /dev/null
> +++ b/drivers/huaweimodem/radio-settings.c
> @@ -0,0 +1,212 @@
> +/*
> + *
> + *  oFono - Open Source Telephony
> + *
> + *  Copyright (C) 2010  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 <string.h>
> +#include <stdlib.h>
> +#include <stdio.h>
> +#include <errno.h>
> +
> +#include <glib.h>
> +
> +#include <ofono/log.h>
> +#include <ofono/modem.h>
> +#include <ofono/radio-settings.h>
> +
> +#include "gatchat.h"
> +#include "gatresult.h"
> +
> +#include "huaweimodem.h"
> +
> +static const char *none_prefix[] = { NULL };
> +static const char *xrat_prefix[] = { "^SYSCFG:", NULL };
> +
> +struct radio_settings_data {
> +       GAtChat *chat;
> +};

I left chat inside a radio_settings_data struct because I plan to
extend it in a follow up patch, when this one is accepted and I finish
my tests with Frequency Band Selection.


Marcel, sorry... I've made a "git commit -c" in one commit of yours
(to re-use the commit message), so this actually came with your name.

I'll send again this patch



regards,

Lucas De Marchi

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/2] huaweimodem: Add support for radio settings
@ 2010-11-30 18:41 Lucas De Marchi
  2010-11-30 18:41 ` [PATCH 2/2] huawei: " Lucas De Marchi
  2010-12-08 16:17 ` [PATCH 1/2] huaweimodem: " Denis Kenzior
  0 siblings, 2 replies; 6+ messages in thread
From: Lucas De Marchi @ 2010-11-30 18:41 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 7584 bytes --]

---
 Makefile.am                          |    3 +-
 drivers/huaweimodem/huaweimodem.c    |    2 +
 drivers/huaweimodem/huaweimodem.h    |    3 +
 drivers/huaweimodem/radio-settings.c |  212 ++++++++++++++++++++++++++++++++++
 4 files changed, 219 insertions(+), 1 deletions(-)
 create mode 100644 drivers/huaweimodem/radio-settings.c

diff --git a/Makefile.am b/Makefile.am
index a4c47e8..5d39c23 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -180,7 +180,8 @@ builtin_sources += drivers/atmodem/atutil.h \
 			drivers/huaweimodem/huaweimodem.c \
 			drivers/huaweimodem/voicecall.c \
 			drivers/huaweimodem/audio-settings.c \
-			drivers/huaweimodem/gprs-context.c
+			drivers/huaweimodem/gprs-context.c \
+			drivers/huaweimodem/radio-settings.c
 
 builtin_modules += calypsomodem
 builtin_sources += drivers/atmodem/atutil.h \
diff --git a/drivers/huaweimodem/huaweimodem.c b/drivers/huaweimodem/huaweimodem.c
index c8b6522..8097a9c 100644
--- a/drivers/huaweimodem/huaweimodem.c
+++ b/drivers/huaweimodem/huaweimodem.c
@@ -36,6 +36,7 @@ static int huaweimodem_init(void)
 {
 	huawei_voicecall_init();
 	huawei_audio_settings_init();
+	huawei_radio_settings_init();
 	huawei_gprs_context_init();
 
 	return 0;
@@ -44,6 +45,7 @@ static int huaweimodem_init(void)
 static void huaweimodem_exit(void)
 {
 	huawei_gprs_context_exit();
+	huawei_radio_settings_exit();
 	huawei_audio_settings_exit();
 	huawei_voicecall_exit();
 }
diff --git a/drivers/huaweimodem/huaweimodem.h b/drivers/huaweimodem/huaweimodem.h
index 03d52ef..596aa08 100644
--- a/drivers/huaweimodem/huaweimodem.h
+++ b/drivers/huaweimodem/huaweimodem.h
@@ -27,5 +27,8 @@ extern void huawei_voicecall_exit();
 extern void huawei_audio_settings_init();
 extern void huawei_audio_settings_exit();
 
+extern void huawei_radio_settings_init();
+extern void huawei_radio_settings_exit();
+
 extern void huawei_gprs_context_init();
 extern void huawei_gprs_context_exit();
diff --git a/drivers/huaweimodem/radio-settings.c b/drivers/huaweimodem/radio-settings.c
new file mode 100644
index 0000000..7f0b223
--- /dev/null
+++ b/drivers/huaweimodem/radio-settings.c
@@ -0,0 +1,212 @@
+/*
+ *
+ *  oFono - Open Source Telephony
+ *
+ *  Copyright (C) 2010  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 <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <errno.h>
+
+#include <glib.h>
+
+#include <ofono/log.h>
+#include <ofono/modem.h>
+#include <ofono/radio-settings.h>
+
+#include "gatchat.h"
+#include "gatresult.h"
+
+#include "huaweimodem.h"
+
+static const char *none_prefix[] = { NULL };
+static const char *xrat_prefix[] = { "^SYSCFG:", NULL };
+
+struct radio_settings_data {
+	GAtChat *chat;
+};
+
+static void xrat_query_cb(gboolean ok, GAtResult *result, gpointer user_data)
+{
+	struct cb_data *cbd = user_data;
+	ofono_radio_settings_rat_mode_query_cb_t cb = cbd->cb;
+	enum ofono_radio_access_mode mode;
+	struct ofono_error error;
+	GAtResultIter iter;
+	int value;
+
+	decode_at_error(&error, g_at_result_final_response(result));
+
+	if (!ok) {
+		cb(&error, -1, cbd->data);
+		return;
+	}
+
+	g_at_result_iter_init(&iter, result);
+
+	if (g_at_result_iter_next(&iter, "^SYSCFG:") == FALSE)
+		goto error;
+
+	if (g_at_result_iter_next_number(&iter, &value) == FALSE)
+		goto error;
+
+	switch (value) {
+	case 2:
+		mode = OFONO_RADIO_ACCESS_MODE_ANY;
+		break;
+	case 13:
+		mode = OFONO_RADIO_ACCESS_MODE_GSM;
+		break;
+	case 14:
+		mode = OFONO_RADIO_ACCESS_MODE_UMTS;
+		break;
+	default:
+		CALLBACK_WITH_FAILURE(cb, -1, cbd->data);
+		return;
+	}
+
+	cb(&error, mode, cbd->data);
+
+	return;
+
+error:
+	CALLBACK_WITH_FAILURE(cb, -1, cbd->data);
+}
+
+static void huawei_query_rat_mode(struct ofono_radio_settings *rs,
+				ofono_radio_settings_rat_mode_query_cb_t cb,
+				void *data)
+{
+	struct radio_settings_data *rsd = ofono_radio_settings_get_data(rs);
+	struct cb_data *cbd = cb_data_new(cb, data);
+
+	if (g_at_chat_send(rsd->chat, "AT^SYSCFG?", xrat_prefix,
+					xrat_query_cb, cbd, g_free) == 0) {
+		CALLBACK_WITH_FAILURE(cb, -1, data);
+		g_free(cbd);
+	}
+}
+
+static void xrat_modify_cb(gboolean ok, GAtResult *result, gpointer user_data)
+{
+	struct cb_data *cbd = user_data;
+	ofono_radio_settings_rat_mode_set_cb_t cb = cbd->cb;
+	struct ofono_error error;
+
+	decode_at_error(&error, g_at_result_final_response(result));
+	cb(&error, cbd->data);
+}
+
+static void huawei_set_rat_mode(struct ofono_radio_settings *rs,
+				enum ofono_radio_access_mode mode,
+				ofono_radio_settings_rat_mode_set_cb_t cb,
+				void *data)
+{
+	struct radio_settings_data *rsd = ofono_radio_settings_get_data(rs);
+	struct cb_data *cbd = cb_data_new(cb, data);
+	char buf[40];
+	int value = 2;
+
+	switch (mode) {
+	case OFONO_RADIO_ACCESS_MODE_ANY:
+		value = 2;
+		break;
+	case OFONO_RADIO_ACCESS_MODE_GSM:
+		value = 13;
+		break;
+	case OFONO_RADIO_ACCESS_MODE_UMTS:
+		value = 14;
+		break;
+	case OFONO_RADIO_ACCESS_MODE_LTE:
+		goto error;
+	}
+
+	snprintf(buf, sizeof(buf), "AT^SYSCFG=%u,0,3FFFFFFF,2,4", value);
+
+	if (g_at_chat_send(rsd->chat, buf, none_prefix,
+					xrat_modify_cb, cbd, g_free) > 0)
+		return;
+
+error:
+	CALLBACK_WITH_FAILURE(cb, data);
+	g_free(cbd);
+}
+
+static void xrat_support_cb(gboolean ok, GAtResult *result, gpointer user_data)
+{
+	struct ofono_radio_settings *rs = user_data;
+
+	if (!ok)
+		return;
+
+	ofono_radio_settings_register(rs);
+}
+
+static int huawei_radio_settings_probe(struct ofono_radio_settings *rs,
+					unsigned int vendor, void *data)
+{
+	GAtChat *chat = data;
+	struct radio_settings_data *rsd;
+
+	rsd = g_try_new0(struct radio_settings_data, 1);
+	if (rsd == NULL)
+		return -ENOMEM;
+
+	rsd->chat = g_at_chat_clone(chat);
+
+	ofono_radio_settings_set_data(rs, rsd);
+
+	g_at_chat_send(rsd->chat, "AT^SYSCFG=?", xrat_prefix,
+					xrat_support_cb, rs, NULL);
+
+	return 0;
+}
+
+static void huawei_radio_settings_remove(struct ofono_radio_settings *rs)
+{
+	struct radio_settings_data *rsd = ofono_radio_settings_get_data(rs);
+
+	ofono_radio_settings_set_data(rs, NULL);
+
+	g_at_chat_unref(rsd->chat);
+	g_free(rsd);
+}
+
+static struct ofono_radio_settings_driver driver = {
+	.name			= "huaweimodem",
+	.probe			= huawei_radio_settings_probe,
+	.remove			= huawei_radio_settings_remove,
+	.query_rat_mode		= huawei_query_rat_mode,
+	.set_rat_mode		= huawei_set_rat_mode
+};
+
+void huawei_radio_settings_init()
+{
+	ofono_radio_settings_driver_register(&driver);
+}
+
+void huawei_radio_settings_exit()
+{
+	ofono_radio_settings_driver_unregister(&driver);
+}
-- 
1.7.3.2


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/2] huawei: Add support for radio settings
  2010-11-30 18:41 [PATCH 1/2] huaweimodem: Add support for radio settings Lucas De Marchi
@ 2010-11-30 18:41 ` Lucas De Marchi
  2010-12-08 16:17 ` [PATCH 1/2] huaweimodem: " Denis Kenzior
  1 sibling, 0 replies; 6+ messages in thread
From: Lucas De Marchi @ 2010-11-30 18:41 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 933 bytes --]

---
 plugins/huawei.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/plugins/huawei.c b/plugins/huawei.c
index 25dfaca..3c58c7f 100644
--- a/plugins/huawei.c
+++ b/plugins/huawei.c
@@ -43,6 +43,7 @@
 #include <ofono/gprs.h>
 #include <ofono/gprs-context.h>
 #include <ofono/audio-settings.h>
+#include <ofono/radio-settings.h>
 #include <ofono/voicecall.h>
 #include <ofono/call-forwarding.h>
 #include <ofono/call-settings.h>
@@ -629,6 +630,9 @@ static void huawei_post_online(struct ofono_modem *modem)
 	ofono_ussd_create(modem, OFONO_VENDOR_QUALCOMM_MSM,
 						"atmodem", data->pcui);
 
+	ofono_radio_settings_create(modem, OFONO_VENDOR_HUAWEI, "huaweimodem",
+								data->pcui);
+
 	if (data->sim_state == HUAWEI_SIM_STATE_VALID ||
 			data->sim_state == HUAWEI_SIM_STATE_INVALID_CS) {
 		data->gprs = ofono_gprs_create(modem, 0, "atmodem", data->pcui);
-- 
1.7.3.2


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/2] huaweimodem: Add support for radio settings
  2010-11-30 18:41 [PATCH 1/2] huaweimodem: Add support for radio settings Lucas De Marchi
  2010-11-30 18:41 ` [PATCH 2/2] huawei: " Lucas De Marchi
@ 2010-12-08 16:17 ` Denis Kenzior
  2010-12-08 17:12   ` Lucas De Marchi
  1 sibling, 1 reply; 6+ messages in thread
From: Denis Kenzior @ 2010-12-08 16:17 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 8452 bytes --]

Hi Lucas,

On 11/30/2010 12:41 PM, Lucas De Marchi wrote:
> ---
>  Makefile.am                          |    3 +-
>  drivers/huaweimodem/huaweimodem.c    |    2 +
>  drivers/huaweimodem/huaweimodem.h    |    3 +
>  drivers/huaweimodem/radio-settings.c |  212 ++++++++++++++++++++++++++++++++++
>  4 files changed, 219 insertions(+), 1 deletions(-)
>  create mode 100644 drivers/huaweimodem/radio-settings.c
> 
> diff --git a/Makefile.am b/Makefile.am
> index a4c47e8..5d39c23 100644
> --- a/Makefile.am
> +++ b/Makefile.am
> @@ -180,7 +180,8 @@ builtin_sources += drivers/atmodem/atutil.h \
>  			drivers/huaweimodem/huaweimodem.c \
>  			drivers/huaweimodem/voicecall.c \
>  			drivers/huaweimodem/audio-settings.c \
> -			drivers/huaweimodem/gprs-context.c
> +			drivers/huaweimodem/gprs-context.c \
> +			drivers/huaweimodem/radio-settings.c
>  
>  builtin_modules += calypsomodem
>  builtin_sources += drivers/atmodem/atutil.h \
> diff --git a/drivers/huaweimodem/huaweimodem.c b/drivers/huaweimodem/huaweimodem.c
> index c8b6522..8097a9c 100644
> --- a/drivers/huaweimodem/huaweimodem.c
> +++ b/drivers/huaweimodem/huaweimodem.c
> @@ -36,6 +36,7 @@ static int huaweimodem_init(void)
>  {
>  	huawei_voicecall_init();
>  	huawei_audio_settings_init();
> +	huawei_radio_settings_init();
>  	huawei_gprs_context_init();
>  
>  	return 0;
> @@ -44,6 +45,7 @@ static int huaweimodem_init(void)
>  static void huaweimodem_exit(void)
>  {
>  	huawei_gprs_context_exit();
> +	huawei_radio_settings_exit();
>  	huawei_audio_settings_exit();
>  	huawei_voicecall_exit();
>  }
> diff --git a/drivers/huaweimodem/huaweimodem.h b/drivers/huaweimodem/huaweimodem.h
> index 03d52ef..596aa08 100644
> --- a/drivers/huaweimodem/huaweimodem.h
> +++ b/drivers/huaweimodem/huaweimodem.h
> @@ -27,5 +27,8 @@ extern void huawei_voicecall_exit();
>  extern void huawei_audio_settings_init();
>  extern void huawei_audio_settings_exit();
>  
> +extern void huawei_radio_settings_init();
> +extern void huawei_radio_settings_exit();
> +
>  extern void huawei_gprs_context_init();
>  extern void huawei_gprs_context_exit();
> diff --git a/drivers/huaweimodem/radio-settings.c b/drivers/huaweimodem/radio-settings.c
> new file mode 100644
> index 0000000..7f0b223
> --- /dev/null
> +++ b/drivers/huaweimodem/radio-settings.c
> @@ -0,0 +1,212 @@
> +/*
> + *
> + *  oFono - Open Source Telephony
> + *
> + *  Copyright (C) 2010  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 <string.h>
> +#include <stdlib.h>
> +#include <stdio.h>
> +#include <errno.h>
> +
> +#include <glib.h>
> +
> +#include <ofono/log.h>
> +#include <ofono/modem.h>
> +#include <ofono/radio-settings.h>
> +
> +#include "gatchat.h"
> +#include "gatresult.h"
> +
> +#include "huaweimodem.h"
> +
> +static const char *none_prefix[] = { NULL };
> +static const char *xrat_prefix[] = { "^SYSCFG:", NULL };
> +
> +struct radio_settings_data {
> +	GAtChat *chat;
> +};
> +
> +static void xrat_query_cb(gboolean ok, GAtResult *result, gpointer user_data)

Why is this named xrat query?

> +{
> +	struct cb_data *cbd = user_data;
> +	ofono_radio_settings_rat_mode_query_cb_t cb = cbd->cb;
> +	enum ofono_radio_access_mode mode;
> +	struct ofono_error error;
> +	GAtResultIter iter;
> +	int value;
> +
> +	decode_at_error(&error, g_at_result_final_response(result));
> +
> +	if (!ok) {
> +		cb(&error, -1, cbd->data);
> +		return;
> +	}
> +
> +	g_at_result_iter_init(&iter, result);
> +
> +	if (g_at_result_iter_next(&iter, "^SYSCFG:") == FALSE)
> +		goto error;
> +
> +	if (g_at_result_iter_next_number(&iter, &value) == FALSE)
> +		goto error;
> +
> +	switch (value) {
> +	case 2:
> +		mode = OFONO_RADIO_ACCESS_MODE_ANY;
> +		break;
> +	case 13:
> +		mode = OFONO_RADIO_ACCESS_MODE_GSM;
> +		break;
> +	case 14:
> +		mode = OFONO_RADIO_ACCESS_MODE_UMTS;
> +		break;
> +	default:
> +		CALLBACK_WITH_FAILURE(cb, -1, cbd->data);
> +		return;
> +	}
> +
> +	cb(&error, mode, cbd->data);
> +
> +	return;
> +
> +error:
> +	CALLBACK_WITH_FAILURE(cb, -1, cbd->data);
> +}
> +
> +static void huawei_query_rat_mode(struct ofono_radio_settings *rs,
> +				ofono_radio_settings_rat_mode_query_cb_t cb,
> +				void *data)
> +{
> +	struct radio_settings_data *rsd = ofono_radio_settings_get_data(rs);
> +	struct cb_data *cbd = cb_data_new(cb, data);
> +
> +	if (g_at_chat_send(rsd->chat, "AT^SYSCFG?", xrat_prefix,
> +					xrat_query_cb, cbd, g_free) == 0) {

And xrat_query here too?

> +		CALLBACK_WITH_FAILURE(cb, -1, data);
> +		g_free(cbd);
> +	}
> +}
> +
> +static void xrat_modify_cb(gboolean ok, GAtResult *result, gpointer user_data)

xrat_modify?

> +{
> +	struct cb_data *cbd = user_data;
> +	ofono_radio_settings_rat_mode_set_cb_t cb = cbd->cb;
> +	struct ofono_error error;
> +
> +	decode_at_error(&error, g_at_result_final_response(result));
> +	cb(&error, cbd->data);
> +}
> +
> +static void huawei_set_rat_mode(struct ofono_radio_settings *rs,
> +				enum ofono_radio_access_mode mode,
> +				ofono_radio_settings_rat_mode_set_cb_t cb,
> +				void *data)
> +{
> +	struct radio_settings_data *rsd = ofono_radio_settings_get_data(rs);
> +	struct cb_data *cbd = cb_data_new(cb, data);
> +	char buf[40];
> +	int value = 2;
> +
> +	switch (mode) {
> +	case OFONO_RADIO_ACCESS_MODE_ANY:
> +		value = 2;
> +		break;
> +	case OFONO_RADIO_ACCESS_MODE_GSM:
> +		value = 13;
> +		break;
> +	case OFONO_RADIO_ACCESS_MODE_UMTS:
> +		value = 14;
> +		break;
> +	case OFONO_RADIO_ACCESS_MODE_LTE:
> +		goto error;
> +	}
> +
> +	snprintf(buf, sizeof(buf), "AT^SYSCFG=%u,0,3FFFFFFF,2,4", value);

These values don't seem to be correct.  At least not after taking a peek
at some of our competitors ;)

> +
> +	if (g_at_chat_send(rsd->chat, buf, none_prefix,
> +					xrat_modify_cb, cbd, g_free) > 0)

xrat_modify again here

> +		return;
> +
> +error:
> +	CALLBACK_WITH_FAILURE(cb, data);
> +	g_free(cbd);
> +}
> +
> +static void xrat_support_cb(gboolean ok, GAtResult *result, gpointer user_data)
> +{

xrat_support?

> +	struct ofono_radio_settings *rs = user_data;
> +
> +	if (!ok)
> +		return;
> +
> +	ofono_radio_settings_register(rs);
> +}
> +
> +static int huawei_radio_settings_probe(struct ofono_radio_settings *rs,
> +					unsigned int vendor, void *data)
> +{
> +	GAtChat *chat = data;
> +	struct radio_settings_data *rsd;
> +
> +	rsd = g_try_new0(struct radio_settings_data, 1);
> +	if (rsd == NULL)
> +		return -ENOMEM;
> +
> +	rsd->chat = g_at_chat_clone(chat);
> +
> +	ofono_radio_settings_set_data(rs, rsd);
> +
> +	g_at_chat_send(rsd->chat, "AT^SYSCFG=?", xrat_prefix,

xrat_prefix?

> +					xrat_support_cb, rs, NULL);
> +
> +	return 0;
> +}
> +
> +static void huawei_radio_settings_remove(struct ofono_radio_settings *rs)
> +{
> +	struct radio_settings_data *rsd = ofono_radio_settings_get_data(rs);
> +
> +	ofono_radio_settings_set_data(rs, NULL);
> +
> +	g_at_chat_unref(rsd->chat);
> +	g_free(rsd);
> +}
> +
> +static struct ofono_radio_settings_driver driver = {
> +	.name			= "huaweimodem",
> +	.probe			= huawei_radio_settings_probe,
> +	.remove			= huawei_radio_settings_remove,
> +	.query_rat_mode		= huawei_query_rat_mode,
> +	.set_rat_mode		= huawei_set_rat_mode
> +};
> +
> +void huawei_radio_settings_init()
> +{
> +	ofono_radio_settings_driver_register(&driver);
> +}
> +
> +void huawei_radio_settings_exit()
> +{
> +	ofono_radio_settings_driver_unregister(&driver);
> +}

Regards,
-Denis

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/2] huaweimodem: Add support for radio settings
  2010-12-08 16:17 ` [PATCH 1/2] huaweimodem: " Denis Kenzior
@ 2010-12-08 17:12   ` Lucas De Marchi
  0 siblings, 0 replies; 6+ messages in thread
From: Lucas De Marchi @ 2010-12-08 17:12 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 8734 bytes --]

On Wed, Dec 8, 2010 at 2:17 PM, Denis Kenzior <denkenz@gmail.com> wrote:
> Hi Lucas,
>
> On 11/30/2010 12:41 PM, Lucas De Marchi wrote:
>> ---
>>  Makefile.am                          |    3 +-
>>  drivers/huaweimodem/huaweimodem.c    |    2 +
>>  drivers/huaweimodem/huaweimodem.h    |    3 +
>>  drivers/huaweimodem/radio-settings.c |  212 ++++++++++++++++++++++++++++++++++
>>  4 files changed, 219 insertions(+), 1 deletions(-)
>>  create mode 100644 drivers/huaweimodem/radio-settings.c
>>
>> diff --git a/Makefile.am b/Makefile.am
>> index a4c47e8..5d39c23 100644
>> --- a/Makefile.am
>> +++ b/Makefile.am
>> @@ -180,7 +180,8 @@ builtin_sources += drivers/atmodem/atutil.h \
>>                       drivers/huaweimodem/huaweimodem.c \
>>                       drivers/huaweimodem/voicecall.c \
>>                       drivers/huaweimodem/audio-settings.c \
>> -                     drivers/huaweimodem/gprs-context.c
>> +                     drivers/huaweimodem/gprs-context.c \
>> +                     drivers/huaweimodem/radio-settings.c
>>
>>  builtin_modules += calypsomodem
>>  builtin_sources += drivers/atmodem/atutil.h \
>> diff --git a/drivers/huaweimodem/huaweimodem.c b/drivers/huaweimodem/huaweimodem.c
>> index c8b6522..8097a9c 100644
>> --- a/drivers/huaweimodem/huaweimodem.c
>> +++ b/drivers/huaweimodem/huaweimodem.c
>> @@ -36,6 +36,7 @@ static int huaweimodem_init(void)
>>  {
>>       huawei_voicecall_init();
>>       huawei_audio_settings_init();
>> +     huawei_radio_settings_init();
>>       huawei_gprs_context_init();
>>
>>       return 0;
>> @@ -44,6 +45,7 @@ static int huaweimodem_init(void)
>>  static void huaweimodem_exit(void)
>>  {
>>       huawei_gprs_context_exit();
>> +     huawei_radio_settings_exit();
>>       huawei_audio_settings_exit();
>>       huawei_voicecall_exit();
>>  }
>> diff --git a/drivers/huaweimodem/huaweimodem.h b/drivers/huaweimodem/huaweimodem.h
>> index 03d52ef..596aa08 100644
>> --- a/drivers/huaweimodem/huaweimodem.h
>> +++ b/drivers/huaweimodem/huaweimodem.h
>> @@ -27,5 +27,8 @@ extern void huawei_voicecall_exit();
>>  extern void huawei_audio_settings_init();
>>  extern void huawei_audio_settings_exit();
>>
>> +extern void huawei_radio_settings_init();
>> +extern void huawei_radio_settings_exit();
>> +
>>  extern void huawei_gprs_context_init();
>>  extern void huawei_gprs_context_exit();
>> diff --git a/drivers/huaweimodem/radio-settings.c b/drivers/huaweimodem/radio-settings.c
>> new file mode 100644
>> index 0000000..7f0b223
>> --- /dev/null
>> +++ b/drivers/huaweimodem/radio-settings.c
>> @@ -0,0 +1,212 @@
>> +/*
>> + *
>> + *  oFono - Open Source Telephony
>> + *
>> + *  Copyright (C) 2010  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 <string.h>
>> +#include <stdlib.h>
>> +#include <stdio.h>
>> +#include <errno.h>
>> +
>> +#include <glib.h>
>> +
>> +#include <ofono/log.h>
>> +#include <ofono/modem.h>
>> +#include <ofono/radio-settings.h>
>> +
>> +#include "gatchat.h"
>> +#include "gatresult.h"
>> +
>> +#include "huaweimodem.h"
>> +
>> +static const char *none_prefix[] = { NULL };
>> +static const char *xrat_prefix[] = { "^SYSCFG:", NULL };
>> +
>> +struct radio_settings_data {
>> +     GAtChat *chat;
>> +};
>> +
>> +static void xrat_query_cb(gboolean ok, GAtResult *result, gpointer user_data)
>
> Why is this named xrat query?

Looking at ifxmodem, I thought the prefix had something to do with
radio technology (please don't ask me why the "x" in front of "rat"
:-) )

As I told through IRC, I'm changing it to syscfg, as this is actually
the command name


>> +{
>> +     struct cb_data *cbd = user_data;
>> +     ofono_radio_settings_rat_mode_query_cb_t cb = cbd->cb;
>> +     enum ofono_radio_access_mode mode;
>> +     struct ofono_error error;
>> +     GAtResultIter iter;
>> +     int value;
>> +
>> +     decode_at_error(&error, g_at_result_final_response(result));
>> +
>> +     if (!ok) {
>> +             cb(&error, -1, cbd->data);
>> +             return;
>> +     }
>> +
>> +     g_at_result_iter_init(&iter, result);
>> +
>> +     if (g_at_result_iter_next(&iter, "^SYSCFG:") == FALSE)
>> +             goto error;
>> +
>> +     if (g_at_result_iter_next_number(&iter, &value) == FALSE)
>> +             goto error;
>> +
>> +     switch (value) {
>> +     case 2:
>> +             mode = OFONO_RADIO_ACCESS_MODE_ANY;
>> +             break;
>> +     case 13:
>> +             mode = OFONO_RADIO_ACCESS_MODE_GSM;
>> +             break;
>> +     case 14:
>> +             mode = OFONO_RADIO_ACCESS_MODE_UMTS;
>> +             break;
>> +     default:
>> +             CALLBACK_WITH_FAILURE(cb, -1, cbd->data);
>> +             return;
>> +     }
>> +
>> +     cb(&error, mode, cbd->data);
>> +
>> +     return;
>> +
>> +error:
>> +     CALLBACK_WITH_FAILURE(cb, -1, cbd->data);
>> +}
>> +
>> +static void huawei_query_rat_mode(struct ofono_radio_settings *rs,
>> +                             ofono_radio_settings_rat_mode_query_cb_t cb,
>> +                             void *data)
>> +{
>> +     struct radio_settings_data *rsd = ofono_radio_settings_get_data(rs);
>> +     struct cb_data *cbd = cb_data_new(cb, data);
>> +
>> +     if (g_at_chat_send(rsd->chat, "AT^SYSCFG?", xrat_prefix,
>> +                                     xrat_query_cb, cbd, g_free) == 0) {
>
> And xrat_query here too?
>
>> +             CALLBACK_WITH_FAILURE(cb, -1, data);
>> +             g_free(cbd);
>> +     }
>> +}
>> +
>> +static void xrat_modify_cb(gboolean ok, GAtResult *result, gpointer user_data)
>
> xrat_modify?
>
>> +{
>> +     struct cb_data *cbd = user_data;
>> +     ofono_radio_settings_rat_mode_set_cb_t cb = cbd->cb;
>> +     struct ofono_error error;
>> +
>> +     decode_at_error(&error, g_at_result_final_response(result));
>> +     cb(&error, cbd->data);
>> +}
>> +
>> +static void huawei_set_rat_mode(struct ofono_radio_settings *rs,
>> +                             enum ofono_radio_access_mode mode,
>> +                             ofono_radio_settings_rat_mode_set_cb_t cb,
>> +                             void *data)
>> +{
>> +     struct radio_settings_data *rsd = ofono_radio_settings_get_data(rs);
>> +     struct cb_data *cbd = cb_data_new(cb, data);
>> +     char buf[40];
>> +     int value = 2;
>> +
>> +     switch (mode) {
>> +     case OFONO_RADIO_ACCESS_MODE_ANY:
>> +             value = 2;
>> +             break;
>> +     case OFONO_RADIO_ACCESS_MODE_GSM:
>> +             value = 13;
>> +             break;
>> +     case OFONO_RADIO_ACCESS_MODE_UMTS:
>> +             value = 14;
>> +             break;
>> +     case OFONO_RADIO_ACCESS_MODE_LTE:
>> +             goto error;
>> +     }
>> +
>> +     snprintf(buf, sizeof(buf), "AT^SYSCFG=%u,0,3FFFFFFF,2,4", value);
>
> These values don't seem to be correct.  At least not after taking a peek
> at some of our competitors ;)

I don't think so after poking other projects and testing with a huawei
E220. The second parameter for SYSCFG command means the acquire order
(https://wiki.archlinux.org/index.php/3G_and_GPRS_modems_with_pppd_alone),
so it's pointless here even if some other competitors explicitly set
to "gsm first" or "umts first" when setting the mode.


Thanks for reviewing.


regards,

Lucas De Marchi

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2010-12-08 17:12 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-11-30 18:41 [PATCH 1/2] huaweimodem: Add support for radio settings Lucas De Marchi
2010-11-30 18:41 ` [PATCH 2/2] huawei: " Lucas De Marchi
2010-12-08 16:17 ` [PATCH 1/2] huaweimodem: " Denis Kenzior
2010-12-08 17:12   ` Lucas De Marchi
  -- strict thread matches above, loose matches on Subject: below --
2010-11-30 18:25 Lucas De Marchi
2010-11-30 18:35 ` Lucas De Marchi

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.