diff options
author | Gustavo F. Padovan <padovan@profusion.mobi> | 2010-12-03 16:52:56 -0200 |
---|---|---|
committer | Denis Kenzior <denkenz@gmail.com> | 2010-12-07 12:16:20 -0600 |
commit | b7cfbff47d79e465e9c53bdfe38a3130ffef8501 (patch) | |
tree | 7ca69d2c5b10e714afcef8f6e9b8ac4b04887237 /plugins/phonesim.c | |
parent | 5862e614fd3eb2741752b3dee75a236a8b7f111f (diff) | |
download | ofono-b7cfbff47d79e465e9c53bdfe38a3130ffef8501.tar.gz |
phonesim: Add modem reset trigger
Diffstat (limited to 'plugins/phonesim.c')
-rw-r--r-- | plugins/phonesim.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/plugins/phonesim.c b/plugins/phonesim.c index 6b483ff6..c7ef0d7d 100644 --- a/plugins/phonesim.c +++ b/plugins/phonesim.c @@ -374,6 +374,30 @@ static void cfun_set_on_cb(gboolean ok, GAtResult *result, gpointer user_data) ofono_modem_set_powered(modem, ok); } +static gboolean phonesim_reset(void *user_data) +{ + struct ofono_modem *modem = user_data; + struct phonesim_data *data = ofono_modem_get_data(modem); + + g_at_chat_unref(data->chat); + data->chat = NULL; + + if (data->mux) { + g_at_mux_shutdown(data->mux); + g_at_mux_unref(data->mux); + data->mux = NULL; + } + + ofono_modem_reset(modem); + + return FALSE; +} + +static void crst_notify(GAtResult *result, gpointer user_data) +{ + g_idle_add(phonesim_reset, user_data); +} + static void phonesim_disconnected(gpointer user_data) { struct ofono_modem *modem = user_data; @@ -526,6 +550,9 @@ static int phonesim_enable(struct ofono_modem *modem) g_at_chat_send(data->chat, "AT+CSCS=\"GSM\"", none_prefix, NULL, NULL, NULL); + g_at_chat_register(data->chat, "+CRST:", + crst_notify, FALSE, modem, NULL); + return 0; } |