Infineon modem selftest, during ifx_enable().
Two steps trigger, with timeout. In case one
fails, modem will not power up.

---
 plugins/ifx.c |   50 +++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 47 insertions(+), 3 deletions(-)

diff --git a/plugins/ifx.c b/plugins/ifx.c
index 411c012..da8ed0b 100644
--- a/plugins/ifx.c
+++ b/plugins/ifx.c
@@ -72,6 +72,8 @@
 #define GPRS3_DLC   4
 #define AUX_DLC     5
 
+#define IFX_SETUP_TIMEOUT      10
+
 static char *dlc_prefixes[NUM_DLC] = { "Voice: ", "Net: ", "GPRS1: ",
                                        "GPRS2: ", "GPRS3: ", "Aux: " };
 
@@ -524,10 +526,12 @@ static gboolean mux_timeout_cb(gpointer user_data)
        struct ofono_modem *modem = user_data;
        struct ifx_data *data = ofono_modem_get_data(modem);
 
-       ofono_error("Timeout with multiplexer setup");
+       ofono_error("Timeout with AT command setup");
 
        data->mux_init_timeout = 0;
 
+       g_at_chat_cancel_all(data->dlcs[AUX_DLC]);
+
        g_at_chat_unref(data->dlcs[AUX_DLC]);
        data->dlcs[AUX_DLC] = NULL;
 
@@ -539,6 +543,35 @@ static gboolean mux_timeout_cb(gpointer user_data)
        return FALSE;
 }
 
+static void dev_ver_selftest_cb(gboolean ok, GAtResult *result,
+                               gpointer user_data)
+{
+
+       struct ofono_modem *modem = user_data;
+       struct ifx_data *data = ofono_modem_get_data(modem);
+
+       if (!ok) {
+               ofono_error("ERROR:IFX Selftest at@vers:device_version_id()"
+                               "-FAILED");
+
+               g_at_chat_cancel_all(data->dlcs[AUX_DLC]);
+       }
+}
+
+static void rtc_gti_selftest_cb(gboolean ok, GAtResult *result,
+                       gpointer user_data)
+{
+       struct ofono_modem *modem = user_data;
+       struct ifx_data *data = ofono_modem_get_data(modem);
+
+       if (!ok) {
+               ofono_error("ERROR:IFX Selftest"
+                       "at@rtc:rtc_gti_test_verify_32khz()-FAILED");
+
+               g_at_chat_cancel_all(data->dlcs[AUX_DLC]);
+       }
+}
+
 static int ifx_enable(struct ofono_modem *modem)
 {
        struct ifx_data *data = ofono_modem_get_data(modem);
@@ -592,13 +625,24 @@ static int ifx_enable(struct ofono_modem *modem)
        g_at_chat_send(chat, "ATE0 +CMEE=1", NULL,
                                        NULL, NULL, NULL);
 
+       /* Execute Modem Self tests */
+       data->dlcs[AUX_DLC] = chat;
+
+       g_at_chat_send(data->dlcs[AUX_DLC],
+               "at@rtc:rtc_gti_test_verify_32khz()",
+               NULL, rtc_gti_selftest_cb, modem, NULL);
+
+       g_at_chat_send(data->dlcs[AUX_DLC], "at@vers:device_version_id()",
+               NULL, dev_ver_selftest_cb, modem, NULL);
+
+       /* Enable  MUX Channels */
        data->frame_size = 1509;
 
        g_at_chat_send(chat, "AT+CMUX=0,0,,1509,10,3,30,,", NULL,
                                        mux_setup_cb, modem, NULL);
 
-       data->mux_init_timeout = g_timeout_add_seconds(5, mux_timeout_cb,
-                                                               modem);
+       data->mux_init_timeout = g_timeout_add_seconds(
+               IFX_SETUP_TIMEOUT, mux_timeout_cb, modem);
 
        data->dlcs[AUX_DLC] = chat;
 
-- 
1.7.1

_______________________________________________
ofono mailing list
[email protected]
http://lists.ofono.org/listinfo/ofono

Reply via email to