Skip to content

Commit

Permalink
applications: serial_lte_modem: Add GNSS data to carrier library
Browse files Browse the repository at this point in the history
When carrier library is enabled the GNSS data will be provided using
the lwm2m_carrier_location_set() and lwm2m_carrier_velocity_set() API.
  • Loading branch information
stig-bjorlykke committed May 28, 2024
1 parent e5e367d commit 45cb56f
Showing 1 changed file with 28 additions and 8 deletions.
36 changes: 28 additions & 8 deletions applications/serial_lte_modem/src/gnss/slm_at_gnss.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ static void pgps_event_handler(struct nrf_cloud_pgps_event *event);

#endif /* CONFIG_SLM_NRF_CLOUD */

#if defined(CONFIG_SLM_CARRIER)
#include <time.h>
#include <lwm2m_carrier.h>
#endif

#include "slm_util.h"
#include "slm_at_host.h"
#include "slm_at_gnss.h"
Expand Down Expand Up @@ -517,14 +522,7 @@ static void fix_rep_wk(struct k_work *work)
}
}

#if defined(CONFIG_SLM_NRF_CLOUD)

if (slm_nrf_cloud_send_location && slm_nrf_cloud_ready) {
/* Report to nRF Cloud by best-effort */
send_location(&pvt);
}

#if defined(CONFIG_NRF_CLOUD_PGPS) && defined(CONFIG_SLM_PGPS_INJECT_FIX_DATA)
#if defined(CONFIG_SLM_PGPS_INJECT_FIX_DATA) || defined(CONFIG_SLM_CARRIER)
struct tm gps_time = {
.tm_year = pvt.datetime.year - 1900,
.tm_mon = pvt.datetime.month - 1,
Expand All @@ -533,14 +531,36 @@ static void fix_rep_wk(struct k_work *work)
.tm_min = pvt.datetime.minute,
.tm_sec = pvt.datetime.seconds,
};
#endif

#if defined(CONFIG_SLM_NRF_CLOUD)

if (slm_nrf_cloud_send_location && slm_nrf_cloud_ready) {
/* Report to nRF Cloud by best-effort */
send_location(&pvt);
}

#if defined(CONFIG_NRF_CLOUD_PGPS) && defined(CONFIG_SLM_PGPS_INJECT_FIX_DATA)
/* help date_time to save SNTP transactions */
date_time_set(&gps_time);
/* help nrf_cloud_pgps as most recent known location */
nrf_cloud_pgps_set_location(pvt.latitude, pvt.longitude);
#endif

#endif /* CONFIG_SLM_NRF_CLOUD */

#if defined(CONFIG_SLM_CARRIER)
lwm2m_carrier_location_set(pvt.latitude,
pvt.longitude,
pvt.altitude,
(uint32_t)mktime(&gps_time),
pvt.accuracy);
lwm2m_carrier_velocity_set(pvt.heading,
pvt.speed,
pvt.vertical_speed,
pvt.speed_accuracy,
pvt.vertical_speed_accuracy);
#endif /* CONFIG_SLM_CARRIER */
}

static void on_gnss_evt_fix(void)
Expand Down

0 comments on commit 45cb56f

Please sign in to comment.