--- plugins/huaweicdma.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 44 insertions(+), 0 deletions(-)
diff --git a/plugins/huaweicdma.c b/plugins/huaweicdma.c index 9151ba8..0036b20 100644 --- a/plugins/huaweicdma.c +++ b/plugins/huaweicdma.c @@ -41,6 +41,7 @@ struct huaweicdma_data { GAtChat *modem; GAtChat *pcui; + GAtHDLC *hdlc; }; static void huaweicdma_debug(const char *str, void *data) @@ -75,6 +76,7 @@ static void huaweicdma_remove(struct ofono_modem *modem) /* Cleanup after hot-unplug */ g_at_chat_unref(data->pcui); + g_at_hdlc_unref(data->hdlc); g_free(data); } @@ -92,6 +94,9 @@ static void cfun_enable(gboolean ok, GAtResult *result, gpointer user_data) g_at_chat_unref(data->pcui); data->pcui = NULL; + + g_at_hdlc_unref(data->hdlc); + data->hdlc = NULL; } ofono_modem_set_powered(modem, ok); @@ -130,6 +135,38 @@ static GAtChat *open_device(struct ofono_modem *modem, return chat; } +static GAtHDLC *open_qcdm(struct ofono_modem *modem) +{ + const char *device; + GIOChannel *channel; + GAtHDLC *hdlc; + + device = ofono_modem_get_string(modem, "Diag"); + if (device == NULL) + return NULL; + + DBG("Diagnostic Monitor %s", device); + + channel = g_at_tty_open_qcdm(device); + if (channel == NULL) + return NULL; + + hdlc = g_at_hdlc_new(channel); + + g_io_channel_unref(channel); + + if (hdlc == NULL) + return NULL; + + if (getenv("OFONO_AT_DEBUG")) + g_at_hdlc_set_debug(hdlc, huaweicdma_debug, "HDLC: "); + + g_at_hdlc_set_xmit_accm(hdlc, 0); + g_at_hdlc_set_recv_accm(hdlc, 0); + + return hdlc; +} + static int huaweicdma_enable(struct ofono_modem *modem) { struct huaweicdma_data *data = ofono_modem_get_data(modem); @@ -147,6 +184,10 @@ static int huaweicdma_enable(struct ofono_modem *modem) return -EIO; } + data->hdlc = open_qcdm(modem); + if (data->hdlc != NULL) + g_at_chat_associate_diag_monitor(data->pcui, data->hdlc); + g_at_chat_send(data->modem, "ATE0 &C0 +CMEE=1", NULL, NULL, NULL, NULL); g_at_chat_send(data->pcui, "ATE0 &C0 +CMEE=1", NULL, NULL, NULL, NULL); @@ -182,6 +223,9 @@ static int huaweicdma_disable(struct ofono_modem *modem) g_at_chat_unref(data->modem); data->modem = NULL; + g_at_hdlc_unref(data->hdlc); + data->hdlc = NULL; + g_at_chat_cancel_all(data->pcui); g_at_chat_unregister_all(data->pcui); -- 1.7.1 _______________________________________________ ofono mailing list ofono@ofono.org http://lists.ofono.org/listinfo/ofono