---
plugins/speedupcdma.c | 91 +++++++++++++++++++++++++++++++-----------------
1 files changed, 59 insertions(+), 32 deletions(-)
diff --git a/plugins/speedupcdma.c b/plugins/speedupcdma.c
index d11afb7..67bb617 100644
--- a/plugins/speedupcdma.c
+++ b/plugins/speedupcdma.c
@@ -37,10 +37,9 @@
#include <ofono/cdma-connman.h>
#include <ofono/log.h>
-static const char *none_prefix[] = { NULL };
-
struct speedupcdma_data {
- GAtChat *chat;
+ GAtChat *modem;
+ GAtChat *aux;
};
static void speedupcdma_debug(const char *str, void *data)
@@ -84,50 +83,70 @@ static void cfun_enable(gboolean ok, GAtResult *result, gpointer
user_data)
DBG("");
if (!ok) {
- g_at_chat_unref(data->chat);
- data->chat = NULL;
+ g_at_chat_unref(data->modem);
+ data->modem = NULL;
- ofono_modem_set_powered(modem, FALSE);
- return;
+ g_at_chat_unref(data->aux);
+ data->aux = NULL;
}
- ofono_modem_set_powered(modem, TRUE);
+ ofono_modem_set_powered(modem, ok);
}
-static int speedupcdma_enable(struct ofono_modem *modem)
+static GAtChat *open_device(struct ofono_modem *modem,
+ const char *key, char *debug)
{
- struct speedupcdma_data *data = ofono_modem_get_data(modem);
- GAtSyntax *syntax;
+ const char *device;
GIOChannel *channel;
- const char *modem_path;
+ GAtSyntax *syntax;
+ GAtChat *chat;
- modem_path = ofono_modem_get_string(modem, "Modem");
- if (modem_path == NULL)
- return -EINVAL;
+ device = ofono_modem_get_string(modem, key);
+ if (device == NULL)
+ return NULL;
- DBG("path is: %s", modem_path);
+ DBG("%s %s", key, device);
- channel = g_at_tty_open(modem_path, NULL);
+ channel = g_at_tty_open(device, NULL);
if (channel == NULL)
- return -EIO;
+ return NULL;
syntax = g_at_syntax_new_gsm_permissive();
- data->chat = g_at_chat_new(channel, syntax);
+ chat = g_at_chat_new(channel, syntax);
g_at_syntax_unref(syntax);
g_io_channel_unref(channel);
- if (data->chat == NULL)
- return -ENOMEM;
+ if (chat == NULL)
+ return NULL;
if (getenv("OFONO_AT_DEBUG"))
- g_at_chat_set_debug(data->chat, speedupcdma_debug, "Modem: ");
+ g_at_chat_set_debug(chat, speedupcdma_debug, debug);
- g_at_chat_send(data->chat, "ATE0 +CMEE=1", none_prefix,
- NULL, NULL, NULL);
+ return chat;
+}
- g_at_chat_send(data->chat, "AT+CFUN=1", none_prefix,
- cfun_enable, modem, NULL);
+static int speedupcdma_enable(struct ofono_modem *modem)
+{
+ struct speedupcdma_data *data = ofono_modem_get_data(modem);
+
+ DBG("");
+
+ data->modem = open_device(modem, "Modem", "Modem: ");
+ if (data->modem == NULL)
+ return -EINVAL;
+
+ data->aux = open_device(modem, "Aux", "Aux: ");
+ if (data->aux == NULL) {
+ g_at_chat_unref(data->modem);
+ data->modem = NULL;
+ return -EIO;
+ }
+
+ g_at_chat_send(data->modem, "ATE0 &C0 +CMEE=1", NULL, NULL, NULL,
NULL);
+ g_at_chat_send(data->aux, "ATE0 &C0 +CMEE=1", NULL, NULL, NULL, NULL);
+
+ g_at_chat_send(data->aux, "AT+CFUN=1", NULL, cfun_enable, modem, NULL);
return -EINPROGRESS;
}
@@ -139,8 +158,8 @@ static void cfun_disable(gboolean ok, GAtResult *result, gpointer
user_data)
DBG("");
- g_at_chat_unref(data->chat);
- data->chat = NULL;
+ g_at_chat_unref(data->aux);
+ data->aux = NULL;
if (ok)
ofono_modem_set_powered(modem, FALSE);
@@ -152,8 +171,16 @@ static int speedupcdma_disable(struct ofono_modem *modem)
DBG("%p", modem);
- g_at_chat_send(data->chat, "AT+CFUN=0", none_prefix,
- cfun_disable, modem, NULL);
+ g_at_chat_cancel_all(data->modem);
+ g_at_chat_unregister_all(data->modem);
+
+ g_at_chat_unref(data->modem);
+ data->modem = NULL;
+
+ g_at_chat_cancel_all(data->aux);
+ g_at_chat_unregister_all(data->aux);
+
+ g_at_chat_send(data->aux, "AT+CFUN=0", NULL, cfun_disable, modem, NULL);
return -EINPROGRESS;
}
@@ -164,7 +191,7 @@ static void speedupcdma_pre_sim(struct ofono_modem *modem)
DBG("%p", modem);
- ofono_devinfo_create(modem, 0, "cdmamodem", data->chat);
+ ofono_devinfo_create(modem, 0, "cdmamodem", data->aux);
}
static void speedupcdma_post_sim(struct ofono_modem *modem)
@@ -178,7 +205,7 @@ static void speedupcdma_post_online(struct ofono_modem *modem)
DBG("%p", modem);
- ofono_cdma_connman_create(modem, 0, "cdmamodem", data->chat);
+ ofono_cdma_connman_create(modem, 0, "cdmamodem", data->modem);
}
static struct ofono_modem_driver speedupcdma_driver = {
--
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.