diff --git a/CMakeLists.txt b/CMakeLists.txt index fbcdf39b..8bd1ddaa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,6 +8,7 @@ cmake_minimum_required(VERSION 3.20.0) find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) project(asset_tracker_v2) +zephyr_compile_definitions(PROJECT_NAME=${PROJECT_NAME}) # NORDIC SDK APP START target_sources(app PRIVATE src/main.c) diff --git a/prj.conf b/prj.conf index 40be42c2..8db10831 100644 --- a/prj.conf +++ b/prj.conf @@ -108,6 +108,7 @@ CONFIG_LOCATION_LOG_LEVEL_WRN=y # Default cloud transport service CONFIG_NRF_CLOUD_MQTT=y -CONFIG_NRF_CLOUD_SEND_DEVICE_STATUS=n +CONFIG_NRF_CLOUD_SEND_DEVICE_STATUS_SIM=y +CONFIG_NRF_CLOUD_DEVICE_STATUS_ENCODE_VOLTAGE=n CONFIG_HW_ID_LIBRARY=y CONFIG_HW_ID_LIBRARY_SOURCE_IMEI=y diff --git a/src/cloud/cloud_codec/nrf_cloud/json_protocol_names_nrf_cloud.h b/src/cloud/cloud_codec/nrf_cloud/json_protocol_names_nrf_cloud.h index c5789ce2..9ee9a183 100644 --- a/src/cloud/cloud_codec/nrf_cloud/json_protocol_names_nrf_cloud.h +++ b/src/cloud/cloud_codec/nrf_cloud/json_protocol_names_nrf_cloud.h @@ -38,16 +38,11 @@ #define MODEM_CURRENT_BAND "currentBand" #define MODEM_NETWORK_MODE "networkMode" -#define MODEM_ICCID "iccid" -#define MODEM_FIRMWARE_VERSION "modemFirmware" -#define MODEM_BOARD "board" -#define MODEM_APP_VERSION "appVersion" #define MODEM_RSRP "rsrp" #define MODEM_AREA_CODE "areaCode" #define MODEM_MCCMNC "mccmnc" #define MODEM_CELL_ID "cellID" #define MODEM_IP_ADDRESS "ipAddress" -#define MODEM_IMEI "imei" #define CONFIG_DEVICE_MODE "activeMode" #define CONFIG_ACTIVE_TIMEOUT "activeWaitTime" diff --git a/src/cloud/cloud_codec/nrf_cloud/nrf_cloud_codec.c b/src/cloud/cloud_codec/nrf_cloud/nrf_cloud_codec.c index 437d9fdf..585b750e 100644 --- a/src/cloud/cloud_codec/nrf_cloud/nrf_cloud_codec.c +++ b/src/cloud/cloud_codec/nrf_cloud/nrf_cloud_codec.c @@ -26,7 +26,9 @@ enum batch_data_type { GNSS, ENVIRONMENTALS, BUTTON, - MODEM_STATIC, + /* Only dynamic modem data is handled here. Static modem data is handled + * in the nrf_cloud library; see CONFIG_NRF_CLOUD_SEND_DEVICE_STATUS. + */ MODEM_DYNAMIC, VOLTAGE, IMPACT, @@ -189,67 +191,6 @@ static int add_pvt_data(cJSON *parent, struct cloud_data_gnss *gnss) return 0; } -static int modem_static_data_add(struct cloud_data_modem_static *data, cJSON **val_obj_ref) -{ - int err; - - if (!data->queued) { - return -ENODATA; - } - - err = date_time_uptime_to_unix_time_ms(&data->ts); - if (err) { - LOG_ERR("date_time_uptime_to_unix_time_ms, error: %d", err); - return err; - } - - cJSON *modem_val_obj = cJSON_CreateObject(); - - if (modem_val_obj == NULL) { - return -ENOMEM; - } - - err = json_add_str(modem_val_obj, MODEM_IMEI, data->imei); - if (err) { - LOG_ERR("Encoding error: %d returned at %s:%d", err, __FILE__, __LINE__); - goto exit; - } - - err = json_add_str(modem_val_obj, MODEM_ICCID, data->iccid); - if (err) { - LOG_ERR("Encoding error: %d returned at %s:%d", err, __FILE__, __LINE__); - goto exit; - } - - err = json_add_str(modem_val_obj, MODEM_FIRMWARE_VERSION, data->fw); - if (err) { - LOG_ERR("Encoding error: %d returned at %s:%d", err, __FILE__, __LINE__); - goto exit; - } - - err = json_add_str(modem_val_obj, MODEM_BOARD, data->brdv); - if (err) { - LOG_ERR("Encoding error: %d returned at %s:%d", err, __FILE__, __LINE__); - goto exit; - } - - err = json_add_str(modem_val_obj, MODEM_APP_VERSION, data->appv); - if (err) { - LOG_ERR("Encoding error: %d returned at %s:%d", err, __FILE__, __LINE__); - goto exit; - } - - *val_obj_ref = modem_val_obj; - - data->queued = false; - - return 0; - -exit: - cJSON_Delete(modem_val_obj); - return err; -} - static int modem_dynamic_data_add(struct cloud_data_modem_dynamic *data, cJSON **val_obj_ref) { int err; @@ -680,28 +621,6 @@ static int add_batch_data(cJSON *array, enum batch_data_type type, void *buf, si data[i].queued = false; break; } - case MODEM_STATIC: { - int err; - cJSON *data_ref = NULL; - struct cloud_data_modem_static *modem_static = - (struct cloud_data_modem_static *)buf; - - err = modem_static_data_add(&modem_static[i], &data_ref); - if (err && err != -ENODATA) { - return err; - } else if (err == -ENODATA) { - break; - } - - err = add_data(array, data_ref, APP_ID_DEVICE, NULL, &modem_static->ts, - true, DATA_MODEM_STATIC, false); - if (err && err != -ENODATA) { - cJSON_Delete(data_ref); - return err; - } - - break; - } case MODEM_DYNAMIC: { int err, len; char rsrp[5]; @@ -1159,6 +1078,8 @@ int cloud_codec_encode_batch_data(struct cloud_codec_data *output, size_t impact_buf_count, size_t bat_buf_count) { + ARG_UNUSED(modem_stat_buf); + int err; char *buffer; @@ -1198,12 +1119,6 @@ int cloud_codec_encode_batch_data(struct cloud_codec_data *output, goto exit; } - err = add_batch_data(root_array, MODEM_STATIC, modem_stat_buf, modem_stat_buf_count); - if (err) { - LOG_ERR("Failed adding static modem data to array, error: %d", err); - goto exit; - } - err = add_batch_data(root_array, MODEM_DYNAMIC, modem_dyn_buf, modem_dyn_buf_count); if (err) { LOG_ERR("Failed adding dynamic modem data to array, error: %d", err); diff --git a/src/cloud/nrf_cloud_integration.c b/src/cloud/nrf_cloud_integration.c index bff15a7f..6a2f47b4 100644 --- a/src/cloud/nrf_cloud_integration.c +++ b/src/cloud/nrf_cloud_integration.c @@ -289,6 +289,7 @@ int cloud_wrap_init(cloud_wrap_evt_handler_t event_handler) int err; struct nrf_cloud_init_param config = { .event_handler = nrf_cloud_event_handler, + .application_version = CONFIG_ASSET_TRACKER_V2_APP_VERSION, #if defined(CONFIG_NRF_CLOUD_FOTA_FULL_MODEM_UPDATE) .fmfu_dev_inf = &ext_flash_dev #endif diff --git a/tests/nrf_cloud_codec/src/nrf_cloud_codec_test.c b/tests/nrf_cloud_codec/src/nrf_cloud_codec_test.c index 9ab6c2c6..9c701176 100644 --- a/tests/nrf_cloud_codec/src/nrf_cloud_codec_test.c +++ b/tests/nrf_cloud_codec/src/nrf_cloud_codec_test.c @@ -111,32 +111,6 @@ const static struct cloud_data_gnss gnss_data_example = { } }; -#define MODEM_STATIC_BATCH_EXAMPLE \ -"[{"\ - "\"appId\":\"DEVICE\","\ - "\"messageType\":\"DATA\","\ - "\"ts\":1563968747123,"\ - "\"data\":{"\ - "\"deviceInfo\":{"\ - "\"imei\":\"352656106111232\","\ - "\"iccid\":\"89450421180216211234\","\ - "\"modemFirmware\":\"mfw_nrf9160_1.2.3\","\ - "\"board\":\"nrf9160dk_nrf9160\","\ - "\"appVersion\":\"v1.0.0-development\""\ - "}"\ - "}"\ -"}]" - -const static struct cloud_data_modem_static modem_stat_data_example = { - .queued = true, - .ts = 1563968747123, - .imei = "352656106111232", - .iccid = "89450421180216211234", - .fw = "mfw_nrf9160_1.2.3", - .brdv = "nrf9160dk_nrf9160", - .appv = "v1.0.0-development", -}; - #define MODEM_DYNAMIC_BATCH_EXAMPLE \ "[{"\ "\"appId\":\"DEVICE\","\ @@ -547,33 +521,6 @@ void test_enc_batch_data_gnss(void) TEST_ASSERT_FALSE(gnss_buf.queued); } -/* tests batch encoding typical static modem data */ -void test_enc_batch_data_modem_static(void) -{ - struct cloud_data_gnss gnss_buf = {0}; - struct cloud_data_sensors sensor_buf = {0}; - struct cloud_data_modem_static modem_stat_buf = modem_stat_data_example; - struct cloud_data_modem_dynamic modem_dyn_buf = {0}; - struct cloud_data_ui ui_buf = {0}; - struct cloud_data_impact impact_buf = {0}; - struct cloud_data_battery bat_buf = {0}; - - ret = cloud_codec_encode_batch_data(&codec, - &gnss_buf, - &sensor_buf, - &modem_stat_buf, - &modem_dyn_buf, - &ui_buf, - &impact_buf, - &bat_buf, - 1, 1, 1, 1, 1, 1, 1); - TEST_ASSERT_EQUAL(EXIT_SUCCESS, ret); - TEST_ASSERT_EQUAL(0, strncmp(MODEM_STATIC_BATCH_EXAMPLE, - codec.buf, - strlen(MODEM_STATIC_BATCH_EXAMPLE))); - TEST_ASSERT_FALSE(modem_stat_buf.queued); -} - /* tests batch encoding typical dynamic modem data */ void test_enc_batch_data_modem_dynamic(void) {