Hi,
I try to send again a patch to support Motorola H24 modem.
Sorry but I can t use git to generate the patch in my environment.
I ve attached a patch file and send my mail in plain text. Hope you can easily use this
patch.
BR
Christophe
----------
Index: ofono-0.45/drivers/atmodem/sms.c
===================================================================
--- ofono-0.45.orig/drivers/atmodem/sms.c 2011-04-07 13:05:12.214329411 +0200
+++ ofono-0.45/drivers/atmodem/sms.c 2011-04-07 13:05:36.826829247 +0200
@@ -783,6 +783,7 @@
case OFONO_VENDOR_QUALCOMM_MSM:
case OFONO_VENDOR_NOVATEL:
case OFONO_VENDOR_HUAWEI:
+ case OFONO_VENDOR_MOTOROLA:
/* MSM devices advertise support for mode 2, but return an
* error if we attempt to actually use it. */
mode = "1";
Index: ofono-0.45/drivers/atmodem/vendor.h
===================================================================
--- ofono-0.45.orig/drivers/atmodem/vendor.h 2011-04-07 13:05:12.222329128 +0200
+++ ofono-0.45/drivers/atmodem/vendor.h 2011-04-07 13:05:36.826829247 +0200
@@ -35,4 +35,5 @@
OFONO_VENDOR_WAVECOM,
OFONO_VENDOR_NOKIA,
OFONO_VENDOR_PHONESIM,
+ OFONO_VENDOR_MOTOROLA,
};
Index: ofono-0.45/plugins/h24.c
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ ofono-0.45/plugins/h24.c 2011-04-07 13:05:36.826829247 +0200
@@ -0,0 +1,249 @@
+/*
+ *
+ * oFono - Open Source Telephony
+ *
+ * Copyright (C) 2008-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
+
+#include <errno.h>
+#include <stdlib.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 <ofono/call-barring.h>
+#include <ofono/call-forwarding.h>
+#include <ofono/call-meter.h>
+#include <ofono/call-settings.h>
+#include <ofono/devinfo.h>
+#include <ofono/message-waiting.h>
+#include <ofono/netreg.h>
+#include <ofono/phonebook.h>
+#include <ofono/sim.h>
+#include <ofono/sms.h>
+#include <ofono/ussd.h>
+#include <ofono/voicecall.h>
+
+#include <drivers/atmodem/atutil.h>
+#include <drivers/atmodem/vendor.h>
+
+#include <ofono/gprs.h>
+#include <ofono/gprs-context.h>
+
+static int h24_probe(struct ofono_modem *modem)
+{
+ return 0;
+}
+
+static void h24_remove(struct ofono_modem *modem)
+{
+}
+
+static void h24_debug(const char *str, void *user_data)
+{
+ const char *prefix = user_data;
+
+ ofono_info("%s%s", prefix, str);
+}
+
+static int h24_enable(struct ofono_modem *modem)
+{
+ GAtChat *chat;
+ GIOChannel *channel;
+ GAtSyntax *syntax;
+ GHashTable *options;
+ const char *device;
+
+ DBG("%p", modem);
+
+ options = g_hash_table_new(g_str_hash, g_str_equal);
+ if (options == NULL)
+ return -ENOMEM;
+
+ device = ofono_modem_get_string(modem, "Device");
+ if (device == NULL)
+ return -EINVAL;
+
+ g_hash_table_insert(options, "Baud", "115200");
+ g_hash_table_insert(options, "StopBits", "1");
+ g_hash_table_insert(options, "DataBits", "8");
+ g_hash_table_insert(options, "Parity", "none");
+ g_hash_table_insert(options, "XonXoff", "off");
+ g_hash_table_insert(options, "RtsCts", "on");
+ g_hash_table_insert(options, "Local", "on");
+ g_hash_table_insert(options, "Read", "on");
+
+ channel = g_at_tty_open(device, options);
+ g_hash_table_destroy(options);
+
+ if (channel == NULL)
+ return -EIO;
+
+ /*
+ * H24 works almost as the 27.007 says. Today I
+ * just copied existing config from tc65.
+ * TODO: check if it works with a more stict parsing
+ */
+ syntax = g_at_syntax_new_gsm_permissive();
+
+ chat = g_at_chat_new(channel, syntax);
+ g_at_syntax_unref(syntax);
+ g_io_channel_unref(channel);
+
+ if (chat == NULL)
+ return -ENOMEM;
+
+ if (getenv("OFONO_AT_DEBUG"))
+ g_at_chat_set_debug(chat, h24_debug, "");
+
+ ofono_modem_set_data(modem, chat);
+
+ return 0;
+}
+
+static int h24_disable(struct ofono_modem *modem)
+{
+ GAtChat *chat = ofono_modem_get_data(modem);
+
+ DBG("%p", modem);
+
+ ofono_modem_set_data(modem, NULL);
+
+ g_at_chat_send(chat, "AT+CFUN=4", NULL, NULL, NULL, NULL);
+
+ g_at_chat_unref(chat);
+
+ return 0;
+}
+
+static void set_online_cb(gboolean ok, GAtResult *result, gpointer user_data)
+{
+ struct cb_data *cbd = user_data;
+ ofono_modem_online_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 h24_set_online(struct ofono_modem *modem, ofono_bool_t online,
+ ofono_modem_online_cb_t cb, void *user_data)
+{
+ GAtChat *chat = ofono_modem_get_data(modem);
+ struct cb_data *cbd = cb_data_new(cb, user_data);
+ char const *command = online ? "AT+CFUN=1" : "AT+CFUN=4";
+
+ DBG("modem %p %s", modem, online ? "online" :
"offline");
+
+ if (g_at_chat_send(chat, command, NULL, set_online_cb, cbd, g_free))
+ return;
+
+ g_free(cbd);
+
+ CALLBACK_WITH_FAILURE(cb, cbd->data);
+}
+
+static void h24_pre_sim(struct ofono_modem *modem)
+{
+ GAtChat *chat = ofono_modem_get_data(modem);
+ struct ofono_sim *sim;
+
+ DBG("%p", modem);
+
+ ofono_devinfo_create(modem, 0, "atmodem", chat);
+ sim = ofono_sim_create(modem, 0, "atmodem", chat);
+ ofono_voicecall_create(modem, 0, "atmodem", chat);
+
+ if (sim)
+ ofono_sim_inserted_notify(sim, TRUE);
+}
+
+static void h24_post_sim(struct ofono_modem *modem)
+{
+ GAtChat *chat = ofono_modem_get_data(modem);
+
+ DBG("%p", modem);
+
+ ofono_phonebook_create(modem, 0, "atmodem", chat);
+
+ ofono_sms_create(modem, OFONO_VENDOR_MOTOROLA, "atmodem", chat);
+}
+
+static void h24_post_online(struct ofono_modem *modem)
+{
+ GAtChat *chat = ofono_modem_get_data(modem);
+ struct ofono_message_waiting *mw;
+ struct ofono_gprs *gprs;
+ struct ofono_gprs_context *gc;
+
+ DBG("%p", modem);
+
+ ofono_ussd_create(modem, 0, "atmodem", chat);
+ ofono_call_forwarding_create(modem, 0, "atmodem", chat);
+ ofono_call_settings_create(modem, 0, "atmodem", chat);
+ ofono_netreg_create(modem, 0, "atmodem", chat);
+ ofono_call_meter_create(modem, 0, "atmodem", chat);
+ ofono_call_barring_create(modem, 0, "atmodem", chat);
+
+ gprs = ofono_gprs_create(modem, 0, "atmodem", chat);
+ gc = ofono_gprs_context_create(modem, OFONO_VENDOR_MOTOROLA, "atmodem",
chat);
+
+ DBG("GPRS");
+ if (gprs && gc){
+ DBG("GPRS add context");
+
+ ofono_gprs_add_context(gprs, gc);
+ }
+ mw = ofono_message_waiting_create(modem);
+ if (mw)
+ ofono_message_waiting_register(mw);
+}
+
+static struct ofono_modem_driver h24_driver = {
+ .name = "h24",
+ .probe = h24_probe,
+ .remove = h24_remove,
+ .enable = h24_enable,
+ .disable = h24_disable,
+ .set_online = h24_set_online,
+ .pre_sim = h24_pre_sim,
+ .post_sim = h24_post_sim,
+ .post_online = h24_post_online,
+};
+
+static int h24_init(void)
+{
+ return ofono_modem_driver_register(&h24_driver);
+}
+
+static void h24_exit(void)
+{
+ ofono_modem_driver_unregister(&h24_driver);
+}
+
+OFONO_PLUGIN_DEFINE(h24, "Motorola H24 driver plugin", VERSION,
+ OFONO_PLUGIN_PRIORITY_DEFAULT, h24_init, h24_exit)
Index: ofono-0.45/plugins/udev.c
===================================================================
--- ofono-0.45.orig/plugins/udev.c 2011-04-07 13:05:12.202389964 +0200
+++ ofono-0.45/plugins/udev.c 2011-04-07 13:05:36.826829247 +0200
@@ -545,6 +545,19 @@
ofono_modem_register(modem);
}
+static void add_h24(struct ofono_modem *modem,
+ struct udev_device *udev_device)
+{
+ const char *devnode;
+
+ DBG("modem %p", modem);
+
+ devnode = udev_device_get_devnode(udev_device);
+ ofono_modem_set_string(modem, "Device", devnode);
+
+ ofono_modem_register(modem);
+}
+
static void add_nokiacdma(struct ofono_modem *modem,
struct udev_device *udev_device)
{
@@ -682,6 +695,8 @@
add_calypso(modem, udev_device);
else if (g_strcmp0(driver, "tc65") == 0)
add_tc65(modem, udev_device);
+ else if (g_strcmp0(driver, "h24") == 0)
+ add_h24(modem, udev_device);
else if (g_strcmp0(driver, "nokiacdma") == 0)
add_nokiacdma(modem, udev_device);
else if (g_strcmp0(driver, "linktop") == 0)
Index: ofono-0.45/doc/h24-modem.txt
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ ofono-0.45/doc/h24-modem.txt 2011-04-07 13:05:36.826829247 +0200
@@ -0,0 +1,11 @@
+H24 modem usage
+===================
+
+The H24 modem is presented by the kernel as serial device
+/dev/ACM0 if usb link to modem is used. To allow oFono to
+autodetect and use this, a simple udev rule is needed:
+
+KERNEL=="ttyACM0", ENV{OFONO_DRIVER}="h24"
+
+You can put this in any file in /lib/udev/rules.d.
+
Index: ofono-0.45/drivers/atmodem/gprs-context.c
===================================================================
--- ofono-0.45.orig/drivers/atmodem/gprs-context.c 2011-04-07 13:05:12.218343796 +0200
+++ ofono-0.45/drivers/atmodem/gprs-context.c 2011-04-07 13:05:36.826829247 +0200
@@ -41,6 +41,7 @@
#include "gatppp.h"
#include "atmodem.h"
+#include "vendor.h"
#define TUN_SYSFS_DIR "/sys/devices/virtual/misc/tun"
@@ -67,6 +68,7 @@
ofono_gprs_context_up_cb_t up_cb; /* Up callback */
};
void *cb_data; /* Callback data */
+ unsigned int vendor;
};
static void ppp_debug(const char *str, void *data)
@@ -209,7 +211,11 @@
return;
}
- sprintf(buf, "AT+CGDATA=\"PPP\",%u", gcd->active_context);
+ if(gcd->vendor == OFONO_VENDOR_MOTOROLA)
+ sprintf(buf, "ATD*99***%u#", gcd->active_context);
+ else
+ sprintf(buf, "AT+CGDATA=\"PPP\",%u", gcd->active_context);
+
if (g_at_chat_send(gcd->chat, buf, none_prefix,
at_cgdata_cb, gc, NULL) > 0)
return;
@@ -287,6 +293,8 @@
gcd->chat = g_at_chat_clone(chat);
+ gcd->vendor = vendor;
+
ofono_gprs_context_set_data(gc, gcd);
return 0;
Index: ofono-0.45/Makefile.am
===================================================================
--- ofono-0.45.orig/Makefile.am 2011-04-07 13:06:29.298329934 +0200
+++ ofono-0.45/Makefile.am 2011-04-07 13:06:55.110329282 +0200
@@ -313,6 +313,9 @@
builtin_modules += tc65
builtin_sources += plugins/tc65.c
+builtin_modules += h24
+builtin_sources += plugins/h24.c
+
builtin_modules += nokia
builtin_sources += plugins/nokia.c
----------
----------
Christophe Ostermann
Software Engineer
Devices Engineering
SICPA Security Solutions SA
Av. de Florissant 41, 1008 Prilly, Switzerland
Tel +41 21 627 59 70 Direct +41 21 627 63 68
Fax +41 21 620 06 22
christophe.ostermann(a)sicpa.com www.sicpa.com
This message was delivered through encrypted mechanism.
The information in this email and any attachments is confidential
and intended solely for the use of the individual(s) to whom it is
addressed or otherwise directed.
Please note that any views or opinions presented in this email are
solely those of the author and do not necessarily represent those
of the Company.
Finally, the recipient should check this email and any attachments
for the presence of viruses.
The Company accepts no liability for any damage caused by any virus
transmitted by this email.