Use HCI error code instead of MGMT disconnection reason 48/276548/1 accepted/tizen/6.5/unified/20220621.140242 submit/tizen_6.5/20220620.221710
authorDohyun Pyun <dh79.pyun@samsung.com>
Mon, 20 Jun 2022 08:37:27 +0000 (17:37 +0900)
committerDohyun Pyun <dh79.pyun@samsung.com>
Mon, 20 Jun 2022 08:37:27 +0000 (17:37 +0900)
Change-Id: If715b847372b0be82ebdd8404a8b2a39bca01970
Signed-off-by: Dohyun Pyun <dh79.pyun@samsung.com>
src/adapter.c

index 8b52c02..aa84156 100644 (file)
@@ -14648,6 +14648,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)
 {
@@ -14666,7 +14699,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,