diff --git a/IntelBluetoothFirmware/BtIntel.cpp b/IntelBluetoothFirmware/BtIntel.cpp index a2cd29f..b5fef3f 100644 --- a/IntelBluetoothFirmware/BtIntel.cpp +++ b/IntelBluetoothFirmware/BtIntel.cpp @@ -65,6 +65,27 @@ intelSendHCISync(HciCommandHdr *cmd, void *event, uint32_t eventBufSize, uint32_ return true; } +bool BtIntel:: +intelSendHCISyncEvent(HciCommandHdr *cmd, void *event, uint32_t eventBufSize, uint32_t *size, uint8_t syncEvent, int timeout) +{ + IOReturn ret; + if ((ret = m_pUSBDeviceController->sendHCIRequest(cmd, timeout)) != kIOReturnSuccess) { + XYLog("%s sendHCIRequest failed: %s %d\n", __FUNCTION__, m_pUSBDeviceController->stringFromReturn(ret), ret); + return false; + } + do { + ret = m_pUSBDeviceController->interruptPipeRead(event, eventBufSize, size, timeout); + if (ret != kIOReturnSuccess) { + XYLog("%s interruptPipeRead failed: %s %d\n", __FUNCTION__, m_pUSBDeviceController->stringFromReturn(ret), ret); + break; + } + if (*(uint8_t *)event == syncEvent) { + return true; + } + } while (true); + return false; +} + bool BtIntel:: intelBulkHCISync(HciCommandHdr *cmd, void *event, uint32_t eventBufSize, uint32_t *size, int timeout) { diff --git a/IntelBluetoothFirmware/BtIntel.h b/IntelBluetoothFirmware/BtIntel.h index 662ffac..d7d8d81 100644 --- a/IntelBluetoothFirmware/BtIntel.h +++ b/IntelBluetoothFirmware/BtIntel.h @@ -192,6 +192,8 @@ class BtIntel : public OSObject { bool intelSendHCISync(HciCommandHdr *cmd, void *event, uint32_t eventBufSize, uint32_t *size, int timeout); + bool intelSendHCISyncEvent(HciCommandHdr *cmd, void *event, uint32_t eventBufSize, uint32_t *size, uint8_t syncEvent, int timeout); + bool intelBulkHCISync(HciCommandHdr *cmd, void *event, uint32_t eventBufSize, uint32_t *size, int timeout); protected: diff --git a/IntelBluetoothFirmware/IntelBluetoothOpsGen1.cpp b/IntelBluetoothFirmware/IntelBluetoothOpsGen1.cpp index f972df3..e7213c3 100644 --- a/IntelBluetoothFirmware/IntelBluetoothOpsGen1.cpp +++ b/IntelBluetoothFirmware/IntelBluetoothOpsGen1.cpp @@ -311,7 +311,7 @@ patching(OSData *fwData, const uint8_t **fw_ptr, bool *disablePatch) hciCmd->len = cmd->len; memcpy(hciCmd->data, cmdParam, hciCmd->len); - if (!intelSendHCISync(hciCmd, resp, sizeof(respBuf), &actRespLen, HCI_INIT_TIMEOUT)) { + if (!intelSendHCISyncEvent(hciCmd, resp, sizeof(respBuf), &actRespLen, evt->evt, HCI_INIT_TIMEOUT)) { XYLog("sending Intel patch command (0x%4.4x) failed\n", hciCmd->opcode); return false; }