summaryrefslogtreecommitdiffstats
path: root/drivers/atmodem
diff options
context:
space:
mode:
authorAndrzej Zaborowski <andrew.zaborowski@intel.com>2009-06-21 03:30:14 +0200
committerDenis Kenzior <denkenz@gmail.com>2009-06-22 13:22:14 -0500
commitfde5fc5a83f959159d606d80b5eeecdcf773f89f (patch)
tree2d3be1261fc8d79ccc0c4586bc87da1a6418ada5 /drivers/atmodem
parent17b7444b47776ce544340b686b5f6d22c00e3a80 (diff)
downloadofono-fde5fc5a83f959159d606d80b5eeecdcf773f89f.tar.bz2
Add write/read operations for cyclic files in SIM.
Diffstat (limited to 'drivers/atmodem')
-rw-r--r--drivers/atmodem/sim.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/drivers/atmodem/sim.c b/drivers/atmodem/sim.c
index 620aefcd..ab05a5be 100644
--- a/drivers/atmodem/sim.c
+++ b/drivers/atmodem/sim.c
@@ -328,6 +328,39 @@ error:
}
}
+static void at_sim_update_cyclic(struct ofono_modem *modem, int fileid,
+ int length, const unsigned char *value,
+ ofono_generic_cb_t cb, void *data)
+{
+ struct at_data *at = ofono_modem_userdata(modem);
+ struct cb_data *cbd = cb_data_new(modem, cb, data);
+ char *buf = g_try_new(char, 36 + length * 2);
+ int len, ret;
+
+ if (!cbd || !buf)
+ goto error;
+
+ len = sprintf(buf, "AT+CRSM=220,%i,0,3,%i,", fileid, length);
+ for (; length; length--)
+ len += sprintf(buf + len, "%02hhx", *value++);
+ ret = g_at_chat_send(at->parser, buf, crsm_prefix,
+ at_crsm_update_cb, cbd, g_free);
+
+ g_free(buf);
+
+ if (ret > 0)
+ return;
+
+error:
+ if (cbd)
+ g_free(cbd);
+
+ {
+ DECLARE_FAILURE(error);
+ cb(&error, data);
+ }
+}
+
static void at_cimi_cb(gboolean ok, GAtResult *result, gpointer user_data)
{
struct cb_data *cbd = user_data;
@@ -383,8 +416,10 @@ static struct ofono_sim_ops ops = {
.read_file_info = at_sim_read_info,
.read_file_transparent = at_sim_read_binary,
.read_file_linear = at_sim_read_record,
+ .read_file_cyclic = at_sim_read_record,
.write_file_transparent = at_sim_update_binary,
.write_file_linear = at_sim_update_record,
+ .write_file_cyclic = at_sim_update_cyclic,
.read_imsi = at_read_imsi,
};