Skip to contentSkip to conversation

Make fetch command function as external

PATCH Applied Yang Gu 2 participants 6 messages Jul 13, 2010 Kbuild

lore
Share & tools
lore

Yang Gu

author
#0 lore raw

PATCH 1/3 Make fetch command function as external

---
 Makefile.am                |    1 +
 drivers/atmodem/sim-poll.c |   55 +------------------------------------------
 drivers/atmodem/stk.c      |   51 ++++++++++++++++++++++++++++++++++++++++
 drivers/atmodem/stk.h      |   22 +++++++++++++++++
 4 files changed, 76 insertions(+), 53 deletions(-)
 create mode 100644 drivers/atmodem/stk.h
Makefile.am +1 -0
index 24aa886..e256841 100644
@@ -143,6 +143,7 @@ builtin_sources += $(gatchat_sources) \
 				drivers/atmodem/network-registration.c \
 				drivers/atmodem/sim.c \
 				drivers/atmodem/stk.c \
+				drivers/atmodem/stk.h \
 				drivers/atmodem/sim-poll.c \
 				drivers/atmodem/sim-poll.h \
 				drivers/atmodem/ussd.c \
drivers/atmodem/sim-poll.c +2 -53

73 lines not on this page · raw message

drivers/atmodem/stk.c +51 -0

63 lines not on this page · raw message

drivers/atmodem/stk.h new file +22 -0
new file mode 100644
index 0000000..265ac2e
@@ -0,0 +1,22 @@
+/*
+ *
+ *  oFono - Open Source Telephony
+ *
+ *  Copyright (C) 2008-2010  Intel Corporation. All rights reserved.
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */
+
+void at_sim_fetch_command(struct ofono_stk *stk, int length);
Signature · 1 line
1.7.0.4
author
#1 lore raw

PATCH 2/3 Support phonesim proactive command notification

---
 drivers/atmodem/stk.c |   25 +++++++++++++++++++++++++
 1 files changed, 25 insertions(+), 0 deletions(-)
drivers/atmodem/stk.c +25 -0
index 1283cca..3850f15 100644
@@ -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 };
@@ -262,10 +264,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;
@@ -278,6 +302,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);
Signature · 1 line
1.7.0.4
#2 lore raw

Re: [PATCH 2/3] Support phonesim proactive command notification

Hi Yang,

Quoted 8 lines
drivers/atmodem/stk.c +8 -0
+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);

drivers/atmodem/stk.c error: · line 284

Quoted 10 lines
drivers/atmodem/stk.c +10 -0
+
+	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);
+}
+

drivers/atmodem/stk.c: In function ‘phonesim_tcmd_notify’:
drivers/atmodem/stk.c:282: error: passing argument 1 of ‘at_sim_fetch_command’ from incompatible pointer type drivers/atmodem/stk.c:92: note: expected ‘struct ofono_stk *’ but argument is of type ‘struct GAtChat *’ drivers/atmodem/stk.c:282: error: passing argument 2 of ‘at_sim_fetch_command’ makes integer from pointer without a cast drivers/atmodem/stk.c:92: note: expected ‘int’ but argument is of type ‘struct ofono_stk *’
drivers/atmodem/stk.c:282: error: too many arguments to function ‘at_sim_fetch_command’

I fixed this up for you since it was trivial, however please at least compile-check your patches ;)

Regards,
-Denis

author
#3 lore raw

PATCH 3/3 Use specific vendor for phonesim stk

In reply to Yang Gu
---
 plugins/phonesim.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
plugins/phonesim.c +1 -1
index d0cd7f3..9c5b2cb 100644
@@ -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);
Signature · 1 line
1.7.0.4
#4 lore raw

Re: [PATCH 3/3] Use specific vendor for phonesim stk

Hi Yang,

Quoted 9 lines · Yang Gu
---
 plugins/phonesim.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
plugins/phonesim.c +0 -0
index d0cd7f3..9c5b2cb 100644

plugins/phonesim.c static void phonesim_pre_sim(struct ofono_modem *modem) · line 295

Quoted 8 lines
plugins/phonesim.c +1 -1
@@ -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);

Applied, thanks.

Regards,
-Denis

#5 lore raw
In reply to Yang Gu

Hi Yang,

Quoted 7 lines · Yang Gu
---
 Makefile.am                |    1 +
 drivers/atmodem/sim-poll.c |   55 +------------------------------------------
 drivers/atmodem/stk.c      |   51 ++++++++++++++++++++++++++++++++++++++++
 drivers/atmodem/stk.h      |   22 +++++++++++++++++
 4 files changed, 76 insertions(+), 53 deletions(-)
 create mode 100644 drivers/atmodem/stk.h

Applied, thanks.

Regards,
-Denis