From 3204c443ad57452102783b0fadd682c429e25a1a Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Fri, 29 Nov 2013 11:13:09 +0200 Subject: [PATCH] emulator/btdev: Simplify connection request logic We should return page timeout both when the remote exists but just doesn't have page scan enabled as well as when the remote doesn't exist. --- emulator/btdev.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/emulator/btdev.c b/emulator/btdev.c index 5f04bd17b..7b40699cd 100644 --- a/emulator/btdev.c +++ b/emulator/btdev.c @@ -833,20 +833,17 @@ static void conn_request(struct btdev *btdev, const uint8_t *bdaddr) { struct btdev *remote = find_btdev_by_bdaddr(bdaddr); - if (remote) { - if (remote->scan_enable & 0x02) { - struct bt_hci_evt_conn_request cr; - - memcpy(cr.bdaddr, btdev->bdaddr, 6); - memcpy(cr.dev_class, btdev->dev_class, 3); - cr.link_type = 0x01; - - send_event(remote, BT_HCI_EVT_CONN_REQUEST, - &cr, sizeof(cr)); - } else - conn_complete(btdev, bdaddr, BT_HCI_ERR_PAGE_TIMEOUT); - } else - conn_complete(btdev, bdaddr, BT_HCI_ERR_UNKNOWN_CONN_ID); + if (remote && remote->scan_enable & 0x02) { + struct bt_hci_evt_conn_request cr; + + memcpy(cr.bdaddr, btdev->bdaddr, 6); + memcpy(cr.dev_class, btdev->dev_class, 3); + cr.link_type = 0x01; + + send_event(remote, BT_HCI_EVT_CONN_REQUEST, &cr, sizeof(cr)); + } else { + conn_complete(btdev, bdaddr, BT_HCI_ERR_PAGE_TIMEOUT); + } } static void disconnect_complete(struct btdev *btdev, uint16_t handle, -- 2.47.3