Send LE Set Random Address and check response 67/199967/1
authorSeungyoun Ju <sy39.ju@samsung.com>
Thu, 25 Oct 2018 09:11:59 +0000 (18:11 +0900)
committerSeungyoun Ju <sy39.ju@samsung.com>
Mon, 18 Feb 2019 03:08:18 +0000 (12:08 +0900)
[Problem] HCI command Tx timeout happens.
[Cause & Measure] Vendor command is sent before Command complete event comes
 for LE Set Random Address. It causes bluetooth chip's malfunction.
 This commit fixs to check the response about LE Set Random Address. So
 that next vendor command is sent after LE Set Random Address is
 processed properly by chipset.
[Checking Method] Turn on Bluetooth > Start advertising

Change-Id: Ie757398be6d8ad71da1cc23b72ac132789df9e49

src/adapter_le_vsc_features.c

index fed654a..b9cec92 100755 (executable)
@@ -14,7 +14,10 @@ static apater_le_vsc_rp_get_vendor_cap ble_vsc_cb = { -1, };
 static int update_le_address(const bdaddr_t *le_addr)
 {
        int hdev = 0;
+       struct hci_request req;
        le_set_random_address_cp cp;
+       uint8_t status = 0;
+       int ret;
 
        hdev = hci_open_dev(0);
        if (hdev < 0) {
@@ -24,9 +27,17 @@ static int update_le_address(const bdaddr_t *le_addr)
 
        bacpy(&cp.bdaddr, le_addr);
 
-       if (hci_send_cmd(hdev, OGF_LE_CTL, OCF_LE_SET_RANDOM_ADDRESS,
-                               LE_SET_RANDOM_ADDRESS_CP_SIZE, &cp) < 0) {
-               error("hci_send_cmd is failed");
+       memset(&req, 0x00, sizeof(req));
+       req.ogf = OGF_LE_CTL;
+       req.ocf = OCF_LE_SET_RANDOM_ADDRESS;
+       req.cparam = &cp;
+       req.clen = LE_SET_RANDOM_ADDRESS_CP_SIZE;
+       req.rparam = &status;
+       req.rlen = sizeof(status);
+
+       ret = hci_send_req(hdev, &req, 5000);
+       if (ret < 0 || status) {
+               error("Cannot set random address [ret : %d] / errno : %d", ret, errno);
                hci_close_dev(hdev);
                return -1;
        }