All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH_v3] huaweicdma: Create first draft for plugin huaweicdma
@ 2011-07-12 11:47 Guillaume Zajac
  2011-07-12 12:06 ` Marcel Holtmann
  0 siblings, 1 reply; 3+ messages in thread
From: Guillaume Zajac @ 2011-07-12 11:47 UTC (permalink / raw)
  To: ofono

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

Changelog from v2:
	- Remove Nokia copyright.
	- Remove cdma voicecall for the moment.
	- Add debug print into post_sim pre_sim.
	- use GSM permissive synthax for the moment.
---
 Makefile.am          |    3 +
 plugins/huaweicdma.c |  182 ++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 185 insertions(+), 0 deletions(-)
 create mode 100644 plugins/huaweicdma.c

diff --git a/Makefile.am b/Makefile.am
index c08e09f..2fa8771 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -294,6 +294,9 @@ builtin_sources += plugins/zte.c
 builtin_modules += huawei
 builtin_sources += plugins/huawei.c
 
+builtin_modules += huaweicdma
+builtin_sources += plugins/huaweicdma.c
+
 builtin_modules += sierra
 builtin_sources += plugins/sierra.c
 
diff --git a/plugins/huaweicdma.c b/plugins/huaweicdma.c
new file mode 100644
index 0000000..3c02e84
--- /dev/null
+++ b/plugins/huaweicdma.c
@@ -0,0 +1,182 @@
+/*
+ * This file is part of 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
+
+#include <stdlib.h>
+#include <errno.h>
+#include <termios.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+
+#include <glib.h>
+#include <gatchat.h>
+#include <gattty.h>
+
+#define OFONO_API_SUBJECT_TO_CHANGE
+#include <ofono/plugin.h>
+#include <ofono/log.h>
+#include <ofono/modem.h>
+
+#include <drivers/atmodem/atutil.h>
+#include <ofono/devinfo.h>
+#include <ofono/cdma-connman.h>
+
+#include "common.h"
+
+struct huaweicdma_data {
+	GAtChat *chat;
+};
+
+static void huaweicdma_debug(const char *str, void *data)
+{
+	const char *prefix = data;
+
+	ofono_info("%s%s", prefix, str);
+}
+
+static int huaweicdma_probe(struct ofono_modem *modem)
+{
+	struct huaweicdma_data *data;
+
+	DBG("%p", modem);
+
+	data = g_try_new0(struct huaweicdma_data, 1);
+	if (data == NULL)
+		return -ENOMEM;
+
+	ofono_modem_set_data(modem, data);
+
+	return 0;
+}
+
+static void huaweicdma_remove(struct ofono_modem *modem)
+{
+	struct huaweicdma_data *data = ofono_modem_get_data(modem);
+
+	DBG("%p", modem);
+
+	ofono_modem_set_data(modem, NULL);
+
+	g_at_chat_unref(data->chat);
+
+	g_free(data);
+}
+
+static int huaweicdma_enable(struct ofono_modem *modem)
+{
+	struct huaweicdma_data *data = ofono_modem_get_data(modem);
+	GAtSyntax *syntax;
+	GIOChannel *channel;
+	const char *device;
+
+	device = ofono_modem_get_string(modem, "Device");
+	if (device == NULL)
+		return -EINVAL;
+
+	channel = g_at_tty_open(device, NULL);
+	if (channel == NULL)
+		return -EIO;
+
+	/*
+	 * TODO: Will need a CDMA AT syntax parser later.
+	 * Using GSM permissive for now.
+	 */
+	syntax = g_at_syntax_new_gsm_permissive();
+
+	data->chat = g_at_chat_new(channel, syntax);
+	g_at_syntax_unref(syntax);
+	g_io_channel_unref(channel);
+
+	if (data->chat == NULL)
+		return -ENOMEM;
+
+	if (getenv("OFONO_AT_DEBUG"))
+		g_at_chat_set_debug(data->chat, huaweicdma_debug,
+					"CDMA Device: ");
+
+	return 0;
+}
+
+static int huaweicdma_disable(struct ofono_modem *modem)
+{
+	struct huaweicdma_data *data = ofono_modem_get_data(modem);
+
+	DBG("%p", modem);
+
+	g_at_chat_unref(data->chat);
+	data->chat = NULL;
+
+	return 0;
+}
+
+static void huaweicdma_pre_sim(struct ofono_modem *modem)
+{
+	struct huaweicdma_data *data = ofono_modem_get_data(modem);
+
+	DBG("%p", modem);
+
+	ofono_devinfo_create(modem, 0, "cdmamodem", data->chat);
+}
+
+static void huaweicdma_post_sim(struct ofono_modem *modem)
+{
+	DBG("%p", modem);
+}
+
+static void huaweicdma_post_online(struct ofono_modem *modem)
+{
+	struct huaweicdma_data *data = ofono_modem_get_data(modem);
+
+	DBG("%p", modem);
+
+	ofono_cdma_connman_create(modem, 0, "cdmamodem", data->chat);
+}
+
+static struct ofono_modem_driver huaweicdma_driver = {
+	.name		= "huaweicdma",
+	.probe		= huaweicdma_probe,
+	.remove		= huaweicdma_remove,
+	.enable		= huaweicdma_enable,
+	.disable	= huaweicdma_disable,
+	.pre_sim	= huaweicdma_pre_sim,
+	.post_sim	= huaweicdma_post_sim,
+	.post_online	= huaweicdma_post_online,
+};
+
+static int huaweicdma_init(void)
+{
+	return ofono_modem_driver_register(&huaweicdma_driver);
+}
+
+static void huaweicdma_exit(void)
+{
+	ofono_modem_driver_unregister(&huaweicdma_driver);
+}
+
+OFONO_PLUGIN_DEFINE(huaweicdma, "Huawei CDMA AT Modem", VERSION,
+			OFONO_PLUGIN_PRIORITY_DEFAULT,
+			huaweicdma_init, huaweicdma_exit)
-- 
1.7.1


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

* Re: [PATCH_v3] huaweicdma: Create first draft for plugin huaweicdma
  2011-07-12 11:47 [PATCH_v3] huaweicdma: Create first draft for plugin huaweicdma Guillaume Zajac
@ 2011-07-12 12:06 ` Marcel Holtmann
  2011-07-12 12:36   ` Guillaume Zajac
  0 siblings, 1 reply; 3+ messages in thread
From: Marcel Holtmann @ 2011-07-12 12:06 UTC (permalink / raw)
  To: ofono

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

Hi Guillaume,

> 	- Remove Nokia copyright.
> 	- Remove cdma voicecall for the moment.
> 	- Add debug print into post_sim pre_sim.
> 	- use GSM permissive synthax for the moment.

the nokiacdma.c was actually the worst example to derive this one from.
I fixed this all up for you now and applied the patch.

> +/*
> + * This file is part of oFono - Open Source Telephony

I missed this part, but all the Nokia copyright headers are wrongly
formatted. They should have been fixed a long time ago.

> +#include <stdlib.h>
> +#include <errno.h>
> +#include <termios.h>
> +#include <string.h>
> +#include <unistd.h>
> +#include <sys/types.h>
> +#include <sys/stat.h>
> +#include <fcntl.h>

This list of includes is useless. Big copy and paste around.

> +#include <glib.h>
> +#include <gatchat.h>
> +#include <gattty.h>
> +
> +#define OFONO_API_SUBJECT_TO_CHANGE
> +#include <ofono/plugin.h>
> +#include <ofono/log.h>
> +#include <ofono/modem.h>
> +
> +#include <drivers/atmodem/atutil.h>
> +#include <ofono/devinfo.h>
> +#include <ofono/cdma-connman.h>
> +
> +#include "common.h"

What is this for?

> +	/*
> +	 * TODO: Will need a CDMA AT syntax parser later.
> +	 * Using GSM permissive for now.
> +	 */
> +	syntax = g_at_syntax_new_gsm_permissive();

The comment is rather pointless until we really know what is going with
CDMA modems. So I removed it.

However you have to keep in mind that you need to turn echo support off
before you can use the permissive syntax parser.

Regards

Marcel



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

* Re: [PATCH_v3] huaweicdma: Create first draft for plugin huaweicdma
  2011-07-12 12:06 ` Marcel Holtmann
@ 2011-07-12 12:36   ` Guillaume Zajac
  0 siblings, 0 replies; 3+ messages in thread
From: Guillaume Zajac @ 2011-07-12 12:36 UTC (permalink / raw)
  To: ofono

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

Hi Marcel,

On 12/07/2011 14:06, Marcel Holtmann wrote:
> Hi Guillaume,
>
>> 	- Remove Nokia copyright.
>> 	- Remove cdma voicecall for the moment.
>> 	- Add debug print into post_sim pre_sim.
>> 	- use GSM permissive synthax for the moment.
> the nokiacdma.c was actually the worst example to derive this one from.
> I fixed this all up for you now and applied the patch.

Sorry this was the only cdma plugin smple I had.
Thanks for fixing the issues.

>> +/*
>> + * This file is part of oFono - Open Source Telephony
> I missed this part, but all the Nokia copyright headers are wrongly
> formatted. They should have been fixed a long time ago.
>
>> +#include<stdlib.h>
>> +#include<errno.h>
>> +#include<termios.h>
>> +#include<string.h>
>> +#include<unistd.h>
>> +#include<sys/types.h>
>> +#include<sys/stat.h>
>> +#include<fcntl.h>
> This list of includes is useless. Big copy and paste around.
>

You got me :)

>> +#include<glib.h>
>> +#include<gatchat.h>
>> +#include<gattty.h>
>> +
>> +#define OFONO_API_SUBJECT_TO_CHANGE
>> +#include<ofono/plugin.h>
>> +#include<ofono/log.h>
>> +#include<ofono/modem.h>
>> +
>> +#include<drivers/atmodem/atutil.h>
>> +#include<ofono/devinfo.h>
>> +#include<ofono/cdma-connman.h>
>> +
>> +#include "common.h"
> What is this for?
>
>> +	/*
>> +	 * TODO: Will need a CDMA AT syntax parser later.
>> +	 * Using GSM permissive for now.
>> +	 */
>> +	syntax = g_at_syntax_new_gsm_permissive();
> The comment is rather pointless until we really know what is going with
> CDMA modems. So I removed it.
>
> However you have to keep in mind that you need to turn echo support off
> before you can use the permissive syntax parser.
>

Ok, thanks for the info.

Kind regards,
Guillaume

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

end of thread, other threads:[~2011-07-12 12:36 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-07-12 11:47 [PATCH_v3] huaweicdma: Create first draft for plugin huaweicdma Guillaume Zajac
2011-07-12 12:06 ` Marcel Holtmann
2011-07-12 12:36   ` Guillaume Zajac

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.