@@ -0,0 +1,269 @@
+diff --git a/drivers/qmimodem/qmi.c b/drivers/qmimodem/qmi.c
+index 69a0e535..d94c5498 100644
+--- a/drivers/qmimodem/qmi.c
++++ b/drivers/qmimodem/qmi.c
+@@ -39,6 +39,7 @@
+ #include <ell/ell.h>
+
+ #include <ofono/log.h>
++#include <gatchat.h>
+
+ #include "qmi.h"
+ #include "ctl.h"
+@@ -106,6 +107,7 @@ struct qmi_device {
+ bool writer_active : 1;
+ bool shutting_down : 1;
+ bool destroyed : 1;
++ GAtChat *atmodem;
+ };
+
+ struct qmi_device_qmux {
+@@ -1053,6 +1055,22 @@ bool qmi_device_has_service(struct qmi_device *device, uint16_t type)
+ return __find_service_info_by_type(device, type);
+ }
+
++void qmi_device_set_atmodem(struct qmi_device *device, GAtChat* atmodem)
++{
++ if (device == NULL)
++ return;
++
++ device->atmodem = atmodem;
++}
++
++GAtChat* qmi_device_get_atmodem(struct qmi_device *device)
++{
++ if (device == NULL)
++ return NULL;
++
++ return device->atmodem;
++}
++
+ struct discover_data {
+ struct discovery super;
+ struct qmi_device *device;
+diff --git a/drivers/qmimodem/qmi.h b/drivers/qmimodem/qmi.h
+index 0075f738..7bc423aa 100644
+--- a/drivers/qmimodem/qmi.h
++++ b/drivers/qmimodem/qmi.h
+@@ -21,6 +21,7 @@
+
+ #include <stdbool.h>
+ #include <stdint.h>
++#include <gatchat.h>
+
+ #define QMI_SERVICE_CONTROL 0 /* Control service */
+ #define QMI_SERVICE_WDS 1 /* Wireless data service */
+@@ -77,6 +78,9 @@ typedef void (*qmi_destroy_func_t)(void *user_data);
+
+ struct qmi_device;
+
++void qmi_device_set_atmodem(struct qmi_device *device, GAtChat* atmodem);
++GAtChat* qmi_device_get_atmodem(struct qmi_device *device);
++
+ typedef void (*qmi_debug_func_t)(const char *str, void *user_data);
+ typedef void (*qmi_shutdown_func_t)(void *user_data);
+ typedef void (*qmi_discover_func_t)(void *user_data);
+diff --git a/drivers/qmimodem/sms.c b/drivers/qmimodem/sms.c
+index c6252d9d..f8882ab9 100644
+--- a/drivers/qmimodem/sms.c
++++ b/drivers/qmimodem/sms.c
+@@ -30,6 +30,8 @@
+ #include <ofono/modem.h>
+ #include <ofono/sms.h>
+
++#include <gatchat.h>
++
+ #include "qmi.h"
+ #include "wms.h"
+ #include "util.h"
+@@ -776,6 +778,15 @@ static void create_wms_cb(struct qmi_service *service, void *user_data)
+ ofono_sms_register(sms);
+ }
+
++static void qmi_sms_at_notify(GAtResult *result, gpointer user_data)
++{
++ struct ofono_sms *sms = user_data;
++
++ DBG("");
++
++ get_msg_list(sms);
++}
++
+ static int qmi_sms_probe(struct ofono_sms *sms,
+ unsigned int vendor, void *user_data)
+ {
+@@ -790,6 +801,12 @@ static int qmi_sms_probe(struct ofono_sms *sms,
+
+ qmi_service_create(device, QMI_SERVICE_WMS, create_wms_cb, sms, NULL);
+
++ GAtChat* atmodem = qmi_device_get_atmodem(device);
++ if (atmodem) {
++ guint ret = g_at_chat_register(atmodem, "+CMTI:", qmi_sms_at_notify, FALSE, sms, NULL);
++ DBG("SMS AT CHAT REGISTER %d", ret);
++ }
++
+ return 0;
+ }
+
+diff --git a/drivers/qmimodem/voicecall.c b/drivers/qmimodem/voicecall.c
+index c6383a56..4b01b784 100644
+--- a/drivers/qmimodem/voicecall.c
++++ b/drivers/qmimodem/voicecall.c
+@@ -24,12 +24,15 @@
+ #include <config.h>
+ #endif
+
++#include <ofono.h>
+ #include <ofono/log.h>
+ #include <ofono/modem.h>
+ #include <ofono/voicecall.h>
+ #include <src/common.h>
+ #include <ell/ell.h>
+
++#include <gatchat.h>
++
+ #include "voice.h"
+
+ #include "qmi.h"
+@@ -750,6 +753,17 @@ static void create_voice_cb(struct qmi_service *service, void *user_data)
+ ofono_voicecall_register(vc);
+ }
+
++static void qmi_voicecall_ring_notify(GAtResult *result, gpointer user_data) {
++ struct ofono_voicecall *vc = user_data;
++ struct voicecall_data *data = ofono_voicecall_get_data(vc);
++
++ DBG("DETECTED AT RING");
++
++ qmi_service_send(data->voice, QMI_VOICE_ALL_CALL_STATUS_IND, NULL,
++ all_call_status_ind, vc, NULL);
++
++}
++
+ static int qmi_voicecall_probe(struct ofono_voicecall *vc,
+ unsigned int vendor, void *user_data)
+ {
+@@ -766,6 +780,15 @@ static int qmi_voicecall_probe(struct ofono_voicecall *vc,
+ qmi_service_create(device, QMI_SERVICE_VOICE,
+ create_voice_cb, vc, NULL);
+
++ //Get a handle to the modem serial interface to detect RING signals
++ //Sometimes the QMI notify doesnt come through if the phone is
++ //asleep
++ GAtChat* atmodem = qmi_device_get_atmodem(device);
++ if (atmodem) {
++ guint ret = g_at_chat_register(atmodem, "RING", qmi_voicecall_ring_notify, FALSE, vc, NULL);
++ DBG("VOICE AT CHAT REGISTER %d", ret);
++ }
++
+ return 0;
+ }
+
+diff --git a/plugins/gobi.c b/plugins/gobi.c
+index 550ce787..4a4d9d1b 100644
+--- a/plugins/gobi.c
++++ b/plugins/gobi.c
+@@ -29,6 +29,7 @@
+ #include <stdlib.h>
+ #include <stdio.h>
+ #include <net/if.h>
++#include <gatchat.h>
+
+ #define OFONO_API_SUBJECT_TO_CHANGE
+ #include <ofono/plugin.h>
+@@ -60,6 +61,12 @@
+ #include <drivers/qmimodem/wda.h>
+ #include <drivers/qmimodem/util.h>
+
++//Define function from atutil.h as it cant be uncluded
++GAtChat *at_util_open_device(struct ofono_modem *modem, const char *key,
++ GAtDebugFunc debug_func, char *debug_prefix,
++ char *tty_option, ...);
++
++
+ #define GOBI_DMS (1 << 0)
+ #define GOBI_NAS (1 << 1)
+ #define GOBI_WMS (1 << 2)
+@@ -448,6 +455,15 @@ static int gobi_enable(struct ofono_modem *modem)
+ if (getenv("OFONO_QMI_DEBUG"))
+ qmi_device_set_debug(data->device, gobi_debug, "QMI: ");
+
++ //Get a handle to an AT interface if one was found, and attach it to the qmi_device
++ GAtChat *atchat = at_util_open_device(modem, "Aux", NULL, "Aux: ", NULL);
++ if (!atchat) {
++ DBG("No Aux");
++ } else {
++ DBG("Have atmodem");
++ }
++ qmi_device_set_atmodem(data->device, atchat); //Will set to NULL if doesnt exist
++
|