[PATCH_v2 4/4] test: add script to set credentials for cdma connection

2011-07-20 Thread Guillaume Zajac
---
 test/create-cdma-credentials |   29 +
 1 files changed, 29 insertions(+), 0 deletions(-)
 create mode 100755 test/create-cdma-credentials

diff --git a/test/create-cdma-credentials b/test/create-cdma-credentials
new file mode 100755
index 000..0f52a98
--- /dev/null
+++ b/test/create-cdma-credentials
@@ -0,0 +1,29 @@
+#!/usr/bin/python
+
+import dbus
+import sys
+
+bus = dbus.SystemBus()
+
+manager = dbus.Interface(bus.get_object('org.ofono', '/'),
+   'org.ofono.Manager')
+
+modems = manager.GetModems()
+
+for path, properties in modems:
+   if "org.ofono.cdma.ConnectionManager" not in properties["Interfaces"]:
+   continue
+
+   cm = dbus.Interface(bus.get_object('org.ofono', path),
+   'org.ofono.cdma.ConnectionManager')
+
+   print "Connecting CDMA Packet Data Service on modem %s..." % path
+
+   if len(sys.argv) > 1:
+   cm.SetProperty("Username", (sys.argv[1]))
+   print "Setting Username to %s" % (sys.argv[1])
+
+   if len(sys.argv) > 2:
+   cm.SetProperty("Password", (sys.argv[2]))
+   print "Setting Password to %s" % (sys.argv[2])
+
-- 
1.7.1

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH_v2 2/4] cdma-connman: add username and password, pass them to drivers

2011-07-20 Thread Guillaume Zajac
---
 src/cdma-connman.c |   48 +++-
 1 files changed, 47 insertions(+), 1 deletions(-)

diff --git a/src/cdma-connman.c b/src/cdma-connman.c
index 3321b87..4466dee 100644
--- a/src/cdma-connman.c
+++ b/src/cdma-connman.c
@@ -57,6 +57,8 @@ struct ofono_cdma_connman {
const struct ofono_cdma_connman_driver *driver;
void *driver_data;
struct ofono_atom *atom;
+   char username[OFONO_CDMA_CONNMAN_MAX_USERNAME_LENGTH + 1];
+   char password[OFONO_CDMA_CONNMAN_MAX_PASSWORD_LENGTH + 1];
 };
 
 static void cdma_connman_settings_free(struct cdma_connman_settings *settings)
@@ -371,6 +373,36 @@ static DBusMessage 
*cdma_connman_get_properties(DBusConnection *conn,
return reply;
 }
 
+static DBusMessage *cdma_connman_set_username(struct ofono_cdma_connman *cm,
+   DBusConnection *conn, DBusMessage *msg,
+   const char *username)
+{
+   if (strlen(username) > OFONO_CDMA_CONNMAN_MAX_USERNAME_LENGTH)
+   return __ofono_error_invalid_format(msg);
+
+   if (g_str_equal(username, cm->username))
+   return dbus_message_new_method_return(msg);
+
+   strcpy(cm->username, username);
+
+   return dbus_message_new_method_return(msg);
+}
+
+static DBusMessage *cdma_connman_set_password(struct ofono_cdma_connman *cm,
+   DBusConnection *conn, DBusMessage *msg,
+   const char *password)
+{
+   if (strlen(password) > OFONO_CDMA_CONNMAN_MAX_PASSWORD_LENGTH)
+   return __ofono_error_invalid_format(msg);
+
+   if (g_str_equal(password, cm->password))
+   return dbus_message_new_method_return(msg);
+
+   strcpy(cm->password, password);
+
+   return dbus_message_new_method_return(msg);
+}
+
 static DBusMessage *cdma_connman_set_property(DBusConnection *conn,
DBusMessage *msg, void *data)
 {
@@ -379,6 +411,7 @@ static DBusMessage 
*cdma_connman_set_property(DBusConnection *conn,
DBusMessageIter var;
const char *property;
dbus_bool_t value;
+   const char *str;
 
DBG("");
 
@@ -416,11 +449,24 @@ static DBusMessage 
*cdma_connman_set_property(DBusConnection *conn,
 
/* TODO: add logic to support CDMA Network Registration */
if (value)
-   cm->driver->activate(cm, activate_callback, cm);
+   cm->driver->activate(cm, cm->username, cm->password,
+   activate_callback, cm);
else
cm->driver->deactivate(cm, deactivate_callback, cm);
 
return dbus_message_new_method_return(msg);
+   } else if (!strcmp(property, "Username")) {
+   if (dbus_message_iter_get_arg_type(&var) != DBUS_TYPE_STRING)
+   return __ofono_error_invalid_args(msg);
+
+   dbus_message_iter_get_basic(&var, &str);
+   return cdma_connman_set_username(cm, conn, msg, str);
+   } else if (!strcmp(property, "Password")) {
+   if (dbus_message_iter_get_arg_type(&var) != DBUS_TYPE_STRING)
+   return __ofono_error_invalid_args(msg);
+
+   dbus_message_iter_get_basic(&var, &str);
+   return cdma_connman_set_password(cm, conn, msg, str);
}
 
/* TODO: Dormant property. Not yet supported. */
-- 
1.7.1

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH_v2 3/4] driver cdma-connman: pass credentials into activate function

2011-07-20 Thread Guillaume Zajac
---
 drivers/cdmamodem/connman.c |9 +
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/drivers/cdmamodem/connman.c b/drivers/cdmamodem/connman.c
index 14c78b1..ce9a748 100644
--- a/drivers/cdmamodem/connman.c
+++ b/drivers/cdmamodem/connman.c
@@ -56,6 +56,8 @@ struct connman_data {
GAtChat *chat;
GAtPPP *ppp;
enum state state;
+   char username[OFONO_CDMA_CONNMAN_MAX_USERNAME_LENGTH + 1];
+   char password[OFONO_CDMA_CONNMAN_MAX_PASSWORD_LENGTH + 1];
union {
ofono_cdma_connman_cb_t down_cb;/* Down callback */
ofono_cdma_connman_up_cb_t up_cb;   /* Up callback */
@@ -145,6 +147,8 @@ static gboolean setup_ppp(struct ofono_cdma_connman *cm)
g_at_ppp_set_connect_function(cd->ppp, ppp_connect, cm);
g_at_ppp_set_disconnect_function(cd->ppp, ppp_disconnect, cm);
 
+   g_at_ppp_set_credentials(cd->ppp, cd->username, cd->password);
+
/* open the ppp connection */
g_at_ppp_open(cd->ppp, io);
 
@@ -175,6 +179,8 @@ static void atd_cb(gboolean ok, GAtResult *result, gpointer 
user_data)
 }
 
 static void cdma_connman_activate(struct ofono_cdma_connman *cm,
+   const char *username,
+   const char *password,
ofono_cdma_connman_up_cb_t cb,
void *data)
 {
@@ -185,6 +191,9 @@ static void cdma_connman_activate(struct ofono_cdma_connman 
*cm,
 
cd->up_cb = cb;
cd->cb_data = data;
+   strcpy(cd->username, username);
+   strcpy(cd->password, password);
+
cd->state = STATE_ENABLING;
 
sprintf(buf, "ATD#777");
-- 
1.7.1

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH_v2 0/4] CDMA-connman add username and password properties

2011-07-20 Thread Guillaume Zajac
Change log from v1:
- username and password storage is now very similar to gprs one.
- rework logic flow.

Guillaume Zajac (4):
  cdma-connman: pass username and password to drivers while activating
cdma-connman
  cdma-connman: add username and password, pass them to drivers
  driver cdma-connman: pass credentials into activate function
  test: add script to set credentials for cdma connection

 drivers/cdmamodem/connman.c  |9 +++
 include/cdma-connman.h   |5 
 src/cdma-connman.c   |   48 +-
 test/create-cdma-credentials |   29 +
 4 files changed, 90 insertions(+), 1 deletions(-)
 create mode 100755 test/create-cdma-credentials

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH_v2 1/4] cdma-connman: pass username and password to drivers while activating cdma-connman

2011-07-20 Thread Guillaume Zajac
---
 include/cdma-connman.h |5 +
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/include/cdma-connman.h b/include/cdma-connman.h
index 22252e0..6a1c9ff 100644
--- a/include/cdma-connman.h
+++ b/include/cdma-connman.h
@@ -30,6 +30,9 @@ extern "C" {
 
 struct ofono_cdma_connman;
 
+#define OFONO_CDMA_CONNMAN_MAX_USERNAME_LENGTH 63
+#define OFONO_CDMA_CONNMAN_MAX_PASSWORD_LENGTH 255
+
 typedef void (*ofono_cdma_connman_cb_t)(const struct ofono_error *error,
void *data);
 typedef void (*ofono_cdma_connman_up_cb_t)(const struct ofono_error *error,
@@ -47,6 +50,8 @@ struct ofono_cdma_connman_driver {
void *data);
void (*remove)(struct ofono_cdma_connman *cm);
void (*activate)(struct ofono_cdma_connman *cm,
+   const char *username,
+   const char *password,
ofono_cdma_connman_up_cb_t cb,
void *data);
void (*deactivate)(struct ofono_cdma_connman *cm,
-- 
1.7.1

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


RE: [PATCH 1/2] speedup: add cpin polling mechanism

2011-07-20 Thread Aygon, Bertrand
Hi,

>  plugins/speedup.c |   64
> -
>  1 files changed, 63 insertions(+), 1 deletions(-)
> 
> diff --git a/plugins/speedup.c b/plugins/speedup.c
> index 7e89b6f..23ba173 100644
> --- a/plugins/speedup.c
> +++ b/plugins/speedup.c
> @@ -49,10 +49,14 @@
>  #include 
> 
>  static const char *none_prefix[] = { NULL };
> +static const char *cpin_prefix[] = { "+CPIN:", NULL };
> 
>  struct speedup_data {
>   GAtChat *modem;
>   GAtChat *aux;
> + guint cpin_poll_source;
> + guint cpin_poll_count;
> + gboolean have_sim;
>   struct ofono_gprs *gprs;
>   struct ofono_gprs_context *gc;
>  };
> @@ -83,6 +87,9 @@ static void speedup_remove(struct ofono_modem *modem)
>   g_at_chat_unref(data->modem);
>   g_at_chat_unref(data->aux);
> 
> + if (data->cpin_poll_source > 0)
> + g_source_remove(data->cpin_poll_source);
> +
>   g_free(data);
>  }
> 
> @@ -152,13 +159,68 @@ static void speedup_disconnect(gpointer user_data)
>   ofono_gprs_add_context(data->gprs, data->gc);
>  }
> 
> +static gboolean init_simpin_check(gpointer user_data);
> +
> +static void simpin_check(gboolean ok, GAtResult *result, gpointer user_data)
> +{
> + struct ofono_modem *modem = user_data;
> + struct speedup_data *data = ofono_modem_get_data(modem);
> + struct ofono_error error;
> +
> + DBG("");
> +
> + decode_at_error(&error, g_at_result_final_response(result));
> +
> + /* Modem returns an error if SIM is not ready. */
> + switch (error.error) {
> + case 10:
> + case 13:
> + data->have_sim = FALSE;
> + break;
> + case 14: /* SIM Busy, wait and check again the SIM pin status */
> + if (data->cpin_poll_count++ < 5) {
> + data->cpin_poll_source =
> + g_timeout_add_seconds(1, init_simpin_check,
> + modem);
> + return;
> + }
> + /*SIM card is present but not accessible*/
> + data->have_sim = FALSE;
> + break;
> + default:
> + data->have_sim = TRUE;
> + }
> +
> + data->cpin_poll_count = 0;
> +
> + ofono_modem_set_powered(modem, TRUE);
> +}
> +
> +static gboolean init_simpin_check(gpointer user_data)
> +{
> + struct ofono_modem *modem = user_data;
> + struct speedup_data *data = ofono_modem_get_data(modem);
> +
> + data->cpin_poll_source = 0;
> +
> + g_at_chat_send(data->modem, "AT+CPIN?", cpin_prefix,
> + simpin_check, modem, NULL);

The command need to be sent to Aux at chat and not Modem. Modem should be used 
only for the data call.

> +
> + return FALSE;
> +}
> +
>  static void cfun_enable(gboolean ok, GAtResult *result, gpointer user_data)
>  {
>   struct ofono_modem *modem = user_data;
> 
>   DBG("");
> 
> - ofono_modem_set_powered(modem, ok);
> + if (!ok) {
> + ofono_modem_set_powered(modem, FALSE);
> + return;
> + }
> +
> + init_simpin_check(modem);
>  }
> 
>  static int speedup_enable(struct ofono_modem *modem)

Thanks,

Bertrand
-
Intel Corporation SAS (French simplified joint stock company)
Registered headquarters: "Les Montalets"- 2, rue de Paris, 
92196 Meudon Cedex, France
Registration Number:  302 456 199 R.C.S. NANTERRE
Capital: 4,572,000 Euros

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH_v2] Create cdmadial tool to work on CDMA data call support.

2011-07-20 Thread Bertrand Aygon
---
 Makefile.am|6 +-
 gatchat/cdmadial.c |  520 
 2 files changed, 525 insertions(+), 1 deletions(-)
 create mode 100644 gatchat/cdmadial.c

diff --git a/Makefile.am b/Makefile.am
index a4e6c95..f5a8504 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -616,11 +616,15 @@ tools_lookup_apn_SOURCES = tools/lookup-apn.c
 tools_lookup_apn_LDADD = @GLIB_LIBS@
 endif
 
-noinst_PROGRAMS += gatchat/gsmdial gatchat/test-server gatchat/test-qcdm
+noinst_PROGRAMS += gatchat/gsmdial gatchat/cdmadial \
+   gatchat/test-server gatchat/test-qcdm
 
 gatchat_gsmdial_SOURCES = gatchat/gsmdial.c $(gatchat_sources)
 gatchat_gsmdial_LDADD = @GLIB_LIBS@
 
+gatchat_cdmadial_SOURCES = gatchat/cdmadial.c $(gatchat_sources)
+gatchat_cdmadial_LDADD = @GLIB_LIBS@
+
 gatchat_test_server_SOURCES = gatchat/test-server.c $(gatchat_sources)
 gatchat_test_server_LDADD = @GLIB_LIBS@ -lutil
 
diff --git a/gatchat/cdmadial.c b/gatchat/cdmadial.c
new file mode 100644
index 000..f3f9686
--- /dev/null
+++ b/gatchat/cdmadial.c
@@ -0,0 +1,520 @@
+/*
+ *
+ *  AT chat library with GLib integration
+ *
+ *  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 
+#endif
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+
+#define IFCONFIG_PATH "/sbin/ifconfig"
+
+static const char *none_prefix[] = { NULL };
+static const char *cfun_prefix[] = { "+CFUN:", NULL };
+
+static gchar *option_ip = NULL;
+static gint option_port = 0;
+static gchar *option_modem = NULL;
+static gchar *option_control = NULL;
+static gint option_cid = 0;
+static gchar *option_apn = NULL;
+static gint option_offmode = 0;
+static gchar *option_username = NULL;
+static gchar *option_password = NULL;
+static gchar *option_pppdump = NULL;
+static gboolean option_acfc = FALSE;
+static gboolean option_pfc = FALSE;
+
+static GAtPPP *ppp;
+static GAtChat *control;
+static GAtChat *modem;
+static GMainLoop *event_loop;
+
+
+static int oldmode = 0;
+
+static void cdmadial_debug(const char *str, void *data)
+{
+   g_print("%s: %s\n", (const char *) data, str);
+}
+
+static gboolean quit_eventloop(gpointer user_data)
+{
+   g_main_loop_quit(event_loop);
+   return FALSE;
+}
+
+static void power_down(gboolean ok, GAtResult *result, gpointer user_data)
+{
+   g_main_loop_quit(event_loop);
+}
+
+static void kill_ppp(gboolean ok, GAtResult *result, gpointer user_data)
+{
+   g_print("kill_ppp: %d\n", ok);
+
+   if (ok == FALSE)
+   return;
+
+   g_at_ppp_unref(ppp);
+   ppp = NULL;
+}
+
+static void ppp_suspend_ath0(gpointer user_data)
+{
+   g_at_chat_resume(modem);
+   g_at_chat_send(modem, "ATH0", none_prefix, kill_ppp, NULL, NULL);
+}
+
+static void resume_ppp(gboolean ok, GAtResult *result, gpointer user_data)
+{
+   g_print("resume_ppp: %d\n", ok);
+
+   if (ok == FALSE)
+   return;
+
+   g_at_chat_suspend(modem);
+   g_at_ppp_resume(ppp);
+}
+
+static void ppp_suspend_ato0(gpointer user_data)
+{
+   g_at_chat_resume(modem);
+   g_at_chat_send(modem, "ATO0", none_prefix, resume_ppp, NULL, NULL);
+}
+
+static gboolean signal_cb(GIOChannel *channel, GIOCondition cond, gpointer 
data)
+{
+   static int terminated = 0;
+   int signal_fd = GPOINTER_TO_INT(data);
+   struct signalfd_siginfo si;
+   ssize_t res;
+
+   if (cond & (G_IO_NVAL | G_IO_ERR))
+   return FALSE;
+
+   res = read(signal_fd, &si, sizeof(si));
+   if (res != sizeof(si))
+   return FALSE;
+
+   switch (si.ssi_signo) {
+   case SIGINT:
+   case SIGTERM:
+   if (terminated == 0) {
+   g_timeout_add_seconds(10, quit_eventloop, NULL);
+
+   if (ppp == NULL) {
+   char buf[64];
+   sprintf(buf, "AT+CFUN=%u", option_offmode);
+   g_at_chat_send(control, buf, none_prefix,
+   power_down, NULL, NULL);
+   } else
+   g_at_ppp_shutdown(ppp);
+   }
+
+

[PATCH] Create cdmadial tool to work on CDMA data call support.

2011-07-20 Thread Bertrand Aygon
---
 Makefile.am|6 +-
 gatchat/cdmadial.c |  520 
 2 files changed, 525 insertions(+), 1 deletions(-)
 create mode 100644 gatchat/cdmadial.c

diff --git a/Makefile.am b/Makefile.am
index a4e6c95..bb712cb 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -616,11 +616,15 @@ tools_lookup_apn_SOURCES = tools/lookup-apn.c
 tools_lookup_apn_LDADD = @GLIB_LIBS@
 endif
 
-noinst_PROGRAMS += gatchat/gsmdial gatchat/test-server gatchat/test-qcdm
+noinst_PROGRAMS += gatchat/gsmdial gatchat/cdmadial /
+   gatchat/test-server gatchat/test-qcdm
 
 gatchat_gsmdial_SOURCES = gatchat/gsmdial.c $(gatchat_sources)
 gatchat_gsmdial_LDADD = @GLIB_LIBS@
 
+gatchat_cdmadial_SOURCES = gatchat/cdmadial.c $(gatchat_sources)
+gatchat_cdmadial_LDADD = @GLIB_LIBS@
+
 gatchat_test_server_SOURCES = gatchat/test-server.c $(gatchat_sources)
 gatchat_test_server_LDADD = @GLIB_LIBS@ -lutil
 
diff --git a/gatchat/cdmadial.c b/gatchat/cdmadial.c
new file mode 100644
index 000..f3f9686
--- /dev/null
+++ b/gatchat/cdmadial.c
@@ -0,0 +1,520 @@
+/*
+ *
+ *  AT chat library with GLib integration
+ *
+ *  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 
+#endif
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+
+#define IFCONFIG_PATH "/sbin/ifconfig"
+
+static const char *none_prefix[] = { NULL };
+static const char *cfun_prefix[] = { "+CFUN:", NULL };
+
+static gchar *option_ip = NULL;
+static gint option_port = 0;
+static gchar *option_modem = NULL;
+static gchar *option_control = NULL;
+static gint option_cid = 0;
+static gchar *option_apn = NULL;
+static gint option_offmode = 0;
+static gchar *option_username = NULL;
+static gchar *option_password = NULL;
+static gchar *option_pppdump = NULL;
+static gboolean option_acfc = FALSE;
+static gboolean option_pfc = FALSE;
+
+static GAtPPP *ppp;
+static GAtChat *control;
+static GAtChat *modem;
+static GMainLoop *event_loop;
+
+
+static int oldmode = 0;
+
+static void cdmadial_debug(const char *str, void *data)
+{
+   g_print("%s: %s\n", (const char *) data, str);
+}
+
+static gboolean quit_eventloop(gpointer user_data)
+{
+   g_main_loop_quit(event_loop);
+   return FALSE;
+}
+
+static void power_down(gboolean ok, GAtResult *result, gpointer user_data)
+{
+   g_main_loop_quit(event_loop);
+}
+
+static void kill_ppp(gboolean ok, GAtResult *result, gpointer user_data)
+{
+   g_print("kill_ppp: %d\n", ok);
+
+   if (ok == FALSE)
+   return;
+
+   g_at_ppp_unref(ppp);
+   ppp = NULL;
+}
+
+static void ppp_suspend_ath0(gpointer user_data)
+{
+   g_at_chat_resume(modem);
+   g_at_chat_send(modem, "ATH0", none_prefix, kill_ppp, NULL, NULL);
+}
+
+static void resume_ppp(gboolean ok, GAtResult *result, gpointer user_data)
+{
+   g_print("resume_ppp: %d\n", ok);
+
+   if (ok == FALSE)
+   return;
+
+   g_at_chat_suspend(modem);
+   g_at_ppp_resume(ppp);
+}
+
+static void ppp_suspend_ato0(gpointer user_data)
+{
+   g_at_chat_resume(modem);
+   g_at_chat_send(modem, "ATO0", none_prefix, resume_ppp, NULL, NULL);
+}
+
+static gboolean signal_cb(GIOChannel *channel, GIOCondition cond, gpointer 
data)
+{
+   static int terminated = 0;
+   int signal_fd = GPOINTER_TO_INT(data);
+   struct signalfd_siginfo si;
+   ssize_t res;
+
+   if (cond & (G_IO_NVAL | G_IO_ERR))
+   return FALSE;
+
+   res = read(signal_fd, &si, sizeof(si));
+   if (res != sizeof(si))
+   return FALSE;
+
+   switch (si.ssi_signo) {
+   case SIGINT:
+   case SIGTERM:
+   if (terminated == 0) {
+   g_timeout_add_seconds(10, quit_eventloop, NULL);
+
+   if (ppp == NULL) {
+   char buf[64];
+   sprintf(buf, "AT+CFUN=%u", option_offmode);
+   g_at_chat_send(control, buf, none_prefix,
+   power_down, NULL, NULL);
+   } else
+   g_at_ppp_shutdown(ppp);
+   }
+
+

[PATCH_v4] speedupcdma: add speedup cdma skeleton plugin

2011-07-20 Thread Guillaume Zajac
Free speedupcdma_data while removing modem.

---
 Makefile.am   |3 +
 plugins/speedupcdma.c |  210 +
 2 files changed, 213 insertions(+), 0 deletions(-)
 create mode 100644 plugins/speedupcdma.c

diff --git a/Makefile.am b/Makefile.am
index a4e6c95..4b72091 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -336,6 +336,9 @@ builtin_sources += plugins/telit.c
 builtin_modules += speedup
 builtin_sources += plugins/speedup.c
 
+builtin_modules += speedupcdma
+builtin_sources += plugins/speedupcdma.c
+
 if BLUETOOTH
 builtin_modules += bluetooth
 builtin_sources += plugins/bluetooth.c plugins/bluetooth.h
diff --git a/plugins/speedupcdma.c b/plugins/speedupcdma.c
new file mode 100644
index 000..65da2f6
--- /dev/null
+++ b/plugins/speedupcdma.c
@@ -0,0 +1,210 @@
+/*
+ *
+ *  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 
+#endif
+
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+#define OFONO_API_SUBJECT_TO_CHANGE
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+static const char *none_prefix[] = { NULL };
+
+struct speedupcdma_data {
+   GAtChat *chat;
+};
+
+static void speedupcdma_debug(const char *str, void *data)
+{
+   const char *prefix = data;
+
+   ofono_info("%s%s", prefix, str);
+}
+
+static int speedupcdma_probe(struct ofono_modem *modem)
+{
+   struct speedupcdma_data *data;
+
+   DBG("%p", modem);
+
+   data = g_try_new0(struct speedupcdma_data, 1);
+   if (data == NULL)
+   return -ENOMEM;
+
+   ofono_modem_set_data(modem, data);
+
+   return 0;
+}
+
+static void speedupcdma_remove(struct ofono_modem *modem)
+{
+   struct speedupcdma_data *data = ofono_modem_get_data(modem);
+
+   DBG("%p", modem);
+
+   g_free(data);
+   ofono_modem_set_data(modem, NULL);
+}
+
+static void cfun_enable(gboolean ok, GAtResult *result, gpointer user_data)
+{
+   struct ofono_modem *modem = user_data;
+
+   DBG("");
+
+   if (!ok) {
+   struct speedupcdma_data *data = ofono_modem_get_data(modem);
+
+   g_at_chat_unref(data->chat);
+   data->chat == NULL;
+
+   ofono_modem_set_powered(modem, FALSE);
+   return;
+   }
+
+   ofono_modem_set_powered(modem, TRUE);
+}
+
+static int speedupcdma_enable(struct ofono_modem *modem)
+{
+   struct speedupcdma_data *data = ofono_modem_get_data(modem);
+   GAtSyntax *syntax;
+   GIOChannel *channel;
+   const char *modem_path;
+
+   modem_path = ofono_modem_get_string(modem, "Modem");
+   if (modem_path == NULL)
+   return -EINVAL;
+
+   DBG("path is: %s", modem_path);
+
+   channel = g_at_tty_open(modem_path, NULL);
+   if (channel == NULL)
+   return -EIO;
+
+   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, speedupcdma_debug, "Modem: ");
+
+   g_at_chat_send(data->chat, "ATE0 +CMEE=1", none_prefix,
+   NULL, NULL, NULL);
+
+   g_at_chat_send(data->chat, "AT+CFUN=1", none_prefix,
+   cfun_enable, modem, NULL);
+
+   return -EINPROGRESS;
+}
+
+static void cfun_disable(gboolean ok, GAtResult *result, gpointer user_data)
+{
+   struct ofono_modem *modem = user_data;
+   struct speedupcdma_data *data = ofono_modem_get_data(modem);
+
+   DBG("");
+
+   g_at_chat_unref(data->chat);
+   data->chat = NULL;
+
+   if (ok)
+   ofono_modem_set_powered(modem, FALSE);
+}
+
+static int speedupcdma_disable(struct ofono_modem *modem)
+{
+   struct speedupcdma_data *data = ofono_modem_get_data(modem);
+
+   DBG("%p", modem);
+
+   g_at_chat_send(data->chat, "AT+CFUN=0", none_prefix,
+   cfun_disable, modem, NULL);
+
+   return -EINPROGRESS;
+}
+
+static void speedupcdma_pre_sim(stru

[PATCH 2/2] zte: add cpin polling mechanism

2011-07-20 Thread Nicolas Bertrand
Make sure that the SIM card is ready before sending commands
---
 plugins/zte.c |   65 -
 1 files changed, 64 insertions(+), 1 deletions(-)

diff --git a/plugins/zte.c b/plugins/zte.c
index 4bac3cf..53b3fa0 100644
--- a/plugins/zte.c
+++ b/plugins/zte.c
@@ -49,10 +49,14 @@
 #include 
 
 static const char *none_prefix[] = { NULL };
+static const char *cpin_prefix[] = { "+CPIN:", NULL };
 
 struct zte_data {
GAtChat *modem;
GAtChat *aux;
+   guint cpin_poll_source;
+   guint cpin_poll_count;
+   gboolean have_sim;
struct ofono_gprs *gprs;
struct ofono_gprs_context *gc;
 };
@@ -83,6 +87,9 @@ static void zte_remove(struct ofono_modem *modem)
g_at_chat_unref(data->modem);
g_at_chat_unref(data->aux);
 
+   if (data->cpin_poll_source > 0)
+   g_source_remove(data->cpin_poll_source);
+
g_free(data);
 }
 
@@ -152,13 +159,69 @@ static void zte_disconnect(gpointer user_data)
ofono_gprs_add_context(data->gprs, data->gc);
 }
 
+static gboolean init_simpin_check(gpointer user_data);
+
+static void simpin_check(gboolean ok, GAtResult *result, gpointer user_data)
+{
+   struct ofono_modem *modem = user_data;
+   struct zte_data *data = ofono_modem_get_data(modem);
+   struct ofono_error error;
+
+   DBG("");
+
+   decode_at_error(&error, g_at_result_final_response(result));
+
+   /* Modem returns an error if SIM is not ready. */
+   switch (error.error) {
+   case 10:
+   case 13:
+   data->have_sim = FALSE;
+   break;
+   case 14: /* SIM Busy, wait and check again the card status */
+   if (data->cpin_poll_count++ < 5) {
+   data->cpin_poll_source =
+   g_timeout_add_seconds(1, init_simpin_check,
+   modem);
+   return;
+   }
+   /*SIM card is present but not accessible*/
+   data->have_sim = FALSE;
+   break;
+   default:
+   data->have_sim = TRUE;
+   }
+
+   data->cpin_poll_count = 0;
+
+   ofono_modem_set_powered(modem, TRUE);
+}
+
+static gboolean init_simpin_check(gpointer user_data)
+{
+   struct ofono_modem *modem = user_data;
+   struct zte_data *data = ofono_modem_get_data(modem);
+
+   data->cpin_poll_source = 0;
+
+   g_at_chat_send(data->modem, "AT+CPIN?", cpin_prefix,
+   simpin_check, modem, NULL);
+
+   return FALSE;
+}
+
+
 static void cfun_enable(gboolean ok, GAtResult *result, gpointer user_data)
 {
struct ofono_modem *modem = user_data;
 
DBG("");
 
-   ofono_modem_set_powered(modem, ok);
+   if (!ok) {
+   ofono_modem_set_powered(modem, FALSE);
+   return;
+   }
+
+   init_simpin_check(modem);
 }
 
 static int zte_enable(struct ofono_modem *modem)
-- 
1.7.4.1

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH 1/2] speedup: add cpin polling mechanism

2011-07-20 Thread Nicolas Bertrand
Make sure that the SIM card is ready before sending commands
---
 plugins/speedup.c |   64 -
 1 files changed, 63 insertions(+), 1 deletions(-)

diff --git a/plugins/speedup.c b/plugins/speedup.c
index 7e89b6f..23ba173 100644
--- a/plugins/speedup.c
+++ b/plugins/speedup.c
@@ -49,10 +49,14 @@
 #include 
 
 static const char *none_prefix[] = { NULL };
+static const char *cpin_prefix[] = { "+CPIN:", NULL };
 
 struct speedup_data {
GAtChat *modem;
GAtChat *aux;
+   guint cpin_poll_source;
+   guint cpin_poll_count;
+   gboolean have_sim;
struct ofono_gprs *gprs;
struct ofono_gprs_context *gc;
 };
@@ -83,6 +87,9 @@ static void speedup_remove(struct ofono_modem *modem)
g_at_chat_unref(data->modem);
g_at_chat_unref(data->aux);
 
+   if (data->cpin_poll_source > 0)
+   g_source_remove(data->cpin_poll_source);
+
g_free(data);
 }
 
@@ -152,13 +159,68 @@ static void speedup_disconnect(gpointer user_data)
ofono_gprs_add_context(data->gprs, data->gc);
 }
 
+static gboolean init_simpin_check(gpointer user_data);
+
+static void simpin_check(gboolean ok, GAtResult *result, gpointer user_data)
+{
+   struct ofono_modem *modem = user_data;
+   struct speedup_data *data = ofono_modem_get_data(modem);
+   struct ofono_error error;
+
+   DBG("");
+
+   decode_at_error(&error, g_at_result_final_response(result));
+
+   /* Modem returns an error if SIM is not ready. */
+   switch (error.error) {
+   case 10:
+   case 13:
+   data->have_sim = FALSE;
+   break;
+   case 14: /* SIM Busy, wait and check again the SIM pin status */
+   if (data->cpin_poll_count++ < 5) {
+   data->cpin_poll_source =
+   g_timeout_add_seconds(1, init_simpin_check,
+   modem);
+   return;
+   }
+   /*SIM card is present but not accessible*/
+   data->have_sim = FALSE;
+   break;
+   default:
+   data->have_sim = TRUE;
+   }
+
+   data->cpin_poll_count = 0;
+
+   ofono_modem_set_powered(modem, TRUE);
+}
+
+static gboolean init_simpin_check(gpointer user_data)
+{
+   struct ofono_modem *modem = user_data;
+   struct speedup_data *data = ofono_modem_get_data(modem);
+
+   data->cpin_poll_source = 0;
+
+   g_at_chat_send(data->modem, "AT+CPIN?", cpin_prefix,
+   simpin_check, modem, NULL);
+
+   return FALSE;
+}
+
 static void cfun_enable(gboolean ok, GAtResult *result, gpointer user_data)
 {
struct ofono_modem *modem = user_data;
 
DBG("");
 
-   ofono_modem_set_powered(modem, ok);
+   if (!ok) {
+   ofono_modem_set_powered(modem, FALSE);
+   return;
+   }
+
+   init_simpin_check(modem);
 }
 
 static int speedup_enable(struct ofono_modem *modem)
-- 
1.7.4.1

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH 0/2] CPIN polling mechanism

2011-07-20 Thread Nicolas Bertrand
As no SIM card status urc is available with ZTE and Speedup, the SIM 
state is set by default to OFONO_SIM_STATE_INSERTED even if no SIM card 
is inserted. Also, we are facing with a modem latency after the ttyUSB 
is opened (first AT commands are failing and the PIN status query 
returns CME ERROR: 14 - SIM Busy).
So, to deal with those 2 issues, this patch set is introducing a 
preliminary PIN status polling in the ZTE/Speedup plugins. In practice, 
this polling is started after the modem is enabled and stopped when the 
CPIN query returns an other result than CME ERROR 14 or when the polling 
duration exceeds 5 seconds.
As a result, the SIM state is set according the result of the CPIN query 
and the update of the modem_powered state is postponed which delays the 
next AT commands.

Developed conjointly with philippe nunes.


Nicolas Bertrand (2):
  speedup: add cpin polling mechanism
  zte: add cpin polling mechanism

 plugins/speedup.c |   64 +++-
 plugins/zte.c |   65 -
 2 files changed, 127 insertions(+), 2 deletions(-)

-- 
1.7.4.1

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


RE: [PATCH] CDMA ConnMan API: add username and password for PPP authentication.

2011-07-20 Thread Marcel Holtmann
Hi Bertrand,

> >For you two TTY cases. That is normal. Huawei treats the first TTY as
> >modem to issue PPP on it. And the second one (PCUI) is used for
> >notifications. So yes, oFono needs to open both. You will need the
> >second one for network registration updates.
> 
> But I think that if you send ATD on a channel, you should receive the CONNECT 
> in the same channel. It's an answer, not a notification.

you do remember me talking about how broken some modems are ;)

So here you go. Wait until you deal with stuff like unsolicited
notification and which channel they appear on. Working with IFX or MBM
hardware is a dream compared to this ;)

Regards

Marcel


___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


RE: [PATCH] CDMA ConnMan API: add username and password for PPP authentication.

2011-07-20 Thread Aygon, Bertrand
Hi,

>fair enough. That is enough for me to confirm that it is used in real
>networks. We do not like to add APIs for something that is not used
>anymore only because some specification or RFC says so ;)

I agree.

>Patch has been applied now. However I changed the commit prefix back to
>doc: to make it look cleaner.

Thanks.

>For you two TTY cases. That is normal. Huawei treats the first TTY as
>modem to issue PPP on it. And the second one (PCUI) is used for
>notifications. So yes, oFono needs to open both. You will need the
>second one for network registration updates.

But I think that if you send ATD on a channel, you should receive the CONNECT 
in the same channel. It's an answer, not a notification.

Regards,

Bertrand

-
Intel Corporation SAS (French simplified joint stock company)
Registered headquarters: "Les Montalets"- 2, rue de Paris, 
92196 Meudon Cedex, France
Registration Number:  302 456 199 R.C.S. NANTERRE
Capital: 4,572,000 Euros

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH v2 2/2] voicecall: remove usage of em_atd_number

2011-07-20 Thread Frédéric Danis
as emulator atom can only run with a 'ready' SIM,
use saved number instead of em_atd_number
---
 src/voicecall.c |   19 +--
 1 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/src/voicecall.c b/src/voicecall.c
index 9160ce8..f4c2358 100644
--- a/src/voicecall.c
+++ b/src/voicecall.c
@@ -74,7 +74,6 @@ struct ofono_voicecall {
ofono_voicecall_cb_t release_queue_done_cb;
struct ofono_emulator *pending_em;
unsigned int pending_id;
-   char *em_atd_number;
 };
 
 struct voicecall {
@@ -1506,14 +1505,14 @@ static int voicecall_dial(struct ofono_voicecall *vc, 
const char *number,
 
string_to_phone_number(number, &ph);
 
-   vc->driver->dial(vc, &ph, clir, cb, vc);
-
if (vc->settings) {
g_key_file_set_string(vc->settings, SETTINGS_GROUP,
"Number", number);
storage_sync(vc->imsi, SETTINGS_STORE, vc->settings);
}
 
+   vc->driver->dial(vc, &ph, clir, cb, vc);
+
return 0;
 }
 
@@ -3154,13 +3153,18 @@ static void emulator_dial_callback(const struct 
ofono_error *error, void *data)
struct ofono_voicecall *vc = data;
gboolean need_to_emit;
struct voicecall *v;
+   const char *number;
+   GError *err = NULL;
+
+   number = g_key_file_get_string(vc->settings, SETTINGS_GROUP,
+   "Number", &err);
 
-   v = dial_handle_result(vc, error, vc->em_atd_number, &need_to_emit);
+   v = dial_handle_result(vc, error, number, &need_to_emit);
 
if (v == NULL) {
struct ofono_modem *modem = __ofono_atom_get_modem(vc->atom);
 
-   if (is_emergency_number(vc, vc->em_atd_number) == TRUE)
+   if (is_emergency_number(vc, number) == TRUE)
__ofono_modem_dec_emergency_mode(modem);
}
 
@@ -3168,8 +3172,6 @@ static void emulator_dial_callback(const struct 
ofono_error *error, void *data)
ofono_emulator_send_final(vc->pending_em, error);
 
vc->pending_em = NULL;
-   g_free(vc->em_atd_number);
-   vc->em_atd_number = NULL;
 
notify_emulator_call_status(vc);
 
@@ -3191,7 +3193,6 @@ static void emulator_dial(struct ofono_emulator *em, 
struct ofono_voicecall *vc,
}
 
vc->pending_em = em;
-   vc->em_atd_number = g_strdup(number);
 
err = voicecall_dial(vc, number, OFONO_CLIR_OPTION_DEFAULT,
emulator_dial_callback, vc);
@@ -3200,8 +3201,6 @@ static void emulator_dial(struct ofono_emulator *em, 
struct ofono_voicecall *vc,
return;
 
vc->pending_em = NULL;
-   g_free(vc->em_atd_number);
-   vc->em_atd_number = NULL;
 
switch (err) {
case -ENETDOWN:
-- 
1.7.1

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH v2 1/2] hfp_ag: start server on sim 'ready' state

2011-07-20 Thread Frédéric Danis
update HFP AG server to start only when a modem has its SIM atom
in 'ready' state and has voice call capability
---
 plugins/hfp_ag.c |   85 ++
 1 files changed, 66 insertions(+), 19 deletions(-)

diff --git a/plugins/hfp_ag.c b/plugins/hfp_ag.c
index 191708b..9fea282 100644
--- a/plugins/hfp_ag.c
+++ b/plugins/hfp_ag.c
@@ -40,6 +40,7 @@
 static struct server *server;
 static guint modemwatch_id;
 static GList *modems;
+static GHashTable *sim_hash = NULL;
 
 static const gchar *hfp_ag_record =
 "\n"
@@ -85,6 +86,11 @@ static const gchar *hfp_ag_record =
 "  \n"
 "\n";
 
+struct sim_entry {
+   int watch;
+   struct ofono_modem *modem;
+};
+
 static void hfp_ag_connect_cb(GIOChannel *io, GError *err, gpointer user_data)
 {
struct ofono_modem *modem;
@@ -115,27 +121,68 @@ static void hfp_ag_connect_cb(GIOChannel *io, GError 
*err, gpointer user_data)
ofono_emulator_register(em, fd);
 }
 
-static void voicecall_watch(struct ofono_atom *atom,
-   enum ofono_atom_watch_condition cond,
-   void *data)
+static void sim_state_watch(enum ofono_sim_state new_state, void *data)
 {
struct ofono_modem *modem = data;
 
-   if (cond == OFONO_ATOM_WATCH_CONDITION_REGISTERED) {
-   modems = g_list_append(modems, modem);
-
-   if (modems->next == NULL)
-   server = bluetooth_register_server(HFP_AG_CHANNEL,
-   hfp_ag_record,
-   hfp_ag_connect_cb,
-   NULL);
-   } else {
+   if (new_state != OFONO_SIM_STATE_READY) {
modems = g_list_remove(modems, modem);
if (modems == NULL && server != NULL) {
bluetooth_unregister_server(server);
server = NULL;
}
+   return;
}
+
+   if (__ofono_modem_find_atom(modem, OFONO_ATOM_TYPE_VOICECALL)
+   == NULL)
+   return;
+
+   modems = g_list_append(modems, modem);
+
+   if (modems->next == NULL)
+   server = bluetooth_register_server(HFP_AG_CHANNEL,
+   hfp_ag_record,
+   hfp_ag_connect_cb,
+   NULL);
+}
+
+static gboolean sim_watch_remove(gpointer key, gpointer value,
+   gpointer user_data)
+{
+   struct ofono_sim *sim = key;
+   struct sim_entry *s = value;
+
+   ofono_sim_remove_state_watch(sim, s->watch);
+   sim_state_watch(OFONO_SIM_STATE_NOT_PRESENT, s->modem);
+
+   return TRUE;
+}
+
+static void sim_watch(struct ofono_atom *atom,
+   enum ofono_atom_watch_condition cond,
+   void *data)
+{
+   struct ofono_sim *sim = __ofono_atom_get_data(atom);
+   struct ofono_modem *modem = data;
+   struct sim_entry *s;
+
+   if (cond == OFONO_ATOM_WATCH_CONDITION_UNREGISTERED) {
+   sim_watch_remove(sim, g_hash_table_lookup(sim_hash, sim), NULL);
+   g_hash_table_remove(sim_hash, sim);
+   return;
+   }
+
+   s = g_try_new0(struct sim_entry, 1);
+   if (s == NULL) {
+   ofono_error("Unable to allocate sim entry structure");
+   return;
+   }
+
+   s->modem = modem;
+   s->watch = ofono_sim_add_state_watch(sim, sim_state_watch, modem, NULL);
+   g_hash_table_insert(sim_hash, sim, s);
+   sim_state_watch(ofono_sim_get_state(sim), modem);
 }
 
 static void modem_watch(struct ofono_modem *modem, gboolean added, void *user)
@@ -145,8 +192,8 @@ static void modem_watch(struct ofono_modem *modem, gboolean 
added, void *user)
if (added == FALSE)
return;
 
-   __ofono_modem_add_atom_watch(modem, OFONO_ATOM_TYPE_VOICECALL,
-   voicecall_watch, modem, NULL);
+   __ofono_modem_add_atom_watch(modem, OFONO_ATOM_TYPE_SIM,
+   sim_watch, modem, NULL);
 }
 
 static void call_modemwatch(struct ofono_modem *modem, void *user)
@@ -156,6 +203,9 @@ static void call_modemwatch(struct ofono_modem *modem, void 
*user)
 
 static int hfp_ag_init()
 {
+   sim_hash = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL,
+   g_free);
+
modemwatch_id = __ofono_modemwatch_add(modem_watch, NULL, NULL);
__ofono_modem_foreach(call_modemwatch, NULL);
 
@@ -165,12 +215,9 @@ static int hfp_ag_init()
 static void hfp_ag_exit()
 {
__ofono_modemwatch_remove(modemwatch_id);
+   g_hash_table_foreach_remove(sim_hash, sim_watch_remove, NULL);
+   g_hash_table_dest

RE: [PATCH] ifxmodem: emergency number list support

2011-07-20 Thread jeevaka . badrappan
Hi,

> Hi Jeevaka,
>
> I'm Nicolas Paccou, I'm in charge of validating the changes applied in new
> oFono release.
> Unfortunately, I have not the hardware to be able to regress your patch:
> "Add support for handling IFX emergency number list"
>
> I wanted to know if you have tested your patch on IFX modem ?
> If yes, can you tell me if the result is ok ?
> If not, do you able to test it and tell me the result please ?

Yep, this has been tested with the IFX modem FW which supports XLEMA.

Regards,
Jeevaka
___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH v2] TODO: add HFP 1.6 AG tasks

2011-07-20 Thread Frédéric Danis
---
 TODO |   14 ++
 1 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/TODO b/TODO
index 8302f6f..b464b19 100644
--- a/TODO
+++ b/TODO
@@ -132,6 +132,20 @@ Modem Emulator
   Complexity: C4
   Priority: Medium
 
+- Support new HFP 1.6 AG command related to indicators (AT+BIA).
+
+  Complexity: C1
+  Priority: Low
+  Owner: Frédéric Danis 
+  Depends: HFP AG emulator
+
+- Support new HFP 1.6 AG commands allowing to publish, select and connect audio
+  codecs (AT+BAC, AT+BCS, +BCS, AT+BCC). This will need to interact with audio
+  framework.
+
+  Complexity: C4
+  Priority: Low
+  Depends: HFP AG emulator
 
 PPP
 ===
-- 
1.7.1

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH] TODO: add HFP 1.6 AG tasks

2011-07-20 Thread Frédéric Danis
---
 TODO |   12 
 1 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/TODO b/TODO
index 8302f6f..4530407 100644
--- a/TODO
+++ b/TODO
@@ -132,6 +132,18 @@ Modem Emulator
   Complexity: C4
   Priority: Medium
 
+- Support new HFP 1.6 AG command related to indicators (AT+BIA).
+
+  Complexity: C1
+  Priority: Low
+  Owner: Frédéric Danis 
+
+- Support new HFP 1.6 AG commands allowing to publish, select and connect audio
+  codecs (AT+BAC, AT+BCS, +BCS, AT+BCC). This will need to interact with audio
+  framework.
+
+  Complexity: C4
+  Priority: Low
 
 PPP
 ===
-- 
1.7.1

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


RE: [PATCH v3] Add basic Telit UC864-G support:

2011-07-20 Thread Paccou, Nicolas
Hi Bernard,

I'm Nicolas Paccou, I'm in charge of validating the changes applied in new 
oFono release.
Unfortunately, I have not the hardware to be able to regress your patch: "Add 
support for Telit UC864-G devices"

I wanted to know if you have tested your patch on Telit UC864-G devices ?
If yes, can you tell me if the result is ok ?
If not, do you able to test it and tell me the result please ?

Thanks,
Nicolas

-Original Message-
From: ofono-boun...@ofono.org [mailto:ofono-boun...@ofono.org] On Behalf Of 
Bernhard Guillon
Sent: Wednesday, June 08, 2011 5:42 PM
To: ofono@ofono.org
Subject: Re: [PATCH v3] Add basic Telit UC864-G support:



On Tue, 7 Jun 2011, Marcel Holtmann wrote:

>> +switch (status) {
>> +case 0:
>> +DBG("SIM not inserted");
>> +ofono_sim_inserted_notify(data->sim, FALSE);
>> +break;
>> +case 1:
>> +DBG("SIM inserted");
>> +/* We need to sleep a bit */
>> +g_timeout_add_seconds(1, sim_inserted_notify_with_timeout,
>> +modem);
>> +break;
>> +case 2:
>> +DBG("SIM inserted and PIN unlocked");
>> +break;
>> +case 3:
>> +DBG("SIM inserted and ready");
>> +break;
>
> Why are you not handling any of case 2 or 3. Are they not also mean that
> SIM is inserted. Or do they always are followed by case 1.
>

The states 2 and 3 never occurred it always reports only one event, which 
is 1. I added the other states because the manual describes them as 
something which should happen. Should I print an error or remove it?

>> +
>> +DBG("%p", modem);
>> +
>> +if (!ok) {
>> +g_at_chat_unref(data->chat);
>> +data->chat = NULL;
>> +return;
>
> If I am not mistaken, then the set_powered(FALSE) call is missing here.
> Did you test this code path?

You are right I did not test this code path. I just tested it with if (ok) 
and the path is wrong.

I added it to the new patch.

Best regards,
Bernhard


--
Scanned by MailScanner.

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono
-
Intel Corporation SAS (French simplified joint stock company)
Registered headquarters: "Les Montalets"- 2, rue de Paris, 
92196 Meudon Cedex, France
Registration Number:  302 456 199 R.C.S. NANTERRE
Capital: 4,572,000 Euros

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


Re: [PATCH] ofono.rules: Add rules for Tata ZTE MF 631

2011-07-20 Thread Denis Kenzior
Hi Bertrand,

On 07/20/2011 12:41 AM, Bertrand Aygon wrote:
> ---
>  plugins/ofono.rules |3 +++
>  1 files changed, 3 insertions(+), 0 deletions(-)
> 

Patch has been applied, thanks.

Regards,
-Denis
___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


RE: [PATCH] ifxmodem: emergency number list support

2011-07-20 Thread Paccou, Nicolas
Hi Jeevaka,

I'm Nicolas Paccou, I'm in charge of validating the changes applied in new 
oFono release.
Unfortunately, I have not the hardware to be able to regress your patch: "Add 
support for handling IFX emergency number list"

I wanted to know if you have tested your patch on IFX modem ?
If yes, can you tell me if the result is ok ?
If not, do you able to test it and tell me the result please ?

Thanks,
Nicolas

-Original Message-
From: ofono-boun...@ofono.org [mailto:ofono-boun...@ofono.org] On Behalf Of 
Jeevaka Badrappan
Sent: Wednesday, June 08, 2011 5:45 PM
To: ofono@ofono.org
Subject: [PATCH] ifxmodem: emergency number list support

---
 drivers/ifxmodem/voicecall.c |   95 ++
 1 files changed, 95 insertions(+), 0 deletions(-)

diff --git a/drivers/ifxmodem/voicecall.c b/drivers/ifxmodem/voicecall.c
index 87a48e6..0aa83e4 100644
--- a/drivers/ifxmodem/voicecall.c
+++ b/drivers/ifxmodem/voicecall.c
@@ -42,11 +42,13 @@
 #include "ifxmodem.h"
 
 static const char *none_prefix[] = { NULL };
+static const char *xlema_prefix[] = { "+XLEMA:", NULL };
 
 struct voicecall_data {
GSList *calls;
unsigned int local_release;
GAtChat *chat;
+   char **en_list;
 };
 
 struct release_id_req {
@@ -786,6 +788,93 @@ static void xcolp_notify(GAtResult *result, gpointer 
user_data)
ofono_voicecall_notify(vc, call);
 }
 
+static void xlema_notify(GAtResult *result, gpointer user_data)
+{
+   struct ofono_voicecall *vc = user_data;
+   struct voicecall_data *vd = ofono_voicecall_get_data(vc);
+   GAtResultIter iter;
+   int index, total_cnt;
+   const char *number;
+   int count = (vd->en_list == NULL) ? 0 : g_strv_length(vd->en_list);
+
+   g_at_result_iter_init(&iter, result);
+
+   if (!g_at_result_iter_next(&iter, "+XLEMA:"))
+   return;
+
+   if (!g_at_result_iter_next_number(&iter, &index))
+   return;
+
+   if (!g_at_result_iter_next_number(&iter, &total_cnt))
+   return;
+
+   if (!g_at_result_iter_next_string(&iter, &number))
+   return;
+
+   /* Skip the category, valid in simpresent and mcc fields */
+
+   if (vd->en_list == NULL)
+   vd->en_list = g_new0(char *, total_cnt + 1);
+
+   vd->en_list[count] = g_strdup(number);
+
+   if (index != total_cnt)
+   return;
+
+   ofono_voicecall_en_list_notify(vc, vd->en_list);
+
+   g_strfreev(vd->en_list);
+   vd->en_list = NULL;
+}
+
+static void xlema_read(gboolean ok, GAtResult *result, gpointer user_data)
+{
+   struct ofono_voicecall *vc = user_data;
+   struct voicecall_data *vd = ofono_voicecall_get_data(vc);
+   GAtResultIter iter;
+   int num = 0;
+   int index, total_cnt;
+   const char *number;
+
+   if (!ok) {
+   DBG("Emergency number list read failed");
+   return;
+   }
+
+   g_at_result_iter_init(&iter, result);
+
+   while (g_at_result_iter_next(&iter, "+XLEMA:"))
+   num += 1;
+
+   vd->en_list = g_new0(char *, num + 1);
+
+   num = 0;
+   g_at_result_iter_init(&iter, result);
+
+   while (g_at_result_iter_next(&iter, "+XLEMA:")) {
+   if (!g_at_result_iter_next_number(&iter, &index))
+   continue;
+
+   if (!g_at_result_iter_next_number(&iter, &total_cnt))
+   continue;
+
+   if (!g_at_result_iter_next_string(&iter, &number))
+   continue;
+
+   /* Skip the category, valid in simpresent and mcc fields */
+   g_at_result_iter_skip_next(&iter);
+   g_at_result_iter_skip_next(&iter);
+   g_at_result_iter_skip_next(&iter);
+
+   vd->en_list[num++] = g_strdup(number);
+   }
+
+   ofono_voicecall_en_list_notify(vc, vd->en_list);
+
+   g_strfreev(vd->en_list);
+   vd->en_list = NULL;
+}
+
 static void ifx_voicecall_initialized(gboolean ok, GAtResult *result,
gpointer user_data)
 {
@@ -802,6 +891,10 @@ static void ifx_voicecall_initialized(gboolean ok, 
GAtResult *result,
g_at_chat_register(vd->chat, "+XCALLSTAT:", xcallstat_notify,
FALSE, vc, NULL);
g_at_chat_register(vd->chat, "+XCOLP:", xcolp_notify, FALSE, vc, NULL);
+   g_at_chat_register(vd->chat, "+XLEMA:", xlema_notify, FALSE, vc, NULL);
+   /* Enable emergency number list notification */
+   g_at_chat_send(vd->chat, "AT+XLEMA=1", xlema_prefix, xlema_read, vc,
+   NULL);
 
ofono_voicecall_register(vc);
 }
@@ -840,6 +933,8 @@ static void ifx_voicecall_remove(struct ofono_voicecall *vc)
g_slist_foreach(vd->calls, (GFunc) g_free, NULL);
g_slist_free(vd->calls);
 
+   g_strfreev(vd->en_list);
+

RE: [PATCH] CDMA ConnMan API: add username and password for PPP authentication.

2011-07-20 Thread Marcel Holtmann
Hi Bertrand,

> >Have you tried empty strings like "". Have you tried random values? Do
> >they have to be really specific ones.
> >
> >Is the password checked? Or just the username? Maybe they treat the
> >username as pseudo APN of some sort, but the password means nothing.
> >
> >OFONO_PPP_DEBUG for starters. And then using cdmadial to create a full
> >pppdump compatible log would be good idea. Something that we can open in
> >Wireshark.
> 
> Here are cdmadial result with multiple possibility. The one with 2 tty is 
> funy ;)
> 
> So from the result, I can tell that both login and password are checked.

fair enough. That is enough for me to confirm that it is used in real
networks. We do not like to add APIs for something that is not used
anymore only because some specification or RFC says so ;)

Patch has been applied now. However I changed the commit prefix back to
doc: to make it look cleaner.

For you two TTY cases. That is normal. Huawei treats the first TTY as
modem to issue PPP on it. And the second one (PCUI) is used for
notifications. So yes, oFono needs to open both. You will need the
second one for network registration updates.

Regards

Marcel


___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


RE: [PATCH] isimodem: Improper handling of missed call

2011-07-20 Thread Paccou, Nicolas
Hi Aki,

I'm Nicolas Paccou, I'm in charge of validating the changes applied in new 
oFono release.
Unfortunately, I have not the hardware to be able to regress your patch: "Add 
support for UICC SIM driver for ISI modems"

I wanted to know if you have tested your patch on an ISI modem ?
If yes, can you tell me if the result is ok ?
If not, do you able to test it and tell me the result please ?

Thanks,
Nicolas

-Original Message-
From: ofono-boun...@ofono.org [mailto:ofono-boun...@ofono.org] On Behalf Of Aki 
Niemi
Sent: Tuesday, June 14, 2011 10:30 AM
To: ofono@ofono.org
Subject: Re: [PATCH] isimodem: Improper handling of missed call

Hi Arun,

2011/5/30 Arun Ravindran :
>> Can you post logs on such a successful case, if you have any around?
>>
>
> tested once again, its working for me. I have attached the log here.
>
> But here i am using as n900 modem and not as isiusb .

It seems to be working for me now using the isiusb plugin.

So I pushed the patch along with the WS fixes.

Sorry for the delay.

Cheers,
Aki
___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono
-
Intel Corporation SAS (French simplified joint stock company)
Registered headquarters: "Les Montalets"- 2, rue de Paris, 
92196 Meudon Cedex, France
Registration Number:  302 456 199 R.C.S. NANTERRE
Capital: 4,572,000 Euros

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


RE: [PATCH] CDMA ConnMan API: add username and password for PPP authentication.

2011-07-20 Thread Aygon, Bertrand
Hi,

>Have you tried empty strings like "". Have you tried random values? Do
>they have to be really specific ones.
>
>Is the password checked? Or just the username? Maybe they treat the
>username as pseudo APN of some sort, but the password means nothing.
>
>OFONO_PPP_DEBUG for starters. And then using cdmadial to create a full
>pppdump compatible log would be good idea. Something that we can open in
>Wireshark.

Here are cdmadial result with multiple possibility. The one with 2 tty is funy 
;)

So from the result, I can tell that both login and password are checked.

If you want another test or if I missed one interesting, feel free to ask.

Regards,

Marcel


___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono
-
Intel Corporation SAS (French simplified joint stock company)
Registered headquarters: "Les Montalets"- 2, rue de Paris, 
92196 Meudon Cedex, France
Registration Number:  302 456 199 R.C.S. NANTERRE
Capital: 4,572,000 Euros

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.
bertrand@bertrand-Latitude-E5410:ofono (master *%)$ sudo ./gatchat/cdmadial 
--control /dev/ttyUSB0 --username a...@aha.co.id
Control: /dev/ttyUSB0
APN: (null)
CID: 0
: > ATE0Q0V1\r
: < \r\nOK\r\n
: > AT+CFUN?\r
: < \r\n+CFUN: 1\r\n\r\nOK\r\n
Current modem mode is 1
: > ATD#777\r
: < \r\nCONNECT 310\r\n
Username: a...@aha.co.id
Password: (null)
PPP: lcp: pppcp_generate_event: current state 0:INITIAL
PPP: event: 0 (Up), action: 2, new_state: 2 (CLOSED)
PPP: lcp: pppcp_generate_event: current state 2:CLOSED
PPP: event: 2 (Open), action: 1026, new_state: 6 (REQSENT)
PPP: lcp: pppcp_initialize_restart_count: current state 2:CLOSED
PPP: lcp: pppcp_send_configure_request: current state 2:CLOSED
PPP: gatchat/gatppp.c:ppp_enter_phase() 1
PPP: lcp: pppcp_timeout: current state 6:REQSENT
PPP: lcp: pppcp_generate_event: current state 6:REQSENT
PPP: event: 4 (TO+), action: 1006, new_state: 6 (REQSENT)
PPP: lcp: pppcp_send_configure_request: current state 6:REQSENT
PPP: lcp: pppcp_timeout: current state 6:REQSENT
PPP: lcp: pppcp_generate_event: current state 6:REQSENT
PPP: event: 4 (TO+), action: 1006, new_state: 6 (REQSENT)
PPP: lcp: pppcp_send_configure_request: current state 6:REQSENT
PPP: lcp: pppcp_process_configure_request: current state 6:REQSENT
PPP: lcp: pppcp_generate_event: current state 6:REQSENT
PPP: event: 7 (RCR-), action: 4006, new_state: 6 (REQSENT)
PPP: lcp: pppcp_send_configure_nak: current state 6:REQSENT
PPP: lcp: pppcp_process_configure_request: current state 6:REQSENT
PPP: lcp: pppcp_generate_event: current state 6:REQSENT
PPP: event: 6 (RCR+), action: 2008, new_state: 8 (ACKSENT)
PPP: lcp: pppcp_send_configure_ack: current state 6:REQSENT
PPP: lcp: pppcp_timeout: current state 8:ACKSENT
PPP: lcp: pppcp_generate_event: current state 8:ACKSENT
PPP: event: 4 (TO+), action: 1008, new_state: 8 (ACKSENT)
PPP: lcp: pppcp_send_configure_request: current state 8:ACKSENT
PPP: lcp: pppcp_process_configure_ack: current state 8:ACKSENT
PPP: lcp: pppcp_generate_event: current state 8:ACKSENT
PPP: event: 8 (RCA), action: 129, new_state: 9 (OPENED)
PPP: lcp: pppcp_initialize_restart_count: current state 8:ACKSENT
PPP: gatchat/gatppp.c:ppp_enter_phase() 2
PPP: lcp: pppcp_generate_event: current state 9:OPENED
PPP: event: 3 (Close), action: 8224, new_state: 4 (CLOSING)
PPP: lcp: pppcp_initialize_restart_count: current state 9:OPENED
PPP: lcp: pppcp_send_terminate_request: current state 9:OPENED
PPP: gatchat/gatppp.c:ppp_enter_phase() 5
PPP: lcp: pppcp_process_terminate_request: current state 4:CLOSING
PPP: lcp: pppcp_generate_event: current state 4:CLOSING
PPP: event: 10 (RTR), action: 10004, new_state: 4 (CLOSING)
PPP: lcp: pppcp_send_terminate_ack: current state 4:CLOSING
PPP: gatchat/gatppp.c:sta_sent() 
PPP: lcp: pppcp_process_terminate_ack: current state 4:CLOSING
PPP: lcp: pppcp_generate_event: current state 4:CLOSING
PPP: event: 11 (RTA), action: 802, new_state: 2 (CLOSED)
PPP: lcp: pppcp_this_layer_finished: current state 2:CLOSED
PPP: gatchat/gatppp.c:ppp_enter_phase() 0
PPP: gatchat/gatppp.c:ppp_dead() 
PPP Link down: 1


bertrand@bertrand-Latitude-E5410:ofono (master *%)$ sudo ./gatchat/cdmadial 
--control /dev/ttyUSB0 --username a...@aha.co.id --password aha
Control: /dev/ttyUSB0
APN: (null)
CID: 0
: > ATE0Q0V1\r
: < \r\nOK\r\n
: > AT+CFUN?\r
: < \r\n+CFUN: 1\r\n\r\nOK\r\n
Current modem mode is 1
: > ATD#777\r
: < \r\nCONNECT 153600\r\n
Username: a...@aha.co.id
Password: aha
PPP: lcp: pppcp_generate_event: current state 0:INITIAL
PPP: event: 0 (Up), action: 2, new_state: 2 (CLOSED)
PPP: lcp: pppcp_generate_event: current state 2:CLOSED
PPP: event: 2 (Open), action: 1026, new

Re: [PATCH_v3] speedupcdma: add speedup cdma skeleton plugin

2011-07-20 Thread Marcel Holtmann
Hi Guillaume,

> Remove unused variable into speedupcdma_remove()



> +static void speedupcdma_remove(struct ofono_modem *modem)
> +{
> + DBG("%p", modem);
> +
> + ofono_modem_set_data(modem, NULL);
> +}

You do actually have to free the data. Otherwise you are leaking memory.

Regards

Marcel


___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


Re: [PATCH_v2] plugins: update ofono rule and udev for using speedupcdma

2011-07-20 Thread Marcel Holtmann
Hi Guillaume,

> >> -# SpeedUp
> >> -ATTRS{idVendor}=="1c9e", ENV{OFONO_DRIVER}="speedup"
> >> +# SpeedUp 7300
> >> +ATTRS{idVendor}=="1c9e", ATTRS{idProduct}=="9e00", 
> >> ENV{OFONO_DRIVER}="speedupcdma"
> >> +
> >> +# SpeedUp 9800
> >> +ATTRS{idVendor}=="1c9e", ATTRS{idProduct}=="9800", 
> >> ENV{OFONO_DRIVER}="speedup"
> >>
> >> -ATTRS{idVendor}=="1c9e", ATTRS{serial}=="1234567890ABCDEF", 
> >> ENV{ID_SERIAL_SHORT}=""
> >> +ATTRS{idVendor}=="1c9e", ATTRS{idProduct}=="9800", 
> >> ATTRS{serial}=="1234567890ABCDEF", ENV{ID_SERIAL_SHORT}=""
> > is the serial number really fake. Adding the content of usb-devices
> > script for this specific modem would help here.
> >
> > Or has this just been copied over from the Huawei entries and we missed
> > it in the review?
> 
> Sorry I committed a wrong patch, I will send you the right version of 
> this patch later.
> This serial, is not a fake, in using usb-devices with the dongle I got 
> before usb_modeswitch:
> 
> T:  Bus=02 Lev=02 Prnt=02 Port=00 Cnt=01 Dev#= 84 Spd=480 MxCh= 0
> D:  Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs=  1
> P:  Vendor=1c9e ProdID=9800 Rev=00.00
> S:  Manufacturer=USB Modem
> S:  Product=USB Modem
> S:  SerialNumber=1234567890ABCDEF
> C:  #Ifs= 2 Cfg#= 1 Atr=e0 MxPwr=500mA
> I:  If#= 0 Alt= 0 #EPs= 2 Cls=08(stor.) Sub=06 Prot=50 Driver=usb-storage
> I:  If#= 1 Alt= 0 #EPs= 2 Cls=08(stor.) Sub=06 Prot=50 Driver=usb-storage

this is a fake serial number, but that is fine, it is before the mode
switch to TTY mode. I care about the serial number after mode switch.

Regards

Marcel


___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


Re: [PATCH_v2] plugins: update ofono rule and udev for using speedupcdma

2011-07-20 Thread Guillaume Zajac

Hi Marcel,

On 20/07/2011 13:02, Marcel Holtmann wrote:

Hi Guillaume,


-# SpeedUp
-ATTRS{idVendor}=="1c9e", ENV{OFONO_DRIVER}="speedup"
+# SpeedUp 7300
+ATTRS{idVendor}=="1c9e", ATTRS{idProduct}=="9e00", 
ENV{OFONO_DRIVER}="speedupcdma"
+
+# SpeedUp 9800
+ATTRS{idVendor}=="1c9e", ATTRS{idProduct}=="9800", ENV{OFONO_DRIVER}="speedup"

-ATTRS{idVendor}=="1c9e", ATTRS{serial}=="1234567890ABCDEF", 
ENV{ID_SERIAL_SHORT}=""
+ATTRS{idVendor}=="1c9e", ATTRS{idProduct}=="9800", ATTRS{serial}=="1234567890ABCDEF", 
ENV{ID_SERIAL_SHORT}=""

is the serial number really fake. Adding the content of usb-devices
script for this specific modem would help here.

Or has this just been copied over from the Huawei entries and we missed
it in the review?


Sorry I committed a wrong patch, I will send you the right version of 
this patch later.
This serial, is not a fake, in using usb-devices with the dongle I got 
before usb_modeswitch:


T:  Bus=02 Lev=02 Prnt=02 Port=00 Cnt=01 Dev#= 84 Spd=480 MxCh= 0
D:  Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs=  1
P:  Vendor=1c9e ProdID=9800 Rev=00.00
S:  Manufacturer=USB Modem
S:  Product=USB Modem
S:  SerialNumber=1234567890ABCDEF
C:  #Ifs= 2 Cfg#= 1 Atr=e0 MxPwr=500mA
I:  If#= 0 Alt= 0 #EPs= 2 Cls=08(stor.) Sub=06 Prot=50 Driver=usb-storage
I:  If#= 1 Alt= 0 #EPs= 2 Cls=08(stor.) Sub=06 Prot=50 Driver=usb-storage





  ATTRS{idVendor}=="2020", ENV{OFONO_DRIVER}="speedup"

diff --git a/plugins/udev.c b/plugins/udev.c
index a28bea7..b50ca2f 100644
--- a/plugins/udev.c
+++ b/plugins/udev.c
@@ -793,6 +793,8 @@ done:
add_linktop(modem, udev_device);
  else if (g_strcmp0(driver, "speedup") == 0)
add_speedup(modem, udev_device);
+   else if (g_strcmp0(driver, "speedupcdma") == 0)
+   add_speedup(modem, udev_device);

Coding style mistake here. Tabs vs spaces.

Regards

Marcel



Kind regards,
Guillaume
___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH_v3] speedupcdma: add speedup cdma skeleton plugin

2011-07-20 Thread Guillaume Zajac
Remove unused variable into speedupcdma_remove()

---
 Makefile.am   |3 +
 plugins/speedupcdma.c |  207 +
 2 files changed, 210 insertions(+), 0 deletions(-)
 create mode 100644 plugins/speedupcdma.c

diff --git a/Makefile.am b/Makefile.am
index a4e6c95..4b72091 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -336,6 +336,9 @@ builtin_sources += plugins/telit.c
 builtin_modules += speedup
 builtin_sources += plugins/speedup.c
 
+builtin_modules += speedupcdma
+builtin_sources += plugins/speedupcdma.c
+
 if BLUETOOTH
 builtin_modules += bluetooth
 builtin_sources += plugins/bluetooth.c plugins/bluetooth.h
diff --git a/plugins/speedupcdma.c b/plugins/speedupcdma.c
new file mode 100644
index 000..9da6200
--- /dev/null
+++ b/plugins/speedupcdma.c
@@ -0,0 +1,207 @@
+/*
+ *
+ *  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 
+#endif
+
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+#define OFONO_API_SUBJECT_TO_CHANGE
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+static const char *none_prefix[] = { NULL };
+
+struct speedupcdma_data {
+   GAtChat *chat;
+};
+
+static void speedupcdma_debug(const char *str, void *data)
+{
+   const char *prefix = data;
+
+   ofono_info("%s%s", prefix, str);
+}
+
+static int speedupcdma_probe(struct ofono_modem *modem)
+{
+   struct speedupcdma_data *data;
+
+   DBG("%p", modem);
+
+   data = g_try_new0(struct speedupcdma_data, 1);
+   if (data == NULL)
+   return -ENOMEM;
+
+   ofono_modem_set_data(modem, data);
+
+   return 0;
+}
+
+static void speedupcdma_remove(struct ofono_modem *modem)
+{
+   DBG("%p", modem);
+
+   ofono_modem_set_data(modem, NULL);
+}
+
+static void cfun_enable(gboolean ok, GAtResult *result, gpointer user_data)
+{
+   struct ofono_modem *modem = user_data;
+
+   DBG("");
+
+   if (!ok) {
+   struct speedupcdma_data *data = ofono_modem_get_data(modem);
+
+   g_at_chat_unref(data->chat);
+   data->chat == NULL;
+
+   ofono_modem_set_powered(modem, FALSE);
+   return;
+   }
+
+   ofono_modem_set_powered(modem, TRUE);
+}
+
+static int speedupcdma_enable(struct ofono_modem *modem)
+{
+   struct speedupcdma_data *data = ofono_modem_get_data(modem);
+   GAtSyntax *syntax;
+   GIOChannel *channel;
+   const char *modem_path;
+
+   modem_path = ofono_modem_get_string(modem, "Modem");
+   if (modem_path == NULL)
+   return -EINVAL;
+
+   DBG("path is: %s", modem_path);
+
+   channel = g_at_tty_open(modem_path, NULL);
+   if (channel == NULL)
+   return -EIO;
+
+   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, speedupcdma_debug, "Modem: ");
+
+   g_at_chat_send(data->chat, "ATE0 +CMEE=1", none_prefix,
+   NULL, NULL, NULL);
+
+   g_at_chat_send(data->chat, "AT+CFUN=1", none_prefix,
+   cfun_enable, modem, NULL);
+
+   return -EINPROGRESS;
+}
+
+static void cfun_disable(gboolean ok, GAtResult *result, gpointer user_data)
+{
+   struct ofono_modem *modem = user_data;
+   struct speedupcdma_data *data = ofono_modem_get_data(modem);
+
+   DBG("");
+
+   g_at_chat_unref(data->chat);
+   data->chat = NULL;
+
+   if (ok)
+   ofono_modem_set_powered(modem, FALSE);
+}
+
+static int speedupcdma_disable(struct ofono_modem *modem)
+{
+   struct speedupcdma_data *data = ofono_modem_get_data(modem);
+
+   DBG("%p", modem);
+
+   g_at_chat_send(data->chat, "AT+CFUN=0", none_prefix,
+   cfun_disable, modem, NULL);
+
+   return -EINPROGRESS;
+}
+
+static void speedupcdma_pre_sim(struct ofono_modem *modem)
+{
+   struct speedupcdma_data *data = ofono_modem_get_data(m

Re: [PATCH_v2] plugins: update ofono rule and udev for using speedupcdma

2011-07-20 Thread Marcel Holtmann
Hi Guillaume,

> -# SpeedUp
> -ATTRS{idVendor}=="1c9e", ENV{OFONO_DRIVER}="speedup"
> +# SpeedUp 7300
> +ATTRS{idVendor}=="1c9e", ATTRS{idProduct}=="9e00", 
> ENV{OFONO_DRIVER}="speedupcdma"
> +
> +# SpeedUp 9800
> +ATTRS{idVendor}=="1c9e", ATTRS{idProduct}=="9800", 
> ENV{OFONO_DRIVER}="speedup"
>  
> -ATTRS{idVendor}=="1c9e", ATTRS{serial}=="1234567890ABCDEF", 
> ENV{ID_SERIAL_SHORT}=""
> +ATTRS{idVendor}=="1c9e", ATTRS{idProduct}=="9800", 
> ATTRS{serial}=="1234567890ABCDEF", ENV{ID_SERIAL_SHORT}=""

is the serial number really fake. Adding the content of usb-devices
script for this specific modem would help here.

Or has this just been copied over from the Huawei entries and we missed
it in the review?
 
>  ATTRS{idVendor}=="2020", ENV{OFONO_DRIVER}="speedup"
>  
> diff --git a/plugins/udev.c b/plugins/udev.c
> index a28bea7..b50ca2f 100644
> --- a/plugins/udev.c
> +++ b/plugins/udev.c
> @@ -793,6 +793,8 @@ done:
>   add_linktop(modem, udev_device);
>  else if (g_strcmp0(driver, "speedup") == 0)
>   add_speedup(modem, udev_device);
> + else if (g_strcmp0(driver, "speedupcdma") == 0)
> + add_speedup(modem, udev_device);

Coding style mistake here. Tabs vs spaces.

Regards

Marcel


___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH_v2] plugins: update ofono rule and udev for using speedupcdma

2011-07-20 Thread Guillaume Zajac
---
 plugins/ofono.rules |9 ++---
 plugins/udev.c  |2 ++
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/plugins/ofono.rules b/plugins/ofono.rules
index 1aef4bd..54df1bc 100644
--- a/plugins/ofono.rules
+++ b/plugins/ofono.rules
@@ -420,10 +420,13 @@ ATTRS{idVendor}=="19d2", ENV{OFONO_DRIVER}="zte"
 
 ATTRS{idVendor}=="19d2", ATTRS{serial}=="1234567890ABCDEF", 
ENV{ID_SERIAL_SHORT}=""
 
-# SpeedUp
-ATTRS{idVendor}=="1c9e", ENV{OFONO_DRIVER}="speedup"
+# SpeedUp 7300
+ATTRS{idVendor}=="1c9e", ATTRS{idProduct}=="9e00", 
ENV{OFONO_DRIVER}="speedupcdma"
+
+# SpeedUp 9800
+ATTRS{idVendor}=="1c9e", ATTRS{idProduct}=="9800", ENV{OFONO_DRIVER}="speedup"
 
-ATTRS{idVendor}=="1c9e", ATTRS{serial}=="1234567890ABCDEF", 
ENV{ID_SERIAL_SHORT}=""
+ATTRS{idVendor}=="1c9e", ATTRS{idProduct}=="9800", 
ATTRS{serial}=="1234567890ABCDEF", ENV{ID_SERIAL_SHORT}=""
 
 ATTRS{idVendor}=="2020", ENV{OFONO_DRIVER}="speedup"
 
diff --git a/plugins/udev.c b/plugins/udev.c
index a28bea7..b50ca2f 100644
--- a/plugins/udev.c
+++ b/plugins/udev.c
@@ -793,6 +793,8 @@ done:
add_linktop(modem, udev_device);
 else if (g_strcmp0(driver, "speedup") == 0)
add_speedup(modem, udev_device);
+   else if (g_strcmp0(driver, "speedupcdma") == 0)
+   add_speedup(modem, udev_device);
 }
 
 static gboolean devpath_remove(gpointer key, gpointer value, gpointer 
user_data)
-- 
1.7.1

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


Re: [PATCH 2/4] cdma-connman: add possibility to set a username and a password

2011-07-20 Thread Guillaume Zajac

Hi Marcel,

On 20/07/2011 11:48, Marcel Holtmann wrote:

Hi Guillaume,


  src/cdma-connman.c |   44 +++-
  1 files changed, 43 insertions(+), 1 deletions(-)

diff --git a/src/cdma-connman.c b/src/cdma-connman.c
index 3321b87..7ca5a0a 100644
--- a/src/cdma-connman.c
+++ b/src/cdma-connman.c
@@ -57,6 +57,8 @@ struct ofono_cdma_connman {
const struct ofono_cdma_connman_driver *driver;
void *driver_data;
struct ofono_atom *atom;
+   char *username;
+   char *password;
  };

I am still not convinced that this is needed. Please provide logs where
it shows that it fails otherwise.


You will find attached an ofono log giving the result in harcoding,
g_at_ppp_set_credentials(cd->ppp, "", ""); before launching PPP session.





  static void cdma_connman_settings_free(struct cdma_connman_settings *settings)
@@ -379,6 +381,8 @@ static DBusMessage 
*cdma_connman_set_property(DBusConnection *conn,
DBusMessageIter var;
const char *property;
dbus_bool_t value;
+   const char *username;
+   const char *password;

DBG("");

@@ -399,7 +403,7 @@ static DBusMessage 
*cdma_connman_set_property(DBusConnection *conn,

dbus_message_iter_recurse(&iter,&var);

-   if (!strcmp(property, "Powered")) {
+   if (!g_strcmp0(property, "Powered")) {

Don't bother here. strcmp is just fine since we know both arguments are
not NULL.

Also if you wanna change this, then please have a separate patch for it.
Intermixing of code with style changes is not a good idea. And we have
always fixed style issues separately.


Ok, I will keep strcmp() fro username and password also, and I will 
commit g_strcmp0() later if needed.



if (dbus_message_iter_get_arg_type(&var) != DBUS_TYPE_BOOLEAN)
return __ofono_error_invalid_args(msg);

@@ -421,6 +425,22 @@ static DBusMessage 
*cdma_connman_set_property(DBusConnection *conn,
cm->driver->deactivate(cm, deactivate_callback, cm);

return dbus_message_new_method_return(msg);
+   } else if (!g_strcmp0(property, "Username")) {
+   if (dbus_message_iter_get_arg_type(&var) != DBUS_TYPE_STRING)
+   return __ofono_error_invalid_args(msg);
+
+   dbus_message_iter_get_basic(&var,&username);
+   cm->username = g_strdup(username);
+   DBG("username: %s", username);
+   return dbus_message_new_method_return(msg);
+   } else if (!g_strcmp0(property, "Password")) {
+   if (dbus_message_iter_get_arg_type(&var) != DBUS_TYPE_STRING)
+   return __ofono_error_invalid_args(msg);
+
+   dbus_message_iter_get_basic(&var,&password);
+   cm->password = g_strdup(password);
+   DBG("password: %s", password);
+   return dbus_message_new_method_return(msg);
}

/* TODO: Dormant property. Not yet supported. */
@@ -488,6 +508,12 @@ static void cdma_connman_remove(struct ofono_atom *atom)
if (cm->driver&&  cm->driver->remove)
cm->driver->remove(cm);

+   if (cm->username)
+   g_free(cm->username);
+
+   if (cm->password)
+   g_free(cm->password);
+

The if check are pointless. g_free (and also free for that matter) does
a NULL check on its parameter.



Right, I forgot about this null check...


@@ -568,3 +594,19 @@ void *ofono_cdma_connman_get_data(struct 
ofono_cdma_connman *cm)
  {
return cm->driver_data;
  }
+
+const char *ofono_cdma_connman_get_username(struct ofono_cdma_connman *cm)
+{
+   if (cm->username)
+   return cm->username;
+
+   return NULL;
+}
+
+const char *ofono_cdma_connman_get_password(struct ofono_cdma_connman *cm)
+{
+   if (cm->password)
+   return cm->password;
+
+   return NULL;
+}

What is wrong with just "return cm->password;". This example is a bit
convoluted right now ;)

The next question is where you want the NULL handling. Or do you want it
all. Please think about that a little bit and maybe have a look at what
GPRS is doing.



Ok

Kind regards,
Guillaume
ofonod[8735]: plugins/speedupcdma.c:speedupcdma_enable() path is: /dev/ttyUSB0
ofonod[8735]: Modem: > ATE0 +CMEE=1\r
ofonod[8735]: plugins/bluetooth.c:manager_properties_cb() 
ofonod[8735]: plugins/bluetooth.c:parse_adapters() 
ofonod[8735]: plugins/bluetooth.c:parse_adapters() Calling GetProperties on /org/bluez/1461/hci0
ofonod[8735]: plugins/bluetooth.c:adapter_properties_cb() 
ofonod[8735]: plugins/bluetooth.c:parse_devices() 
ofonod[8735]: plugins/bluetooth.c:adapter_properties_cb() Adapter Address: 5C:AC:4C:FF:0C:05, Path: /org/bluez/1461/hci0
ofonod[8735]: Modem: < \r\nOK\r\n
ofonod[8735]: Modem: > AT+CFUN=1\r
ofonod[8735]: Modem: < \r\nOK\r\n
ofonod[8735]: plugins/speedupcdma.c:cfun_enable() 
ofonod[8735]: src/modem.c:modem_change_state() old state: 0, new stat

Re: [PATCH] speedupcdma: add speedup cdma skeleton plugin

2011-07-20 Thread Marcel Holtmann
Hi Guillaume,

>  Makefile.am   |3 +
>  plugins/speedupcdma.c |  207 
> +
>  2 files changed, 210 insertions(+), 0 deletions(-)
>  create mode 100644 plugins/speedupcdma.c
> 
> diff --git a/Makefile.am b/Makefile.am
> index a4e6c95..4b72091 100644
> --- a/Makefile.am
> +++ b/Makefile.am
> @@ -336,6 +336,9 @@ builtin_sources += plugins/telit.c
>  builtin_modules += speedup
>  builtin_sources += plugins/speedup.c
>  
> +builtin_modules += speedupcdma
> +builtin_sources += plugins/speedupcdma.c
> +
>  if BLUETOOTH
>  builtin_modules += bluetooth
>  builtin_sources += plugins/bluetooth.c plugins/bluetooth.h
> diff --git a/plugins/speedupcdma.c b/plugins/speedupcdma.c
> new file mode 100644
> index 000..3c8f1b1
> --- /dev/null
> +++ b/plugins/speedupcdma.c
> @@ -0,0 +1,207 @@
> +/*
> + *
> + *  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 
> +#endif
> +
> +#include 
> +#include 
> +#include 
> +
> +#include 
> +#include 
> +#include 
> +
> +#define OFONO_API_SUBJECT_TO_CHANGE
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#include 
> +
> +static const char *none_prefix[] = { NULL };
> +
> +struct speedupcdma_data {
> + GAtChat *chat;
> +};
> +
> +static void speedupcdma_debug(const char *str, void *data)
> +{
> + const char *prefix = data;
> +
> + ofono_info("%s%s", prefix, str);
> +}
> +
> +static int speedupcdma_probe(struct ofono_modem *modem)
> +{
> + struct speedupcdma_data *data;
> +
> + DBG("%p", modem);
> +
> + data = g_try_new0(struct speedupcdma_data, 1);
> + if (data == NULL)
> + return -ENOMEM;
> +
> + ofono_modem_set_data(modem, data);
> +
> + return 0;
> +}
> +
> +static void speedupcdma_remove(struct ofono_modem *modem)
> +{
> + struct speedupcdma_data *data = ofono_modem_get_data(modem);
> +
> + DBG("%p", modem);
> +
> + ofono_modem_set_data(modem, NULL);
> +
> + g_at_chat_unref(data->chat);

I think that I overlooked this one in the Huawei CDMA driver, but this
is wrong. The unref of the chat object needs to be done in the disable
callback.

Doing it here is pretty bad idea since you really do not know if where
ever enabled or not. Please remove it and if I by accident overlooked it
in the Huawei CDMA driver, fix it there as well.

> +
> + g_free(data);
> +}
> +
> +static void cfun_enable(gboolean ok, GAtResult *result, gpointer user_data)
> +{
> + struct ofono_modem *modem = user_data;
> +
> + DBG("");
> +
> + if (!ok) {

I think we have this bug in a few modem plugins that have not been
properly audited yet.

However you are leaking data->chat here and thus you are also leaking
file descriptors and memory.

So please add this before calling set_powered:

g_at_chat_unref(data->chat);
data->chat == NULL;

ofono_modem_set_powered(modem, FALSE);
return;

> + ofono_modem_set_powered(modem, FALSE);
> + return;
> + }

Please add an extra empty line here. You do wanna clearly separate
these.

> + ofono_modem_set_powered(modem, TRUE);
> +}
> +
> +static int speedupcdma_enable(struct ofono_modem *modem)
> +{
> + struct speedupcdma_data *data = ofono_modem_get_data(modem);
> + GAtSyntax *syntax;
> + GIOChannel *channel;
> + const char *modem_path;
> +
> + modem_path = ofono_modem_get_string(modem, "Modem");
> + if (modem_path == NULL)
> + return -EINVAL;
> +
> + DBG("path is: %s", modem_path);
> +
> + channel = g_at_tty_open(modem_path, NULL);
> + if (channel == NULL)
> + return -EIO;
> +
> + 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, speedupcdma_debug, "Modem: ");
> +
> + g_at_chat_send(data->chat, "ATE0 +CMEE=1", none_prefix,
> + NULL, NULL, NULL

RE: [PATCH] CDMA ConnMan API: add username and password for PPP authentication.

2011-07-20 Thread Marcel Holtmann
Hi Betrand,

> >as with the previous attempt to add these fields, are they really really
> >needed? Or is an empty username + password in CHAP also working just
> >fine?
> 
> They are really needed.
> 
> >For GPRS for example all operators are just ignoring these values. At
> >least the few I have known that required them, gave up on it by now.
> 
> We are in Indonesia, and for AHA operator, we have to give a username and a 
> password. If we do not specify them, the PPP negotiation fails.

Have you tried empty strings like "". Have you tried random values? Do
they have to be really specific ones.

Is the password checked? Or just the username? Maybe they treat the
username as pseudo APN of some sort, but the password means nothing.

> >So please try with an empty username + password and show us logs of what
> >is happening on a real network.
> 
> Which log? Pppd log?

OFONO_PPP_DEBUG for starters. And then using cdmadial to create a full
pppdump compatible log would be good idea. Something that we can open in
Wireshark.

Regards

Marcel


___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


Re: [PATCH 2/4] cdma-connman: add possibility to set a username and a password

2011-07-20 Thread Marcel Holtmann
Hi Guillaume,

>  src/cdma-connman.c |   44 +++-
>  1 files changed, 43 insertions(+), 1 deletions(-)
> 
> diff --git a/src/cdma-connman.c b/src/cdma-connman.c
> index 3321b87..7ca5a0a 100644
> --- a/src/cdma-connman.c
> +++ b/src/cdma-connman.c
> @@ -57,6 +57,8 @@ struct ofono_cdma_connman {
>   const struct ofono_cdma_connman_driver *driver;
>   void *driver_data;
>   struct ofono_atom *atom;
> + char *username;
> + char *password;
>  };

I am still not convinced that this is needed. Please provide logs where
it shows that it fails otherwise.
 
>  static void cdma_connman_settings_free(struct cdma_connman_settings 
> *settings)
> @@ -379,6 +381,8 @@ static DBusMessage 
> *cdma_connman_set_property(DBusConnection *conn,
>   DBusMessageIter var;
>   const char *property;
>   dbus_bool_t value;
> + const char *username;
> + const char *password;
>  
>   DBG("");
>  
> @@ -399,7 +403,7 @@ static DBusMessage 
> *cdma_connman_set_property(DBusConnection *conn,
>  
>   dbus_message_iter_recurse(&iter, &var);
>  
> - if (!strcmp(property, "Powered")) {
> + if (!g_strcmp0(property, "Powered")) {

Don't bother here. strcmp is just fine since we know both arguments are
not NULL.

Also if you wanna change this, then please have a separate patch for it.
Intermixing of code with style changes is not a good idea. And we have
always fixed style issues separately.

>   if (dbus_message_iter_get_arg_type(&var) != DBUS_TYPE_BOOLEAN)
>   return __ofono_error_invalid_args(msg);
>  
> @@ -421,6 +425,22 @@ static DBusMessage 
> *cdma_connman_set_property(DBusConnection *conn,
>   cm->driver->deactivate(cm, deactivate_callback, cm);
>  
>   return dbus_message_new_method_return(msg);
> + } else if (!g_strcmp0(property, "Username")) {
> + if (dbus_message_iter_get_arg_type(&var) != DBUS_TYPE_STRING)
> + return __ofono_error_invalid_args(msg);
> +
> + dbus_message_iter_get_basic(&var, &username);
> + cm->username = g_strdup(username);
> + DBG("username: %s", username);
> + return dbus_message_new_method_return(msg);
> + } else if (!g_strcmp0(property, "Password")) {
> + if (dbus_message_iter_get_arg_type(&var) != DBUS_TYPE_STRING)
> + return __ofono_error_invalid_args(msg);
> +
> + dbus_message_iter_get_basic(&var, &password);
> + cm->password = g_strdup(password);
> + DBG("password: %s", password);
> + return dbus_message_new_method_return(msg);
>   }
>  
>   /* TODO: Dormant property. Not yet supported. */
> @@ -488,6 +508,12 @@ static void cdma_connman_remove(struct ofono_atom *atom)
>   if (cm->driver && cm->driver->remove)
>   cm->driver->remove(cm);
>  
> + if (cm->username)
> + g_free(cm->username);
> +
> + if (cm->password)
> + g_free(cm->password);
> +

The if check are pointless. g_free (and also free for that matter) does
a NULL check on its parameter.

> @@ -568,3 +594,19 @@ void *ofono_cdma_connman_get_data(struct 
> ofono_cdma_connman *cm)
>  {
>   return cm->driver_data;
>  }
> +
> +const char *ofono_cdma_connman_get_username(struct ofono_cdma_connman *cm)
> +{
> + if (cm->username)
> + return cm->username;
> +
> + return NULL;
> +}
> +
> +const char *ofono_cdma_connman_get_password(struct ofono_cdma_connman *cm)
> +{
> + if (cm->password)
> + return cm->password;
> +
> + return NULL;
> +}

What is wrong with just "return cm->password;". This example is a bit
convoluted right now ;)

The next question is where you want the NULL handling. Or do you want it
all. Please think about that a little bit and maybe have a look at what
GPRS is doing.

Regards

Marcel


___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


RE: [PATCH] CDMA ConnMan API: add username and password for PPP authentication.

2011-07-20 Thread Aygon, Bertrand
Hi,

>as with the previous attempt to add these fields, are they really really
>needed? Or is an empty username + password in CHAP also working just
>fine?

They are really needed.

>For GPRS for example all operators are just ignoring these values. At
>least the few I have known that required them, gave up on it by now.

We are in Indonesia, and for AHA operator, we have to give a username and a 
password. If we do not specify them, the PPP negotiation fails.

>So please try with an empty username + password and show us logs of what
>is happening on a real network.

Which log? Pppd log?

Regards,

Bertrand


-
Intel Corporation SAS (French simplified joint stock company)
Registered headquarters: "Les Montalets"- 2, rue de Paris, 
92196 Meudon Cedex, France
Registration Number:  302 456 199 R.C.S. NANTERRE
Capital: 4,572,000 Euros

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


Re: [PATCH] CDMA ConnMan API: add username and password for PPP authentication.

2011-07-20 Thread Marcel Holtmann
Hi Bertrand,

>  doc/cdma-connman-api.txt |   10 ++
>  1 files changed, 10 insertions(+), 0 deletions(-)
> 
> diff --git a/doc/cdma-connman-api.txt b/doc/cdma-connman-api.txt
> index e486c09..48699a3 100644
> --- a/doc/cdma-connman-api.txt
> +++ b/doc/cdma-connman-api.txt
> @@ -35,6 +35,16 @@ Properties boolean Powered [readwrite]
>   Contains whether the connection is dormant.  Will
>   always be false if the connection is not powered.
>  
> + string Username [readwrite]
> +
> + Holds the username to be used for authentication
> + purposes.
> +
> + string Password [readwrite]
> +
> + Holds the password to be used for authentication
> + purposes.
> +

as with the previous attempt to add these fields, are they really really
needed? Or is an empty username + password in CHAP also working just
fine?

For GPRS for example all operators are just ignoring these values. At
least the few I have known that required them, gave up on it by now.

So please try with an empty username + password and show us logs of what
is happening on a real network.

Regards

Marcel


___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH] speedupcdma: add speedup cdma skeleton plugin

2011-07-20 Thread Guillaume Zajac
---
 Makefile.am   |3 +
 plugins/speedupcdma.c |  207 +
 2 files changed, 210 insertions(+), 0 deletions(-)
 create mode 100644 plugins/speedupcdma.c

diff --git a/Makefile.am b/Makefile.am
index a4e6c95..4b72091 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -336,6 +336,9 @@ builtin_sources += plugins/telit.c
 builtin_modules += speedup
 builtin_sources += plugins/speedup.c
 
+builtin_modules += speedupcdma
+builtin_sources += plugins/speedupcdma.c
+
 if BLUETOOTH
 builtin_modules += bluetooth
 builtin_sources += plugins/bluetooth.c plugins/bluetooth.h
diff --git a/plugins/speedupcdma.c b/plugins/speedupcdma.c
new file mode 100644
index 000..3c8f1b1
--- /dev/null
+++ b/plugins/speedupcdma.c
@@ -0,0 +1,207 @@
+/*
+ *
+ *  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 
+#endif
+
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+#define OFONO_API_SUBJECT_TO_CHANGE
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+static const char *none_prefix[] = { NULL };
+
+struct speedupcdma_data {
+   GAtChat *chat;
+};
+
+static void speedupcdma_debug(const char *str, void *data)
+{
+   const char *prefix = data;
+
+   ofono_info("%s%s", prefix, str);
+}
+
+static int speedupcdma_probe(struct ofono_modem *modem)
+{
+   struct speedupcdma_data *data;
+
+   DBG("%p", modem);
+
+   data = g_try_new0(struct speedupcdma_data, 1);
+   if (data == NULL)
+   return -ENOMEM;
+
+   ofono_modem_set_data(modem, data);
+
+   return 0;
+}
+
+static void speedupcdma_remove(struct ofono_modem *modem)
+{
+   struct speedupcdma_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 void cfun_enable(gboolean ok, GAtResult *result, gpointer user_data)
+{
+   struct ofono_modem *modem = user_data;
+
+   DBG("");
+
+   if (!ok) {
+   ofono_modem_set_powered(modem, FALSE);
+   return;
+   }
+   ofono_modem_set_powered(modem, TRUE);
+}
+
+static int speedupcdma_enable(struct ofono_modem *modem)
+{
+   struct speedupcdma_data *data = ofono_modem_get_data(modem);
+   GAtSyntax *syntax;
+   GIOChannel *channel;
+   const char *modem_path;
+
+   modem_path = ofono_modem_get_string(modem, "Modem");
+   if (modem_path == NULL)
+   return -EINVAL;
+
+   DBG("path is: %s", modem_path);
+
+   channel = g_at_tty_open(modem_path, NULL);
+   if (channel == NULL)
+   return -EIO;
+
+   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, speedupcdma_debug, "Modem: ");
+
+   g_at_chat_send(data->chat, "ATE0 +CMEE=1", none_prefix,
+   NULL, NULL, NULL);
+
+   g_at_chat_send(data->chat, "AT+CFUN=1", none_prefix,
+   cfun_enable, modem, NULL);
+
+   return -EINPROGRESS;
+}
+
+static void cfun_disable(gboolean ok, GAtResult *result, gpointer user_data)
+{
+   struct ofono_modem *modem = user_data;
+   struct speedupcdma_data *data = ofono_modem_get_data(modem);
+
+   DBG("");
+
+   g_at_chat_unref(data->chat);
+   data->chat = NULL;
+
+   if (ok)
+   ofono_modem_set_powered(modem, FALSE);
+}
+
+static int speedupcdma_disable(struct ofono_modem *modem)
+{
+   struct speedupcdma_data *data = ofono_modem_get_data(modem);
+
+   DBG("%p", modem);
+
+   g_at_chat_send(data->chat, "AT+CFUN=0", none_prefix,
+   cfun_disable, modem, NULL);
+
+   return -EINPROGRESS;
+}
+
+static void speedupcdma_pre_sim(struct ofono_modem *modem)
+{
+   struct speedupcdma_data *data = ofono_modem_get_data(modem);
+
+   DBG("%p", modem);
+
+   ofono_devinfo_create(modem, 0, "cdm

[PATCH 4/4] test: add script to set credentials for cdma connection

2011-07-20 Thread Guillaume Zajac
---
 test/create-cdma-credentials |   29 +
 1 files changed, 29 insertions(+), 0 deletions(-)
 create mode 100755 test/create-cdma-credentials

diff --git a/test/create-cdma-credentials b/test/create-cdma-credentials
new file mode 100755
index 000..0f52a98
--- /dev/null
+++ b/test/create-cdma-credentials
@@ -0,0 +1,29 @@
+#!/usr/bin/python
+
+import dbus
+import sys
+
+bus = dbus.SystemBus()
+
+manager = dbus.Interface(bus.get_object('org.ofono', '/'),
+   'org.ofono.Manager')
+
+modems = manager.GetModems()
+
+for path, properties in modems:
+   if "org.ofono.cdma.ConnectionManager" not in properties["Interfaces"]:
+   continue
+
+   cm = dbus.Interface(bus.get_object('org.ofono', path),
+   'org.ofono.cdma.ConnectionManager')
+
+   print "Connecting CDMA Packet Data Service on modem %s..." % path
+
+   if len(sys.argv) > 1:
+   cm.SetProperty("Username", (sys.argv[1]))
+   print "Setting Username to %s" % (sys.argv[1])
+
+   if len(sys.argv) > 2:
+   cm.SetProperty("Password", (sys.argv[2]))
+   print "Setting Password to %s" % (sys.argv[2])
+
-- 
1.7.1

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH 3/4] driver cdma-connman: add credential while setting up PPP if required

2011-07-20 Thread Guillaume Zajac
---
 drivers/cdmamodem/connman.c |8 
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/drivers/cdmamodem/connman.c b/drivers/cdmamodem/connman.c
index 14c78b1..7f6bf5a 100644
--- a/drivers/cdmamodem/connman.c
+++ b/drivers/cdmamodem/connman.c
@@ -123,9 +123,14 @@ static gboolean setup_ppp(struct ofono_cdma_connman *cm)
 {
struct connman_data *cd = ofono_cdma_connman_get_data(cm);
GAtIO *io;
+   const char *username;
+   const char *password;
 
DBG("");
 
+   username = ofono_cdma_connman_get_username(cm);
+   password = ofono_cdma_connman_get_password(cm);
+
io = g_at_chat_get_io(cd->chat);
 
g_at_chat_suspend(cd->chat);
@@ -145,6 +150,9 @@ static gboolean setup_ppp(struct ofono_cdma_connman *cm)
g_at_ppp_set_connect_function(cd->ppp, ppp_connect, cm);
g_at_ppp_set_disconnect_function(cd->ppp, ppp_disconnect, cm);
 
+   if (username && password)
+   g_at_ppp_set_credentials(cd->ppp, username, password);
+
/* open the ppp connection */
g_at_ppp_open(cd->ppp, io);
 
-- 
1.7.1

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH 2/4] cdma-connman: add possibility to set a username and a password

2011-07-20 Thread Guillaume Zajac
---
 src/cdma-connman.c |   44 +++-
 1 files changed, 43 insertions(+), 1 deletions(-)

diff --git a/src/cdma-connman.c b/src/cdma-connman.c
index 3321b87..7ca5a0a 100644
--- a/src/cdma-connman.c
+++ b/src/cdma-connman.c
@@ -57,6 +57,8 @@ struct ofono_cdma_connman {
const struct ofono_cdma_connman_driver *driver;
void *driver_data;
struct ofono_atom *atom;
+   char *username;
+   char *password;
 };
 
 static void cdma_connman_settings_free(struct cdma_connman_settings *settings)
@@ -379,6 +381,8 @@ static DBusMessage 
*cdma_connman_set_property(DBusConnection *conn,
DBusMessageIter var;
const char *property;
dbus_bool_t value;
+   const char *username;
+   const char *password;
 
DBG("");
 
@@ -399,7 +403,7 @@ static DBusMessage 
*cdma_connman_set_property(DBusConnection *conn,
 
dbus_message_iter_recurse(&iter, &var);
 
-   if (!strcmp(property, "Powered")) {
+   if (!g_strcmp0(property, "Powered")) {
if (dbus_message_iter_get_arg_type(&var) != DBUS_TYPE_BOOLEAN)
return __ofono_error_invalid_args(msg);
 
@@ -421,6 +425,22 @@ static DBusMessage 
*cdma_connman_set_property(DBusConnection *conn,
cm->driver->deactivate(cm, deactivate_callback, cm);
 
return dbus_message_new_method_return(msg);
+   } else if (!g_strcmp0(property, "Username")) {
+   if (dbus_message_iter_get_arg_type(&var) != DBUS_TYPE_STRING)
+   return __ofono_error_invalid_args(msg);
+
+   dbus_message_iter_get_basic(&var, &username);
+   cm->username = g_strdup(username);
+   DBG("username: %s", username);
+   return dbus_message_new_method_return(msg);
+   } else if (!g_strcmp0(property, "Password")) {
+   if (dbus_message_iter_get_arg_type(&var) != DBUS_TYPE_STRING)
+   return __ofono_error_invalid_args(msg);
+
+   dbus_message_iter_get_basic(&var, &password);
+   cm->password = g_strdup(password);
+   DBG("password: %s", password);
+   return dbus_message_new_method_return(msg);
}
 
/* TODO: Dormant property. Not yet supported. */
@@ -488,6 +508,12 @@ static void cdma_connman_remove(struct ofono_atom *atom)
if (cm->driver && cm->driver->remove)
cm->driver->remove(cm);
 
+   if (cm->username)
+   g_free(cm->username);
+
+   if (cm->password)
+   g_free(cm->password);
+
g_free(cm);
 }
 
@@ -568,3 +594,19 @@ void *ofono_cdma_connman_get_data(struct 
ofono_cdma_connman *cm)
 {
return cm->driver_data;
 }
+
+const char *ofono_cdma_connman_get_username(struct ofono_cdma_connman *cm)
+{
+   if (cm->username)
+   return cm->username;
+
+   return NULL;
+}
+
+const char *ofono_cdma_connman_get_password(struct ofono_cdma_connman *cm)
+{
+   if (cm->password)
+   return cm->password;
+
+   return NULL;
+}
-- 
1.7.1

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH 1/4] cdma-connman: add prototype to retrieve username and password

2011-07-20 Thread Guillaume Zajac
---
 include/cdma-connman.h |4 
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/include/cdma-connman.h b/include/cdma-connman.h
index 22252e0..1439ea9 100644
--- a/include/cdma-connman.h
+++ b/include/cdma-connman.h
@@ -72,6 +72,10 @@ void ofono_cdma_connman_set_data(struct ofono_cdma_connman 
*cm,
void *data);
 void *ofono_cdma_connman_get_data(struct ofono_cdma_connman *cm);
 
+const char *ofono_cdma_connman_get_username(struct ofono_cdma_connman *cm);
+
+const char *ofono_cdma_connman_get_password(struct ofono_cdma_connman *cm);
+
 #ifdef __cplusplus
 }
 #endif
-- 
1.7.1

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH 0/4] CDMA-connman add username and password properties

2011-07-20 Thread Guillaume Zajac
Hi,

These patches will be used to set PPP credentials when CDMA network will need 
them.
It contains a test script based on create-internet-context script.

Guillaume Zajac (4):
  cdma-connman: add prototype to retrieve username and password
  cdma-connman: add possibility to set a username and a password
  driver cdma-connman: add credential while setting up PPP if required
  test: add script to set credentials for cdma connection

 drivers/cdmamodem/connman.c  |8 +++
 include/cdma-connman.h   |4 +++
 src/cdma-connman.c   |   44 +-
 test/create-cdma-credentials |   29 +++
 4 files changed, 84 insertions(+), 1 deletions(-)
 create mode 100755 test/create-cdma-credentials

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH] CDMA ConnMan API: add username and password for PPP authentication.

2011-07-20 Thread Bertrand Aygon
---
 doc/cdma-connman-api.txt |   10 ++
 1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/doc/cdma-connman-api.txt b/doc/cdma-connman-api.txt
index e486c09..48699a3 100644
--- a/doc/cdma-connman-api.txt
+++ b/doc/cdma-connman-api.txt
@@ -35,6 +35,16 @@ Properties   boolean Powered [readwrite]
Contains whether the connection is dormant.  Will
always be false if the connection is not powered.
 
+   string Username [readwrite]
+
+   Holds the username to be used for authentication
+   purposes.
+
+   string Password [readwrite]
+
+   Holds the password to be used for authentication
+   purposes.
+
dict Settings [readonly, optional]
 
Holds all the IP network settings
-- 
1.7.4.1

-
Intel Corporation SAS (French simplified joint stock company)
Registered headquarters: "Les Montalets"- 2, rue de Paris, 
92196 Meudon Cedex, France
Registration Number:  302 456 199 R.C.S. NANTERRE
Capital: 4,572,000 Euros

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.
___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono