Get RSSI when link loss occurs 87/220787/1
authorDeokhyun Kim <dukan.kim@samsung.com>
Mon, 23 Dec 2019 07:28:54 +0000 (16:28 +0900)
committerDeokhyun Kim <dukan.kim@samsung.com>
Mon, 23 Dec 2019 07:28:54 +0000 (16:28 +0900)
Change-Id: I2e611271c6541d5d90d5fb5f8e3bf679707c3efd
Signed-off-by: Deokhyun Kim <dukan.kim@samsung.com>
bt-api/bt-event-handler.c
bt-oal/include/oal-event.h
bt-oal/oal-device-mgr.c
bt-service-adaptation/services/device/bt-service-core-device.c
include/bluetooth-api.h

index a9b24c97cc194f0cd1658085eff17f5d3bb1b680..0827627a673c4e1654ae135f8ed3ffe428adb916 100644 (file)
@@ -1029,8 +1029,9 @@ void __bt_device_event_filter(GDBusConnection *connection,
                unsigned char addr_type;
                bt_connection_info_t conn_info;
                bluetooth_device_address_t dev_address = { {0} };
+               int rssi;
                BT_DBG("BT_DEVICE_DISCONNECTED");
-               g_variant_get(parameters, "(i&sy)", &result, &address, &addr_type);
+               g_variant_get(parameters, "(i&syi)", &result, &address, &addr_type, &rssi);
 
                _bt_convert_addr_string_to_type(dev_address.addr,
                                                address);
@@ -1043,6 +1044,7 @@ void __bt_device_event_filter(GDBusConnection *connection,
 
                conn_info.addr_type = addr_type;
                conn_info.disc_reason = result;
+               conn_info.rssi = rssi;
                BT_DBG("Sending Event to Framework, disconnect reason [0x%x]", result);
                _bt_common_event_cb(BLUETOOTH_EVENT_DEVICE_DISCONNECTED,
                                result, &conn_info,
index b14dbeb3bb7b7e68506bbe378a702575dbb29e57..798663a174847d236a5d36adee2c664c9cebd8c8 100644 (file)
@@ -270,6 +270,7 @@ typedef struct {
 typedef struct {
        bt_address_t address;
        oal_status_t status;
+       int rssi;
 } event_dev_conn_status_t;
 
 typedef event_dev_conn_status_t event_dev_bond_failed_t;
index db6168788bc282c210261f9ffc51dcea4b107e9a..f95c32561c5816840e598ad6d57e823b8676e8d6 100755 (executable)
@@ -31,6 +31,9 @@
 #include "oal-device-mgr.h"
 
 static const bt_interface_t * blued_api;
+#ifdef TIZEN_BT_HAL
+static int dbfw_rssi;
+#endif
 
 void device_mgr_init(const bt_interface_t * stack_if)
 {
@@ -753,6 +756,7 @@ void cb_device_acl_state_changed(bt_status_t status, bt_bdaddr_t *bd_addr,
 
 #ifdef TIZEN_BT_HAL
        conn_status->status = convert_to_oal_status(status);
+       conn_status->rssi = dbfw_rssi;
 #else
        if (BT_STATUS_SUCCESS != status) {
                /* At present only timeout will cause non-success status, later we can add more */
@@ -796,6 +800,7 @@ void cb_device_le_conn_state_changed(bt_status_t status, bt_bdaddr_t *bd_addr,
        BT_DBG("LE conn status:%d, state: %d", status, state);
        memcpy(conn_status->address.addr, bd_addr->address, 6);
        conn_status->status = convert_to_oal_status(status);
+       conn_status->rssi = dbfw_rssi;
 
        switch (state) {
        case BT_LE_CONN_STATE_CONNECTED:
@@ -999,6 +1004,20 @@ void cb_raw_rssi_received(bt_bdaddr_t *bd_addr, int32_t link_type, int32_t rssi)
        BT_DBG("-");
 }
 
+static gboolean __device_init_dbfw_rssi_cb(gpointer user_data)
+{
+       dbfw_rssi = 0;
+       return FALSE;
+}
+
+static void __device_parse_dbfw_set_rssi(unsigned char *data, uint32_t length)
+{
+       ret_if(length < 5);
+       dbfw_rssi = 0xFFFFFF00 | data[4];
+       BT_INFO("dbfw_rssi = %d", dbfw_rssi);
+       g_timeout_add(1000, __device_init_dbfw_rssi_cb, NULL);
+}
+
 void cb_dbfw_plus_info_received(unsigned char *data, uint32_t length, uint8_t event_code)
 {
        char evt_str[18];
@@ -1016,6 +1035,7 @@ void cb_dbfw_plus_info_received(unsigned char *data, uint32_t length, uint8_t ev
                case BT_DBFW_PLUS_EVENT_CODE_LINK_LOSS_INFO:
                        BT_DBG("## Event Code: Linkloss Debug Info");
                        snprintf(evt_str, 18, "[DBFW]Linkloss(D)");
+                       __device_parse_dbfw_set_rssi(data, length);
                        break;
                case BT_DBFW_PLUS_EVENT_CODE_LINK_LOSS_CLOCK_INFO:
                        BT_DBG("## Event Code: Linkloss Clock Info");
index 55c1cea2371b4dc31c061ca7bdc8a887f1dcfce6..20d848e9aaa06bb1ff604099d17949510942db88 100644 (file)
@@ -1439,7 +1439,7 @@ static void __bt_device_acl_state_changed_callback(event_dev_conn_status_t *acl_
                                BLUETOOTH_EVENT_DEVICE_CONNECTED,
                                param);
        } else {
-               param = g_variant_new("(isy)", result, address, type);
+               param = g_variant_new("(isyi)", result, address, type, acl_event->rssi);
                _bt_send_event(BT_DEVICE_EVENT,
                                BLUETOOTH_EVENT_DEVICE_DISCONNECTED,
                                param);
index c0249b44b3754f1f80b24f6e74027c65fc93334c..774a4b85316cd1be96b14adadc954ec82ea8d91d 100644 (file)
@@ -1353,6 +1353,7 @@ typedef struct {
        bluetooth_device_address_t device_addr;
        unsigned char addr_type;
        int disc_reason;
+       int rssi;
 } bt_connection_info_t;
 
 /**