Implement the modem reset function for Huawei.

Huawei devices can be reset (reboot) by sending the AT^RESET command.
---
 plugins/huawei.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/plugins/huawei.c b/plugins/huawei.c
index bb876701..35195e2d 100644
--- a/plugins/huawei.c
+++ b/plugins/huawei.c
@@ -900,6 +900,30 @@ static void huawei_post_online(struct ofono_modem *modem)
        }
 }
 
+static void reset_cb(gboolean ok, GAtResult *result,
+                                               gpointer user_data)
+{
+       if (!ok)
+               DBG("Failed to reset device");
+       else
+               DBG("Device resets shortly");
+}
+
+static int huawei_reset(struct ofono_modem *modem)
+{
+       struct huawei_data *data = ofono_modem_get_data(modem);
+
+       DBG("Reset device: %p", modem);
+
+       if (g_at_chat_send(data->pcui, "AT^RESET", NULL,
+                       reset_cb, NULL, NULL) == FALSE) {
+               DBG("Failed to send reset command");
+               return -EIO;
+       }
+
+       return 0;
+}
+
 static struct ofono_modem_driver huawei_driver = {
        .name           = "huawei",
        .probe          = huawei_probe,
@@ -910,6 +934,7 @@ static struct ofono_modem_driver huawei_driver = {
        .pre_sim        = huawei_pre_sim,
        .post_sim       = huawei_post_sim,
        .post_online    = huawei_post_online,
+       .reset          = huawei_reset,
 };
 
 static int huawei_init(void)
-- 
2.17.1
_______________________________________________
ofono mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to