Skip to contentSkip to conversation

stk: API for SMS Point-to-Point download to UICC

RFC PATCH In review Andrzej Zaborowski 2 participants 6 messages Nov 7, 2010 – Nov 8, 2010

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/3 stk: API for SMS Point-to-Point download to UICC

The callback returns the TP-User-Data element content of the RP-ACK or RP-ERROR message, returned by the UICC.

---
 src/ofono.h |    8 ++++++++
 src/stk.c   |   39 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 47 insertions(+), 0 deletions(-)
src/ofono.h +8 -0
index ab6ecd2..e5b4acb 100644
@@ -283,9 +283,17 @@ unsigned short __ofono_sms_get_next_ref(struct ofono_sms *sms);
 #include <ofono/sim.h>
 #include <ofono/stk.h>
 
+typedef void (*__ofono_sms_sim_download_cb_t)(ofono_bool_t ok,
+						const unsigned char *tp_ud,
+						int len, void *data);
+
 struct cbs;
 void __ofono_cbs_sim_download(struct ofono_stk *stk, const struct cbs *msg);
 
+struct sms;
+int __ofono_sms_sim_download(struct ofono_stk *stk, const struct sms *msg,
+				__ofono_sms_sim_download_cb_t cb, void *data);
+
 #include <ofono/ssn.h>
 
 typedef void (*ofono_ssn_mo_notify_cb)(int index, void *user);
src/stk.c +39 -0
index 230c923..18beee6 100644
@@ -75,6 +75,9 @@ struct ofono_stk {
 	struct stk_icon_id idle_mode_icon;
 	struct timeval get_inkey_start_ts;
 	int dtmf_id;
+
+	__ofono_sms_sim_download_cb_t sms_pp_cb;
+	void *sms_pp_userdata;
 };
 
 struct envelope_op {
@@ -257,6 +260,42 @@ void __ofono_cbs_sim_download(struct ofono_stk *stk, const struct cbs *msg)
 		stk_cbs_download_cb(stk, FALSE, NULL, -1);
 }
 
+static void stk_sms_download_cb(struct ofono_stk *stk, gboolean ok,
+				const unsigned char *data, int len)
+{
+	DBG("SMS-PP download to UICC reported %s", ok ? "success" : "error");
+
+	if (stk->sms_pp_cb)
+		stk->sms_pp_cb(ok, data, len, stk->sms_pp_userdata);
+}
+
+int __ofono_sms_sim_download(struct ofono_stk *stk, const struct sms *msg,
+				__ofono_sms_sim_download_cb_t cb, void *data)
+{
+	struct stk_envelope e;
+
+	if (msg->type != SMS_TYPE_DELIVER)
+		return -EINVAL;
+
+	DBG("");
+
+	memset(&e, 0, sizeof(e));
+
+	e.type = STK_ENVELOPE_TYPE_SMS_PP_DOWNLOAD;
+	e.src = STK_DEVICE_IDENTITY_TYPE_NETWORK;
+
+	e.sms_pp_download.address.number = (char *) msg->sc_addr.address;
+	e.sms_pp_download.address.ton_npi = msg->sc_addr.numbering_plan |
+		(msg->sc_addr.number_type << 4);
+	memcpy(&e.sms_pp_download.message, &msg->deliver, sizeof(msg->deliver));
+
+	stk->sms_pp_cb = cb;
+	stk->sms_pp_userdata = data;
+
+	return stk_send_envelope(stk, &e, stk_sms_download_cb,
+					ENVELOPE_RETRIES_DEFAULT);
+}
+
 static char *dbus_apply_text_attributes(const char *text,
 					const struct stk_text_attribute *attr)
 {
Signature · 1 line
1.7.1.86.g0e460.dirty
#1 lore raw

PATCH 2/3 sms: Handle "USIM Download" SMS type.

---
 src/sms.c |   21 ++++++++++++++++-----
 1 files changed, 16 insertions(+), 5 deletions(-)
src/sms.c +16 -5
index 456dda9..eba4564 100644
@@ -1415,6 +1415,8 @@ static inline gboolean handle_mwi(struct ofono_sms *sms, struct sms *s)
 void ofono_sms_deliver_notify(struct ofono_sms *sms, unsigned char *pdu,
 				int len, int tpdu_len)
 {
+	struct ofono_modem *modem = __ofono_atom_get_modem(sms->atom);
+	struct ofono_atom *stk_atom;
 	struct sms s;
 	enum sms_class cls;
 
@@ -1479,13 +1481,22 @@ void ofono_sms_deliver_notify(struct ofono_sms *sms, unsigned char *pdu,
 		break;
 	case SMS_PID_TYPE_USIM_DOWNLOAD:
 	case SMS_PID_TYPE_ANSI136:
-		if (cls == SMS_CLASS_2) {
-			ofono_error("(U)SIM Download messages not supported");
+		/* If not Class 2, handle in a "normal" way */
+		if (cls != SMS_CLASS_2)
+			break;
+
+		stk_atom = __ofono_modem_find_atom(modem, OFONO_ATOM_TYPE_STK);
+
+		if (!stk_atom)
 			return;
-		}
 
-		/* Otherwise handle in a "normal" way */
-		break;
+		__ofono_sms_sim_download(__ofono_atom_get_data(stk_atom),
+						&s, NULL, sms);
+
+		/* Passing the USIM response back to network is not
+		 * currently support */
+		/* TODO: store in EFsms if not handled */
+		return;
 	default:
 		break;
 	}
Signature · 1 line
1.7.1.86.g0e460.dirty
#2 lore raw

Re: [PATCH 2/3] sms: Handle "USIM Download" SMS type.

Hi Andrew,

Quoted 3 lines · Andrzej Zaborowski
---
 src/sms.c |   21 ++++++++++++++++-----
 1 files changed, 16 insertions(+), 5 deletions(-)

Patch has been applied, thanks.

Regards,
-Denis

#3 lore raw

PATCH 3/3 Update TODO.

In reply to Andrzej Zaborowski
---
 TODO |   22 +++++++++++++---------
 1 files changed, 13 insertions(+), 9 deletions(-)
TODO +13 -9
index 0d04208..c0dee09 100644
@@ -76,6 +76,19 @@ SMS
   Complexity: C4
   Owner: Rajesh Kadhiravan Nagaiah <[email protected]>
 
+- Asynchronously acknowledge SMS DELIVER messages sent by the SMS driver
+  to core using ofono_sms_deliver_notify().  This may require the struct
+  ofono_sms_driver to be extended with one more function pointer like:
+    void (*deliver_ack)(unsigned char *pdu, int len, cb_t cb, void *data)
+  because currently messages are automatically acknowledged by either the
+  modem (this is the case of some AT modems) or the driver right after
+  ofono_sms_deliver_notify() and a failure to deliver at an upper level is
+  ignored.  The PDU can be an RP-ACK or RP-ERROR message with optional
+  TP-User-Content element, for example if returned from USIM Data Download.
+
+  Priority: Low
+  Complexity: C2
+
 SIM / SIM File system
 =====================
 
@@ -339,15 +352,6 @@ Sim Toolkit
   Priority: High
   Complexity: C8
 
-- Support 'SMS-PP' Download Envelope.  Whenever a special type of SMS is
-  received indicating that this is an SMS-PP Download message, this message
-  will be sent to the SIM via an SMS-PP Download Envelope.  No user interaction
-  will be required.  If the modem hardware supports this transparently, then
-  no indication to oFono will be necessary.
-
-  Priority: High
-  Complexity: C2
-
 - Support Language Notification proactive command.
 
   Priority: Medium
Signature · 1 line
1.7.1.86.g0e460.dirty
#4 lore raw

Re: [PATCH 3/3] Update TODO.

Quoted 3 lines · Andrzej Zaborowski
---
 TODO |   22 +++++++++++++---------
 1 files changed, 13 insertions(+), 9 deletions(-)

Patch has been applied. I did break this patch up into two, one marking the task as done and the other adding the new task.

Regards,
-Denis

#5 lore raw
In reply to Andrzej Zaborowski

Hi Andrew,

Quoted 19 lines · Andrzej Zaborowski

The callback returns the TP-User-Data element content of the RP-ACK or RP-ERROR message, returned by the UICC.

---
 src/ofono.h |    8 ++++++++
 src/stk.c   |   39 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 47 insertions(+), 0 deletions(-)
src/stk.c +12 -0
+int __ofono_sms_sim_download(struct ofono_stk *stk, const struct sms *msg,
+				__ofono_sms_sim_download_cb_t cb, void *data)
+{
+	struct stk_envelope e;
+
+	if (msg->type != SMS_TYPE_DELIVER)
+		return -EINVAL;
+
+	DBG("");
+
+	memset(&e, 0, sizeof(e));
+

src/stk.c void __ofono_cbs_sim_download(struct ofono_stk *stk, const struct cbs *msg) · line 293

Quoted 10 lines
src/stk.c +10 -0
+	e.type = STK_ENVELOPE_TYPE_SMS_PP_DOWNLOAD;
+	e.src = STK_DEVICE_IDENTITY_TYPE_NETWORK;
+
+	e.sms_pp_download.address.number = (char *) msg->sc_addr.address;
+	e.sms_pp_download.address.ton_npi = msg->sc_addr.numbering_plan |
+		(msg->sc_addr.number_type << 4);
+	memcpy(&e.sms_pp_download.message, &msg->deliver, sizeof(msg->deliver));
+
+	stk->sms_pp_cb = cb;
+	stk->sms_pp_userdata = data;

Please note that this has a possibility of overwriting the sms_pp_cb and sms_pp_userdata if multiple SMS-PP sms messages are received (and acknowledged) in short succession.

However, I assume you already thought of this and will take care of it with the async ack task.

Patch has been applied, thanks.

Regards,
-Denis