* [PATCH 1/4] huawei: use g_at_result_iter_skip_next()
2010-05-25 14:23 [PATCH 0/4] huawei: minor cleanups Kalle Valo
@ 2010-05-25 14:23 ` Kalle Valo
2010-05-25 14:23 ` [PATCH 2/4] huawei: properly notify sim state to ofono Kalle Valo
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Kalle Valo @ 2010-05-25 14:23 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 1222 bytes --]
---
plugins/huawei.c | 10 +++++-----
1 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/plugins/huawei.c b/plugins/huawei.c
index a2492a7..1c44be1 100644
--- a/plugins/huawei.c
+++ b/plugins/huawei.c
@@ -91,7 +91,7 @@ static void sysinfo_cb(gboolean ok, GAtResult *result, gpointer user_data)
{
struct ofono_modem *modem = user_data;
struct huawei_data *data = ofono_modem_get_data(modem);
- gint srv_status, srv_domain, roam, sys_mode, sim_state;
+ gint sim_state;
GAtResultIter iter;
if (!ok)
@@ -102,16 +102,16 @@ static void sysinfo_cb(gboolean ok, GAtResult *result, gpointer user_data)
if (!g_at_result_iter_next(&iter, "^SYSINFO:"))
return;
- if (!g_at_result_iter_next_number(&iter, &srv_status))
+ if (!g_at_result_iter_skip_next(&iter))
return;
- if (!g_at_result_iter_next_number(&iter, &srv_domain))
+ if (!g_at_result_iter_skip_next(&iter))
return;
- if (!g_at_result_iter_next_number(&iter, &roam))
+ if (!g_at_result_iter_skip_next(&iter))
return;
- if (!g_at_result_iter_next_number(&iter, &sys_mode))
+ if (!g_at_result_iter_skip_next(&iter))
return;
if (!g_at_result_iter_next_number(&iter, &sim_state))
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCH 2/4] huawei: properly notify sim state to ofono
2010-05-25 14:23 [PATCH 0/4] huawei: minor cleanups Kalle Valo
2010-05-25 14:23 ` [PATCH 1/4] huawei: use g_at_result_iter_skip_next() Kalle Valo
@ 2010-05-25 14:23 ` Kalle Valo
2010-05-25 14:23 ` [PATCH 3/4] huawei: send a prefix with AT commands Kalle Valo
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Kalle Valo @ 2010-05-25 14:23 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 4484 bytes --]
Instead of using ofono_modem_set_powered(), use ofono_sim_inserted_notify()
which is the proper way to notify about sim state changes.
Now the problem is that voicecall commands fail with my Huawei E1552:
ofonod[12395]: > AT+CRC=1\r
ofonod[12395]: src/sim.c:ofono_sim_add_state_watch() 0x1bf8e50
ofonod[12395]: src/sim.c:ofono_sim_add_state_watch() 0x1bf8e50
ofonod[12395]: < \r\n+CME ERROR: SIM busy\r\n
ofonod[12395]: > AT+CLIP=1\r
ofonod[12395]: < \r\n+CME ERROR: SIM busy\r\n
ofonod[12395]: > AT+COLP=1\r
ofonod[12395]: < \r\n+CME ERROR: SIM busy\r\n
ofonod[12395]: > AT+CCWA=1\r
ofonod[12395]: < \r\n+CME ERROR: SIM busy\r\n
ofonod[12395]: drivers/atmodem/voicecall.c:at_voicecall_initialized()
voicecall_init: registering to notifications
ofonod[12395]: src/sim.c:ofono_sim_add_state_watch() 0x1bf8e50
ofonod[12395]: > AT^SYSINFO\r
ofonod[12395]: < \r\n^SYSINFO:0,0,0,0,255,,0\r\n\r\nOK\r\n
ofonod[12395]: > AT+CGMI\r
ofonod[12395]: < \r\nhuawei\r\n\r\nOK\r\n
ofonod[12395]: EventChannel: < \r\n^STIN:0,0,0\r\n
ofonod[12395]: > AT+CLCC\r
ofonod[12395]: < \r\n+CME ERROR: SIM busy\r\n
But as I can't make voice calls with this modem anyway, I don't worry
about them right now.
---
plugins/huawei.c | 44 +++++++++++++++++++++++---------------------
1 files changed, 23 insertions(+), 21 deletions(-)
diff --git a/plugins/huawei.c b/plugins/huawei.c
index 1c44be1..962895a 100644
--- a/plugins/huawei.c
+++ b/plugins/huawei.c
@@ -50,6 +50,7 @@
struct huawei_data {
GAtChat *chat;
GAtChat *event;
+ struct ofono_sim *sim;
gint sim_state;
};
@@ -87,6 +88,17 @@ static void huawei_debug(const char *str, void *user_data)
ofono_info("%s%s", prefix, str);
}
+static void notify_sim_state(struct huawei_data *data, gint sim_state)
+{
+ 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;
+ }
+}
+
static void sysinfo_cb(gboolean ok, GAtResult *result, gpointer user_data)
{
struct ofono_modem *modem = user_data;
@@ -117,10 +129,7 @@ static void sysinfo_cb(gboolean ok, GAtResult *result, gpointer user_data)
if (!g_at_result_iter_next_number(&iter, &sim_state))
return;
- if (data->sim_state == 0 && sim_state == 1) {
- ofono_modem_set_powered(modem, TRUE);
- data->sim_state = sim_state;
- }
+ notify_sim_state(data, sim_state);
}
static void simst_notify(GAtResult *result, gpointer user_data)
@@ -138,10 +147,7 @@ static void simst_notify(GAtResult *result, gpointer user_data)
if (!g_at_result_iter_next_number(&iter, &state))
return;
- if (data->sim_state == 0 && state == 1) {
- ofono_modem_set_powered(modem, TRUE);
- data->sim_state = state;
- }
+ notify_sim_state(data, state);
}
static void cfun_enable(gboolean ok, GAtResult *result, gpointer user_data)
@@ -151,12 +157,16 @@ static void cfun_enable(gboolean ok, GAtResult *result, gpointer user_data)
DBG("");
- if (!ok) {
- ofono_modem_set_powered(modem, FALSE);
+ ofono_modem_set_powered(modem, ok);
+
+ if (!ok)
return;
- }
- /* check sim state */
+ /* follow sim state */
+ g_at_chat_register(data->event, "^SIMST:", simst_notify,
+ FALSE, modem, NULL);
+
+ /* query current sim state */
g_at_chat_send(data->chat, "AT^SYSINFO", NULL, sysinfo_cb, modem, NULL);
}
@@ -221,10 +231,6 @@ static int huawei_enable(struct ofono_modem *modem)
data->sim_state = 0;
- /* follow sim state */
- g_at_chat_register(data->event, "^SIMST:", simst_notify,
- FALSE, modem, NULL);
-
g_at_chat_send(data->chat, "ATE0", NULL, NULL, NULL, NULL);
g_at_chat_send(data->chat, "AT+CFUN=1", NULL,
@@ -274,16 +280,12 @@ static int huawei_disable(struct ofono_modem *modem)
static void huawei_pre_sim(struct ofono_modem *modem)
{
struct huawei_data *data = ofono_modem_get_data(modem);
- struct ofono_sim *sim;
DBG("%p", modem);
ofono_devinfo_create(modem, 0, "atmodem", data->chat);
- sim = ofono_sim_create(modem, 0, "atmodem", data->chat);
+ data->sim = ofono_sim_create(modem, 0, "atmodem", data->chat);
ofono_voicecall_create(modem, 0, "atmodem", data->chat);
-
- if (sim)
- ofono_sim_inserted_notify(sim, TRUE);
}
static void cgreg_notify(GAtResult *result, gpointer user_data)
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCH 3/4] huawei: send a prefix with AT commands
2010-05-25 14:23 [PATCH 0/4] huawei: minor cleanups Kalle Valo
2010-05-25 14:23 ` [PATCH 1/4] huawei: use g_at_result_iter_skip_next() Kalle Valo
2010-05-25 14:23 ` [PATCH 2/4] huawei: properly notify sim state to ofono Kalle Valo
@ 2010-05-25 14:23 ` Kalle Valo
2010-05-25 14:23 ` [PATCH 4/4] huawei: remove voicecall support Kalle Valo
2010-05-25 14:52 ` [PATCH 0/4] huawei: minor cleanups Denis Kenzior
4 siblings, 0 replies; 6+ messages in thread
From: Kalle Valo @ 2010-05-25 14:23 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 1619 bytes --]
---
plugins/huawei.c | 12 ++++++++----
1 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/plugins/huawei.c b/plugins/huawei.c
index 962895a..d7697b9 100644
--- a/plugins/huawei.c
+++ b/plugins/huawei.c
@@ -47,6 +47,9 @@
#include <drivers/atmodem/atutil.h>
#include <drivers/atmodem/vendor.h>
+static const char *none_prefix[] = { NULL };
+static const char *sysinfo_prefix[] = { "^SYSINFO:", NULL };
+
struct huawei_data {
GAtChat *chat;
GAtChat *event;
@@ -167,7 +170,8 @@ static void cfun_enable(gboolean ok, GAtResult *result, gpointer user_data)
FALSE, modem, NULL);
/* query current sim state */
- g_at_chat_send(data->chat, "AT^SYSINFO", NULL, sysinfo_cb, modem, NULL);
+ g_at_chat_send(data->chat, "AT^SYSINFO", sysinfo_prefix,
+ sysinfo_cb, modem, NULL);
}
static GAtChat *create_port(const char *device)
@@ -231,9 +235,9 @@ static int huawei_enable(struct ofono_modem *modem)
data->sim_state = 0;
- g_at_chat_send(data->chat, "ATE0", NULL, NULL, NULL, NULL);
+ g_at_chat_send(data->chat, "ATE0", none_prefix, NULL, NULL, NULL);
- g_at_chat_send(data->chat, "AT+CFUN=1", NULL,
+ g_at_chat_send(data->chat, "AT+CFUN=1", none_prefix,
cfun_enable, modem, NULL);
return -EINPROGRESS;
@@ -271,7 +275,7 @@ static int huawei_disable(struct ofono_modem *modem)
g_at_chat_cancel_all(data->chat);
g_at_chat_unregister_all(data->chat);
- g_at_chat_send(data->chat, "AT+CFUN=0", NULL,
+ g_at_chat_send(data->chat, "AT+CFUN=0", none_prefix,
cfun_disable, modem, NULL);
return -EINPROGRESS;
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCH 4/4] huawei: remove voicecall support
2010-05-25 14:23 [PATCH 0/4] huawei: minor cleanups Kalle Valo
` (2 preceding siblings ...)
2010-05-25 14:23 ` [PATCH 3/4] huawei: send a prefix with AT commands Kalle Valo
@ 2010-05-25 14:23 ` Kalle Valo
2010-05-25 14:52 ` [PATCH 0/4] huawei: minor cleanups Denis Kenzior
4 siblings, 0 replies; 6+ messages in thread
From: Kalle Valo @ 2010-05-25 14:23 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 622 bytes --]
These modems don't support voicecall anyway. Recommended by Denis.
---
plugins/huawei.c | 1 -
1 files changed, 0 insertions(+), 1 deletions(-)
diff --git a/plugins/huawei.c b/plugins/huawei.c
index d7697b9..1b7a185 100644
--- a/plugins/huawei.c
+++ b/plugins/huawei.c
@@ -289,7 +289,6 @@ static void huawei_pre_sim(struct ofono_modem *modem)
ofono_devinfo_create(modem, 0, "atmodem", data->chat);
data->sim = ofono_sim_create(modem, 0, "atmodem", data->chat);
- ofono_voicecall_create(modem, 0, "atmodem", data->chat);
}
static void cgreg_notify(GAtResult *result, gpointer user_data)
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [PATCH 0/4] huawei: minor cleanups
2010-05-25 14:23 [PATCH 0/4] huawei: minor cleanups Kalle Valo
` (3 preceding siblings ...)
2010-05-25 14:23 ` [PATCH 4/4] huawei: remove voicecall support Kalle Valo
@ 2010-05-25 14:52 ` Denis Kenzior
4 siblings, 0 replies; 6+ messages in thread
From: Denis Kenzior @ 2010-05-25 14:52 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 142 bytes --]
Hi Kalle,
> Some more love to Huawei, based on Dennis' comments.
>
> ---
All four have been pushed now, thanks.
Regards,
-Denis
^ permalink raw reply [flat|nested] 6+ messages in thread