From 0b82269b113d09855d2c470651c4f0a7e8a8bce6 Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Sun, 1 Jan 2012 18:00:39 -0800 Subject: [PATCH] hso: Add support for detecting is no SIM card is present --- plugins/hso.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/plugins/hso.c b/plugins/hso.c index 897cd12..ed1a4c1 100644 --- a/plugins/hso.c +++ b/plugins/hso.c @@ -58,7 +58,7 @@ struct hso_data { GAtChat *control; guint sim_poll_source; guint sim_poll_count; - gboolean have_sim; + ofono_bool_t have_sim; }; static int hso_probe(struct ofono_modem *modem) @@ -144,7 +144,8 @@ static void sim_status(gboolean ok, GAtResult *result, gpointer user_data) DBG("status sim %d pb %d sms %d", sim, pb, sms); - if (sim == 0) { + switch (sim) { + case 0: /* not ready */ data->have_sim = FALSE; if (data->sim_poll_count++ < 5) { @@ -152,12 +153,24 @@ static void sim_status(gboolean ok, GAtResult *result, gpointer user_data) init_sim_check, modem); return; } - } else + break; + case 1: /* SIM card ready */ data->have_sim = TRUE; + break; + case 2: /* no SIM card */ + data->have_sim = FALSE; + break; + default: + data->have_sim = FALSE; + break; + } data->sim_poll_count = 0; - ofono_modem_set_powered(modem, TRUE); + ofono_modem_set_powered(modem, data->have_sim); + + if (data->have_sim == FALSE) + return; /* * Option has the concept of Speech Service versus -- 2.7.4