In case of LTE modem, attaching manually is normally unneeded.
Forcing a detach (in case of gprs-context activation failure) is
actually a mistake, also because this will also trigger a technology
reselection and a possible invalid state, especially for LTE-only
modems.

This simple patch adds a flag to skip the AT+CGATT=x command.
The flag is to be set by vendor-specific options.

By default the behavior remains unchanged.
---
 drivers/atmodem/gprs.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/atmodem/gprs.c b/drivers/atmodem/gprs.c
index 6e01738a..fc0d8aa3 100644
--- a/drivers/atmodem/gprs.c
+++ b/drivers/atmodem/gprs.c
@@ -59,6 +59,7 @@ struct gprs_data {
        gboolean has_cereg;
        gboolean has_c5greg;
        gboolean nb_inds;
+       gboolean auto_attach; /* for LTE modems & co */
        int attached;
        int cgreg_status;
        int cereg_status;
@@ -88,9 +89,15 @@ static void at_gprs_set_attached(struct ofono_gprs *gprs, 
int attached,
                                        ofono_gprs_cb_t cb, void *data)
 {
        struct gprs_data *gd = ofono_gprs_get_data(gprs);
-       struct cb_data *cbd = cb_data_new(cb, data);
+       struct cb_data *cbd;
        char buf[64];
 
+       if (gd->auto_attach) {
+               CALLBACK_WITH_SUCCESS(cb, data);
+               return;
+       }
+
+       cbd = cb_data_new(cb, data);
        snprintf(buf, sizeof(buf), "AT+CGATT=%i", attached ? 1 : 0);
 
        if (g_at_chat_send(gd->chat, buf, none_prefix,
-- 
2.17.1

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

Reply via email to