Add the Rx / Tx / idle time in the battery monitor
[platform/core/connectivity/bluetooth-frwk.git] / bt-service-adaptation / services / bt-service-battery-monitor.c
index 33a11b4..59d93cd 100644 (file)
@@ -31,6 +31,7 @@
 #include "bt-service-battery-monitor.h"
 #include "bt-service-common.h"
 #include "bt-service-event.h"
+#include "bt-service-core-adapter.h"
 
 static time_t scan_start = 0;
 static time_t connect_start = 0;
@@ -57,6 +58,11 @@ static void __bt_display_session_data()
 /*After reading data, the function resets it*/
 int _bt_bm_read_data(_bt_battery_data_t *data)
 {
+       uint32_t tx_time = 0;
+       uint32_t rx_time = 0;
+       uint32_t idle_time = 0;
+       uint32_t energy_used = 0;
+
        BT_DBG("");
 
        if (data == NULL) {
@@ -64,6 +70,16 @@ int _bt_bm_read_data(_bt_battery_data_t *data)
                return BLUETOOTH_ERROR_NO_DATA;
        }
 
+       if (_bt_get_energy_info(&tx_time, &rx_time,
+                               &idle_time, &energy_used) != BLUETOOTH_ERROR_NONE) {
+               BT_ERR("Fail to get energy info");
+               return BLUETOOTH_ERROR_NOT_SUPPORT;
+       }
+
+       data->tx_time = tx_time;
+       data->rx_time = rx_time;
+       data->idle_time = idle_time;
+
        data->session_start_time = current_session_data->session_start_time;
        data->session_end_time = time(NULL);
        current_session_data->session_start_time = time(NULL);
@@ -248,6 +264,9 @@ static void _bt_notify_battery_data(void)
                dbus_data.session_end_time = data->session_end_time;
                dbus_data.session_scan_time = data->session_scan_time;
                dbus_data.session_connected_time = data->session_connected_time;
+               dbus_data.tx_time = data->tx_time;
+               dbus_data.rx_time = data->rx_time;
+               dbus_data.idle_time = data->idle_time;
 
                /*Populating app data*/
                int n = 0;