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.

Signed-off-by: Stig Bjørlykke <[email protected]>
  • Loading branch information
stig-bjorlykke authored and anangl committed Jun 6, 2024
1 parent eb1e1b5 commit 2f40d82
Show file tree
Hide file tree
Showing 2 changed files with 29 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 @@ -28,6 +28,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 @@ -582,14 +587,7 @@ static void gnss_fix_sender(struct k_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 @@ -598,14 +596,36 @@ static void gnss_fix_sender(struct k_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_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
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ Serial LTE modem

* New behavior for when a connection is closed unexpectedly while SLM is in data mode.
SLM now sends the :ref:`CONFIG_SLM_DATAMODE_TERMINATOR <CONFIG_SLM_DATAMODE_TERMINATOR>` string when this happens.
* Sending of GNSS data to carrier library when the library is enabled.

* Removed:

Expand Down

0 comments on commit 2f40d82

Please sign in to comment.