2 * Copyright (c) 2018 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 __BM_PLUGIN_INTERFACE_H__
19 #define __BM_PLUGIN_INTERFACE_H__
29 typedef unsigned int uint;
30 typedef unsigned char uchar;
32 #define BM_DATA_TYPE_MAX (BM_DATA_TYPE_BATTERY + 1)
33 #define BM_PLUGIN_ID_MAX (BM_PLUGIN_ID_BATTERY + 1)
34 #define BM_DURATION_TYPE_MAX (BM_DURATION_TYPE_1WEEK + 1)
37 BM_PLUGIN_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */
38 BM_PLUGIN_ERROR_NO_DATA = TIZEN_ERROR_NO_DATA, /**< No data */
39 BM_PLUGIN_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */
40 BM_PLUGIN_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */
41 BM_PLUGIN_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED, /**< Not supported */
42 BM_PLUGIN_ERROR_SERVICE_UNAVAILABLE = TIZEN_ERROR_UNKNOWN - 1 /**< Service unavailable */
46 * enum for plugin identifier
49 BM_PLUGIN_ID_BLE=0, /**< Bluetooth Low Energy */
50 BM_PLUGIN_ID_WIFI, /**< Wi-Fi */
51 BM_PLUGIN_ID_CPU, /**< CPU */
52 BM_PLUGIN_ID_DISPLAY, /**< Display */
53 BM_PLUGIN_ID_DEVICE_NETWORK, /**< Network */
54 BM_PLUGIN_ID_GPS_SENSOR, /**< GPS */
55 BM_PLUGIN_ID_HRM_SENSOR, /**< Heart Rate Monitor */
56 BM_PLUGIN_ID_BATTERY /**< Battery */
60 * enum for feature data collection period
63 BM_DURATION_TYPE_1DAY = 0, /**< Set the period from a day ago to now */
64 BM_DURATION_TYPE_1WEEK /**< Set the period from a week ago to now */
68 * enum for feature data type
71 BM_DATA_TYPE_BLE=0, /**< Bluetooth Low Energy */
72 BM_DATA_TYPE_WIFI, /**< Wi-Fi */
73 BM_DATA_TYPE_CPU, /**< CPU */
74 BM_DATA_TYPE_DISPLAY, /**< Display */
75 BM_DATA_TYPE_DEVICE_NETWORK, /**< Network */
76 BM_DATA_TYPE_GPS_SENSOR, /**< GPS */
77 BM_DATA_TYPE_HRM_SENSOR, /**< Heart Rate Monitor */
78 BM_DATA_TYPE_BATTERY /**< Battery */
79 } bm_plugin_data_type_e;
82 * common structure for application time map.
85 char *app_id; /**< application id */
86 uint time; /**< total duration for which application as active */
90 char *app_id; /**< application id */
91 uint time; /**< total duration for which application as active */
92 uint rx; /**< Total Bytes received by the application during runtime */
93 uint tx; /**< Total Bytes transmitted by the application during runtime */
97 * structure for "display" feature data.
100 uint high; /**< total time in milliseconds during which brightness intensity was high */
101 uint low; /**< total time in milliseconds during which brightness intensity was low */
102 uint med; /**< total time in milliseconds during which brightness intensity was medium */
103 time_t start; /**< start time of feature data collection session */
104 time_t stop; /**< stop time of feature data collection session */
105 GSList *atm_list; /**< application time map('app_time_map_st1') list for all active applications between start & stop */
106 GSList *display_list; /**< list of nodes of 'bm_display_st' for next consecutive sessions */
110 * structure for "cpu" feature data.
113 uint cpuTicks; /**< CPU Usage during the session */
114 uint cpuTimeBackground; /**< Time spent in Background State average operating frequency will be used to calculate the power */
115 uint cpuTimeForeground; /**< Time spent in Foreground state average operating frequency will be used to calculate the power */
116 GSList *atm_list; /**< application time map('app_time_map_st1') list for all active applications between start & stop */
117 GSList *cpu_data_list; /**< list of nodes of 'bm_cpu_st' for next consecutive sessions */
121 * structure for "device_network" feature data.
124 uint time_level_0; /**< Total time in milliseconds during which signal_strength was on level 0 */
125 uint time_level_1; /**< Total time in milliseconds during which signal_strength was on level 1 */
126 uint time_level_2; /**< Total time in milliseconds during which signal_strength was on level 2 */
127 uint time_level_3; /**< Total time in milliseconds during which signal_strength was on level 3 */
128 uint time_level_4; /**< Total time in milliseconds during which signal_strength was on level 4 */
129 uint time_level_5; /**< Total time in milliseconds during which signal_strength was on level 5 */
130 uint time_level_6; /**< Total time in milliseconds during which signal_strength was on level 6 */
131 GSList *atm_list; /**< application time map('app_time_map_st2') list for all active applications between start & stop */
132 GSList *dn_data_list; /**< list of nodes of 'bm_device_network_st' for next consecutive sessions */
133 } bm_device_network_st;
136 * structure for "Wi-Fi" feature data.
139 uint time_level_0; /**< Total time in milliseconds during which rssi was on level 0 */
140 uint time_level_1; /**< Total time in milliseconds during which rssi was on level 1 */
141 uint time_level_2; /**< Total time in milliseconds during which rssi was on level 2 */
142 uint time_level_3; /**< Total time in milliseconds during which rssi was on level 3 */
143 uint time_level_4; /**< Total time in milliseconds during which rssi was on level 4 */
144 time_t startTime; /**< start time of feature data collection session */
145 time_t endTime; /**< end time of feature data collection session */
146 uint scanTime; /**< Total time spent by the resource in (scan) mode during the session */
147 GSList *atm_list; /**< application time map('app_time_map_st2') list for all active applications between start & stop */
148 GSList *wifi_data_list; /**< list of nodes of 'bm_wifi_st' for next consecutive sessions */
152 * structure for "bluetooth" feature data.
155 uint scanTime; /**< Total time spent by the resource in (scan) mode during the session */
156 uint connectedTime; /**< Total time spent by the resource in (connected) mode during the session */
157 time_t startTime; /**< start time of feature data collection session */
158 time_t stopTime; /**< stop time of feature data collection session */
159 GSList *atm_list; /**< application time map('app_time_map_st2') list for all active applications between start & stop */
160 GSList *bt_data_list; /**< list of nodes of 'bm_bluetooth_st' for next consecutive sessions */
164 * structure for "gps" feature data.
167 time_t connStartTime; /**< start time of feature data collection session */
168 time_t connStopTime; /**< stop time of feature data collection session */
169 GSList *atm_list; /**< application time map('app_time_map_st1') list for all active applications between start & stop */
170 GSList *gps_data_list; /**< list of nodes of 'bm_gps_st' for next consecutive sessions */
174 * structure for "hrm-sensor" feature data.
177 uint sensor_hub_wakeup_time; /**< wake-up time of sensor-hub */
178 uint sensor_hub_wakeup_count; /**< wake-up count of sensor-hub */
179 uint sensor_wakeup_time; /**< sensor wake-up time */
180 uint sensor_wakeup_count; /**< sensor wake-up count */
181 GSList *atm_list; /**< application time map('app_time_map_st1') list for all active applications between start & stop */
182 GSList *hrm_data_list; /**< list of nodes of 'bm_hrm_sensor_st' for next consecutive sessions */
186 * structure for "battery" feature data.
189 uint battery_percent; /**< Battery percent */
190 uint is_charging; /**< State of charging */
193 /* ========================================================================== */
196 * battery-monitor data handle
198 typedef void *bm_data_h;
201 * Callback to be invoked when service is going OFF
203 * [Param] handle - handle through which service will provide data
204 * to battery-monitor service daemon.
206 * [Param] result - the result of callback operation
208 typedef void (*bm_data_callback)(bm_plugin_error_e result, bm_data_h *handle);
211 * battery-monitor callback structure
214 bm_data_callback provide_feature_data;
218 * structure for plugin API's
222 * [Sync API] To initialize plugin
224 int (*init)(const bm_callbacks_st *callbacks);
226 * [Sync API] To deinitialize plugin
230 * [Sync API] To get feature data from plugin
232 * [Param] handle - battery-monitor data handle through which plugin
233 * will provide data to the manager. This handle will be passed
234 * as reference, plugin will assign a valid object which will be
235 * set free by the manager; battery-monitor manager will typecast
236 * the object provided through handle for each plugin and will use
237 * it for further calculation.
239 * [Param] data_type - type of data like - BLE, WiFi, CPU etc.
241 int (*get_feature_data)(bm_data_h *handle, bm_plugin_data_type_e data_type);
245 * structure for plugin information
249 * Respective "identifier" of Plugin
253 * Respective "name" of Plugin
257 * Respective "author" of Plugin
261 * Respective "version" of Plugin
265 * Plugin init function
267 int (*init)(bm_api_st **api);
269 * Plugin de-init function
276 * macro for adding plugin
278 #define BM_PLUGIN_ADD(id, name, author, version, init, deinit) \
279 __attribute__ ((visibility("default"))) bm_plugin_st bm_plugin = { id, name, author, version, init, deinit };
286 #endif /* __BM_PLUGIN_INTERFACE_H__ */