From 2aac4d095447bc1fcbe4238f9f46ae3cd093c3f4 Mon Sep 17 00:00:00 2001 From: Deokhyun Kim Date: Fri, 20 Dec 2019 17:46:34 +0900 Subject: [PATCH] Handle DBFW plus info events Change-Id: I8edc76764ebc301c5f9a866f73c4df8b52774b93 Signed-off-by: Deokhyun Kim --- bt-oal/bluez_hal/inc/bt-hal-msg.h | 8 ++++ bt-oal/bluez_hal/src/bt-hal-bluetooth.c | 17 +++++++++ bt-oal/bluez_hal/src/bt-hal-dbus-common-utils.h | 4 +- bt-oal/bluez_hal/src/bt-hal-event-receiver.c | 34 +++++++++++++++-- bt-oal/hardware/bluetooth.h | 15 ++++++++ bt-oal/oal-adapter-mgr.c | 2 + bt-oal/oal-device-mgr.c | 51 +++++++++++++++++++++++++ 7 files changed, 124 insertions(+), 7 deletions(-) diff --git a/bt-oal/bluez_hal/inc/bt-hal-msg.h b/bt-oal/bluez_hal/inc/bt-hal-msg.h index e42f101..e033e26 100644 --- a/bt-oal/bluez_hal/inc/bt-hal-msg.h +++ b/bt-oal/bluez_hal/inc/bt-hal-msg.h @@ -794,4 +794,12 @@ struct hal_ev_hf_client_conn_state { uint8_t state; uint8_t bdaddr[6]; } __attribute__((packed)); + +#define HAL_EV_DBFW_PLUS_INFO_RECIEVED 0xCE +struct hal_ev_dbfw_plus_info_recieved { + uint8_t event_code; + unsigned char *data; + uint32_t data_len; +} __attribute__((packed)); + #endif //_BT_HAL_MSG_H_ diff --git a/bt-oal/bluez_hal/src/bt-hal-bluetooth.c b/bt-oal/bluez_hal/src/bt-hal-bluetooth.c index 79c63b7..d914d3e 100644 --- a/bt-oal/bluez_hal/src/bt-hal-bluetooth.c +++ b/bt-oal/bluez_hal/src/bt-hal-bluetooth.c @@ -1047,6 +1047,19 @@ static void __bt_handle_raw_rssi_recieved(void *buf, uint16_t len) DBG("-"); } +static void __bt_handle_dbfw_plus_info_recieved(void *buf, uint16_t len) +{ + struct hal_ev_dbfw_plus_info_recieved *info = buf; + + DBG("+"); +#ifdef TIZEN_BT_HAL + if (bt_hal_cbacks->dbfw_plus_info_received_cb) + bt_hal_cbacks->dbfw_plus_info_received_cb( + info->data, info->data_len, info->event_code); +#endif + DBG("-"); +} + static void __bt_hal_handle_stack_messages(int message, void *buf, uint16_t len) { DBG("+"); @@ -1125,6 +1138,10 @@ static void __bt_hal_handle_stack_messages(int message, void *buf, uint16_t len) DBG("Event: HAL_EV_RAW_RSSI_RECIEVED"); __bt_handle_raw_rssi_recieved(buf, len); break; + case HAL_EV_DBFW_PLUS_INFO_RECIEVED: + DBG("Event: HAL_EV_DBFW_PLUS_INFO_RECIEVED"); + __bt_handle_dbfw_plus_info_recieved(buf, len); + break; default: DBG("Event Currently not handled!!"); break; diff --git a/bt-oal/bluez_hal/src/bt-hal-dbus-common-utils.h b/bt-oal/bluez_hal/src/bt-hal-dbus-common-utils.h index edcb24d..8615f7c 100644 --- a/bt-oal/bluez_hal/src/bt-hal-dbus-common-utils.h +++ b/bt-oal/bluez_hal/src/bt-hal-dbus-common-utils.h @@ -61,9 +61,6 @@ extern "C" { #define BT_HAL_LOWER_ADDRESS_LENGTH 9 #define BT_HAL_AGENT_NEW_LINE "\r\n" -#define BT_HAL_HARDWARE_ERROR "HardwareError" -#define BT_HAL_TX_TIMEOUT_ERROR "TxTimeoutError" - #define BT_HAL_VERSION_LENGTH_MAX 30 /**< This specifies bluetooth device version length */ #define BT_HAL_INTERFACE_NAME_LENGTH 16 #define BT_HAL_DEVICE_NAME_LENGTH_MAX 248 /**< This specifies maximum device name length */ @@ -86,6 +83,7 @@ extern "C" { #define BT_HAL_HARDWARE_ERROR "HardwareError" #define BT_HAL_TX_TIMEOUT_ERROR "TxTimeoutError" +#define BT_HAL_DBFW_PLUS_INFO "BrcmEnhancedDBFWInfo" #define BT_HAL_FREEDESKTOP_INTERFACE "org.freedesktop.DBus" #define BT_HAL_FREEDESKTOP_PATH "/org/freedesktop/DBus" diff --git a/bt-oal/bluez_hal/src/bt-hal-event-receiver.c b/bt-oal/bluez_hal/src/bt-hal-event-receiver.c index e88edbc..905defe 100644 --- a/bt-oal/bluez_hal/src/bt-hal-event-receiver.c +++ b/bt-oal/bluez_hal/src/bt-hal-event-receiver.c @@ -555,8 +555,6 @@ void _bt_hal_handle_adapter_event(GVariant *msg, const char *member) if (strcasecmp(member, "DeviceCreated") == 0) { DBG("DeviceCreated: Unhandled"); - } else if (strcasecmp(member, "InterfacesRemoved") == 0) { - DBG("InterfacesRemoved: Unhandled"); } else if (strcasecmp(member, "AdvertisingEnabled") == 0) { DBG("AdvertisingEnabled"); DBG("Advertising Enabled"); @@ -631,8 +629,37 @@ void _bt_hal_handle_adapter_event(GVariant *msg, const char *member) DBG("BT Hardware Error: Unhandled"); } else if (strcasecmp(member, BT_HAL_TX_TIMEOUT_ERROR) == 0) { DBG("BT TX Timeout Error: Unhandled"); - + } else if (strcasecmp(member, BT_HAL_DBFW_PLUS_INFO) == 0) { +#ifdef TIZEN_BT_HAL + DBG("### DBFW+ info received from BLUEZ"); + struct hal_ev_dbfw_plus_info_recieved info; + int length; + char event_code; + unsigned char *buffer = NULL; + GVariant *value = NULL; + + g_variant_get(msg, "(y@ay)", &event_code, &value); + if (value == NULL) { + ERR("g_variant_get fails"); + } else { + length = g_variant_get_size(value); + if (length <= 0) { + ERR("Invalid g_variant len = %d", length); + } else { + info.event_code = event_code; + buffer = (unsigned char*)g_variant_get_data(value); + info.data = g_memdup(buffer, length); + info.data_len = length; + if (!event_cb) + ERR("event_cb is NULL"); + else + event_cb(HAL_EV_DBFW_PLUS_INFO_RECIEVED, &info, sizeof(info)); + g_free(info.data); + } + } +#endif } + DBG("-"); } @@ -1127,7 +1154,6 @@ static gboolean __bt_hal_event_manager(gpointer data) __bt_hal_handle_gatt_char_event(param->parameters, param->signal_name); } - /* Free data */ g_free(param->sender_name); g_free(param->object_path); diff --git a/bt-oal/hardware/bluetooth.h b/bt-oal/hardware/bluetooth.h index deaa2ce..e4c3fa1 100644 --- a/bt-oal/hardware/bluetooth.h +++ b/bt-oal/hardware/bluetooth.h @@ -500,6 +500,17 @@ typedef enum { BT_PASSKEY_ENTRY, BT_PINCODE_ENTRY, } bt_gap_auth_variant_t; + +/** DBFW+ Event Code */ +typedef enum { + BT_DBFW_PLUS_EVENT_CODE_LINK_LOSS_INFO = 0x10, + BT_DBFW_PLUS_EVENT_CODE_LINK_LOSS_CLOCK_INFO = 0x11, + BT_DBFW_PLUS_EVENT_CODE_LINK_LOSS_PAGE_SLOTS = 0x12, + BT_DBFW_PLUS_EVENT_CODE_LINK_LOSS_LMP_TRACE = 0x13, + BT_DBFW_PLUS_EVENT_CODE_A2DP_INFO = 0x20, + BT_DBFW_PLUS_EVENT_CODE_HFP_INFO = 0x31, + BT_DBFW_PLUS_EVENT_CODE_HFP_SCO_PACKET_TYPE_INFO = 0x32, +} bt_dbfw_plus_event_code_t; #endif /** Bluetooth Interface callbacks */ @@ -623,6 +634,9 @@ typedef void (*rssi_alert_callback)(bt_bdaddr_t *bd_addr, int32_t link_type, int /** Remote device Raw RSSI received callback */ typedef void (*raw_rssi_received_callback)(bt_bdaddr_t *bd_addr, int32_t link_type, int32_t rssi); + +/** DBFW plus info received callback */ +typedef void (*dbfw_plus_info_received_callback)(unsigned char *data, uint32_t length, uint8_t event_code); #endif /** TODO: Add callbacks for Link Up/Down and other generic @@ -659,6 +673,7 @@ typedef struct { rssi_monitor_state_changed_callback rssi_monitor_state_changed_cb; rssi_alert_callback rssi_alert_cb; raw_rssi_received_callback raw_rssi_received_cb; + dbfw_plus_info_received_callback dbfw_plus_info_received_cb; #endif } bt_callbacks_t; diff --git a/bt-oal/oal-adapter-mgr.c b/bt-oal/oal-adapter-mgr.c index 544e639..b2f718d 100644 --- a/bt-oal/oal-adapter-mgr.c +++ b/bt-oal/oal-adapter-mgr.c @@ -79,6 +79,7 @@ extern void cb_device_trusted_profiles_changed(bt_bdaddr_t *bd_addr, uint32_t tr extern void cb_rssi_monitor_state_changed(bt_bdaddr_t *bd_addr, int32_t link_type, uint8_t state); extern void cb_rssi_alert(bt_bdaddr_t *bd_addr, int32_t link_type, int32_t alert_type, int32_t rssi); extern void cb_raw_rssi_received(bt_bdaddr_t *bd_addr, int32_t link_type, int32_t rssi); +extern void cb_dbfw_plus_info_received(unsigned char *data, uint32_t length, uint8_t event_code); #endif static bt_callbacks_t callbacks = { @@ -106,6 +107,7 @@ static bt_callbacks_t callbacks = { .rssi_monitor_state_changed_cb = cb_rssi_monitor_state_changed, .rssi_alert_cb = cb_rssi_alert, .raw_rssi_received_cb = cb_raw_rssi_received, + .dbfw_plus_info_received_cb = cb_dbfw_plus_info_received, #endif }; diff --git a/bt-oal/oal-device-mgr.c b/bt-oal/oal-device-mgr.c index 69ceaf3..db61687 100755 --- a/bt-oal/oal-device-mgr.c +++ b/bt-oal/oal-device-mgr.c @@ -999,4 +999,55 @@ void cb_raw_rssi_received(bt_bdaddr_t *bd_addr, int32_t link_type, int32_t rssi) BT_DBG("-"); } +void cb_dbfw_plus_info_received(unsigned char *data, uint32_t length, uint8_t event_code) +{ + char evt_str[18]; + char *data_str = NULL; + int i; + + ret_if(data == NULL); + + data_str = g_malloc0(length * 2 + 1); + for (i = 0; i < length; i++) + snprintf(&data_str[i * 2], 3, "%02X", data[i]); + data_str[i * 2] = '\0'; + + switch(event_code) { + case BT_DBFW_PLUS_EVENT_CODE_LINK_LOSS_INFO: + BT_DBG("## Event Code: Linkloss Debug Info"); + snprintf(evt_str, 18, "[DBFW]Linkloss(D)"); + break; + case BT_DBFW_PLUS_EVENT_CODE_LINK_LOSS_CLOCK_INFO: + BT_DBG("## Event Code: Linkloss Clock Info"); + snprintf(evt_str, 18, "[DBFW]Linkloss(C)"); + break; + case BT_DBFW_PLUS_EVENT_CODE_LINK_LOSS_PAGE_SLOTS: + BT_DBG("## Event Code: Linkloss Page slots"); + snprintf(evt_str, 18, "[DBFW]Linkloss(P)"); + break; + case BT_DBFW_PLUS_EVENT_CODE_LINK_LOSS_LMP_TRACE: + BT_DBG("## Event Code: Linkloss LMP trace"); + snprintf(evt_str, 18, "[DBFW]Linkloss(L)"); + break; + case BT_DBFW_PLUS_EVENT_CODE_A2DP_INFO: + BT_DBG("## Event Code: A2DP Info"); + snprintf(evt_str, 18, "[DBFW]A2DP"); + break; + case BT_DBFW_PLUS_EVENT_CODE_HFP_INFO: + BT_DBG("## Event Code: HFP Info"); + snprintf(evt_str, 18, "[DBFW]HFP"); + break; + case BT_DBFW_PLUS_EVENT_CODE_HFP_SCO_PACKET_TYPE_INFO: + BT_DBG("## Event Code: HFP SCO Packet Type"); + snprintf(evt_str, 18, "[DBFW]SCO"); + break; + default: + BT_DBG("## Unknown event code (0x%02x)", event_code); + snprintf(evt_str, 18, "[DBFW]0x%02X", event_code); + break; + } + + g_free(data_str); +} + #endif -- 2.7.4