#include "bt-service-battery-monitor.h"
#include "bt-service-common.h"
+#include "bt-service-event.h"
static time_t scan_start = 0;
static time_t connect_start = 0;
BT_DBG("App-wise data transaction details");
for (GSList *l = data->atm_list; l != NULL; l = g_slist_next(l)) {
_bt_battery_app_data_t *t = (_bt_battery_app_data_t *)(l->data);
- BT_DBG("%ld %ld %d %d", (long int)(t->uid), (long int)(t->pid), t->rx_bytes, t->tx_bytes);
+ BT_DBG("%ld %ld %d %d %u", (long int)(t->uid), (long int)(t->pid), t->rx_bytes, t->tx_bytes, t->time);
}
current_session_data->atm_list = NULL;
}
}
+static void _bt_notify_battery_data(void)
+{
+ BT_INFO("+");
+ _bt_battery_data_t *data = NULL;
+ int result;
+
+ data = g_new0(_bt_battery_data_t, 1);
+ result = _bt_bm_read_data(data);
+ GVariant *out_var = NULL, *param = NULL;
+ GArray *info = NULL;
+
+ if (result != BLUETOOTH_ERROR_NONE) {
+ BT_ERR("Battery data not collected");
+ }
+ else {
+ bt_battery_dbus_data_t dbus_data;
+ memset(&dbus_data, 0, sizeof(bt_battery_dbus_data_t));
+ dbus_data.session_start_time = data->session_start_time;
+ 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;
+
+ /*Populating app data*/
+ int n = 0;
+ for (GSList *l = data->atm_list; l != NULL; l = g_slist_next(l)) {
+ bt_battery_app_data *t = (bt_battery_app_data *)(l->data);
+ memcpy(&dbus_data.app_data[n], t, sizeof(bt_battery_app_data));
+ n++;
+ }
+ dbus_data.num_app = n;
+
+ info = g_array_new(FALSE, FALSE, sizeof(gchar));
+ g_array_append_vals(info, &dbus_data, sizeof(bt_battery_dbus_data_t));
+
+ out_var = g_variant_new_from_data((const GVariantType *)"ay",
+ info->data, info->len,
+ TRUE, NULL, NULL);
+ }
+ param = g_variant_new("(iv)", result, out_var);
+ _bt_send_event(BT_ADAPTER_EVENT,
+ BLUETOOTH_EVENT_DISABLED_BATTERY_DATA,
+ param);
+
+ g_slist_free(data->atm_list);
+ g_free(data);
+ g_array_free(info, TRUE);
+ BT_INFO("-");
+}
+
void _bt_bm_event_handler(gpointer data)
{
bt_service_oal_event_data_t *oal_event = data;
case OAL_EVENT_ADAPTER_DISABLED:
BT_DBG("Handling Adapter Disabled");
_bt_stop_session_time();
+ _bt_notify_battery_data();
break;
case OAL_EVENT_ADAPTER_INQUIRY_STARTED:
case OAL_EVENT_BLE_DISCOVERY_STARTED: