Skip to contentSkip to conversation

Add functions to notify core of SIM insertion/removal or request polling.

RFC PATCH In review Andrzej Zaborowski 3 participants 3 messages Mar 15, 2010 – Mar 19, 2010

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/8 Add functions to notify core of SIM insertion/removal or request polling.

Implement optional polling. Polling is mandatory according to the specification but on most hardware it will me impractical because there will be vendor specific unsolicited notifications that can be used instead. Modem plugins need to handle them.

---
 include/sim.h |   21 ++++++-
 src/sim.c     |  197 ++++++++++++++++++++++++++++++++++++++++++++++++++-------
 2 files changed, 195 insertions(+), 23 deletions(-)
include/sim.h +20 -1
index 6ff29f7..fdfe2e8 100644
@@ -106,6 +106,8 @@ typedef void (*ofono_sim_lock_unlock_cb_t)(const struct ofono_error *error,
 typedef void (*ofono_sim_locked_cb_t)(const struct ofono_error *error,
 					int locked, void *data);
 
+typedef void (*ofono_sim_cb_t)(const struct ofono_error *error, void *data);
+
 struct ofono_sim_driver {
 	const char *name;
 	int (*probe)(struct ofono_sim *sim, unsigned int vendor, void *data);
@@ -152,6 +154,12 @@ struct ofono_sim_driver {
 	void (*envelope)(struct ofono_sim *sim, int length,
 				const guint8 *command,
 				ofono_sim_read_cb_t cb, void *data);
+	void (*status)(struct ofono_sim *sim, ofono_sim_cb_t cb, void *data);
+	void (*fetch)(struct ofono_sim *sim, int length,
+			ofono_sim_read_cb_t cb, void *data);
+	void (*terminal_response)(struct ofono_sim *sim, int length,
+			const unsigned char *value, ofono_sim_write_cb_t cb,
+			void *data);
 };
 
 int ofono_sim_driver_register(const struct ofono_sim_driver *d);
@@ -179,8 +187,19 @@ unsigned int ofono_sim_add_ready_watch(struct ofono_sim *sim,
 
 void ofono_sim_remove_ready_watch(struct ofono_sim *sim, unsigned int id);
 
+unsigned int ofono_sim_add_removed_watch(struct ofono_sim *sim,
+				ofono_sim_ready_notify_cb_t cb,
+				void *data, ofono_destroy_func destroy);
+
+void ofono_sim_remove_removed_watch(struct ofono_sim *sim, unsigned int id);
+
 int ofono_sim_get_ready(struct ofono_sim *sim);
-void ofono_sim_set_ready(struct ofono_sim *sim);
+
+void ofono_sim_inserted(struct ofono_sim *sim);
+void ofono_sim_removed(struct ofono_sim *sim);
+void ofono_sim_proactive_command_notify(struct ofono_sim *sim, int length);
+
+void ofono_sim_poll_enable(struct ofono_sim *sim);
 
 /* This will queue an operation to read all available records with id from the
  * SIM.  Callback cb will be called every time a record has been read, or once
src/sim.c +175 -22

259 lines not on this page · raw message

Signature · 1 line
1.6.1
#1 lore raw

Hi Andrew,

Quoted 5 lines

Implement optional polling. Polling is mandatory according to the specification but on most hardware it will me impractical because there will be vendor specific unsolicited notifications that can be used instead. Modem plugins need to handle them.
---

So I've been going back and forth on this one and my opinion is we should not do the poll in the core. The modem has to do it anyway, so let the modem do it and tell us when it happens. Most vendors provide unsolicited notifications for SIM Toolkit events anyway. Let us treat it the same way as voicecalls. The standard does not define any unsolicited responses for call state notifications, yet in practice all modem vendors provide this.

Keep this code around and let us re-examine this decision if we ever need to implement POLLING ON / POLLING OFF / POLLING INTERVAL commands. Based on all the vendor specific docs I have these are intercepted by the modem and we never see them anyway.

Quoted 3 lines
 include/sim.h |   21 ++++++-
 src/sim.c     |  197

++++++++++++++++++++++++++++++++++++++++++++++++++------- 2 files

changed,

Quoted 16 lines

195 insertions(+), 23 deletions(-)

include/sim.h +1 -0
index 6ff29f7..fdfe2e8 100644
@@ -106,6 +106,8 @@ typedef void (*ofono_sim_lock_unlock_cb_t)(const struct
 ofono_error *error, typedef void (*ofono_sim_locked_cb_t)(const struct
 ofono_error *error, int locked, void *data);
 
+typedef void (*ofono_sim_cb_t)(const struct ofono_error *error, void
 *data); +
 struct ofono_sim_driver {
 	const char *name;
 	int (*probe)(struct ofono_sim *sim, unsigned int vendor, void *data);

include/sim.h struct ofono_sim_driver { · line 159

Quoted 6 lines
include/sim.h +3 -0
@@ -152,6 +154,12 @@ struct ofono_sim_driver {
 	void (*envelope)(struct ofono_sim *sim, int length,
 				const guint8 *command,
 				ofono_sim_read_cb_t cb, void *data);
+	void (*status)(struct ofono_sim *sim, ofono_sim_cb_t cb, void *data);
+	void (*fetch)(struct ofono_sim *sim, int length,
+			ofono_sim_read_cb_t cb, void *data);

So three things here: First the STK details should be moved to a separate atom since they are highly vendor specific.

Second, why are we bothering with fetch, can't we simply use ofono_sim_proactive_command_notify to send us the apdu directly?

And we should get rid of status if we're not doing polling.

include/sim.h struct ofono_sim_driver { · line 161

Quoted 2 lines
include/sim.h +2 -0
+	void (*terminal_response)(struct ofono_sim *sim, int length,
+			const unsigned char *value, ofono_sim_write_cb_t cb,

to be more consistent, value first, then length.

include/sim.h struct ofono_sim_driver { · line 163

Quoted 2 lines
include/sim.h +1 -0
+			void *data);
 };

Regards,
-Denis

#2 lore raw

Hi Denis,

Quoted 6 lines · Denis Kenzior
Quoted 5 lines

Implement optional polling.  Polling is mandatory according to the specification but on most hardware it will me impractical because there will be vendor specific unsolicited notifications that can be used instead.  Modem plugins need to handle them.
---

Quoted 6 lines

So I've been going back and forth on this one and my opinion is we should not do the poll in the core.  The modem has to do it anyway, so let the modem do it and tell us when it happens.  Most vendors provide unsolicited notifications for SIM Toolkit events anyway.  Let us treat it the same way as voicecalls. The standard does not define any unsolicited responses for call state notifications, yet in practice all modem vendors provide this.

I'm fine with that, but note that we will lose the ability to have STK working out of the box on a AT compliant modem or emulator, this would be useful even just during the early development. The spec specifically says the ME that supports STK needs to poll and with what interval.

Quoted 36 lines

Keep this code around and let us re-examine this decision if we ever need to implement POLLING ON / POLLING OFF / POLLING INTERVAL commands.  Based on all the vendor specific docs I have these are intercepted by the modem and we never see them anyway.

Quoted 3 lines

 include/sim.h |   21 ++++++-
 src/sim.c     |  197 ++++++++++++++++++++++++++++++++++++++++++++++++++------- 2 files

changed,

Quoted 16 lines

 195 insertions(+), 23 deletions(-)

include/sim.h +0 -0
index 6ff29f7..fdfe2e8 100644
@@ -106,6 +106,8 @@ typedef void (*ofono_sim_lock_unlock_cb_t)(const struct

 ofono_error *error, typedef void (*ofono_sim_locked_cb_t)(const struct ofono_error *error, int locked, void *data);

+typedef void (*ofono_sim_cb_t)(const struct ofono_error *error, void *data); +
 struct ofono_sim_driver {
      const char *name;
      int (*probe)(struct ofono_sim *sim, unsigned int vendor, void *data);

include/sim.h struct ofono_sim_driver { · line 159

Quoted 6 lines
include/sim.h +3 -0
@@ -152,6 +154,12 @@ struct ofono_sim_driver {
       void (*envelope)(struct ofono_sim *sim, int length,
                               const guint8 *command,
                               ofono_sim_read_cb_t cb, void *data);
+     void (*status)(struct ofono_sim *sim, ofono_sim_cb_t cb, void *data);
+     void (*fetch)(struct ofono_sim *sim, int length,
+                     ofono_sim_read_cb_t cb, void *data);

So three things here: First the STK details should be moved to a separate atom since they are highly vendor specific.

Quoted 2 lines

Second, why are we bothering with fetch, can't we simply use ofono_sim_proactive_command_notify to send us the apdu directly?

Yes, good idea. Do we want to still call ofono_sim_proactive_command_notify from atmodem/sim.c or will we just count on modem driver to do that?

I noticed that we also need to cancel all commands already sent to GAtChat when we conclude that STATUS timed out and am not sure where to do this cancellation.

Regards