Skip to content
This repository has been archived by the owner on Jul 9, 2024. It is now read-only.

Commit

Permalink
fix: update from upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Oct 7, 2023
1 parent fa53945 commit 48a77c5
Show file tree
Hide file tree
Showing 9 changed files with 86 additions and 78 deletions.
1 change: 0 additions & 1 deletion sample.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ tests:
platform_allow: nrf9160dk_nrf9160_ns thingy91_nrf9160_ns
integration_platforms:
- nrf9160dk_nrf9160_ns
- thingy91_nrf9160_ns
extra_args: EXTRA_CONF_FILE=overlay-carrier.conf
tags: ci_build
applications.asset_tracker_v2.carrier.nrf9161dk:
Expand Down
2 changes: 1 addition & 1 deletion src/cloud/cloud_codec/cloud_codec.h
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ struct cloud_data_agps_request {
/** Area Code. */
uint32_t area;
/** AGPS request types */
struct nrf_modem_gnss_agps_data_frame request;
struct nrf_modem_gnss_agnss_data_frame request;
/** Flag signifying that the data entry is to be encoded. */
bool queued : 1;
};
Expand Down
22 changes: 14 additions & 8 deletions src/cloud/cloud_codec/json_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -820,7 +820,7 @@ int json_common_agps_request_data_add(cJSON *parent,
return -ENOMEM;
}

if (data->request.data_flags & NRF_MODEM_GNSS_AGPS_GPS_UTC_REQUEST) {
if (data->request.data_flags & NRF_MODEM_GNSS_AGNSS_GPS_UTC_REQUEST) {
err = json_add_number_to_array(agps_types,
DATA_AGPS_REQUEST_TYPE_UTC_PARAMETERS);
if (err) {
Expand All @@ -829,7 +829,13 @@ int json_common_agps_request_data_add(cJSON *parent,
}
}

if (data->request.sv_mask_ephe) {
/* GPS data need is always expected to be present and first in list. */
__ASSERT(data->request.system_count > 0,
"GNSS system data need not found");
__ASSERT(data->request.system[0].system_id == NRF_MODEM_GNSS_SYSTEM_GPS,
"GPS data need not found");

if (data->request.system[0].sv_mask_ephe) {
err = json_add_number_to_array(agps_types,
DATA_AGPS_REQUEST_TYPE_EPHEMERIDES);
if (err) {
Expand All @@ -838,7 +844,7 @@ int json_common_agps_request_data_add(cJSON *parent,
}
}

if (data->request.sv_mask_alm) {
if (data->request.system[0].sv_mask_alm) {
err = json_add_number_to_array(agps_types,
DATA_AGPS_REQUEST_TYPE_ALMANAC);
if (err) {
Expand All @@ -847,7 +853,7 @@ int json_common_agps_request_data_add(cJSON *parent,
}
}

if (data->request.data_flags & NRF_MODEM_GNSS_AGPS_KLOBUCHAR_REQUEST) {
if (data->request.data_flags & NRF_MODEM_GNSS_AGNSS_KLOBUCHAR_REQUEST) {
err = json_add_number_to_array(agps_types,
DATA_AGPS_REQUEST_TYPE_KLOBUCHAR_CORRECTION);
if (err) {
Expand All @@ -856,7 +862,7 @@ int json_common_agps_request_data_add(cJSON *parent,
}
}

if (data->request.data_flags & NRF_MODEM_GNSS_AGPS_NEQUICK_REQUEST) {
if (data->request.data_flags & NRF_MODEM_GNSS_AGNSS_NEQUICK_REQUEST) {
err = json_add_number_to_array(agps_types,
DATA_AGPS_REQUEST_TYPE_NEQUICK_CORRECTION);
if (err) {
Expand All @@ -865,7 +871,7 @@ int json_common_agps_request_data_add(cJSON *parent,
}
}

if (data->request.data_flags & NRF_MODEM_GNSS_AGPS_SYS_TIME_AND_SV_TOW_REQUEST) {
if (data->request.data_flags & NRF_MODEM_GNSS_AGNSS_GPS_SYS_TIME_AND_SV_TOW_REQUEST) {
err = json_add_number_to_array(agps_types,
DATA_AGPS_REQUEST_TYPE_GPS_TOWS);
if (err) {
Expand All @@ -881,7 +887,7 @@ int json_common_agps_request_data_add(cJSON *parent,
}
}

if (data->request.data_flags & NRF_MODEM_GNSS_AGPS_POSITION_REQUEST) {
if (data->request.data_flags & NRF_MODEM_GNSS_AGNSS_POSITION_REQUEST) {
err = json_add_number_to_array(agps_types,
DATA_AGPS_REQUEST_TYPE_LOCATION);
if (err) {
Expand All @@ -890,7 +896,7 @@ int json_common_agps_request_data_add(cJSON *parent,
}
}

if (data->request.data_flags & NRF_MODEM_GNSS_AGPS_INTEGRITY_REQUEST) {
if (data->request.data_flags & NRF_MODEM_GNSS_AGNSS_INTEGRITY_REQUEST) {
err = json_add_number_to_array(agps_types,
DATA_AGPS_REQUEST_TYPE_INTEGRITY);
if (err) {
Expand Down
4 changes: 2 additions & 2 deletions src/events/location_module_event.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ enum location_module_event_type {
LOCATION_MODULE_EVT_SHUTDOWN_READY,

/** The location library has reported that it needs GPS assistance data.
* The event has associated payload of the type ``struct nrf_modem_gnss_agps_data_frame``
* The event has associated payload of the type ``struct nrf_modem_gnss_agnss_data_frame``
* in the event struct member ``data.agps_request``, which contains the types
* of A-GPS data that the modem needs.
*/
Expand Down Expand Up @@ -184,7 +184,7 @@ struct location_module_event {
/** Data for event LOCATION_MODULE_EVT_CLOUD_LOCATION_DATA_READY. */
struct location_module_cloud_location cloud_location;
/** Data for event LOCATION_MODULE_EVT_AGPS_NEEDED. */
struct nrf_modem_gnss_agps_data_frame agps_request;
struct nrf_modem_gnss_agnss_data_frame agps_request;
#if defined(CONFIG_NRF_CLOUD_PGPS)
/** Data for event LOCATION_MODULE_EVT_PGPS_NEEDED. */
struct gps_pgps_request pgps_request;
Expand Down
47 changes: 27 additions & 20 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,41 +174,48 @@ static void sub_state_set(enum sub_state_type new_state)
}

#if defined(CONFIG_NRF_MODEM_LIB)
/* Check the return code from nRF modem library initialization to ensure that
* the modem is rebooted if a modem firmware update is ready to be applied or
* an error condition occurred during firmware update or library initialization.
*/
static void modem_init(void)
{
int ret = nrf_modem_lib_init();

/* Handle return values relating to modem firmware update */
switch (ret) {
case 0:
/* Initialization successful, no action required. */
return;
static void on_modem_lib_dfu(int dfu_res, void *ctx)
{
switch (dfu_res) {
case NRF_MODEM_DFU_RESULT_OK:
LOG_DBG("MODEM UPDATE OK. Will run new modem firmware after reboot");
LOG_DBG("MODEM UPDATE OK. Running new firmware");
break;
case NRF_MODEM_DFU_RESULT_UUID_ERROR:
case NRF_MODEM_DFU_RESULT_AUTH_ERROR:
LOG_ERR("MODEM UPDATE ERROR %d. Will run old firmware", ret);
LOG_ERR("MODEM UPDATE ERROR 0x%x. Running old firmware", dfu_res);
break;
case NRF_MODEM_DFU_RESULT_HARDWARE_ERROR:
case NRF_MODEM_DFU_RESULT_INTERNAL_ERROR:
LOG_ERR("MODEM UPDATE FATAL ERROR %d. Modem failure", ret);
LOG_ERR("MODEM UPDATE FATAL ERROR 0x%x. Modem failure", dfu_res);
break;
case NRF_MODEM_DFU_RESULT_VOLTAGE_LOW:
LOG_ERR("MODEM UPDATE CANCELLED %d.", ret);
LOG_ERR("MODEM UPDATE CANCELLED 0x%x.", dfu_res);
LOG_ERR("Please reboot once you have sufficient power for the DFU");
break;
default:
/* All non-zero return codes other than DFU result codes are
* considered irrecoverable and a reboot is needed.
*/
LOG_ERR("nRF modem lib initialization failed, error: %d", ret);
/* Unknown DFU result code */
LOG_ERR("nRF modem DFU failed, error: 0x%x", dfu_res);
break;
}
}

NRF_MODEM_LIB_ON_DFU_RES(main_dfu_hook, on_modem_lib_dfu, NULL);

/* Check the return code from nRF modem library initialization to ensure that
* the modem is rebooted or an error condition occurred during library initialization.
*/
static void modem_init(void)
{
int ret;

ret = nrf_modem_lib_init();
if (ret == 0) {
LOG_DBG("nRF Modem Library initialized successfully");
return;
}

LOG_ERR("nRF modem lib initialization failed, error: %d", ret);

#if defined(CONFIG_NRF_CLOUD_FOTA)
/* Ignore return value, rebooting below */
Expand Down
35 changes: 14 additions & 21 deletions src/modules/data_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ enum coneval_supported_data_type {
bool agps_request_buffered;

/* Buffered A-GPS request. */
struct nrf_modem_gnss_agps_data_frame agps_request_buffer;
struct nrf_modem_gnss_agnss_data_frame agps_request_buffer;

/* Data module message queue. */
#define DATA_QUEUE_ENTRY_COUNT 10
Expand Down Expand Up @@ -704,7 +704,7 @@ static int get_modem_info(struct modem_param_info *const modem_info)
*
* @return 0 on success, otherwise a negative error code indicating reason of failure.
*/
static int agps_request_encode(struct nrf_modem_gnss_agps_data_frame *incoming_request)
static int agps_request_encode(struct nrf_modem_gnss_agnss_data_frame *incoming_request)
{
int err;
struct cloud_codec_data codec = {0};
Expand All @@ -720,15 +720,16 @@ static int agps_request_encode(struct nrf_modem_gnss_agps_data_frame *incoming_r
const uint32_t mask = IS_ENABLED(CONFIG_NRF_CLOUD_PGPS) ? 0u : 0xFFFFFFFFu;

LOG_DBG("Requesting all A-GPS elements");
cloud_agps_request.request.sv_mask_ephe = mask,
cloud_agps_request.request.sv_mask_alm = mask,
cloud_agps_request.request.data_flags =
NRF_MODEM_GNSS_AGPS_GPS_UTC_REQUEST |
NRF_MODEM_GNSS_AGPS_KLOBUCHAR_REQUEST |
NRF_MODEM_GNSS_AGPS_NEQUICK_REQUEST |
NRF_MODEM_GNSS_AGPS_SYS_TIME_AND_SV_TOW_REQUEST |
NRF_MODEM_GNSS_AGPS_POSITION_REQUEST |
NRF_MODEM_GNSS_AGPS_INTEGRITY_REQUEST;
NRF_MODEM_GNSS_AGNSS_GPS_UTC_REQUEST |
NRF_MODEM_GNSS_AGNSS_KLOBUCHAR_REQUEST |
NRF_MODEM_GNSS_AGNSS_NEQUICK_REQUEST |
NRF_MODEM_GNSS_AGNSS_GPS_SYS_TIME_AND_SV_TOW_REQUEST |
NRF_MODEM_GNSS_AGNSS_POSITION_REQUEST |
NRF_MODEM_GNSS_AGNSS_INTEGRITY_REQUEST;
cloud_agps_request.request.system_count = 1;
cloud_agps_request.request.system[0].sv_mask_ephe = mask;
cloud_agps_request.request.system[0].sv_mask_alm = mask;
} else {
cloud_agps_request.request = *incoming_request;
}
Expand Down Expand Up @@ -1060,25 +1061,17 @@ static void new_config_handle(struct cloud_data_cfg *new_config)
* requested by the modem. If incoming_request is NULL, all A-GPS data
* types are requested.
*/
static void agps_request_handle(struct nrf_modem_gnss_agps_data_frame *incoming_request)
static void agps_request_handle(struct nrf_modem_gnss_agnss_data_frame *incoming_request)
{
int err;

#if defined(CONFIG_NRF_CLOUD_AGPS)
struct nrf_modem_gnss_agps_data_frame request;

if (incoming_request != NULL) {
request.sv_mask_ephe = incoming_request->sv_mask_ephe;
request.sv_mask_alm = incoming_request->sv_mask_alm;
request.data_flags = incoming_request->data_flags;
}

#if defined(CONFIG_NRF_CLOUD_MQTT)
/* If CONFIG_NRF_CLOUD_MQTT is enabled, the nRF Cloud MQTT transport library will be used
* to send the request.
*/
err = (incoming_request == NULL) ? nrf_cloud_agps_request_all() :
nrf_cloud_agps_request(&request);
nrf_cloud_agps_request(incoming_request);
if (err) {
LOG_WRN("Failed to request A-GPS data, error: %d", err);
LOG_DBG("This is expected to fail if we are not in a connected state");
Expand All @@ -1096,7 +1089,7 @@ static void agps_request_handle(struct nrf_modem_gnss_agps_data_frame *incoming_
* up and send to the cloud that is currently used.
*/
err = (incoming_request == NULL) ? agps_request_encode(NULL) :
agps_request_encode(&request);
agps_request_encode(incoming_request);
if (err) {
LOG_WRN("Failed to request A-GPS data, error: %d", err);
} else {
Expand Down
16 changes: 8 additions & 8 deletions tests/json_common/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -701,15 +701,15 @@ void test_encode_agps_request_data_object(void)
.mnc = 1,
.cell = 21679716,
.area = 40401,
.request.sv_mask_ephe = UINT32_MAX,
.request.sv_mask_alm = UINT32_MAX,
.request.system[0].sv_mask_ephe = UINT32_MAX,
.request.system[0].sv_mask_alm = UINT32_MAX,
.request.data_flags =
NRF_MODEM_GNSS_AGPS_GPS_UTC_REQUEST |
NRF_MODEM_GNSS_AGPS_KLOBUCHAR_REQUEST |
NRF_MODEM_GNSS_AGPS_NEQUICK_REQUEST |
NRF_MODEM_GNSS_AGPS_SYS_TIME_AND_SV_TOW_REQUEST |
NRF_MODEM_GNSS_AGPS_POSITION_REQUEST |
NRF_MODEM_GNSS_AGPS_INTEGRITY_REQUEST,
NRF_MODEM_GNSS_AGNSS_GPS_UTC_REQUEST |
NRF_MODEM_GNSS_AGNSS_KLOBUCHAR_REQUEST |
NRF_MODEM_GNSS_AGNSS_NEQUICK_REQUEST |
NRF_MODEM_GNSS_AGNSS_GPS_SYS_TIME_AND_SV_TOW_REQUEST |
NRF_MODEM_GNSS_AGNSS_POSITION_REQUEST |
NRF_MODEM_GNSS_AGNSS_INTEGRITY_REQUEST,
.queued = true
};

Expand Down
33 changes: 18 additions & 15 deletions tests/location_module/src/location_module_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ static void validate_location_module_evt(struct app_event_header *aeh, int no_of
uint32_t index = location_module_event_count;
struct location_module_event *event = cast_location_module_event(aeh);

struct nrf_modem_gnss_agnss_data_frame *agps_req_exp =
&expected_location_module_events[index].data.agps_request;

/* Make sure we don't get more events than expected. */
TEST_ASSERT_LESS_THAN(expected_location_module_event_count, location_module_event_count);

Expand Down Expand Up @@ -212,13 +215,13 @@ static void validate_location_module_evt(struct app_event_header *aeh, int no_of
break;
case LOCATION_MODULE_EVT_AGPS_NEEDED:
TEST_ASSERT_EQUAL(
expected_location_module_events[index].data.agps_request.sv_mask_ephe,
event->data.agps_request.sv_mask_ephe);
agps_req_exp->system[0].sv_mask_ephe,
event->data.agps_request.system[0].sv_mask_ephe);
TEST_ASSERT_EQUAL(
expected_location_module_events[index].data.agps_request.sv_mask_alm,
event->data.agps_request.sv_mask_alm);
agps_req_exp->system[0].sv_mask_alm,
event->data.agps_request.system[0].sv_mask_alm);
TEST_ASSERT_EQUAL(
expected_location_module_events[index].data.agps_request.data_flags,
agps_req_exp->data_flags,
event->data.agps_request.data_flags);
break;
case LOCATION_MODULE_EVT_PGPS_NEEDED:
Expand Down Expand Up @@ -358,12 +361,12 @@ void test_location_gnss_with_agps(void)
expected_location_module_events[0].type = LOCATION_MODULE_EVT_ACTIVE;

expected_location_module_events[1].type = LOCATION_MODULE_EVT_AGPS_NEEDED;
expected_location_module_events[1].data.agps_request.sv_mask_ephe = 0xabbaabba,
expected_location_module_events[1].data.agps_request.sv_mask_alm = 0xdeaddead,
expected_location_module_events[1].data.agps_request.system[0].sv_mask_ephe = 0xabbaabba,
expected_location_module_events[1].data.agps_request.system[0].sv_mask_alm = 0xdeaddead,
expected_location_module_events[1].data.agps_request.data_flags =
NRF_MODEM_GNSS_AGPS_GPS_UTC_REQUEST |
NRF_MODEM_GNSS_AGPS_NEQUICK_REQUEST |
NRF_MODEM_GNSS_AGPS_POSITION_REQUEST;
NRF_MODEM_GNSS_AGNSS_GPS_UTC_REQUEST |
NRF_MODEM_GNSS_AGNSS_NEQUICK_REQUEST |
NRF_MODEM_GNSS_AGNSS_POSITION_REQUEST;

expected_location_module_events[2].type = LOCATION_MODULE_EVT_GNSS_DATA_READY;
expected_location_module_events[2].data.location.pvt.latitude = 34.087;
Expand All @@ -382,11 +385,11 @@ void test_location_gnss_with_agps(void)
/* Location request is responded with location library events. */
struct location_event_data event_data_agps = {
.id = LOCATION_EVT_GNSS_ASSISTANCE_REQUEST,
.agps_request.sv_mask_ephe = 0xabbaabba,
.agps_request.sv_mask_alm = 0xdeaddead,
.agps_request.data_flags = NRF_MODEM_GNSS_AGPS_GPS_UTC_REQUEST |
NRF_MODEM_GNSS_AGPS_NEQUICK_REQUEST |
NRF_MODEM_GNSS_AGPS_POSITION_REQUEST
.agps_request.system[0].sv_mask_ephe = 0xabbaabba,
.agps_request.system[0].sv_mask_alm = 0xdeaddead,
.agps_request.data_flags = NRF_MODEM_GNSS_AGNSS_GPS_UTC_REQUEST |
NRF_MODEM_GNSS_AGNSS_NEQUICK_REQUEST |
NRF_MODEM_GNSS_AGNSS_POSITION_REQUEST
};
location_event_handler(&event_data_agps);

Expand Down
4 changes: 2 additions & 2 deletions tests/lwm2m_codec_helpers/src/lwm2m_codec_helpers_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,8 @@ void test_codec_helpers_set_agps_data(void)
.mcc = 242,
.area = 30601,
.cell = 52118273,
.request.sv_mask_ephe = 0xFFFFFFFFu,
.request.sv_mask_alm = 0xFFFFFFFFu,
.request.system[0].sv_mask_ephe = 0xFFFFFFFFu,
.request.system[0].sv_mask_alm = 0xFFFFFFFFu,
.request.data_flags = 0xFFFFFFFFu,
.queued = true,
};
Expand Down

0 comments on commit 48a77c5

Please sign in to comment.