diff options
author | Denis Kenzior <denkenz@gmail.com> | 2009-08-18 17:05:50 -0500 |
---|---|---|
committer | Denis Kenzior <denkenz@gmail.com> | 2009-08-19 18:35:06 -0500 |
commit | 7e8f2ef24167b518ae13e835fb13c2a96dbdf110 (patch) | |
tree | 61b1b0eb7a3ff74ff43a607e57b25cdc72217f1a /drivers/atmodem | |
parent | 5e7240512044b2826789084ad4d8a0165149be71 (diff) | |
download | ofono-7e8f2ef24167b518ae13e835fb13c2a96dbdf110.tar.bz2 |
Update SIM AT driver to the new API
Diffstat (limited to 'drivers/atmodem')
-rw-r--r-- | drivers/atmodem/at.h | 4 | ||||
-rw-r--r-- | drivers/atmodem/atmodem.c | 5 | ||||
-rw-r--r-- | drivers/atmodem/sim.c | 103 |
3 files changed, 69 insertions, 43 deletions
diff --git a/drivers/atmodem/at.h b/drivers/atmodem/at.h index 3c55fb4f..3b359431 100644 --- a/drivers/atmodem/at.h +++ b/drivers/atmodem/at.h @@ -84,8 +84,8 @@ extern void at_call_meter_exit(); extern void at_call_barring_init(); extern void at_call_barring_exit(); -extern void at_sim_init(struct ofono_modem *modem); -extern void at_sim_exit(struct ofono_modem *modem); +extern void at_sim_init(); +extern void at_sim_exit(); extern void at_sms_init(); extern void at_sms_exit(); diff --git a/drivers/atmodem/atmodem.c b/drivers/atmodem/atmodem.c index c25096ba..d50bb478 100644 --- a/drivers/atmodem/atmodem.c +++ b/drivers/atmodem/atmodem.c @@ -102,7 +102,6 @@ static void interface_exit(struct at_data *at) at_phonebook_exit(at->modem); at_network_registration_exit(at->modem); at_voicecall_exit(at->modem); - at_sim_exit(at->modem); } static void manager_free(gpointer user) @@ -359,7 +358,7 @@ static void create_cb(GIOChannel *io, gboolean success, gpointer user) ofono_modem_set_userdata(at->modem, at); ofono_ussd_create(at->modem, "generic_at", at->parser); - at_sim_init(at->modem); + ofono_sim_create(at->modem, "generic_at", at->parser); ofono_call_forwarding_create(at->modem, "generic_at", at->parser); ofono_call_settings_create(at->modem, "generic_at", at->parser); at_network_registration_init(at->modem); @@ -533,6 +532,7 @@ static int atmodem_init(void) at_ssn_init(); at_ussd_init(); at_sms_init(); + at_sim_init(); manager_init(conn); @@ -545,6 +545,7 @@ static void atmodem_exit(void) manager_exit(conn); + at_sim_exit(); at_sms_exit(); at_ussd_exit(); at_ssn_exit(); diff --git a/drivers/atmodem/sim.c b/drivers/atmodem/sim.c index 90f02e23..84f8548e 100644 --- a/drivers/atmodem/sim.c +++ b/drivers/atmodem/sim.c @@ -32,7 +32,7 @@ #include <ofono/log.h> #include <ofono/modem.h> -#include "driver.h" +#include <ofono/sim.h> #include "gatchat.h" #include "gatresult.h" @@ -101,12 +101,12 @@ static void at_crsm_info_cb(gboolean ok, GAtResult *result, gpointer user_data) cb(&error, flen, str, rlen, access, cbd->data); } -static void at_sim_read_info(struct ofono_modem *modem, int fileid, +static void at_sim_read_info(struct ofono_sim *sim, int fileid, ofono_sim_file_info_cb_t cb, void *data) { - struct at_data *at = ofono_modem_get_userdata(modem); - struct cb_data *cbd = cb_data_new(modem, cb, data); + GAtChat *chat = ofono_sim_get_data(sim); + struct cb_data *cbd = cb_data_new(NULL, cb, data); char buf[64]; if (!cbd) @@ -114,7 +114,7 @@ static void at_sim_read_info(struct ofono_modem *modem, int fileid, snprintf(buf, sizeof(buf), "AT+CRSM=192,%i,0,0,15", fileid); - if (g_at_chat_send(at->parser, buf, crsm_prefix, + if (g_at_chat_send(chat, buf, crsm_prefix, at_crsm_info_cb, cbd, g_free) > 0) return; @@ -172,12 +172,12 @@ static void at_crsm_read_cb(gboolean ok, GAtResult *result, cb(&error, response, len, cbd->data); } -static void at_sim_read_binary(struct ofono_modem *modem, int fileid, +static void at_sim_read_binary(struct ofono_sim *sim, int fileid, int start, int length, ofono_sim_read_cb_t cb, void *data) { - struct at_data *at = ofono_modem_get_userdata(modem); - struct cb_data *cbd = cb_data_new(modem, cb, data); + GAtChat *chat = ofono_sim_get_data(sim); + struct cb_data *cbd = cb_data_new(NULL, cb, data); char buf[64]; if (!cbd) @@ -186,7 +186,7 @@ static void at_sim_read_binary(struct ofono_modem *modem, int fileid, snprintf(buf, sizeof(buf), "AT+CRSM=176,%i,%i,%i,%i", fileid, start >> 8, start & 0xff, length); - if (g_at_chat_send(at->parser, buf, crsm_prefix, + if (g_at_chat_send(chat, buf, crsm_prefix, at_crsm_read_cb, cbd, g_free) > 0) return; @@ -200,12 +200,12 @@ error: } } -static void at_sim_read_record(struct ofono_modem *modem, int fileid, +static void at_sim_read_record(struct ofono_sim *sim, int fileid, int record, int length, ofono_sim_read_cb_t cb, void *data) { - struct at_data *at = ofono_modem_get_userdata(modem); - struct cb_data *cbd = cb_data_new(modem, cb, data); + GAtChat *chat = ofono_sim_get_data(sim); + struct cb_data *cbd = cb_data_new(NULL, cb, data); char buf[64]; if (!cbd) @@ -214,7 +214,7 @@ static void at_sim_read_record(struct ofono_modem *modem, int fileid, snprintf(buf, sizeof(buf), "AT+CRSM=178,%i,%i,4,%i", fileid, record, length); - if (g_at_chat_send(at->parser, buf, crsm_prefix, + if (g_at_chat_send(chat, buf, crsm_prefix, at_crsm_read_cb, cbd, g_free) > 0) return; @@ -233,7 +233,7 @@ static void at_crsm_update_cb(gboolean ok, GAtResult *result, { struct cb_data *cbd = user_data; GAtResultIter iter; - ofono_generic_cb_t cb = cbd->cb; + ofono_sim_write_cb_t cb = cbd->cb; struct ofono_error error; gint sw1, sw2; @@ -270,13 +270,13 @@ static void at_crsm_update_cb(gboolean ok, GAtResult *result, cb(&error, cbd->data); } -static void at_sim_update_binary(struct ofono_modem *modem, int fileid, +static void at_sim_update_binary(struct ofono_sim *sim, int fileid, int start, int length, const unsigned char *value, - ofono_generic_cb_t cb, void *data) + ofono_sim_write_cb_t cb, void *data) { - struct at_data *at = ofono_modem_get_userdata(modem); - struct cb_data *cbd = cb_data_new(modem, cb, data); + GAtChat *chat = ofono_sim_get_data(sim); + struct cb_data *cbd = cb_data_new(NULL, cb, data); char *buf = g_try_new(char, 36 + length * 2); int len, ret; @@ -289,7 +289,7 @@ static void at_sim_update_binary(struct ofono_modem *modem, int fileid, for (; length; length--) len += sprintf(buf + len, "%02hhx", *value++); - ret = g_at_chat_send(at->parser, buf, crsm_prefix, + ret = g_at_chat_send(chat, buf, crsm_prefix, at_crsm_update_cb, cbd, g_free); g_free(buf); @@ -307,13 +307,13 @@ error: } } -static void at_sim_update_record(struct ofono_modem *modem, int fileid, +static void at_sim_update_record(struct ofono_sim *sim, int fileid, int record, int length, const unsigned char *value, - ofono_generic_cb_t cb, void *data) + ofono_sim_write_cb_t cb, void *data) { - struct at_data *at = ofono_modem_get_userdata(modem); - struct cb_data *cbd = cb_data_new(modem, cb, data); + GAtChat *chat = ofono_sim_get_data(sim); + struct cb_data *cbd = cb_data_new(NULL, cb, data); char *buf = g_try_new(char, 36 + length * 2); int len, ret; @@ -326,7 +326,7 @@ static void at_sim_update_record(struct ofono_modem *modem, int fileid, for (; length; length--) len += sprintf(buf + len, "%02hhx", *value++); - ret = g_at_chat_send(at->parser, buf, crsm_prefix, + ret = g_at_chat_send(chat, buf, crsm_prefix, at_crsm_update_cb, cbd, g_free); g_free(buf); @@ -344,12 +344,12 @@ error: } } -static void at_sim_update_cyclic(struct ofono_modem *modem, int fileid, +static void at_sim_update_cyclic(struct ofono_sim *sim, int fileid, int length, const unsigned char *value, - ofono_generic_cb_t cb, void *data) + ofono_sim_write_cb_t cb, void *data) { - struct at_data *at = ofono_modem_get_userdata(modem); - struct cb_data *cbd = cb_data_new(modem, cb, data); + GAtChat *chat = ofono_sim_get_data(sim); + struct cb_data *cbd = cb_data_new(NULL, cb, data); char *buf = g_try_new(char, 36 + length * 2); int len, ret; @@ -361,7 +361,7 @@ static void at_sim_update_cyclic(struct ofono_modem *modem, int fileid, for (; length; length--) len += sprintf(buf + len, "%02hhx", *value++); - ret = g_at_chat_send(at->parser, buf, crsm_prefix, + ret = g_at_chat_send(chat, buf, crsm_prefix, at_crsm_update_cb, cbd, g_free); g_free(buf); @@ -383,7 +383,7 @@ static void at_cimi_cb(gboolean ok, GAtResult *result, gpointer user_data) { struct cb_data *cbd = user_data; GAtResultIter iter; - ofono_imsi_cb_t cb = cbd->cb; + ofono_sim_imsi_cb_t cb = cbd->cb; struct ofono_error error; const char *imsi; int i; @@ -408,16 +408,16 @@ static void at_cimi_cb(gboolean ok, GAtResult *result, gpointer user_data) cb(&error, imsi, cbd->data); } -static void at_read_imsi(struct ofono_modem *modem, ofono_imsi_cb_t cb, +static void at_read_imsi(struct ofono_sim *sim, ofono_sim_imsi_cb_t cb, void *data) { - struct at_data *at = ofono_modem_get_userdata(modem); - struct cb_data *cbd = cb_data_new(modem, cb, data); + GAtChat *chat = ofono_sim_get_data(sim); + struct cb_data *cbd = cb_data_new(NULL, cb, data); if (!cbd) goto error; - if (g_at_chat_send(at->parser, "AT+CIMI", NULL, + if (g_at_chat_send(chat, "AT+CIMI", NULL, at_cimi_cb, cbd, g_free) > 0) return; @@ -431,7 +431,32 @@ error: } } -static struct ofono_sim_ops ops = { +static gboolean at_sim_register(gpointer user) +{ + struct ofono_sim *sim = user; + GAtChat *chat = ofono_sim_get_data(sim); + + ofono_sim_register(sim); + + return FALSE; +} + +static int at_sim_probe(struct ofono_sim *sim) +{ + g_idle_add(at_sim_register, sim); + + return 0; +} + +static int at_sim_remove(struct ofono_sim *sim) +{ + return 0; +} + +static struct ofono_sim_driver driver = { + .name = "generic_at", + .probe = at_sim_probe, + .remove = at_sim_remove, .read_file_info = at_sim_read_info, .read_file_transparent = at_sim_read_binary, .read_file_linear = at_sim_read_record, @@ -442,12 +467,12 @@ static struct ofono_sim_ops ops = { .read_imsi = at_read_imsi, }; -void at_sim_init(struct ofono_modem *modem) +void at_sim_init() { - ofono_sim_manager_register(modem, &ops); + ofono_sim_driver_register(&driver); } -void at_sim_exit(struct ofono_modem *modem) +void at_sim_exit() { - ofono_sim_manager_unregister(modem); + ofono_sim_driver_unregister(&driver); } |