battery: Enhance API description 53/318153/2
authorYunhee Seo <yuni.seo@samsung.com>
Wed, 25 Sep 2024 04:29:12 +0000 (13:29 +0900)
committerYunhee Seo <yuni.seo@samsung.com>
Thu, 26 Sep 2024 06:27:16 +0000 (15:27 +0900)
To improve readability and facilitate comprehension,
more detailed API descriptions are added.

Change-Id: I3a8acde35dc9b8f98aa99750310baef6976642de
Signed-off-by: Yunhee Seo <yuni.seo@samsung.com>
include/battery-internal.h
include/battery.h

index 2ce0e56d4d48752655919f3ecc24ee5a6456447f..bb36a4d8176846cb37b4fbc361a6f63c5d9f4a83 100644 (file)
@@ -49,17 +49,28 @@ struct device_battery_info {
 };
 
 /**
- * @brief Gets the battery status..
+ * @brief Gets the current device's battery status from HAL battery module.
+ * @details Retrieves detailed information about the battery status, including capacity, voltage averages and etc.
  * @since_tizen 6.0
+ * @remarks Ensure that the provided @a info pointer is valid and has enough memory allocated.
  * @param[out] info battery status information.\n
  *                  The current_average is INT_MAX if battery hw does not provide current average.\n
  *                  The voltage_average is INT_MAX if battery hw does not provide voltage average.
- * @return @c 0 on success,
- *         otherwise a negative error value
+ * @return @c 0 on success, otherwise a negative error value
  * @retval #DEVICE_ERROR_NONE Successful
  * @retval #DEVICE_ERROR_INVALID_PARAMETER Invalid parameter
  * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed
  * @retval #DEVICE_ERROR_NOT_SUPPORTED Not supported device
+ * @code
+ * #include <device/battery-internal.h>
+ * ...
+ * struct device_battery_info info;
+ * int ret = 0;
+ * ...
+ * ret = device_battery_get_info(&info);
+ * ...
+ * @endcode
+ * @see device_battery_info
  */
 int device_battery_get_info_direct(struct device_battery_info *info);
 
index ca96ac976203f45157838ecc719c878b6076daf7..c8c03f0b3cc417faa2fc84b00a943794c879267a 100644 (file)
@@ -101,32 +101,51 @@ typedef enum {
 
 
 /**
- * @brief Gets the battery charge percentage.
+ * @brief Gets the current device's battery charge percentage as an interger value.
  * @details It returns an integer value from @c 0 to @c 100 that indicates remaining battery charge
  *          as a percentage of the maximum level.
  * @since_tizen 2.3
+ * @remarks Ensure that the provided @a percent pointer is valid and has enough memory allocated.
  * @param[out] percent The remaining battery charge percentage (@c 0 ~ @c 100)
- * @return @c 0 on success,
- *         otherwise a negative error value
+ * @return @c 0 on success, otherwise a negative error value
  * @retval #DEVICE_ERROR_NONE Successful
  * @retval #DEVICE_ERROR_INVALID_PARAMETER Invalid parameter
  * @retval #DEVICE_ERROR_PERMISSION_DENIED Permission denied
  * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed
  * @retval #DEVICE_ERROR_NOT_SUPPORTED Not supported device
+ * @code
+ * #include <device/battery.h>
+ * ...
+ * int percent = 0;
+ * int ret = 0;
+ * ...
+ * ret = device_battery_get_info(&percent);
+ * ...
+ * @endcode
  */
 int device_battery_get_percent(int *percent);
 
 
 /**
- * @brief Gets the charging state.
+ * @brief Gets the current device's charging state which the battery is charging.
+ * @details Checks whether the battery is currently being charged or not.
  * @since_tizen 2.3
+ * @remarks Ensure that the provided @a charging pointer is valid and has enough memory allocated.
  * @param[out] charging The battery charging state
- * @return @c 0 on success,
- *         otherwise a negative error value
+ * @return @c 0 on success, otherwise a negative error value
  * @retval #DEVICE_ERROR_NONE Successful
  * @retval #DEVICE_ERROR_INVALID_PARAMETER Invalid parameter
  * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed
  * @retval #DEVICE_ERROR_NOT_SUPPORTED Not supported device
+ * @code
+ * #include <device/battery.h>
+ * ...
+ * bool is_charging = false;
+ * int ret = 0;
+ * ...
+ * ret = device_battery_is_charging(&is_charging);
+ * ...
+ * @endcode
  * @see device_add_callback
  * @see device_remove_callback
  * @see #DEVICE_CALLBACK_BATTERY_CHARGING
@@ -135,15 +154,25 @@ int device_battery_is_charging(bool *charging);
 
 
 /**
- * @brief Gets the battery level status.
+ * @brief Gets the current device's battery level status as a @a device_battery_level_e.
+ * @details Retrieves the current battery level status based on remaining battery capacity.
  * @since_tizen 2.3
+ * @remarks Ensure that the provided @a status pointer is valid and has enough memory allocated.
  * @param[out] status The battery level status
- * @return @c 0 on success,
- *         otherwise a negative error value
+ * @return @c 0 on success, otherwise a negative error value
  * @retval #DEVICE_ERROR_NONE Successful
  * @retval #DEVICE_ERROR_INVALID_PARAMETER Invalid parameter
  * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed
  * @retval #DEVICE_ERROR_NOT_SUPPORTED Not supported device
+ * @code
+ * #include <device/battery.h>
+ * ...
+ * device_battery_level_e batt_lev_status = DEVICE_BATTERY_LEVEL_EMPTY;
+ * int ret = 0;
+ * ...
+ * ret = device_battery_get_level_status(&batt_lev_status);
+ * ...
+ * @endcode
  * @see device_battery_level_e
  * @see device_add_callback
  * @see device_remove_callback
@@ -153,58 +182,102 @@ int device_battery_get_level_status(device_battery_level_e *status);
 
 
 /**
- * @brief Gets the battery health information.
+ * @brief Gets the current device's battery health information as a @a device_battery_health_e.
+ * @details Retrieves the current battery health status information (e.g., good, overheat, dead, etc).
  * @since_tizen 3.0
+ * @remarks Ensure that the provided @a health pointer is valid and has enough memory allocated.
  * @param[out] health The battery health information
- * @return @c 0 on success,
- *         otherwise a negative error value
+ * @return @c 0 on success, otherwise a negative error value
  * @retval #DEVICE_ERROR_NONE Successful
  * @retval #DEVICE_ERROR_INVALID_PARAMETER Invalid parameter
  * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed
  * @retval #DEVICE_ERROR_NOT_SUPPORTED Not supported device
+ * @code
+ * #include <device/battery.h>
+ * ...
+ * device_battery_health_e batt_health = DEVICE_BATTERY_HEALTH_GOOD;
+ * int ret = 0;
+ * ...
+ * ret = device_battery_get_health(&batt_health);
+ * ...
+ * @endcode
+ * @see device_battery_health_e
  */
 int device_battery_get_health(device_battery_health_e *health);
 
 
 /**
- * @brief Gets the battery power source information.
+ * @brief Gets the current device's power source information from the battery.
+ * @details Retrieves the current battery power source information (e.g., ac, usb, etc).
  * @since_tizen 3.0
+ * @remarks Ensure that the provided @a source pointer is valid and has enough memory allocated.
  * @param[out] source The battery power source information
- * @return @c 0 on success,
- *         otherwise a negative error value
+ * @return @c 0 on success, otherwise a negative error value
  * @retval #DEVICE_ERROR_NONE Successful
  * @retval #DEVICE_ERROR_INVALID_PARAMETER Invalid parameter
  * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed
  * @retval #DEVICE_ERROR_NOT_SUPPORTED Not supported device
+ * @code
+ * #include <device/battery.h>
+ * ...
+ * device_battery_power_source_e batt_power_src = DEVICE_BATTERY_POWER_SOURCE_NONE;
+ * int ret = 0;
+ * ...
+ * ret = device_battery_get_power_source(&batt_power_src);
+ * ...
+ * @endcode
+ * @see device_battery_power_source_e
  */
 int device_battery_get_power_source(device_battery_power_source_e *source);
 
 
 /**
- * @brief Gets the battery properties.
+ * @brief Gets the current device's specified battery property as an interger value.
+ * @details Retrieves the current battery property information (e.g., capacity, current_average, temperature, etc).
  * @since_tizen 3.0
+ * @remarks Ensure that the provided @a value pointer is valid and has enough memory allocated.
  * @param[in] property The property type
  * @param[out] value The battery information for the property given
- * @return @c 0 on success,
- *         otherwise a negative error value
+ * @return @c 0 on success, otherwise a negative error value
  * @retval #DEVICE_ERROR_NONE Successful
  * @retval #DEVICE_ERROR_INVALID_PARAMETER Invalid parameter
  * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed
  * @retval #DEVICE_ERROR_NOT_SUPPORTED Not supported device
+ * @code
+ * #include <device/battery.h>
+ * ...
+ * int value = 0;
+ * int ret = 0;
+ * ...
+ * ret = device_battery_get_property(DEVICE_BATTERY_PROPERTY_CAPACITY, &value);
+ * ...
+ * @endcode
+ * @see device_battery_property_e
  */
 int device_battery_get_property(device_battery_property_e property, int *value);
 
 
 /**
- * @brief Gets the battery status information.
+ * @brief Gets the current device's battery status according to the degree of charge.
+ * @details Retrieves the current battery status information (e.g., charging, discharging, full, etc).
  * @since_tizen 3.0
+ * @remarks Ensure that the provided @a status pointer is valid and has enough memory allocated.
  * @param[out] status The battery status information
- * @return @c 0 on success,
- *         otherwise a negative error value
+ * @return @c 0 on success, otherwise a negative error value
  * @retval #DEVICE_ERROR_NONE Successful
  * @retval #DEVICE_ERROR_INVALID_PARAMETER Invalid parameter
  * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed
  * @retval #DEVICE_ERROR_NOT_SUPPORTED Not supported device
+ * @code
+ * #include <device/battery.h>
+ * ...
+ * device_battery_status_e batt_status = DEVICE_BATTERY_STATUS_CHARGING;
+ * int ret = 0;
+ * ...
+ * ret = device_battery_get_property(&batt_status);
+ * ...
+ * @endcode
+ * @see device_battery_status_e
  */
 int device_battery_get_status(device_battery_status_e *status);