@@ -212,9 +212,13 @@ struct cloud_codec_data {
212212};
213213
214214struct 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
253257enum 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
257262struct 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+ */
262274typedef 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+ */
264286int 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+ */
266300int 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+ */
269314int 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+ */
272328int 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+ */
275344int 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+ */
278357int 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+ */
281378int 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+ */
290398int 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+ */
293426int 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