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 Feb 15, 2023
1 parent 2976dc3 commit c199c59
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 149 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion prj.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
95 changes: 5 additions & 90 deletions src/cloud/cloud_codec/nrf_cloud/nrf_cloud_codec.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions src/cloud/nrf_cloud_integration.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
53 changes: 0 additions & 53 deletions tests/nrf_cloud_codec/src/nrf_cloud_codec_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -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\","\
Expand Down Expand Up @@ -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)
{
Expand Down

0 comments on commit c199c59

Please sign in to comment.