diff options
author | Mika Liljeberg <mika.liljeberg@nokia.com> | 2010-09-10 16:50:58 +0300 |
---|---|---|
committer | Denis Kenzior <denkenz@gmail.com> | 2010-09-10 10:52:07 -0500 |
commit | 74e4f9ee519e2bac877864ca306df519e561e5d5 (patch) | |
tree | 2b25e4c6c9b0db6ab85146821d46ece0a3eea16b /drivers/isimodem/gprs.c | |
parent | 1e139eb1cedd6cb818c9b32f0d0043507ddc8cf0 (diff) | |
download | ofono-74e4f9ee519e2bac877864ca306df519e561e5d5.tar.bz2 |
isimodem: implement Suspended property
Diffstat (limited to 'drivers/isimodem/gprs.c')
-rw-r--r-- | drivers/isimodem/gprs.c | 56 |
1 files changed, 55 insertions, 1 deletions
diff --git a/drivers/isimodem/gprs.c b/drivers/isimodem/gprs.c index 6f4f686d..93786ec5 100644 --- a/drivers/isimodem/gprs.c +++ b/drivers/isimodem/gprs.c @@ -72,6 +72,55 @@ static void detach_ind_cb(GIsiClient *client, /*ofono_gprs_detached_notify(gprs);*/ } +static void suspend_notify(struct ofono_gprs *gprs, uint8_t suspend_status, + uint8_t suspend_cause) +{ + int cause; + + DBG("transfer status: %s (0x%02"PRIx8") cause %s (0x%02"PRIx8")", + gpds_transfer_status_name(suspend_status), suspend_status, + gpds_transfer_cause_name(suspend_cause), suspend_cause); + + if (suspend_status == GPDS_TRANSFER_AVAIL) { + ofono_gprs_resume_notify(gprs); + return; + } + + switch (suspend_cause) { + case GPDS_TRANSFER_CAUSE_SUSPENDED_NO_COVERAGE: + cause = GPRS_SUSPENDED_NO_COVERAGE; + break; + + case GPDS_TRANSFER_CAUSE_SUSPENDED_CALL: + cause = GPRS_SUSPENDED_CALL; + break; + + case GPDS_TRANSFER_CAUSE_SUSPENDED_CALL_SMS: + case GPDS_TRANSFER_CAUSE_SUSPENDED_RAU: + case GPDS_TRANSFER_CAUSE_SUSPENDED_LU: + cause = GPRS_SUSPENDED_SIGNALLING; + break; + + default: + return; + } + + ofono_gprs_suspend_notify(gprs, cause); +} + +static void transfer_status_ind_cb(GIsiClient *client, + const void *restrict data, size_t len, + uint16_t object, void *opaque) +{ + struct ofono_gprs *gprs = opaque; + const unsigned char *msg = data; + + if (!msg || len < 3 || msg[0] != GPDS_TRANSFER_STATUS_IND) + return; + + suspend_notify(gprs, msg[1], msg[2]); +} + static gboolean isi_gprs_register(gpointer user) { struct ofono_gprs *gprs = user; @@ -83,6 +132,8 @@ static gboolean isi_gprs_register(gpointer user) g_isi_client_set_debug(gd->client, gpds_debug, NULL); g_isi_subscribe(gd->client, GPDS_DETACH_IND, detach_ind_cb, gprs); + g_isi_subscribe(gd->client, GPDS_TRANSFER_STATUS_IND, + transfer_status_ind_cb, gprs); ofono_gprs_register(user); @@ -258,6 +309,7 @@ static gboolean status_resp_cb(GIsiClient *client, const unsigned char *msg = data; struct isi_cb_data *cbd = opaque; ofono_gprs_status_cb_t cb = cbd->cb; + struct ofono_gprs *gprs = cbd->data; int status; if (!msg) { @@ -265,7 +317,7 @@ static gboolean status_resp_cb(GIsiClient *client, goto error; } - if (len < 2 || msg[0] != GPDS_STATUS_RESP) + if (len < 13 || msg[0] != GPDS_STATUS_RESP) return FALSE; /* FIXME: the core still expects reg status, and not a boolean @@ -281,6 +333,8 @@ static gboolean status_resp_cb(GIsiClient *client, status = GPRS_STAT_UNKNOWN; } + suspend_notify(gprs, msg[11], msg[12]); + CALLBACK_WITH_SUCCESS(cb, status, cbd->data); return TRUE; |