From: Florian Steinel <Florian.Steinel@gmail.com>
To: ofono@ofono.org
Subject: [PATCH 1/1] (RFC) Huawei: Modify ^SYSINFO logic
Date: Mon, 19 Jul 2010 00:09:03 +0200 [thread overview]
Message-ID: <20100718220903.GA10397@h02.hostsharing.net> (raw)
In-Reply-To: <20100718201936.GA29262@h02.hostsharing.net>
[-- Attachment #1: Type: text/plain, Size: 4125 bytes --]
---
plugins/huawei.c | 114 +++++++++++++++++++++++++++++++++++++++++++++++++----
1 files changed, 105 insertions(+), 9 deletions(-)
diff --git a/plugins/huawei.c b/plugins/huawei.c
index cfc693d..c14b076 100644
--- a/plugins/huawei.c
+++ b/plugins/huawei.c
@@ -57,12 +57,22 @@
static const char *none_prefix[] = { NULL };
static const char *sysinfo_prefix[] = { "^SYSINFO:", NULL };
+static const char *cpin_prefix[] = { "CPIN:", NULL };
+
+enum my_sim_state {
+ SIM_STATE_INVALID_OR_PIN_BLOCKED = 0,
+ SIM_STATE_NORMAL_SIM_CARD = 1,
+ SIM_STATE_SIM_NOT_VALID_IN_CS_MODE = 2,
+ SIM_STATE_SIM_NOT_VALID_IN_PS_MODE = 3,
+ SIM_STATE_SIM_NOT_VALID_IN_CS_OR_PS_MODE = 4,
+ SIM_STATE_SIM_NOT_PRESENT = 255
+};
struct huawei_data {
GAtChat *modem;
GAtChat *pcui;
struct ofono_sim *sim;
- gint sim_state;
+ enum my_sim_state sim_state;
struct ofono_gprs *gprs;
struct ofono_gprs_context *gc;
};
@@ -101,19 +111,105 @@ static void huawei_debug(const char *str, void *user_data)
ofono_info("%s%s", prefix, str);
}
-static void notify_sim_state(struct ofono_modem *modem, gint sim_state)
+static void notify_sim_state(struct ofono_modem *modem, enum my_sim_state sim_state)
{
struct huawei_data *data = ofono_modem_get_data(modem);
- if (data->sim_state == 0 && sim_state == 1) {
- ofono_sim_inserted_notify(data->sim, TRUE);
- data->sim_state = sim_state;
- } else if (data->sim_state == 1 && sim_state == 0) {
- ofono_sim_inserted_notify(data->sim, FALSE);
- data->sim_state = sim_state;
+ switch (sim_state) {
+ case SIM_STATE_INVALID_OR_PIN_BLOCKED:
+ if (data->sim_state != sim_state) {
+ /* TODO copy code from mbm.c function init_simpin_check and ff */
+ ofono_sim_inserted_notify(data->sim, TRUE);
+ }
+
+ break;
+
+ case SIM_STATE_NORMAL_SIM_CARD:
+ if (data->sim_state != sim_state) {
+ ofono_sim_inserted_notify(data->sim, TRUE);
+ }
+
+ break;
+
+ case SIM_STATE_SIM_NOT_VALID_IN_CS_MODE:
+ if (data->sim_state != sim_state) {
+ ofono_sim_inserted_notify(data->sim, FALSE);
+ }
+
+ break;
+
+ case SIM_STATE_SIM_NOT_VALID_IN_PS_MODE:
+ if (data->sim_state != sim_state) {
+ ofono_sim_inserted_notify(data->sim, FALSE);
+ }
+
+ break;
+
+ case SIM_STATE_SIM_NOT_VALID_IN_CS_OR_PS_MODE:
+ if (data->sim_state != sim_state) {
+ ofono_sim_inserted_notify(data->sim, FALSE);
+ }
+
+ break;
+
+ case SIM_STATE_SIM_NOT_PRESENT:
+ if (data->sim_state != sim_state) {
+ ofono_sim_inserted_notify(data->sim, FALSE);
+ }
+
+ break;
+
+ default:
+ break;
}
+ data->sim_state = sim_state;
}
+/*
+ *
+ * SYSINFO = a,b,c,d,e,f
+ *
+ * a :
+ * 0 - no network access
+ * 1 - limited access to the network
+ * 2 - normal access to the network
+ * 3 - limited access to networks in your area
+ * 4 - Power saving mode
+ * b:
+ * 0 - no access to the call date
+ * 1 - only the circuit switching
+ * 2 - only the packet switching
+ * 3 - PS + SC
+ * 4 - had not registered
+ * c:
+ * 0 - registered in your home network
+ * 1 - registered in roaming
+ * d:
+ * 0 - no network access
+ * 1 - APMs
+ * 2 - CDMA
+ * 3 - GSM / GPRS
+ * 4 - HDR
+ * 5 - WCDMA
+ * 6 - GPS
+ * e:
+ * 0 - invalid SIM card or PIN code blocked
+ * 1 - normal SIM card
+ * 2 - SIM card not valid in CS mode
+ * 3 - SIM card not valid in PS mode
+ * 4 - SIM card not valid in PS or CS mode
+ * f:
+ * 0 - no network access
+ * 1 - GSM mode
+ * 2 - GPRS
+ * 3 - Mode EDGE
+ * 4 - WCDMA mode
+ * 5 - HSDPA mode
+ * 6 - HSUPA mode
+ * 7 - mode HSPA
+ * 8 - HSPA + mode
+ *
+ */
static void sysinfo_cb(gboolean ok, GAtResult *result, gpointer user_data)
{
struct ofono_modem *modem = user_data;
@@ -277,7 +373,7 @@ static int huawei_enable(struct ofono_modem *modem)
return -EIO;
}
- data->sim_state = 0;
+ data->sim_state = SIM_STATE_SIM_NOT_PRESENT;
g_at_chat_send(data->pcui, "ATE0", none_prefix, NULL, NULL, NULL);
--
1.7.1
next prev parent reply other threads:[~2010-07-18 22:09 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-07-18 11:04 Huawei E176 - not online Florian Steinel
2010-07-18 14:55 ` Denis Kenzior
2010-07-18 20:19 ` Florian Steinel
2010-07-18 22:09 ` Florian Steinel [this message]
2010-07-18 22:59 ` [PATCH 1/1] (RFC) Huawei: Modify ^SYSINFO logic Marcel Holtmann
2010-07-19 1:42 ` Huawei E176 - not online Denis Kenzior
2010-07-21 8:56 ` Kalle Valo
2010-07-21 9:06 ` Kalle Valo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20100718220903.GA10397@h02.hostsharing.net \
--to=florian.steinel@gmail.com \
--cc=ofono@ofono.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.