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

Commit f2ca63a

Browse files
author
github-actions[bot]
committed
1 parent 0244bbe commit f2ca63a

3 files changed

Lines changed: 145 additions & 17 deletions

File tree

doc/asset_tracker_v2_description.rst

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -363,18 +363,17 @@ After programming the application and all the prerequisites to your development
363363

364364
#. Observe that data is sampled periodically and sent to the cloud::
365365

366-
<inf> app_event_manager: APP_EVT_DATA_GET_ALL
367-
<inf> app_event_manager: APP_EVT_DATA_GET - Requested data types (MOD_DYN, BAT, ENV, GNSS)
368-
<inf> app_event_manager: GNSS_EVT_ACTIVE
369-
<inf> app_event_manager: SENSOR_EVT_ENVIRONMENTAL_NOT_SUPPORTED
370-
<inf> app_event_manager: MODEM_EVT_MODEM_DYNAMIC_DATA_READY
371-
<inf> app_event_manager: MODEM_EVT_BATTERY_DATA_READY
372-
<inf> app_event_manager: GNSS_EVT_DATA_READY
373-
<inf> app_event_manager: DATA_EVT_DATA_READY
374-
<inf> app_event_manager: GNSS_EVT_INACTIVE
375-
<inf> app_event_manager: DATA_EVT_DATA_SEND
376-
<wrn> data_module: No batch data to encode, ringbuffers empty
377-
<inf> app_event_manager: CLOUD_EVT_DATA_ACK
366+
<inf> app_event_manager: APP_EVT_DATA_GET_ALL
367+
<inf> app_event_manager: APP_EVT_DATA_GET - Requested data types (MOD_DYN, BAT, ENV, GNSS)
368+
<inf> app_event_manager: GNSS_EVT_ACTIVE
369+
<inf> app_event_manager: SENSOR_EVT_ENVIRONMENTAL_NOT_SUPPORTED
370+
<inf> app_event_manager: MODEM_EVT_MODEM_DYNAMIC_DATA_NOT_READY
371+
<inf> app_event_manager: MODEM_EVT_BATTERY_DATA_READY
372+
<inf> app_event_manager: GNSS_EVT_INACTIVE
373+
<inf> app_event_manager: GNSS_EVT_DATA_READY
374+
<inf> app_event_manager: DATA_EVT_DATA_READY
375+
<inf> app_event_manager: DATA_EVT_DATA_SEND_BATCH
376+
<inf> app_event_manager: CLOUD_EVT_DATA_SEND_QOS
378377

379378
.. _asset_tracker_v2_internal_modules:
380379

overlay-lwm2m.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ CONFIG_LWM2M_INTEGRATION=y
22
CONFIG_LWM2M=y
33
CONFIG_LWM2M_DTLS_SUPPORT=y
44
CONFIG_LWM2M_SECURITY_KEY_SIZE=33
5+
CONFIG_JSON_LIBRARY=y
56
CONFIG_LWM2M_RW_SENML_JSON_SUPPORT=y
67
CONFIG_LWM2M_RW_OMA_TLV_SUPPORT=y
78
CONFIG_LWM2M_VERSION_1_1=y

src/cloud/cloud_codec/cloud_codec.h

Lines changed: 133 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -212,9 +212,13 @@ struct cloud_codec_data {
212212
};
213213

214214
struct cloud_data_neighbor_cells {
215+
/** Contains current cell and number of neighbor cells. */
215216
struct lte_lc_cells_info cell_data;
217+
/** Contains neighborhood cells. */
216218
struct lte_lc_ncell neighbor_cells[17];
219+
/** Neighbor cells data timestamp. UNIX milliseconds. */
217220
int64_t ts;
221+
/** Flag signifying that the data entry is to be encoded. */
218222
bool queued : 1;
219223
};
220224

@@ -251,33 +255,126 @@ struct cloud_data_pgps_request {
251255
};
252256

253257
enum cloud_codec_event_type {
258+
/** Only used in LwM2M codec. This event carries a config update. */
254259
CLOUD_CODEC_EVT_CONFIG_UPDATE = 1,
255260
};
256261

257262
struct cloud_codec_evt {
263+
/** Cloud codec event type */
258264
enum cloud_codec_event_type type;
265+
/** New config data */
259266
struct cloud_data_cfg config_update;
260267
};
261268

269+
/**
270+
* @brief Event handler prototype.
271+
*
272+
* @param[in] evt event type
273+
*/
262274
typedef void (*cloud_codec_evt_handler_t)(const struct cloud_codec_evt *evt);
263275

276+
/**
277+
* @brief Initialize cloud codec.
278+
* @note currently only used for config updates in LwM2M
279+
*
280+
* @param[in] cfg initial config data
281+
* @param[in] event_handler handler for events coming from the codec
282+
*
283+
* @retval 0 on success
284+
* @retval -ENOMEM if LwM2M engine couldn't allocate its objects
285+
*/
264286
int cloud_codec_init(struct cloud_data_cfg *cfg, cloud_codec_evt_handler_t event_handler);
265287

288+
/**
289+
* @brief Encode cloud codec neighbor cells data.
290+
*
291+
* @param[out] output string buffer for encoding result
292+
* @param[in] neighbor_cells pointer to neighbor cells data
293+
*
294+
* @retval 0 on success
295+
* @retval -ENODATA if data object is not marked valid
296+
* @retval -ENOMEM if codec couldn't allocate memory
297+
* @retval -EINVAL if the data is invalid
298+
* @retval -ENOTSUP if compiled without support for neighbor cell encoding
299+
*/
266300
int cloud_codec_encode_neighbor_cells(struct cloud_codec_data *output,
267301
struct cloud_data_neighbor_cells *neighbor_cells);
268302

303+
/**
304+
* @brief Encode cloud codec A-GPS request.
305+
*
306+
* @param[out] output string buffer for encoding result
307+
* @param[in] agps_request pointer to A-GPS request data
308+
*
309+
* @retval 0 on success
310+
* @retval -ENODATA if data object is not marked valid
311+
* @retval -ENOMEM if codec couldn't allocate memory
312+
* @retval -ENOTSUP if nrf cloud codec is used
313+
*/
269314
int cloud_codec_encode_agps_request(struct cloud_codec_data *output,
270315
struct cloud_data_agps_request *agps_request);
271316

317+
/**
318+
* @brief Encode cloud codec P-GPS request.
319+
*
320+
* @param[out] output string buffer for encoding result
321+
* @param[in] pgps_request pointer to P-GPS request data
322+
*
323+
* @retval 0 on success
324+
* @retval -ENODATA if data object is not marked valid
325+
* @retval -ENOMEM if codec couldn't allocate memory
326+
* @retval -ENOTSUP if nRF or LwM2M cloud codec is used
327+
*/
272328
int cloud_codec_encode_pgps_request(struct cloud_codec_data *output,
273329
struct cloud_data_pgps_request *pgps_request);
274330

331+
/**
332+
* @brief Decode received configuration.
333+
*
334+
* @param[in] input string buffer with encoded config
335+
* @param[in] input_len length of input
336+
* @param[out] cfg where to store the decoded config
337+
*
338+
* @retval 0 on success
339+
* @retval -ENODATA if string doesn't contain required JSON objects
340+
* @retval -ENOMEM if codec couldn't allocate memory
341+
* @retval -ECANCELED if data was already processed
342+
* @retval -ENOTSUP if LwM2M cloud codec is used
343+
*/
275344
int cloud_codec_decode_config(char *input, size_t input_len,
276345
struct cloud_data_cfg *cfg);
277346

347+
/**
348+
* @brief Encode current configuration.
349+
*
350+
* @param[out] output string buffer for encoding result
351+
* @param[in] cfg pointer to current configuration
352+
*
353+
* @retval 0 on success
354+
* @retval -ENOMEM if codec couldn't allocate memory
355+
* @retval -ENOTSUP if LwM2M cloud codec is used
356+
*/
278357
int cloud_codec_encode_config(struct cloud_codec_data *output,
279358
struct cloud_data_cfg *cfg);
280359

360+
/**
361+
* @brief Encode cloud buffer data.
362+
*
363+
* @param[out] output string buffer for encoding result
364+
* @param[in] gnss_buf pointer to GNSS data
365+
* @param[in] sensor_buf pointer to Sensor data
366+
* @param[in] modem_stat_buf pointer to static modem data
367+
* @param[in] modem_dyn_buf pointer to dynamic modem data
368+
* @param[in] ui_buf pointer to button data
369+
* @param[in] accel_buf pointer to accelerometer data
370+
* @param[in] bat_buf pointer to battery data
371+
*
372+
* @retval 0 on success
373+
* @retval -ENODATA if none of the data elements are marked valid
374+
* @retval -EINVAL if the data is invalid
375+
* @retval -ENOMEM if codec couldn't allocate memory
376+
* @retval -ENOTSUP if nRF cloud codec is used
377+
*/
281378
int cloud_codec_encode_data(struct cloud_codec_data *output,
282379
struct cloud_data_gnss *gnss_buf,
283380
struct cloud_data_sensors *sensor_buf,
@@ -287,9 +384,45 @@ int cloud_codec_encode_data(struct cloud_codec_data *output,
287384
struct cloud_data_accelerometer *accel_buf,
288385
struct cloud_data_battery *bat_buf);
289386

387+
/**
388+
* @brief Encode UI data.
389+
*
390+
* @param[out] output string buffer for encoding result
391+
* @param[in] ui_buf UI data to encode
392+
*
393+
* @retval 0 on success
394+
* @retval -ENODATA if the data elements is not marked valid
395+
* @retval -EINVAL if the data is invalid
396+
* @retval -ENOMEM if codec couldn't allocate memory
397+
*/
290398
int cloud_codec_encode_ui_data(struct cloud_codec_data *output,
291399
struct cloud_data_ui *ui_buf);
292400

401+
/**
402+
* @brief Encode a batch of cloud buffer data.
403+
*
404+
* @param[out] output string buffer for encoding result
405+
* @param[in] gnss_buf GNSS data buffer
406+
* @param[in] sensor_buf Sensor data buffer
407+
* @param[in] modem_stat_buf static modem data buffer
408+
* @param[in] modem_dyn_buf dynamic modem data buffer
409+
* @param[in] ui_buf button data buffer
410+
* @param[in] accel_buf accelerometer data buffer
411+
* @param[in] bat_buf battery data buffer
412+
* @param[in] gnss_buf_count length of GNSS data buffer
413+
* @param[in] sensor_buf_count length of Sensor data buffer
414+
* @param[in] modem_stat_buf_count length of static modem data buffer
415+
* @param[in] modem_dyn_buf_count length of dynamic modem data buffer
416+
* @param[in] ui_buf_count length of button data buffer
417+
* @param[in] accel_buf_count length of accelerometer data buffer
418+
* @param[in] bat_buf_count length of battery data buffer
419+
*
420+
* @retval 0 on success
421+
* @retval -ENODATA if none of the data elements are marked valid
422+
* @retval -EINVAL if the data is invalid
423+
* @retval -ENOMEM if codec couldn't allocate memory
424+
* @retval -ENOTSUP if LwM2M cloud codec is used
425+
*/
293426
int cloud_codec_encode_batch_data(struct cloud_codec_data *output,
294427
struct cloud_data_gnss *gnss_buf,
295428
struct cloud_data_sensors *sensor_buf,
@@ -339,11 +472,6 @@ void cloud_codec_populate_modem_dynamic_buffer(
339472
int *head_modem_buf,
340473
size_t buffer_count);
341474

342-
static inline void cloud_codec_release_data(struct cloud_codec_data *output)
343-
{
344-
cJSON_FreeString(output->buf);
345-
}
346-
347475
/**
348476
* @}
349477
*/

0 commit comments

Comments
 (0)