summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2010-08-19 21:01:21 +0200
committerMarcel Holtmann <marcel@holtmann.org>2010-08-19 21:01:21 +0200
commitd0fdaa7f72b4864ac3089a17b0d7bdc8747eadae (patch)
tree1ad44b42a71ba98dfe9817d7579c7f50ebeb6bdd /plugins
parentf261f38fd93e77c30f433520877d8968f996723b (diff)
downloadofono-d0fdaa7f72b4864ac3089a17b0d7bdc8747eadae.tar.bz2
huawei: Add support for switching USSD mode
Some newer Huawei modems have support for ^USSDMODE command which seems to be default to 1. In that mode the text USSD is not working. Switching it to 0 and text USSD works just fine. Assumption is that with this command the modem switches between text and PDU mode for USSD. Currently it is unclear on how the PDU mode is suppose to work all. So default to text mode if this command is supported.
Diffstat (limited to 'plugins')
-rw-r--r--plugins/huawei.c61
1 files changed, 56 insertions, 5 deletions
diff --git a/plugins/huawei.c b/plugins/huawei.c
index f8ada24a..4571b1b7 100644
--- a/plugins/huawei.c
+++ b/plugins/huawei.c
@@ -56,6 +56,7 @@
static const char *none_prefix[] = { NULL };
static const char *sysinfo_prefix[] = { "^SYSINFO:", NULL };
+static const char *ussdmode_prefix[] = { "^USSDMODE:", NULL };
enum huawei_sim_state {
HUAWEI_SIM_STATE_INVALID_OR_LOCKED = 0,
@@ -109,6 +110,51 @@ static void huawei_debug(const char *str, void *user_data)
ofono_info("%s%s", prefix, str);
}
+static void ussdmode_query_cb(gboolean ok, GAtResult *result,
+ gpointer user_data)
+{
+ struct huawei_data *data = user_data;
+ GAtResultIter iter;
+ gint ussdmode;
+
+ if (!ok)
+ return;
+
+ g_at_result_iter_init(&iter, result);
+
+ if (!g_at_result_iter_next(&iter, "^USSDMODE:"))
+ return;
+
+ if (!g_at_result_iter_next_number(&iter, &ussdmode))
+ return;
+
+ if (ussdmode == 0)
+ return;
+
+ /* set USSD mode to text mode */
+ g_at_chat_send(data->pcui, "AT^USSDMODE=0", none_prefix,
+ NULL, NULL, NULL);
+}
+
+static void ussdmode_support_cb(gboolean ok, GAtResult *result,
+ gpointer user_data)
+{
+ struct huawei_data *data = user_data;
+ GAtResultIter iter;
+
+ if (!ok)
+ return;
+
+ g_at_result_iter_init(&iter, result);
+
+ if (!g_at_result_iter_next(&iter, "^USSDMODE:"))
+ return;
+
+ /* query current USSD mode */
+ g_at_chat_send(data->pcui, "AT^USSDMODE?", ussdmode_prefix,
+ ussdmode_query_cb, data, NULL);
+}
+
static void notify_sim_state(struct ofono_modem *modem,
enum huawei_sim_state sim_state)
{
@@ -185,11 +231,15 @@ static void cfun_enable(gboolean ok, GAtResult *result, gpointer user_data)
/* follow sim state */
g_at_chat_register(data->pcui, "^SIMST:", simst_notify,
- FALSE, modem, NULL);
+ FALSE, modem, NULL);
/* query current sim state */
g_at_chat_send(data->pcui, "AT^SYSINFO", sysinfo_prefix,
- sysinfo_cb, modem, NULL);
+ sysinfo_cb, modem, NULL);
+
+ /* check USSD mode support */
+ g_at_chat_send(data->pcui, "AT^USSDMODE=?", ussdmode_prefix,
+ ussdmode_support_cb, data, NULL);
}
static GAtChat *create_port(const char *device)
@@ -369,9 +419,10 @@ static void huawei_post_sim(struct ofono_modem *modem)
data->pcui);
ofono_sms_create(modem, OFONO_VENDOR_HUAWEI, "atmodem", data->pcui);
- ofono_cbs_create(modem, OFONO_VENDOR_QUALCOMM_MSM, "atmodem",
- data->pcui);
- ofono_ussd_create(modem, 0, "atmodem", data->pcui);
+ ofono_cbs_create(modem, OFONO_VENDOR_QUALCOMM_MSM,
+ "atmodem", data->pcui);
+ ofono_ussd_create(modem, OFONO_VENDOR_QUALCOMM_MSM,
+ "atmodem", data->pcui);
ofono_phonebook_create(modem, 0, "atmodem", data->pcui);
if (data->sim_state == HUAWEI_SIM_STATE_VALID ||