Invoke HAL_DISCOVERY_STATE_STOPPED event once
[platform/core/connectivity/bluetooth-frwk.git] / bt-oal / bluez_hal / src / bt-hal-event-receiver.c
index 29caf36..b74a110 100644 (file)
@@ -382,13 +382,17 @@ static void __bt_hal_adapter_property_changed_event(GVariant *msg)
                                                DBUS_TIMEOUT, NULL,
                                                &err);
                                if (err) {
+                                       struct hal_ev_discovery_state_changed ev;
+
                                        ERR("Dbus Error : %s", err->message);
 
+                                       if (g_strrstr(err->message, "No discovery started"))
+                                               continue;
+
                                        /* This error is thrown by Bluez, as Discovery is already stopped.
                                           Discovery is stopped if user cancels on going discovery.
                                           In order to maintain correct state of Bluetooth Discovery state,
                                           simply send Discovery stopped event to HAL user */
-                                       struct hal_ev_discovery_state_changed ev;
                                        ev.state = HAL_DISCOVERY_STATE_STOPPED;
                                        event_cb(HAL_EV_DISCOVERY_STATE_CHANGED, &ev, sizeof(ev));
                                        g_clear_error(&err);
@@ -581,9 +585,25 @@ void _bt_hal_handle_adapter_event(GVariant *msg, const char *member)
 
                g_free(address);
        } else if (strcasecmp(member, BT_HAL_HARDWARE_ERROR) == 0) {
+#ifndef TIZEN_BT_HAL
                DBG("BT Hardware Error: Unhandled");
+#else
+               struct hal_ev_controller_error_recieved info;
+
+               INFO("### BT Hardware Error");
+               info.code = HAL_CONTROLLER_ERROR_HW_ERROR;
+               event_cb(HAL_EV_CONTROLLER_ERROR_RECIEVED, &info, sizeof(info));
+#endif
        } else if (strcasecmp(member, BT_HAL_TX_TIMEOUT_ERROR) == 0) {
-               DBG("BT TX Timeout Error: Unhandled");
+#ifndef TIZEN_BT_HAL
+               DBG("BT Hardware Error: Unhandled");
+#else
+               struct hal_ev_controller_error_recieved info;
+
+               INFO("### BT TX Timeout Error");
+               info.code = HAL_CONTROLLER_ERROR_TX_TIMEOUT;
+               event_cb(HAL_EV_CONTROLLER_ERROR_RECIEVED, &info, sizeof(info));
+#endif
        } else if (strcasecmp(member, BT_HAL_DBFW_PLUS_INFO) == 0) {
 #ifdef TIZEN_BT_HAL
                DBG("### DBFW+ info received from BLUEZ");
@@ -1558,7 +1578,7 @@ static void __bt_hal_device_property_changed_event(GVariant *msg, const char *pa
                } else if (!g_strcmp0(key, "GattConnected")) {
                        gboolean gatt_connected = FALSE;
                        g_variant_get(value, "b", &gatt_connected);
-                       INFO("Device property changed : GattConnected [%d]", gatt_connected);
+                       INFO_C("Device property changed : GattConnected [%d]", gatt_connected);
 
                        char *address = g_malloc0(BT_HAL_ADDRESS_STRING_SIZE);
                        _bt_hal_convert_device_path_to_address(path, address);
@@ -1825,7 +1845,7 @@ static void __bt_hal_device_properties_lookup(GVariant *result, char *address)
                                        (BT_HAL_STACK_UUID_SIZE * uuid_count),
                                        uuids);
                        ev->num_props = num_props_tmp + 1;
-                       g_free(uuid_value);
+                       g_strfreev(uuid_value);
                }
                g_variant_unref(tmp_value);
 
@@ -1878,7 +1898,6 @@ static void __bt_hal_device_properties_lookup(GVariant *result, char *address)
 
 static void __bt_hal_send_device_acl_connection_state_event(int status, gboolean connected, const char *address)
 {
-       DBG("+");
        struct hal_ev_acl_state_changed ev;
 
        ev.status = status;
@@ -2019,9 +2038,9 @@ static void __bt_hal_handle_device_specific_events(GVariant *msg, const char *me
                        disc_reason, _bt_hal_convert_disc_reason_to_string(disc_reason), address, name);
 
                if (!addr_type)
-                       __bt_hal_send_device_acl_connection_state_event(_bt_hal_convert_disc_reason_to_status(disc_reason), FALSE, address);
+                       __bt_hal_send_device_acl_connection_state_event(disc_reason, FALSE, address);
                else
-                       __bt_hal_send_device_le_connection_state_event(_bt_hal_convert_disc_reason_to_status(disc_reason), FALSE, address);
+                       __bt_hal_send_device_le_connection_state_event(disc_reason, FALSE, address);
                g_free(address);
        } else if (strcasecmp(member, "ProfileStateChanged") == 0) {
                int state = 0;