From 70e79bc1b0bb31edff0e39d272ae5e4cb90c06d5 Mon Sep 17 00:00:00 2001 From: Dohyun Pyun Date: Mon, 20 Jun 2022 17:37:27 +0900 Subject: [PATCH] Use HCI error code instead of MGMT disconnection reason Change-Id: If715b847372b0be82ebdd8404a8b2a39bca01970 Signed-off-by: Dohyun Pyun --- src/adapter.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/src/adapter.c b/src/adapter.c index e9b11b6..d0d79c6 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -15230,6 +15230,39 @@ static int adapter_unregister(struct btd_adapter *adapter) return 0; } +#ifdef TIZEN_FEATURE_BLUEZ_MODIFY +/* ---- HCI Error Codes ---- */ +#define HCI_ERROR_AUTH_FAILURE 0x05 +#define HCI_ERROR_PIN_OR_KEY_MISSING 0x06 +#define HCI_ERROR_MEMORY_EXCEEDED 0x07 +#define HCI_ERROR_CONNECTION_TIMEOUT 0x08 +#define HCI_ERROR_REJ_LIMITED_RESOURCES 0x0d +#define HCI_ERROR_REJ_BAD_ADDR 0x0f +#define HCI_ERROR_REMOTE_USER_TERM 0x13 +#define HCI_ERROR_REMOTE_LOW_RESOURCES 0x14 +#define HCI_ERROR_REMOTE_POWER_OFF 0x15 +#define HCI_ERROR_LOCAL_HOST_TERM 0x16 +#define HCI_ERROR_PAIRING_NOT_ALLOWED 0x18 +#define HCI_ERROR_INVALID_LL_PARAMS 0x1e +#define HCI_ERROR_UNSPECIFIED 0x1f +#define HCI_ERROR_ADVERTISING_TIMEOUT 0x3c + +static uint8_t mgmt_to_hci_reason(uint8_t err) +{ + switch (err) { + case MGMT_DEV_DISCONN_TIMEOUT: + return HCI_ERROR_CONNECTION_TIMEOUT; + case MGMT_DEV_DISCONN_REMOTE: + return HCI_ERROR_REMOTE_USER_TERM; + case MGMT_DEV_DISCONN_LOCAL_HOST: + return HCI_ERROR_LOCAL_HOST_TERM; + default: + error("No match MGMT error"); + return err; + } +} +#endif + static void disconnected_callback(uint16_t index, uint16_t length, const void *param, void *user_data) { @@ -15248,7 +15281,12 @@ static void disconnected_callback(uint16_t index, uint16_t length, else reason = ev->reason; +#ifdef TIZEN_FEATURE_BLUEZ_MODIFY + /* Use HCI error code instead of MGMT disconnection reason */ + dev_disconnected(adapter, &ev->addr, mgmt_to_hci_reason(reason)); +#else dev_disconnected(adapter, &ev->addr, reason); +#endif } static void connected_callback(uint16_t index, uint16_t length, -- 2.7.4