Skip to content

Commit f36abd1

Browse files
committed
lwm2m_carrier: doc: documentation improvements
- Aligned the use of "retval 0" closer to the NCS codebase style. - Corrected some functions which can return a positive integer, such as length (as opposed to just "0 If success"). - Added documentation for some undocumented return values. - Minor tweaks for consistendy such as spacing, and ms to milliseconds. Signed-off-by: Håvard Vermeer <[email protected]>
1 parent 5f6286b commit f36abd1

File tree

1 file changed

+57
-31
lines changed

1 file changed

+57
-31
lines changed

lib/bin/lwm2m_carrier/include/lwm2m_os.h

Lines changed: 57 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,8 @@ typedef void (*lwm2m_os_pdn_event_handler_t)
188188
* @param[out] cid The ID of the new PDP context.
189189
* @param cb Optional event handler.
190190
*
191-
* @retval 0 If success.
191+
* @retval 0 If the operation was successful.
192+
* Otherwise, a negative error code is returned.
192193
*/
193194
int lwm2m_os_pdn_ctx_create(uint8_t *cid, lwm2m_os_pdn_event_handler_t cb);
194195

@@ -199,7 +200,8 @@ int lwm2m_os_pdn_ctx_create(uint8_t *cid, lwm2m_os_pdn_event_handler_t cb);
199200
* @param apn The Access Point Name to configure the PDP context with.
200201
* @param family The family to configure the PDN context for.
201202
*
202-
* @retval 0 If success.
203+
* @retval 0 If the operation was successful.
204+
* Otherwise, a negative error code is returned.
203205
*/
204206
int lwm2m_os_pdn_ctx_configure(uint8_t cid, const char *apn, enum lwm2m_os_pdn_fam family);
205207

@@ -208,7 +210,8 @@ int lwm2m_os_pdn_ctx_configure(uint8_t cid, const char *apn, enum lwm2m_os_pdn_f
208210
*
209211
* @param cid The PDP context to destroy.
210212
*
211-
* @retval 0 If success.
213+
* @retval 0 If the operation was successful.
214+
* Otherwise, a negative error code is returned.
212215
*/
213216
int lwm2m_os_pdn_ctx_destroy(uint8_t cid);
214217

@@ -283,8 +286,8 @@ int lwm2m_os_sem_init(lwm2m_os_sem_t **sem, unsigned int initial_count, unsigned
283286
* @brief Take a semaphore.
284287
*
285288
* @param sem Address of the semaphore.
286-
* @param timeout Timeout in ms, or -1 for forever, in which case the semaphore is taken for as long
287-
* as necessary.
289+
* @param timeout Timeout in milliseconds, or -1 for forever, in which case the semaphore is taken
290+
* for as long as necessary.
288291
*
289292
* @retval 0 Semaphore taken.
290293
* @retval -EBUSY Returned without waiting.
@@ -308,35 +311,47 @@ void lwm2m_os_sem_reset(lwm2m_os_sem_t *sem);
308311

309312
/**
310313
* @brief Get uptime, in milliseconds.
314+
*
315+
* @return Current uptime.
311316
*/
312317
int64_t lwm2m_os_uptime_get(void);
313318

314319
/**
315320
* @brief Get uptime delta, in milliseconds.
321+
*
322+
* @param[in] ref Pointer to a reference time, which is updated to the current
323+
* uptime upon return.
324+
*
325+
* @return Elapsed time.
316326
*/
317327
int64_t lwm2m_os_uptime_delta(int64_t *ref);
318328

319329
/**
320-
* @brief Put a thread to a sleep.
330+
* @brief Put a thread to sleep.
321331
*
322332
* @param ms Desired duration of sleep in milliseconds.
333+
*
334+
* @return 0 if the requested duration has elapsed, or, if the thread was woken up before the
335+
* desired duration @c ms, the remaining duration left to sleep is returned.
323336
*/
324337
int lwm2m_os_sleep(int ms);
325338

326339
/**
327-
* @brief Reboot system.
340+
* @brief Reboot the system.
328341
*/
329342
void lwm2m_os_sys_reset(void);
330343

331344
/**
332345
* @brief Get a random value.
346+
*
347+
* @return A random 32-bit value.
333348
*/
334349
uint32_t lwm2m_os_rand_get(void);
335350

336351
/**
337352
* @brief Delete a non-volatile storage entry.
338353
*
339-
* @param[in] id of the entry to be deleted.
354+
* @param[in] id ID of the entry to be deleted.
340355
*
341356
* @retval 0 If the operation was successful.
342357
* Otherwise, a negative error code is returned.
@@ -346,7 +361,7 @@ int lwm2m_os_storage_delete(uint16_t id);
346361
/**
347362
* @brief Read an entry from non-volatile storage.
348363
*
349-
* @param[in] id of the entry to be read.
364+
* @param[in] id ID of the entry to be read.
350365
* @param[out] data Pointer to data buffer.
351366
* @param[in,out] len Number of bytes to be read.
352367
*
@@ -385,6 +400,8 @@ void lwm2m_os_timer_get(lwm2m_os_timer_handler_t handler, lwm2m_os_timer_t **tim
385400

386401
/**
387402
* @brief Release a timer task.
403+
*
404+
* @param timer Timer task to be released.
388405
*/
389406
void lwm2m_os_timer_release(lwm2m_os_timer_t *timer);
390407

@@ -393,7 +410,7 @@ void lwm2m_os_timer_release(lwm2m_os_timer_t *timer);
393410
*
394411
* @param work_q Workqueue.
395412
* @param timer Timer task.
396-
* @param delay Delay before submitting the task in ms.
413+
* @param delay Delay before submitting the task in milliseconds.
397414
*
398415
* @retval 0 Work placed on queue, already on queue or already running.
399416
* @retval -EINVAL Timer or work_q not found.
@@ -403,7 +420,7 @@ int lwm2m_os_timer_start_on_q(lwm2m_os_work_q_t *work_q, lwm2m_os_timer_t *timer
403420
/**
404421
* @brief Cancel a timer run.
405422
*
406-
* @param timer Timer task.
423+
* @param timer Timer task to cancel.
407424
* @param sync If true, wait for active tasks to finish before canceling.
408425
*/
409426
void lwm2m_os_timer_cancel(lwm2m_os_timer_t *timer, bool sync);
@@ -413,7 +430,7 @@ void lwm2m_os_timer_cancel(lwm2m_os_timer_t *timer, bool sync);
413430
*
414431
* @param timer Timer task.
415432
*
416-
* @return Time remaining in ms.
433+
* @return Time remaining in milliseconds.
417434
*/
418435
int64_t lwm2m_os_timer_remaining(lwm2m_os_timer_t *timer);
419436

@@ -422,23 +439,24 @@ int64_t lwm2m_os_timer_remaining(lwm2m_os_timer_t *timer);
422439
*
423440
* @param timer Timer task.
424441
*
425-
* @retval true If a timer task is pending.
442+
* @retval true If the timer task is pending.
443+
* @retval false If the timer task is idle.
426444
*/
427445
bool lwm2m_os_timer_is_pending(lwm2m_os_timer_t *timer);
428446

429447
/**
430448
* @brief Initialize AT command driver.
431449
*
432-
* @retval 0 If success.
433-
* @retval -EIO If AT command driver initialization failed.
450+
* @retval 0 If success.
451+
* @retval -EIO If AT command driver initialization failed.
434452
*/
435453
int lwm2m_os_at_init(lwm2m_os_at_handler_callback_t callback);
436454

437455
/**
438456
* @brief Register as an SMS client/listener.
439457
*
440-
* @retval 0 If success.
441-
* @retval -EIO If unable to register as SMS listener.
458+
* @retval 0 If success.
459+
* @retval -EIO If unable to register as SMS listener.
442460
*/
443461
int lwm2m_os_sms_client_register(lwm2m_os_sms_callback_t lib_callback, void *context);
444462

@@ -450,38 +468,42 @@ void lwm2m_os_sms_client_deregister(int handle);
450468
/**
451469
* @brief Establish a connection with the server and download a file.
452470
*
453-
* @retval 0 If success.
471+
* @retval 0 If the operation was successful.
472+
* Otherwise, a negative error code is returned.
454473
*/
455474
int lwm2m_os_download_get(const char *uri, const struct lwm2m_os_download_cfg *cfg, size_t from);
456475

457476
/**
458477
* @brief Disconnect from the server.
459478
*
460-
* @retval 0 If success.
479+
* @retval 0 If the operation was successful.
480+
* Otherwise, a negative error code is returned.
461481
*/
462482
int lwm2m_os_download_disconnect(void);
463483

464484
/**
465485
* @brief Initialize the download client.
466486
*
467-
* @retval 0 If success.
487+
* @retval 0 If the operation was successful.
488+
* Otherwise, a negative error code is returned.
468489
*/
469490
int lwm2m_os_download_init(lwm2m_os_download_callback_t lib_callback);
470491

471492
/**
472493
* @brief Retrieve size of file being downloaded.
473494
*
474-
* @param size Size of the file being downloaded.
495+
* @param[out] size Size of the file being downloaded.
475496
*
476-
* @retval 0 If success.
497+
* @retval 0 If the operation was successful.
498+
* Otherwise, a negative error code is returned.
477499
*/
478500
int lwm2m_os_download_file_size_get(size_t *size);
479501

480502
/**
481503
* @brief Check if UICC LwM2M bootstrap is enabled.
482504
*
483-
* @retval true If enabled
484-
* @retval false If disabled
505+
* @retval true If enabled
506+
* @retval false If disabled
485507
*/
486508
bool lwm2m_os_uicc_bootstrap_is_enabled(void);
487509

@@ -491,7 +513,7 @@ bool lwm2m_os_uicc_bootstrap_is_enabled(void);
491513
* @param p_buffer Buffer to store UICC LwM2M bootstrap record.
492514
* @param buffer_size Size of the buffer in bytes.
493515
*
494-
* @retval 0 If success.
516+
* @retval Length of the record. On error, returns a negative value.
495517
*/
496518
int lwm2m_os_uicc_bootstrap_read(uint8_t *p_buffer, int buffer_size);
497519

@@ -557,10 +579,10 @@ struct __attribute__((__packed__)) lwm2m_os_dfu_header {
557579
/**
558580
* @brief Find the image type for the buffer of bytes received.
559581
*
560-
* @param[in] buf A buffer of bytes which are the start of a binary firmware image.
561-
* @param[in] len The length of the provided buffer.
562-
* @param[out] header DFU image header descriptor. Only applicable to MCUboot-style upgrades over
563-
* multiple files.
582+
* @param[in] buf A buffer of bytes which are the start of a binary firmware image.
583+
* @param[in] len The length of the provided buffer.
584+
* @param[out] header DFU image header descriptor. Only applicable to MCUboot-style upgrades over
585+
* multiple files.
564586
*
565587
* @return Identifier for a supported image type or LWM2M_OS_DFU_IMG_TYPE_NONE if
566588
* image type is not recognized or not supported.
@@ -628,7 +650,10 @@ int lwm2m_os_dfu_pause(void);
628650
/**
629651
* @brief Schedule update for uploaded image.
630652
*
631-
* @retval 0 If success.
653+
* @retval 0 If the update was scheduled successfully.
654+
* @retval -EINVAL If the data needed to perform the update was incomplete.
655+
* @retval -EACCES If the DFU process was not in progress.
656+
* @retval -EIO Internal error.
632657
*/
633658
int lwm2m_os_dfu_schedule_update(void);
634659

@@ -640,7 +665,8 @@ void lwm2m_os_dfu_reset(void);
640665
/**
641666
* @brief Validate the application image update.
642667
*
643-
* @retval true If the application image was updated successfully.
668+
* @retval true If the application image was updated successfully.
669+
* @retval false If the application image was not updated successfully.
644670
*/
645671
bool lwm2m_os_dfu_application_update_validate(void);
646672

0 commit comments

Comments
 (0)