From 73868260a239fa1605b64fd3db00022bc76c7295 Mon Sep 17 00:00:00 2001 From: Arnaud Ferraris Date: Wed, 6 Oct 2021 01:48:43 +0200 Subject: [PATCH] gnss: wait for the modem to confirm upload success If we clear QFUPL right after we finished the file transfer, we will execute the following commands right away, leading to interleaved replies from the modem (i.e. the reply to QGPSXTRATIME being received with the notification of upload completion). Keeping the command in the queue allows us to use the callback a second time once the upload is complete and resume assistance data processing accordingly. --- src/at.c | 3 ++- src/gnss.c | 11 ++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/at.c b/src/at.c index 5c35844..a6cb7e0 100644 --- a/src/at.c +++ b/src/at.c @@ -289,8 +289,9 @@ static gboolean modem_response(gint fd, /* * Successful AT responses contain 'OK', except for AT+QFUPL which also * returns 'CONNECT' when the modem is ready to receive data over serial + * and '+QFUPL:...' when data upload is complete */ - else if (strstr(response, "OK") || strstr(response, "CONNECT")) { + else if (strstr(response, "OK") || strstr(response, "CONNECT") || strstr(response, "QFUPL")) { if (manager->at_callback != NULL) manager->at_callback(manager, response); else diff --git a/src/gnss.c b/src/gnss.c index a71ba1e..d95f071 100644 --- a/src/gnss.c +++ b/src/gnss.c @@ -273,6 +273,12 @@ static void init_assistance_data_upload_ready(struct EG25Manager *manager, /* Search for 'CONNECT' in response to start upload */ if (strstr(response, "CONNECT")) { g_message("Modem ready for GNSS assistance data upload"); + manager->gnss_assistance_step++; + gnss_step(manager); + } else if (strstr(response, "QFUPL")) { + /* Clear QFUPL AT command and process next */ + at_next_command(manager); + manager->gnss_assistance_step++; gnss_step(manager); } @@ -341,14 +347,9 @@ static void upload_assistance_data(struct EG25Manager *manager) usleep(UPLOAD_DELAY_US); } while ((!error && written_total < sb.st_size) || (ret == -1 && error == EAGAIN)); - /* Clear QFUPL AT command and process next */ - at_next_command(manager); - /* Go to the next step if successful */ if (!error) { g_message("Successfully uploaded %ld bytes to the modem", written_total); - manager->gnss_assistance_step++; - gnss_step(manager); } else { g_critical("Unable to upload xtra data: %s", g_strerror(error)); manager->gnss_assistance_step = EG25_GNSS_STEP_LAST;