2 * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 #ifndef __TIZEN_SYSTEM_BATTERY_H__
19 #define __TIZEN_SYSTEM_BATTERY_H__
23 #include "device-error.h"
30 #define BATTERY_INFO_MAX 32
33 * @addtogroup CAPI_SYSTEM_DEVICE_BATTERY_MODULE
39 * @brief Enumeration for the battery level status.
40 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
43 DEVICE_BATTERY_LEVEL_EMPTY = 0, /**< The battery goes empty. Prepare for the safe termination of the application, because the device starts a shutdown process soon after entering this level. */
44 DEVICE_BATTERY_LEVEL_CRITICAL, /**< The battery charge is at a critical state. You may have to stop using multimedia features, because they are not guaranteed to work correctly at this battery status. */
45 DEVICE_BATTERY_LEVEL_LOW, /**< The battery has little charge left. */
46 DEVICE_BATTERY_LEVEL_HIGH, /**< The battery status is not to be careful. */
47 DEVICE_BATTERY_LEVEL_FULL, /**< The battery status is fully charged. It means no more charge. */
48 } device_battery_level_e;
52 * @brief Enumeration for battery health information.
56 DEVICE_BATTERY_HEALTH_GOOD, /**< The battery health is good */
57 DEVICE_BATTERY_HEALTH_COLD, /**< The temperature of the battery is cold */
58 DEVICE_BATTERY_HEALTH_DEAD, /**< The battery is dead */
59 DEVICE_BATTERY_HEALTH_OVER_HEAT, /**< The temperature of the battery is high */
60 DEVICE_BATTERY_HEALTH_OVER_VOLTAGE, /**< The battery is in over voltage state */
61 } device_battery_health_e;
65 * @brief Enumeration for power source information.
69 DEVICE_BATTERY_POWER_SOURCE_NONE, /**< There is no power source */
70 DEVICE_BATTERY_POWER_SOURCE_AC, /**< AC power cable is connected */
71 DEVICE_BATTERY_POWER_SOURCE_USB, /**< USB power cable is connected */
72 DEVICE_BATTERY_POWER_SOURCE_WIRELESS, /**< Power is provided by a wireless source */
73 } device_battery_power_source_e;
77 * @brief Enumeration for battery property information.
81 DEVICE_BATTERY_PROPERTY_CAPACITY, /**< The battery capacity (0 ~ 100 %) */
82 DEVICE_BATTERY_PROPERTY_CURRENT_NOW, /**< The battery current (uA) */
83 DEVICE_BATTERY_PROPERTY_CURRENT_AVERAGE, /**< The average battery current (uA) */
84 DEVICE_BATTERY_PROPERTY_VOLTAGE_NOW, /**< The battery voltage (uV) (Since 5.0) */
85 DEVICE_BATTERY_PROPERTY_VOLTAGE_AVERAGE, /**< The average battery voltage (uV) (Since 5.0) */
86 DEVICE_BATTERY_PROPERTY_TEMPERATURE, /**< The battery temperature (`C) (Since 5.0) */
87 } device_battery_property_e;
91 * @brief Enumeration for battery status information.
95 DEVICE_BATTERY_STATUS_CHARGING, /**< Battery is charging */
96 DEVICE_BATTERY_STATUS_DISCHARGING, /**< Battery is discharging */
97 DEVICE_BATTERY_STATUS_FULL, /**< Battery is fully charged */
98 DEVICE_BATTERY_STATUS_NOT_CHARGING, /**< Battery is not charging */
99 } device_battery_status_e;
102 struct device_battery_info {
103 char status[BATTERY_INFO_MAX];
104 char health[BATTERY_INFO_MAX];
105 char power_source[BATTERY_INFO_MAX];
117 * @brief Gets the battery charge percentage.
118 * @details It returns an integer value from @c 0 to @c 100 that indicates remaining battery charge
119 * as a percentage of the maximum level.
120 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
121 * @remarks In order to be notified when the battery state changes, use system_info_set_changed_cb().
122 * @param[out] percent The remaining battery charge percentage (@c 0 ~ @c 100)
123 * @return @c 0 on success,
124 * otherwise a negative error value
125 * @retval #DEVICE_ERROR_NONE Successful
126 * @retval #DEVICE_ERROR_INVALID_PARAMETER Invalid parameter
127 * @retval #DEVICE_ERROR_PERMISSION_DENIED Permission denied
128 * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed
129 * @retval #DEVICE_ERROR_NOT_SUPPORTED Not supported device
131 int device_battery_get_percent(int *percent);
135 * @brief Gets the charging state.
136 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
137 * @param[out] charging The battery charging state
138 * @return @c 0 on success,
139 * otherwise a negative error value
140 * @retval #DEVICE_ERROR_NONE Successful
141 * @retval #DEVICE_ERROR_INVALID_PARAMETER Invalid parameter
142 * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed
143 * @retval #DEVICE_ERROR_NOT_SUPPORTED Not supported device
144 * @see device_add_callback
145 * @see device_remove_callback
146 * @see #DEVICE_CALLBACK_BATTERY_CHARGING
148 int device_battery_is_charging(bool *charging);
152 * @brief Gets the battery level status.
153 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
154 * @param[out] status The battery level status
155 * @return @c 0 on success,
156 * otherwise a negative error value
157 * @retval #DEVICE_ERROR_NONE Successful
158 * @retval #DEVICE_ERROR_INVALID_PARAMETER Invalid parameter
159 * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed
160 * @retval #DEVICE_ERROR_NOT_SUPPORTED Not supported device
161 * @see device_battery_level_e
162 * @see device_add_callback
163 * @see device_remove_callback
164 * @see #DEVICE_CALLBACK_BATTERY_LEVEL
166 int device_battery_get_level_status(device_battery_level_e *status);
170 * @brief Gets the battery health information.
172 * @param[out] health The battery health information
173 * @return @c 0 on success,
174 * otherwise a negative error value
175 * @retval #DEVICE_ERROR_NONE Successful
176 * @retval #DEVICE_ERROR_INVALID_PARAMETER Invalid parameter
177 * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed
178 * @retval #DEVICE_ERROR_NOT_SUPPORTED Not supported device
180 int device_battery_get_health(device_battery_health_e *health);
184 * @brief Gets the battery power source information.
186 * @param[out] source The battery power source information
187 * @return @c 0 on success,
188 * otherwise a negative error value
189 * @retval #DEVICE_ERROR_NONE Successful
190 * @retval #DEVICE_ERROR_INVALID_PARAMETER Invalid parameter
191 * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed
192 * @retval #DEVICE_ERROR_NOT_SUPPORTED Not supported device
194 int device_battery_get_power_source(device_battery_power_source_e *source);
198 * @brief Gets the battery properties.
200 * @param[in] property The property type
201 * @param[out] value The battery information for the property given
202 * @return @c 0 on success,
203 * otherwise a negative error value
204 * @retval #DEVICE_ERROR_NONE Successful
205 * @retval #DEVICE_ERROR_INVALID_PARAMETER Invalid parameter
206 * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed
207 * @retval #DEVICE_ERROR_NOT_SUPPORTED Not supported device
209 int device_battery_get_property(device_battery_property_e property, int *value);
213 * @brief Gets the battery status information.
215 * @param[out] status The battery status information
216 * @return @c 0 on success,
217 * otherwise a negative error value
218 * @retval #DEVICE_ERROR_NONE Successful
219 * @retval #DEVICE_ERROR_INVALID_PARAMETER Invalid parameter
220 * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed
221 * @retval #DEVICE_ERROR_NOT_SUPPORTED Not supported device
223 int device_battery_get_status(device_battery_status_e *status);
236 #endif // __TIZEN_SYSTEM_BATTERY_H__