Open Source Telephony
 help / color / mirror / Atom feed
From: Yang Gu <gyagp0@gmail.com>
To: ofono@ofono.org
Subject: [PATCH 2/3] Support phonesim proactive command notification
Date: Fri, 09 Jul 2010 22:52:07 +0800	[thread overview]
Message-ID: <1278687128-8983-2-git-send-email-yang.gu@intel.com> (raw)
In-Reply-To: <1278687128-8983-1-git-send-email-yang.gu@intel.com>

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

---
 drivers/atmodem/stk.c |   25 +++++++++++++++++++++++++
 plugins/phonesim.c    |    2 +-
 2 files changed, 26 insertions(+), 1 deletions(-)

diff --git a/drivers/atmodem/stk.c b/drivers/atmodem/stk.c
index 6058d69..91b9195 100644
--- a/drivers/atmodem/stk.c
+++ b/drivers/atmodem/stk.c
@@ -39,9 +39,11 @@
 
 #include "atmodem.h"
 #include "stk.h"
+#include "vendor.h"
 
 struct stk_data {
 	GAtChat *chat;
+	unsigned int vendor;
 };
 
 static const char *csim_prefix[] = { "+CSIM:", NULL };
@@ -264,10 +266,32 @@ error:
 	CALLBACK_WITH_FAILURE(cb, data);
 }
 
+static void phonesim_tcmd_notify(GAtResult *result, gpointer user_data)
+{
+	struct ofono_stk *stk = user_data;
+	struct stk_data *data = ofono_stk_get_data(stk);
+	GAtResultIter iter;
+	int length;
+
+	g_at_result_iter_init(&iter, result);
+
+	if (!g_at_result_iter_next(&iter, "*TCMD:"))
+		return;
+
+	if (!g_at_result_iter_next_number(&iter, &length))
+		return;
+
+	at_sim_fetch_command(data->chat, stk, length);
+}
+
 static gboolean at_stk_register(gpointer user)
 {
 	struct ofono_stk *stk = user;
+	struct stk_data *sd = ofono_stk_get_data(stk);
 
+	if (sd->vendor == OFONO_VENDOR_PHONESIM)
+		g_at_chat_register(sd->chat, "*TCMD", phonesim_tcmd_notify,
+							FALSE, stk, NULL);
 	ofono_stk_register(stk);
 
 	return FALSE;
@@ -280,6 +304,7 @@ static int at_stk_probe(struct ofono_stk *stk, unsigned int vendor, void *data)
 
 	sd = g_new0(struct stk_data, 1);
 	sd->chat = chat;
+	sd->vendor = vendor;
 
 	ofono_stk_set_data(stk, sd);
 	g_idle_add(at_stk_register, stk);
diff --git a/plugins/phonesim.c b/plugins/phonesim.c
index d0cd7f3..9c5b2cb 100644
--- a/plugins/phonesim.c
+++ b/plugins/phonesim.c
@@ -289,7 +289,7 @@ static void phonesim_pre_sim(struct ofono_modem *modem)
 	else
 		ofono_voicecall_create(modem, 0, "atmodem", data->chat);
 
-	ofono_stk_create(modem, 0, "atmodem", data->chat);
+	ofono_stk_create(modem, OFONO_VENDOR_PHONESIM, "atmodem", data->chat);
 
 	if (sim)
 		ofono_sim_inserted_notify(sim, TRUE);
-- 
1.7.0.4


  reply	other threads:[~2010-07-09 14:52 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-09 14:52 [PATCH 1/3] Make fetch command function as external Yang Gu
2010-07-09 14:52 ` Yang Gu [this message]
2010-07-09 17:18   ` [PATCH 2/3] Support phonesim proactive command notification Denis Kenzior
2010-07-09 14:52 ` [PATCH 3/3] Interpret "" Alpha Id as empty data object Yang Gu
2010-07-09 15:22   ` Gu, Yang
2010-07-09 17:32   ` Denis Kenzior
2010-07-11 13:59     ` Gu, Yang
2010-07-09 15:09 ` [PATCH 1/3] Make fetch command function as external Gu, Yang
2010-07-09 17:17 ` Denis Kenzior
  -- strict thread matches above, loose matches on Subject: below --
2010-07-13 10:29 Yang Gu
2010-07-13 10:30 ` [PATCH 2/3] Support phonesim proactive command notification Yang Gu
2010-07-13 14:56   ` Denis Kenzior

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1278687128-8983-2-git-send-email-yang.gu@intel.com \
    --to=gyagp0@gmail.com \
    --cc=ofono@ofono.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox