gnss: Gracefully handle failure to access xtra data file

This commit is contained in:
ArenM
2021-09-28 14:30:31 -04:00
parent ee10cafa00
commit 36ac57b627

View File

@@ -271,13 +271,19 @@ static void init_assistance_data_upload_start(struct EG25Manager *manager,
const char *response)
{
gchar value[BUFFER_SIZE];
long int size;
off_t size;
/* Process AT response */
at_process_result(manager, response);
/* Get file size in bytes */
size = (long int)lseek(manager->gnss_assistance_fd, 0, SEEK_END);
size = lseek(manager->gnss_assistance_fd, 0, SEEK_END);
if (size == -1) {
g_critical("gnss: unable to read size of xtra data file: %s", g_strerror(errno));
manager->gnss_assistance_step = EG25_GNSS_STEP_LAST;
return;
}
lseek(manager->gnss_assistance_fd, 0, SEEK_SET);
/* Start upload */
@@ -308,7 +314,12 @@ static void upload_assistance_data(struct EG25Manager *manager)
struct stat sb;
if (fstat(manager->gnss_assistance_fd, &sb) != 0) {
g_error("Unable to upload xtra data: %s", g_strerror(errno));
g_critical("gnss: unable to stat xtra data file: %s", g_strerror(errno));
/* Make sure the upload times out and the modem goes back to AT command mode */
sleep(UPLOAD_TIMEOUT_S + 1);
manager->gnss_assistance_step = EG25_GNSS_STEP_LAST;
return;
}
do {