diff --git a/Source/Core/Core/Core.vcproj b/Source/Core/Core/Core.vcproj index 164cac1ec5..194ed12876 100644 --- a/Source/Core/Core/Core.vcproj +++ b/Source/Core/Core/Core.vcproj @@ -1206,14 +1206,6 @@ - - - - @@ -1226,22 +1218,10 @@ RelativePath=".\Src\IPC_HLE\WII_IPC_HLE_Device.h" > - - - - - - @@ -1255,8 +1235,24 @@ + + + + + + + + @@ -1298,18 +1294,6 @@ > - - - - - - @@ -1337,6 +1321,14 @@ + + + + diff --git a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_usb.cpp b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_usb.cpp index dcc7980f83..3e52772f49 100644 --- a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_usb.cpp +++ b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_usb.cpp @@ -15,10 +15,7 @@ // Official SVN repository and contact information can be found at // http://code.google.com/p/dolphin-emu/ - - -// Include -#include "../Core.h" // Local core functions +#include "../Core.h" #include "../Debugger/Debugger_SymbolMap.h" #include "../Host.h" #include "../PluginManager.h" @@ -29,21 +26,11 @@ // The device class CWII_IPC_HLE_Device_usb_oh1_57e_305::CWII_IPC_HLE_Device_usb_oh1_57e_305(u32 _DeviceID, const std::string& _rDeviceName) : IWII_IPC_HLE_Device(_DeviceID, _rDeviceName) - , m_PINType(0) , m_ScanEnable(0) - , m_EventFilterType(0) - , m_EventFilterCondition(0) - , m_HostMaxACLSize(0) - , m_HostMaxSCOSize(0) - , m_HostNumACLPackets(0) - , m_HostNumSCOPackets(0) - , m_HCIBuffer(0) - , m_HCIPool(0) - , m_ACLBuffer(0) - , m_ACLPool(0) - , m_LastCmd(0) - , m_FreqDividerMote(0) - , m_FreqDividerSync(0) + , m_HCIEndpoint(0) + , m_ACLEndpoint(0) + , m_WiimoteUpdate_Freq(0) + , m_NumCompPackets_Freq(0) { // Activate only first Wiimote by default m_WiiMotes.push_back(CWII_IPC_HLE_WiiMote(this, 0, true)); @@ -59,12 +46,6 @@ CWII_IPC_HLE_Device_usb_oh1_57e_305::CWII_IPC_HLE_Device_usb_oh1_57e_305(u32 _De m_ControllerBD.b[4] = 0x00; m_ControllerBD.b[5] = 0xFF; - // Class and name are written via HCI - m_ClassOfDevice[0] = 0x00; - m_ClassOfDevice[1] = 0x00; - m_ClassOfDevice[2] = 0x00; - - memset(m_LocalName, 0, HCI_UNIT_NAME_SIZE); memset(m_PacketCount, 0, sizeof(m_PacketCount)); Host_SetWiiMoteConnectionState(0); @@ -77,15 +58,12 @@ CWII_IPC_HLE_Device_usb_oh1_57e_305::~CWII_IPC_HLE_Device_usb_oh1_57e_305() void CWII_IPC_HLE_Device_usb_oh1_57e_305::DoState(PointerWrap &p) { - p.Do(m_LastCmd); p.Do(m_CtrlSetup); p.Do(m_ACLSetup); - p.Do(m_HCIBuffer); - p.Do(m_HCIPool); - p.Do(m_ACLBuffer); - p.Do(m_ACLPool); - p.Do(m_FreqDividerSync); - p.Do(m_FreqDividerMote); + p.Do(m_HCIEndpoint); + p.Do(m_ACLEndpoint); + p.Do(m_NumCompPackets_Freq); + p.Do(m_WiimoteUpdate_Freq); for (int i = 0; i < 4; i++) { @@ -101,56 +79,32 @@ bool CWII_IPC_HLE_Device_usb_oh1_57e_305::RemoteDisconnect(u16 _connectionHandle return SendEventDisconnect(_connectionHandle, 0x13); } -// =================================================== -// Open bool CWII_IPC_HLE_Device_usb_oh1_57e_305::Open(u32 _CommandAddress, u32 _Mode) { - m_PINType = 0; m_ScanEnable = 0; - m_EventFilterType = 0; - m_EventFilterCondition = 0; - m_HostMaxACLSize = 0; - m_HostMaxSCOSize = 0; - m_HostNumACLPackets = 0; - m_HostNumSCOPackets = 0; - m_LastCmd = 0; - m_FreqDividerSync = 0; - m_FreqDividerMote = 0; + m_NumCompPackets_Freq = 0; + m_WiimoteUpdate_Freq = 0; memset(m_PacketCount, 0, sizeof(m_PacketCount)); - m_HCIBuffer.m_address = 0; - m_HCIPool.m_number = 0; - m_ACLBuffer.m_address = 0; - m_ACLPool.m_number = 0; + m_HCIEndpoint.m_address = 0; + m_ACLEndpoint.m_address = 0; - Memory::Write_U32(GetDeviceID(), _CommandAddress+4); + Memory::Write_U32(GetDeviceID(), _CommandAddress + 4); m_Active = true; return true; } -// =================================================== -// Close bool CWII_IPC_HLE_Device_usb_oh1_57e_305::Close(u32 _CommandAddress, bool _bForce) { - m_PINType = 0; m_ScanEnable = 0; - m_EventFilterType = 0; - m_EventFilterCondition = 0; - m_HostMaxACLSize = 0; - m_HostMaxSCOSize = 0; - m_HostNumACLPackets = 0; - m_HostNumSCOPackets = 0; - m_LastCmd = 0; - m_FreqDividerSync = 0; - m_FreqDividerMote = 0; + m_NumCompPackets_Freq = 0; + m_WiimoteUpdate_Freq = 0; memset(m_PacketCount, 0, sizeof(m_PacketCount)); - m_HCIBuffer.m_address = 0; - m_HCIPool.m_number = 0; - m_ACLBuffer.m_address = 0; - m_ACLPool.m_number = 0; + m_HCIEndpoint.m_address = 0; + m_ACLEndpoint.m_address = 0; if (!_bForce) Memory::Write_U32(0, _CommandAddress + 4); @@ -158,17 +112,12 @@ bool CWII_IPC_HLE_Device_usb_oh1_57e_305::Close(u32 _CommandAddress, bool _bForc return true; } - -// =================================================== -// IOCtl bool CWII_IPC_HLE_Device_usb_oh1_57e_305::IOCtl(u32 _CommandAddress) { + ERROR_LOG(WII_IPC_WIIMOTE, "passing ioctl to ioctlv"); return IOCtlV(_CommandAddress); //hack } - -// =================================================== -// IOCtlV bool CWII_IPC_HLE_Device_usb_oh1_57e_305::IOCtlV(u32 _CommandAddress) { /* @@ -188,24 +137,25 @@ bool CWII_IPC_HLE_Device_usb_oh1_57e_305::IOCtlV(u32 _CommandAddress) SIOCtlVBuffer CommandBuffer(_CommandAddress); - switch(CommandBuffer.Parameter) + switch (CommandBuffer.Parameter) { - case USB_IOCTL_HCI_COMMAND_MESSAGE: + case USBV0_IOCTL_CTRLMSG: // HCI command is received from the stack { // This is the HCI datapath from CPU to Wiimote, the USB stuff is little endian.. - m_CtrlSetup.bRequestType = *(u8*)Memory::GetPointer(CommandBuffer.InBuffer[0].m_Address); - m_CtrlSetup.bRequest = *(u8*)Memory::GetPointer(CommandBuffer.InBuffer[1].m_Address); - m_CtrlSetup.wValue = *(u16*)Memory::GetPointer(CommandBuffer.InBuffer[2].m_Address); - m_CtrlSetup.wIndex = *(u16*)Memory::GetPointer(CommandBuffer.InBuffer[3].m_Address); - m_CtrlSetup.wLength = *(u16*)Memory::GetPointer(CommandBuffer.InBuffer[4].m_Address); - m_CtrlSetup.m_PayLoadAddr = CommandBuffer.PayloadBuffer[0].m_Address; - m_CtrlSetup.m_PayLoadSize = CommandBuffer.PayloadBuffer[0].m_Size; - m_CtrlSetup.m_Address = CommandBuffer.m_Address; + m_CtrlSetup.bRequestType = *( u8*)Memory::GetPointer(CommandBuffer.InBuffer[0].m_Address); + m_CtrlSetup.bRequest = *( u8*)Memory::GetPointer(CommandBuffer.InBuffer[1].m_Address); + m_CtrlSetup.wValue = *(u16*)Memory::GetPointer(CommandBuffer.InBuffer[2].m_Address); + m_CtrlSetup.wIndex = *(u16*)Memory::GetPointer(CommandBuffer.InBuffer[3].m_Address); + m_CtrlSetup.wLength = *(u16*)Memory::GetPointer(CommandBuffer.InBuffer[4].m_Address); + m_CtrlSetup.m_PayLoadAddr = CommandBuffer.PayloadBuffer[0].m_Address; + m_CtrlSetup.m_PayLoadSize = CommandBuffer.PayloadBuffer[0].m_Size; + m_CtrlSetup.m_Address = CommandBuffer.m_Address; // check termination _dbg_assert_msg_(WII_IPC_WIIMOTE, *(u8*)Memory::GetPointer(CommandBuffer.InBuffer[5].m_Address) == 0, - "WIIMOTE: Termination != 0"); - #if defined(_DEBUG) || defined(DEBUGFAST) + "WIIMOTE: Termination != 0"); + + #if 0 // this log can get really annoying DEBUG_LOG(WII_IPC_WIIMOTE, "USB_IOCTL_CTRLMSG (0x%08x) - execute command", _CommandAddress); DEBUG_LOG(WII_IPC_WIIMOTE, " bRequestType: 0x%x", m_CtrlSetup.bRequestType); DEBUG_LOG(WII_IPC_WIIMOTE, " bRequest: 0x%x", m_CtrlSetup.bRequest); @@ -216,17 +166,17 @@ bool CWII_IPC_HLE_Device_usb_oh1_57e_305::IOCtlV(u32 _CommandAddress) DEBUG_LOG(WII_IPC_WIIMOTE, " m_PayLoadSize: 0x%x", m_CtrlSetup.m_PayLoadSize); #endif - ExecuteHCICommandMessage(m_CtrlSetup); // Replies are generated inside + ExecuteHCICommandMessage(m_CtrlSetup); } break; - case USB_IOCTL_BLKMSG: + case USBV0_IOCTL_BLKMSG: { u8 Command = Memory::Read_U8(CommandBuffer.InBuffer[0].m_Address); switch (Command) { - case ACL_DATA_BLK_OUT: + case ACL_DATA_OUT: // ACL data is received from the stack { // This is the ACL datapath from CPU to Wiimote // Here we only need to record the command address in case we need to delay the reply @@ -237,34 +187,31 @@ bool CWII_IPC_HLE_Device_usb_oh1_57e_305::IOCtlV(u32 _CommandAddress) #endif CtrlBuffer BulkBuffer(_CommandAddress); - UACLHeader* pACLHeader = (UACLHeader*)Memory::GetPointer(BulkBuffer.m_buffer); + hci_acldata_hdr_t* pACLHeader = (hci_acldata_hdr_t*)Memory::GetPointer(BulkBuffer.m_buffer); - _dbg_assert_(WII_IPC_WIIMOTE, pACLHeader->BCFlag == 0); - _dbg_assert_(WII_IPC_WIIMOTE, pACLHeader->PBFlag == 2); + _dbg_assert_(WII_IPC_WIIMOTE, HCI_BC_FLAG(pACLHeader->con_handle) == HCI_POINT2POINT); + _dbg_assert_(WII_IPC_WIIMOTE, HCI_PB_FLAG(pACLHeader->con_handle) == HCI_PACKET_START); - SendToDevice(pACLHeader->ConnectionHandle, Memory::GetPointer(BulkBuffer.m_buffer + 4), pACLHeader->Size); - m_PacketCount[pACLHeader->ConnectionHandle & 0xFF]++; + SendToDevice(HCI_CON_HANDLE(pACLHeader->con_handle), + Memory::GetPointer(BulkBuffer.m_buffer + sizeof(hci_acldata_hdr_t)), + pACLHeader->length); - // If ACLPool is not used, we can send a reply immediately - // or else we have to delay this reply - if (m_ACLPool.m_number == 0) - _SendReply = true; + _SendReply = true; } break; - case ACL_DATA_ENDPOINT: + case ACL_DATA_IN: // We are given an ACL buffer to fill { - CtrlBuffer _TempCtrlBuffer(_CommandAddress); - m_ACLBuffer = _TempCtrlBuffer; - // Reply should not be sent here but when this buffer is filled + CtrlBuffer temp(_CommandAddress); + m_ACLEndpoint = temp; - INFO_LOG(WII_IPC_WIIMOTE, "ACL_DATA_ENDPOINT: 0x%08x ", _CommandAddress); + DEBUG_LOG(WII_IPC_WIIMOTE, "ACL_DATA_IN: 0x%08x ", _CommandAddress); } break; default: { - _dbg_assert_msg_(WII_IPC_WIIMOTE, 0, "Unknown USB_IOCTL_BLKMSG: %x", Command); + _dbg_assert_msg_(WII_IPC_WIIMOTE, 0, "Unknown USBV0_IOCTL_BLKMSG: %x", Command); } break; } @@ -272,26 +219,19 @@ bool CWII_IPC_HLE_Device_usb_oh1_57e_305::IOCtlV(u32 _CommandAddress) break; - case USB_IOCTL_INTRMSG: + case USBV0_IOCTL_INTRMSG: { u8 Command = Memory::Read_U8(CommandBuffer.InBuffer[0].m_Address); - switch (Command) + if (Command == HCI_EVENT) // We are given a HCI buffer to fill { - case HCI_EVENT_ENDPOINT: - { - CtrlBuffer _TempCtrlBuffer(_CommandAddress); - m_HCIBuffer = _TempCtrlBuffer; - // Reply should not be sent here but when this buffer is filled + CtrlBuffer temp(_CommandAddress); + m_HCIEndpoint = temp; - INFO_LOG(WII_IPC_WIIMOTE, "HCI_EVENT_ENDPOINT: 0x%08x ", _CommandAddress); - } - break; - - default: - { - _dbg_assert_msg_(WII_IPC_WIIMOTE, 0, "Unknown USB_IOCTL_INTRMSG: %x", Command); - } - break; + DEBUG_LOG(WII_IPC_WIIMOTE, "HCI_EVENT: 0x%08x ", _CommandAddress); + } + else + { + _dbg_assert_msg_(WII_IPC_WIIMOTE, 0, "Unknown USBV0_IOCTL_INTRMSG: %x", Command); } } break; @@ -315,24 +255,23 @@ bool CWII_IPC_HLE_Device_usb_oh1_57e_305::IOCtlV(u32 _CommandAddress) } // write return value - Memory::Write_U32(0, _CommandAddress + 0x4); + Memory::Write_U32(0, _CommandAddress + 4); return _SendReply; } -// Here we handle the USB_IOCTL_BLKMSG Ioctlv +// Here we handle the USBV0_IOCTL_BLKMSG Ioctlv void CWII_IPC_HLE_Device_usb_oh1_57e_305::SendToDevice(u16 _ConnectionHandle, u8* _pData, u32 _Size) { CWII_IPC_HLE_WiiMote* pWiiMote = AccessWiiMote(_ConnectionHandle); if (pWiiMote == NULL) return; - INFO_LOG(WII_IPC_WIIMOTE, "++++++++++++++++++++++++++++++++++++++"); - INFO_LOG(WII_IPC_WIIMOTE, "Execute ACL Command: ConnectionHandle 0x%04x", _ConnectionHandle); + INFO_LOG(WII_IPC_WIIMOTE, "Send ACL Packet to ConnectionHandle 0x%04x", _ConnectionHandle); pWiiMote->ExecuteL2capCmd(_pData, _Size); } -// Here we send ACL pakcets to CPU. They will consist of header + data. +// Here we send ACL packets to CPU. They will consist of header + data. // The header is for example 07 00 41 00 which means size 0x0007 and channel 0x0041. // --------------------------------------------------- // AyuanX: Basically, our WII_IPC_HLE is efficient enough to send the packet immediately @@ -340,193 +279,33 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305::SendToDevice(u16 _ConnectionHandle, u8 // But...the only exception comes from the Wiimote_Plugin void CWII_IPC_HLE_Device_usb_oh1_57e_305::SendACLPacket(u16 _ConnectionHandle, u8* _pData, u32 _Size) { - if(m_ACLBuffer.m_address != 0) - { - INFO_LOG(WII_IPC_WIIMOTE, "Sending ACL Packet: 0x%08x .... (ConnectionHandle 0x%04x)", m_ACLBuffer.m_address, _ConnectionHandle); + DEBUG_LOG(WII_IPC_WIIMOTE, "ACL packet from %x ready to send to stack...", _ConnectionHandle); - UACLHeader* pHeader = (UACLHeader*)Memory::GetPointer(m_ACLBuffer.m_buffer); - pHeader->ConnectionHandle = _ConnectionHandle; - pHeader->BCFlag = 0; - pHeader->PBFlag = 2; - pHeader->Size = _Size; + m_PacketCount[_ConnectionHandle & 0xff]++; + + if (m_ACLEndpoint.IsValid() && !m_HCIEndpoint.IsValid() && m_EventQueue.empty()) + { + DEBUG_LOG(WII_IPC_WIIMOTE, "ACL endpoint valid, sending packet to %08x", m_ACLEndpoint.m_address); + + hci_acldata_hdr_t* pHeader = (hci_acldata_hdr_t*)Memory::GetPointer(m_ACLEndpoint.m_buffer); + pHeader->con_handle = HCI_MK_CON_HANDLE(_ConnectionHandle, HCI_PACKET_START, HCI_POINT2POINT); + pHeader->length = _Size; // Write the packet to the buffer - memcpy((u8*)pHeader + sizeof(UACLHeader), _pData, _Size); + memcpy((u8*)pHeader + sizeof(hci_acldata_hdr_t), _pData, pHeader->length); + //m_ACLEndpoint.FillBuffer(_pData, _Size); - // Write the packet size as return value - Memory::Write_U32(sizeof(UACLHeader) + _Size, m_ACLBuffer.m_address + 0x4); - - // Send a reply to indicate ACL buffer is sent - WII_IPC_HLE_Interface::EnqReply(m_ACLBuffer.m_address); - - // Invalidate ACL buffer - m_ACLBuffer.m_address = 0; - m_ACLBuffer.m_buffer = 0; - } - else if ((sizeof(UACLHeader) + _Size) > ACL_MAX_SIZE ) - { - ERROR_LOG(WII_IPC_HLE, "ACL Packet size is too big!"); - PanicAlert("WII_IPC_HLE: ACL Packet size is too big!"); - } - else if (m_ACLPool.m_number >= 16) - { - ERROR_LOG(WII_IPC_HLE, "ACL Pool is full, something must be wrong!"); - PanicAlert("WII_IPC_HLE: ACL Pool is full, something must be wrong!"); + m_ACLEndpoint.SetRetVal(sizeof(hci_acldata_hdr_t) + _Size); + WII_IPC_HLE_Interface::EnqReply(m_ACLEndpoint.m_address); + m_ACLEndpoint.Invalidate(); } else { - UACLHeader* pHeader = (UACLHeader*)(m_ACLPool.m_data + m_ACLPool.m_number * ACL_MAX_SIZE); - pHeader->ConnectionHandle = _ConnectionHandle; - pHeader->BCFlag = 0; - pHeader->PBFlag = 2; - pHeader->Size = _Size; - - memcpy((u8*)pHeader + sizeof(UACLHeader), _pData, _Size); - m_ACLPool.m_number++; + DEBUG_LOG(WII_IPC_WIIMOTE, "ACL endpoint not currently valid, queueing(%i)...", m_ACLQ.size()); + m_ACLQ.push(ACLQ(_pData, _Size, _ConnectionHandle)); } } -// The normal hardware behavior is like this: -// e.g. if you have 3 packets to send you have to send them one by one in 3 cycles -// and this is the mechanism how our IPC works -// but current implementation of WiiMote_Plugin doesn't comply with this rule -// It acts like sending all the 3 packets in one cycle and idling around in the other two cycles -// that's why we need this contingent ACL pool -void CWII_IPC_HLE_Device_usb_oh1_57e_305::PurgeACLPool() -{ - if(m_ACLBuffer.m_address == 0) - return; - - INFO_LOG(WII_IPC_WIIMOTE, "Purging ACL Pool: 0x%08x ....", m_ACLBuffer.m_address); - - if(m_ACLPool.m_number > 0) - { - m_ACLPool.m_number--; - // Fill the buffer - u8* _Address = m_ACLPool.m_data + m_ACLPool.m_number * ACL_MAX_SIZE; - memcpy(Memory::GetPointer(m_ACLBuffer.m_buffer), _Address, ACL_MAX_SIZE); - // Write the packet size as return value - Memory::Write_U32(sizeof(UACLHeader) + ((UACLHeader*)_Address)->Size, m_ACLBuffer.m_address + 0x4); - // Send a reply to indicate ACL buffer is sent - WII_IPC_HLE_Interface::EnqReply(m_ACLBuffer.m_address); - // Invalidate ACL buffer - m_ACLBuffer.m_address = 0; - m_ACLBuffer.m_buffer = 0; - } -} - -// See IPC_HLE_PERIOD in SystemTimers.cpp for a documentation of this update. -u32 CWII_IPC_HLE_Device_usb_oh1_57e_305::Update() -{ - // Check if HCI Pool is not purged - if (m_HCIPool.m_number > 0) - { - PurgeHCIPool(); - if (m_HCIPool.m_number == 0) - WII_IPC_HLE_Interface::EnqReply(m_CtrlSetup.m_Address); - return true; - } - - // Check if last command needs more work - if (m_HCIBuffer.m_address && m_LastCmd) - { - ExecuteHCICommandMessage(m_CtrlSetup); - return true; - } - - // Check if ACL Pool is not purged - if (m_ACLPool.m_number > 0) - { - PurgeACLPool(); - if (m_ACLPool.m_number == 0) - WII_IPC_HLE_Interface::EnqReply(m_ACLSetup); - return true; - } - - /* We wait for ScanEnable to be sent from the game through HCI_CMD_WRITE_SCAN_ENABLE - before we initiate the connection. - - FiRES: TODO find a good solution to do this - - Why do we need this? 0 worked with the emulated wiimote in all games I tried. Do we have to - wait for wiiuse_init() and wiiuse_find() for a real Wiimote here? I'm testing - this new method of not waiting at all if there are no real Wiimotes. Please let me know - if it doesn't work. */ - - // AyuanX: I don't know the Real Wiimote behavior, so I'll leave it here untouched - - // Initiate ACL connection - static int counter = (Core::GetRealWiimote() ? 1000 : 0); - if (m_HCIBuffer.m_address && (m_ScanEnable & 0x2)) - { - counter--; - if (counter < 0) - { - for (unsigned int i = 0; i < m_WiiMotes.size(); i++) - if (m_WiiMotes[i].EventPagingChanged(m_ScanEnable)) - { - Host_SetWiiMoteConnectionState(1); - // Create ACL connection - SendEventRequestConnection(m_WiiMotes[i]); - return true; - } - } - } - - // Link channels when connected - if (m_ACLBuffer.m_address && !m_LastCmd) - { - for (size_t i = 0; i < m_WiiMotes.size(); i++) - { - if (m_WiiMotes[i].LinkChannel()) - return true; - } - } - - // The Real Wiimote sends report at a fixed frequency of 100Hz - // So let's make it also 100Hz here - // Calculation: 15000Hz (IPC_HLE) / 100Hz (WiiMote) = 150 - if (m_ACLBuffer.m_address && !m_LastCmd) - { - if (++m_FreqDividerMote > 150) - m_FreqDividerMote = 0; - for (unsigned int i = 0; i < m_WiiMotes.size(); i++) - { - if (m_WiiMotes[i].IsConnected() == 3 && m_FreqDividerMote == 150 / (i + 1)) - { -#if defined(HAVE_WX) && HAVE_WX - NetPlay_WiimoteUpdate(i); -#endif - CPluginManager::GetInstance().GetWiimote()->Wiimote_Update(i); - return true; - } - } - } - - // This event should be sent periodically after ACL connection is accepted - // or CPU will disconnect WiiMote automatically - // but don't send too many or it will jam the bus and cost extra CPU time - // TODO: Figure out the correct frequency to send this thing - if (m_HCIBuffer.m_address) - { - if (++m_FreqDividerSync > 500) - m_FreqDividerSync = 0; - for (unsigned int i = 0; i < m_WiiMotes.size(); i++) - { - if (m_WiiMotes[i].IsConnected() == 3 && m_FreqDividerSync == 500 / (i + 1)) - { - SendEventNumberOfCompletedPackets(m_WiiMotes[i].GetConnectionHandle(), m_PacketCount[i]); - m_PacketCount[i] = 0; - return true; - } - } - } - - return false; -} - -// Events -// ----------------- // These messages are sent from the Wiimote to the game, for example RequestConnection() // or ConnectionComplete(). // @@ -534,67 +313,159 @@ u32 CWII_IPC_HLE_Device_usb_oh1_57e_305::Update() // rather than enqueue it to some other memory and this will do good for StateSave void CWII_IPC_HLE_Device_usb_oh1_57e_305::AddEventToQueue(const SQueuedEvent& _event) { - if (m_HCIBuffer.m_address != 0) + DEBUG_LOG(WII_IPC_WIIMOTE, "HCI event %x completed...", ((hci_event_hdr_t*)_event.m_buffer)->event); + + if (_event.m_connectionHandle) + m_PacketCount[_event.m_connectionHandle & 0xff]++; + + if (m_HCIEndpoint.IsValid()) { - INFO_LOG(WII_IPC_WIIMOTE, "Sending HCI Packet to Address: 0x%08x ....", m_HCIBuffer.m_address); - - memcpy(Memory::GetPointer(m_HCIBuffer.m_buffer), _event.m_buffer, _event.m_size); - - // Calculate buffer size - Memory::Write_U32((u32)_event.m_size, m_HCIBuffer.m_address + 0x4); - - // Send a reply to indicate HCI buffer is filled - WII_IPC_HLE_Interface::EnqReply(m_HCIBuffer.m_address); - - // Invalidate HCI buffer - m_HCIBuffer.m_address = 0; - m_HCIBuffer.m_buffer = 0; - } - else if (_event.m_size > HCI_MAX_SIZE) - { - ERROR_LOG(WII_IPC_HLE, "HCI Packet size too big!"); - PanicAlert("WII_IPC_HLE: HCI Packet size too big!"); - } - else if (m_HCIPool.m_number >= 16) - { - ERROR_LOG(WII_IPC_HLE, "HCI Pool is full, something must be wrong!"); - PanicAlert("WII_IPC_HLE: HCI Pool is full, something must be wrong!"); + if (m_EventQueue.empty()) // fast path :) + { + DEBUG_LOG(WII_IPC_WIIMOTE, "HCI endpoint valid, sending packet to %08x", m_HCIEndpoint.m_address); + m_HCIEndpoint.FillBuffer(_event.m_buffer, _event.m_size); + m_HCIEndpoint.SetRetVal(_event.m_size); + // Send a reply to indicate HCI buffer is filled + WII_IPC_HLE_Interface::EnqReply(m_HCIEndpoint.m_address); + m_HCIEndpoint.Invalidate(); + } + else // push new one, pop oldest + { + DEBUG_LOG(WII_IPC_WIIMOTE, "HCI endpoint not currently valid, queueing(%i)...", m_EventQueue.size()); + m_EventQueue.push(_event); + const SQueuedEvent& event = m_EventQueue.front(); + DEBUG_LOG(WII_IPC_WIIMOTE, "HCI event %x being written from queue(%i) to %08x...", + ((hci_event_hdr_t*)event.m_buffer)->event, m_EventQueue.size()-1, m_HCIEndpoint.m_address); + m_HCIEndpoint.FillBuffer(event.m_buffer, event.m_size); + m_HCIEndpoint.SetRetVal(event.m_size); + // Send a reply to indicate HCI buffer is filled + WII_IPC_HLE_Interface::EnqReply(m_HCIEndpoint.m_address); + m_HCIEndpoint.Invalidate(); + m_EventQueue.pop(); + } } else { - memcpy(m_HCIPool.m_data + m_HCIPool.m_number * HCI_MAX_SIZE, _event.m_buffer, _event.m_size); - // HCI Packet doesn't contain size info inside, so we have to store it somewhere - m_HCIPool.m_size[m_HCIPool.m_number] = _event.m_size; - m_HCIPool.m_number++; + DEBUG_LOG(WII_IPC_WIIMOTE, "HCI endpoint not currently valid, queueing(%i)...", m_EventQueue.size()); + m_EventQueue.push(_event); } } -// Generally, CPU should send us a valid HCI buffer before issuing any HCI command -// but since we don't know the exact frequency at which IPC should be running -// so when IPC is running too fast that CPU can't catch up -// then CPU(actually it is the usb driver) sometimes throws out a command before sending us a HCI buffer -// So I put this contingent HCI Pool here until we figure out the true reason -void CWII_IPC_HLE_Device_usb_oh1_57e_305::PurgeHCIPool() +u32 CWII_IPC_HLE_Device_usb_oh1_57e_305::Update() { - if(m_HCIBuffer.m_address == 0) - return; + // check hci queue + if (!m_EventQueue.empty() && m_HCIEndpoint.IsValid()) + { + // an endpoint has become available, and we have a stored response. + const SQueuedEvent& event = m_EventQueue.front(); + DEBUG_LOG(WII_IPC_WIIMOTE, "HCI event %x being written from queue(%i) to %08x...", + ((hci_event_hdr_t*)event.m_buffer)->event, m_EventQueue.size()-1, m_HCIEndpoint.m_address); + m_HCIEndpoint.FillBuffer(event.m_buffer, event.m_size); + m_HCIEndpoint.SetRetVal(event.m_size); + // Send a reply to indicate HCI buffer is filled + WII_IPC_HLE_Interface::EnqReply(m_HCIEndpoint.m_address); + m_HCIEndpoint.Invalidate(); + m_EventQueue.pop(); + return true; + } - INFO_LOG(WII_IPC_WIIMOTE, "Purging HCI Pool: 0x%08x ....", m_HCIBuffer.m_address); + // check acl queue + // We give priority to HCI events, so ACL data won't be sent to host if HCI event queue contains events. + if (!m_ACLQ.empty() && m_ACLEndpoint.IsValid() && m_EventQueue.empty()) + { + const ACLQ& acl_data = m_ACLQ.front(); + DEBUG_LOG(WII_IPC_WIIMOTE, "ACL packet being written from queue(%i) to %08x", + m_ACLQ.size()-1, m_ACLEndpoint.m_address); - if(m_HCIPool.m_number > 0) + hci_acldata_hdr_t* pHeader = (hci_acldata_hdr_t*)Memory::GetPointer(m_ACLEndpoint.m_buffer); + pHeader->con_handle = HCI_MK_CON_HANDLE(acl_data.m_conn_handle, HCI_PACKET_START, HCI_POINT2POINT); + pHeader->length = acl_data.m_size; + + // Write the packet to the buffer + memcpy((u8*)pHeader + sizeof(hci_acldata_hdr_t), acl_data.m_buffer, pHeader->length); + + m_ACLEndpoint.SetRetVal(sizeof(hci_acldata_hdr_t) + acl_data.m_size); + WII_IPC_HLE_Interface::EnqReply(m_ACLEndpoint.m_address); + m_ACLEndpoint.Invalidate(); + m_ACLQ.pop(); + return true; + } + + // We wait for ScanEnable to be sent from the bt stack through HCI_CMD_WRITE_SCAN_ENABLE + // before we initiate the connection. + // + // FiRES: TODO find a better way to do this + + // Supposedly this delay is needed for real wiimotes + // TODO try removing this hack, or handling real wiimotes better + static int counter = Core::GetRealWiimote() ? 1000 : 0; + // Create ACL connection + if (m_HCIEndpoint.IsValid() && (m_ScanEnable & HCI_PAGE_SCAN_ENABLE)) + { + if (--counter < 0) { - m_HCIPool.m_number--; - // Fill the buffer - u8* _Address = m_HCIPool.m_data + m_HCIPool.m_number * 64; - memcpy(Memory::GetPointer(m_HCIBuffer.m_buffer), _Address, 64); - // Write the packet size as return value - Memory::Write_U32(m_HCIPool.m_size[m_HCIPool.m_number], m_HCIBuffer.m_address + 0x4); - // Send a reply to indicate ACL buffer is sent - WII_IPC_HLE_Interface::EnqReply(m_HCIBuffer.m_address); - // Invalidate ACL buffer - m_HCIBuffer.m_address = 0; - m_HCIBuffer.m_buffer = 0; + for (unsigned int i = 0; i < m_WiiMotes.size(); i++) + { + if (m_WiiMotes[i].EventPagingChanged(m_ScanEnable)) + { + Host_SetWiiMoteConnectionState(1); + SendEventRequestConnection(m_WiiMotes[i]); + //return true; + } + } } + } + + // Link channels when connected + if (m_ACLEndpoint.IsValid()) + { + for (unsigned int i = 0; i < m_WiiMotes.size(); i++) + { + if (m_WiiMotes[i].LinkChannel()) + break; + } + } + + // The Real Wiimote sends report at a fixed frequency of 100Hz + // So let's make it also 100Hz here + // Calculation: 15000Hz (IPC_HLE) / 100Hz (WiiMote) = 150 + if (m_ACLEndpoint.IsValid()) + { + if (++m_WiimoteUpdate_Freq > 150) + m_WiimoteUpdate_Freq = 0; + for (unsigned int i = 0; i < m_WiiMotes.size(); i++) + { + if (m_WiiMotes[i].IsConnected() && m_WiimoteUpdate_Freq == 150 / (i + 1)) + { + #if defined(HAVE_WX) && HAVE_WX + NetPlay_WiimoteUpdate(i); + #endif + CPluginManager::GetInstance().GetWiimote()->Wiimote_Update(i); + //return true; + } + } + } + + ////////////////////////////////////////////////////////////////////////// + // This event should be sent periodically after ACL connection is accepted + // or CPU will disconnect WiiMote automatically + // but don't send too many or it will jam the bus and cost extra CPU time + ////////////////////////////////////////////////////////////////////////// + // "When the Host has completed one or more HCI Data Packet(s) it shall send a + // Host_Number_Of_Completed_Packets command to the Controller, until it + // finally reports that all pending HCI Data Packets have been completed. The + // frequency at which this command is sent is manufacturer specific." + // -- Figuring out the "correct" rate could be annoying, so our guess will suffice :p + if (m_HCIEndpoint.IsValid()) + { + if (++m_NumCompPackets_Freq > 500) + { + m_NumCompPackets_Freq = 0; + SendEventNumberOfCompletedPackets(); + } + } + + return false; } bool CWII_IPC_HLE_Device_usb_oh1_57e_305::SendEventInquiryComplete() @@ -658,7 +529,7 @@ bool CWII_IPC_HLE_Device_usb_oh1_57e_305::SendEventInquiryResponse() } bool CWII_IPC_HLE_Device_usb_oh1_57e_305::SendEventConnectionComplete(const bdaddr_t& _bd) -{ +{ CWII_IPC_HLE_WiiMote* pWiiMote = AccessWiiMote(_bd); if (pWiiMote == NULL) return false; @@ -677,6 +548,10 @@ bool CWII_IPC_HLE_Device_usb_oh1_57e_305::SendEventConnectionComplete(const bdad AddEventToQueue(Event); + CWII_IPC_HLE_WiiMote* pWiimote = AccessWiiMote(pConnectionComplete->Connection_Handle); + if (pWiimote) + pWiimote->EventConnectionAccepted(); + static char s_szLinkType[][128] = { { "HCI_LINK_SCO 0x00 - Voice"}, @@ -698,6 +573,9 @@ bool CWII_IPC_HLE_Device_usb_oh1_57e_305::SendEventConnectionComplete(const bdad // This is called from Update() after ScanEnable has been enabled. bool CWII_IPC_HLE_Device_usb_oh1_57e_305::SendEventRequestConnection(CWII_IPC_HLE_WiiMote& _rWiiMote) { + // We have to disable scan now to avoid running this function over and over again + m_ScanEnable = 0; + SQueuedEvent Event(sizeof(SHCIEventRequestConnection), 0); SHCIEventRequestConnection* pEventRequestConnection = (SHCIEventRequestConnection*)Event.m_buffer; @@ -710,17 +588,15 @@ bool CWII_IPC_HLE_Device_usb_oh1_57e_305::SendEventRequestConnection(CWII_IPC_HL pEventRequestConnection->uclass[2] = _rWiiMote.GetClass()[2]; pEventRequestConnection->LinkType = HCI_LINK_ACL; - // Log -#if 0 + AddEventToQueue(Event); + static char LinkType[][128] = { { "HCI_LINK_SCO 0x00 - Voice"}, - { "HCI_LINK_ACL 0x01 - Data"}, - { "HCI_LINK_eSCO 0x02 - eSCO"}, + { "HCI_LINK_ACL 0x01 - Data" }, + { "HCI_LINK_eSCO 0x02 - eSCO" }, }; -#endif - INFO_LOG(WII_IPC_WIIMOTE, "<<<<<<< Request ACL Connection >>>>>>>"); INFO_LOG(WII_IPC_WIIMOTE, "Event: SendEventRequestConnection"); INFO_LOG(WII_IPC_WIIMOTE, " bd: %02x:%02x:%02x:%02x:%02x:%02x", pEventRequestConnection->bdaddr.b[0], pEventRequestConnection->bdaddr.b[1], pEventRequestConnection->bdaddr.b[2], @@ -728,9 +604,7 @@ bool CWII_IPC_HLE_Device_usb_oh1_57e_305::SendEventRequestConnection(CWII_IPC_HL DEBUG_LOG(WII_IPC_WIIMOTE, " COD[0]: 0x%02x", pEventRequestConnection->uclass[0]); DEBUG_LOG(WII_IPC_WIIMOTE, " COD[1]: 0x%02x", pEventRequestConnection->uclass[1]); DEBUG_LOG(WII_IPC_WIIMOTE, " COD[2]: 0x%02x", pEventRequestConnection->uclass[2]); - //DEBUG_LOG(WII_IPC_WIIMOTE, " LinkType: %s", LinkType[pEventRequestConnection->LinkType]); - - AddEventToQueue(Event); + DEBUG_LOG(WII_IPC_WIIMOTE, " LinkType: %s", LinkType[pEventRequestConnection->LinkType]); return true; } @@ -901,39 +775,20 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305::SendEventCommandComplete(u16 _OpCode, bool CWII_IPC_HLE_Device_usb_oh1_57e_305::SendEventCommandStatus(u16 _Opcode) { - // If we haven't sent this event or other events before, we will send it - // If we have, then skip it - if (m_LastCmd == 0) - { - // Let's make a mark to show further events are scheduled - // besides this should also guarantee we won't send this event twice - // I think 65535 is big enough, so it won't trouble other events who also make use of g_LastCmd - m_LastCmd = 0xFFFF; + SQueuedEvent Event(sizeof(SHCIEventStatus), 0); - SQueuedEvent Event(sizeof(SHCIEventStatus), 0); + SHCIEventStatus* pHCIEvent = (SHCIEventStatus*)Event.m_buffer; + pHCIEvent->EventType = HCI_EVENT_COMMAND_STATUS; + pHCIEvent->PayloadLength = sizeof(SHCIEventStatus) - 2; + pHCIEvent->EventStatus = 0x0; + pHCIEvent->PacketIndicator = 0x01; + pHCIEvent->Opcode = _Opcode; - SHCIEventStatus* pHCIEvent = (SHCIEventStatus*)Event.m_buffer; - pHCIEvent->EventType = HCI_EVENT_COMMAND_STATUS; - pHCIEvent->PayloadLength = sizeof(SHCIEventStatus) - 2; - pHCIEvent->EventStatus = 0x0; - pHCIEvent->PacketIndicator = 0x01; - pHCIEvent->Opcode = _Opcode; + INFO_LOG(WII_IPC_WIIMOTE, "Event: Command Status (Opcode: 0x%04x)", pHCIEvent->Opcode); - INFO_LOG(WII_IPC_WIIMOTE, "Event: Command Status (Opcode: 0x%04x)", pHCIEvent->Opcode); + AddEventToQueue(Event); - AddEventToQueue(Event); - - return true; - } - else - { - // If the mark matches, clear it - // if not, keep it untouched - if (m_LastCmd==0xFFFF) - m_LastCmd = 0; - - return false; - } + return true; } bool CWII_IPC_HLE_Device_usb_oh1_57e_305::SendEventRoleChange(bdaddr_t _bd, bool _master) @@ -963,29 +818,32 @@ bool CWII_IPC_HLE_Device_usb_oh1_57e_305::SendEventRoleChange(bdaddr_t _bd, bool return true; } -bool CWII_IPC_HLE_Device_usb_oh1_57e_305::SendEventNumberOfCompletedPackets(u16 _connectionHandle, u16 _count) +bool CWII_IPC_HLE_Device_usb_oh1_57e_305::SendEventNumberOfCompletedPackets() { - CWII_IPC_HLE_WiiMote* pWiiMote = AccessWiiMote(_connectionHandle); - if (pWiiMote == NULL) - { - ERROR_LOG(WII_IPC_WIIMOTE, "SendEventNumberOfCompletedPackets: Cant find WiiMote by connection handle %02x", _connectionHandle); - PanicAlert("SendEventNumberOfCompletedPackets: Cant find WiiMote by connection handle %02x", _connectionHandle); - return false; - } + SQueuedEvent Event(sizeof(hci_event_hdr_t) + sizeof(hci_num_compl_pkts_ep) + sizeof(hci_num_compl_pkts_info) * m_WiiMotes.size(), 0); - SQueuedEvent Event(sizeof(SHCIEventNumberOfCompletedPackets), 0); // zero, so this packet isnt counted - - SHCIEventNumberOfCompletedPackets* pNumberOfCompletedPackets = (SHCIEventNumberOfCompletedPackets*)Event.m_buffer; - pNumberOfCompletedPackets->EventType = 0x13; - pNumberOfCompletedPackets->PayloadLength = sizeof(SHCIEventNumberOfCompletedPackets) - 2; - pNumberOfCompletedPackets->NumberOfHandles = 1; - pNumberOfCompletedPackets->Connection_Handle = _connectionHandle; - pNumberOfCompletedPackets->Number_Of_Completed_Packets = _count; - - // Log INFO_LOG(WII_IPC_WIIMOTE, "Event: SendEventNumberOfCompletedPackets"); - DEBUG_LOG(WII_IPC_WIIMOTE, " Connection_Handle: 0x%04x", pNumberOfCompletedPackets->Connection_Handle); - DEBUG_LOG(WII_IPC_WIIMOTE, " Number_Of_Completed_Packets: %i", pNumberOfCompletedPackets->Number_Of_Completed_Packets); + + hci_event_hdr_t* event_hdr = (hci_event_hdr_t*)Event.m_buffer; + hci_num_compl_pkts_ep* event = (hci_num_compl_pkts_ep*)((u8*)event_hdr + sizeof(hci_event_hdr_t)); + hci_num_compl_pkts_info* info = (hci_num_compl_pkts_info*)((u8*)event + sizeof(hci_num_compl_pkts_ep)); + + event_hdr->event = HCI_EVENT_NUM_COMPL_PKTS; + event_hdr->length = sizeof(hci_num_compl_pkts_ep); + event->num_con_handles = 0; + + for (unsigned int i = 0; i < m_WiiMotes.size(); i++) + { + event_hdr->length += sizeof(hci_num_compl_pkts_info); + event->num_con_handles++; + info->compl_pkts = m_PacketCount[i]; + info->con_handle = m_WiiMotes[i].GetConnectionHandle(); + info++; + m_PacketCount[i] = 0; + + DEBUG_LOG(WII_IPC_WIIMOTE, " Connection_Handle: 0x%04x", info->con_handle); + DEBUG_LOG(WII_IPC_WIIMOTE, " Number_Of_Completed_Packets: %i", info->compl_pkts); + } AddEventToQueue(Event); @@ -1018,27 +876,36 @@ bool CWII_IPC_HLE_Device_usb_oh1_57e_305::SendEventModeChange(u16 _connectionHan return true; } -bool CWII_IPC_HLE_Device_usb_oh1_57e_305::SendEventLinkKeyNotification(const CWII_IPC_HLE_WiiMote& _rWiiMote) +bool CWII_IPC_HLE_Device_usb_oh1_57e_305::SendEventLinkKeyNotification(const u8 num_to_send) { - SQueuedEvent Event(sizeof(SHCIEventLinkKeyNotification), 0); - + u8 payload_length = sizeof(hci_return_link_keys_ep) + sizeof(hci_link_key_rep_cp) * num_to_send; + SQueuedEvent Event(2 + payload_length, 0); SHCIEventLinkKeyNotification* pEventLinkKey = (SHCIEventLinkKeyNotification*)Event.m_buffer; - pEventLinkKey->EventType = HCI_EVENT_RETURN_LINK_KEYS; - pEventLinkKey->PayloadLength = sizeof(SHCIEventLinkKeyNotification) - 2; - pEventLinkKey->numKeys = 1; - pEventLinkKey->bdaddr = _rWiiMote.GetBD(); - memcpy(pEventLinkKey->LinkKey, _rWiiMote.GetLinkKey(), 16); + INFO_LOG(WII_IPC_WIIMOTE, "Event: SendEventLinkKeyNotification"); + + // event header + pEventLinkKey->EventType = HCI_EVENT_RETURN_LINK_KEYS; + pEventLinkKey->PayloadLength = payload_length; + // this is really hci_return_link_keys_ep.num_keys + pEventLinkKey->numKeys = num_to_send; + + // copy infos - this only works correctly if we're meant to start at first device and read all keys + for (int i = 0; i < num_to_send; i++) + { + hci_link_key_rep_cp* link_key_info + = (hci_link_key_rep_cp*)((u8*)&pEventLinkKey->bdaddr + sizeof(hci_link_key_rep_cp) * i); + link_key_info->bdaddr = m_WiiMotes[i].GetBD(); + memcpy(link_key_info->key, m_WiiMotes[i].GetLinkKey(), HCI_KEY_SIZE); + + DEBUG_LOG(WII_IPC_WIIMOTE, " bd: %02x:%02x:%02x:%02x:%02x:%02x", + link_key_info->bdaddr.b[0], link_key_info->bdaddr.b[1], link_key_info->bdaddr.b[2], + link_key_info->bdaddr.b[3], link_key_info->bdaddr.b[4], link_key_info->bdaddr.b[5]); + LOG_LinkKey(link_key_info->key); + } AddEventToQueue(Event); - INFO_LOG(WII_IPC_WIIMOTE, "Event: SendEventLinkKeyNotification"); - DEBUG_LOG(WII_IPC_WIIMOTE, " bd: %02x:%02x:%02x:%02x:%02x:%02x", - pEventLinkKey->bdaddr.b[0], pEventLinkKey->bdaddr.b[1], pEventLinkKey->bdaddr.b[2], - pEventLinkKey->bdaddr.b[3], pEventLinkKey->bdaddr.b[4], pEventLinkKey->bdaddr.b[5]); - - LOG_LinkKey(pEventLinkKey->LinkKey); - return true; }; @@ -1114,8 +981,7 @@ bool CWII_IPC_HLE_Device_usb_oh1_57e_305::SendEventConPacketTypeChange(u16 _conn // Command dispatcher -// ----------------- -// This is called from the USB_IOCTL_HCI_COMMAND_MESSAGE Ioctlv +// This is called from the USBV0_IOCTL_CTRLMSG Ioctlv void CWII_IPC_HLE_Device_usb_oh1_57e_305::ExecuteHCICommandMessage(const SHCICommandMessage& _rHCICommandMessage) { u8* pInput = Memory::GetPointer(_rHCICommandMessage.m_PayLoadAddr + 3); @@ -1124,15 +990,10 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305::ExecuteHCICommandMessage(const SHCICom u16 ocf = HCI_OCF(pMsg->Opcode); u16 ogf = HCI_OGF(pMsg->Opcode); - // Only show info if this is a new HCI command - // or else we are continuing to execute last command - if(m_LastCmd == 0) - { - INFO_LOG(WII_IPC_WIIMOTE, "**************************************************"); - INFO_LOG(WII_IPC_WIIMOTE, "Execute HCI Command: 0x%04x (ocf: 0x%02x, ogf: 0x%02x)", pMsg->Opcode, ocf, ogf); - } + INFO_LOG(WII_IPC_WIIMOTE, "**************************************************"); + INFO_LOG(WII_IPC_WIIMOTE, "Execute HCI Command: 0x%04x (ocf: 0x%02x, ogf: 0x%02x)", pMsg->Opcode, ocf, ogf); - switch(pMsg->Opcode) + switch (pMsg->Opcode) { // // --- read commands --- @@ -1278,36 +1139,28 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305::ExecuteHCICommandMessage(const SHCICom CommandDeleteStoredLinkKey(pInput); break; - // - // --- default --- - // default: - { - // send fake okay msg... - SendEventCommandComplete(pMsg->Opcode, NULL, 0); + // send fake okay msg... + SendEventCommandComplete(pMsg->Opcode, NULL, 0); - if (ogf == 0x3f) + if (ogf == HCI_OGF_VENDOR) + { + ERROR_LOG(WII_IPC_WIIMOTE, "Command: vendor specific: 0x%04X (ocf: 0x%x)", pMsg->Opcode, ocf); + for (int i = 0; i < pMsg->len; i++) { - PanicAlert("Vendor specific HCI command"); - ERROR_LOG(WII_IPC_WIIMOTE, "Command: vendor specific: 0x%04X (ocf: 0x%x)", pMsg->Opcode, ocf); - for (int i=0; ilen; i++) - { - ERROR_LOG(WII_IPC_WIIMOTE, " 0x02%x", pInput[i]); - } - } - else - { - _dbg_assert_msg_(WII_IPC_WIIMOTE, 0, "Unknown USB_IOCTL_CTRLMSG: 0x%04X (ocf: 0x%x ogf 0x%x)", pMsg->Opcode, ocf, ogf); + ERROR_LOG(WII_IPC_WIIMOTE, " 0x02%x", pInput[i]); } } + else + { + _dbg_assert_msg_(WII_IPC_WIIMOTE, 0, + "Unknown USB_IOCTL_CTRLMSG: 0x%04X (ocf: 0x%x ogf 0x%x)", pMsg->Opcode, ocf, ogf); + } break; } - if ((m_LastCmd == 0) && (m_HCIPool.m_number == 0)) - { - // If HCI command is finished and HCI pool is empty, send a reply to command - WII_IPC_HLE_Interface::EnqReply(_rHCICommandMessage.m_Address); - } + // HCI command is finished, send a reply to command + WII_IPC_HLE_Interface::EnqReply(_rHCICommandMessage.m_Address); } @@ -1319,24 +1172,7 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305::ExecuteHCICommandMessage(const SHCICom void CWII_IPC_HLE_Device_usb_oh1_57e_305::CommandInquiry(u8* _Input) { // Inquiry should not be called normally - // FGFEmperor: It's called from the MiiChannel, when you try to upload your Miis to the WiiMote... And nothing bad happens after that... - // PanicAlert("HCI_CMD_INQUIRY is called, please report!"); - - if (SendEventCommandStatus(HCI_CMD_INQUIRY)) - return; - - if (m_LastCmd == 0) - { - SendEventInquiryResponse(); - // Now let's set up a mark - m_LastCmd = HCI_CMD_INQUIRY; - } - else - { - SendEventInquiryComplete(); - // Clean up - m_LastCmd = 0; - } + PanicAlert("HCI_CMD_INQUIRY is called, please report!"); hci_inquiry_cp* pInquiry = (hci_inquiry_cp*)_Input; @@ -1346,7 +1182,11 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305::CommandInquiry(u8* _Input) DEBUG_LOG(WII_IPC_WIIMOTE, " LAP[1]: 0x%02x", pInquiry->lap[1]); DEBUG_LOG(WII_IPC_WIIMOTE, " LAP[2]: 0x%02x", pInquiry->lap[2]); DEBUG_LOG(WII_IPC_WIIMOTE, " inquiry_length: %i (N x 1.28) sec", pInquiry->inquiry_length); - DEBUG_LOG(WII_IPC_WIIMOTE, " num_responses: %i (N x 1.28) sec", pInquiry->num_responses); + DEBUG_LOG(WII_IPC_WIIMOTE, " num_responses: %i (N x 1.28) sec", pInquiry->num_responses); + + SendEventCommandStatus(HCI_CMD_INQUIRY); + SendEventInquiryResponse(); + SendEventInquiryComplete(); } void CWII_IPC_HLE_Device_usb_oh1_57e_305::CommandInquiryCancel(u8* _Input) @@ -1362,9 +1202,6 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305::CommandInquiryCancel(u8* _Input) void CWII_IPC_HLE_Device_usb_oh1_57e_305::CommandCreateCon(u8* _Input) { - if(SendEventCommandStatus(HCI_CMD_CREATE_CON)) - return; - // command parameters hci_create_con_cp* pCreateCon = (hci_create_con_cp*)_Input; @@ -1380,14 +1217,12 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305::CommandCreateCon(u8* _Input) DEBUG_LOG(WII_IPC_WIIMOTE, " clock_offset: %i", pCreateCon->clock_offset); DEBUG_LOG(WII_IPC_WIIMOTE, " accept_role_switch: %i", pCreateCon->accept_role_switch); + SendEventCommandStatus(HCI_CMD_CREATE_CON); SendEventConnectionComplete(pCreateCon->bdaddr); } void CWII_IPC_HLE_Device_usb_oh1_57e_305::CommandDisconnect(u8* _Input) { - if(SendEventCommandStatus(HCI_CMD_DISCONNECT)) - return; - // command parameters hci_discon_cp* pDiscon = (hci_discon_cp*)_Input; @@ -1395,6 +1230,9 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305::CommandDisconnect(u8* _Input) DEBUG_LOG(WII_IPC_WIIMOTE, " ConnectionHandle: 0x%04x", pDiscon->con_handle); DEBUG_LOG(WII_IPC_WIIMOTE, " Reason: 0x%02x", pDiscon->reason); + Host_SetWiiMoteConnectionState(0); + + SendEventCommandStatus(HCI_CMD_DISCONNECT); SendEventDisconnect(pDiscon->con_handle, pDiscon->reason); CWII_IPC_HLE_WiiMote* pWiimote = AccessWiiMote(pDiscon->con_handle); @@ -1404,27 +1242,9 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305::CommandDisconnect(u8* _Input) void CWII_IPC_HLE_Device_usb_oh1_57e_305::CommandAcceptCon(u8* _Input) { - if(SendEventCommandStatus(HCI_CMD_ACCEPT_CON)) - return; - // command parameters hci_accept_con_cp* pAcceptCon = (hci_accept_con_cp*)_Input; - // this connection wants to be the master - if ((m_LastCmd == 0)&&(pAcceptCon->role == 0)) - { - SendEventRoleChange(pAcceptCon->bdaddr, true); - // Now let us set up a mark - m_LastCmd = HCI_CMD_ACCEPT_CON; - return; - } - else - { - SendEventConnectionComplete(pAcceptCon->bdaddr); - // Clean up - m_LastCmd = 0; - } - static char s_szRole[][128] = { { "Master (0x00)"}, @@ -1436,6 +1256,16 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305::CommandAcceptCon(u8* _Input) pAcceptCon->bdaddr.b[0], pAcceptCon->bdaddr.b[1], pAcceptCon->bdaddr.b[2], pAcceptCon->bdaddr.b[3], pAcceptCon->bdaddr.b[4], pAcceptCon->bdaddr.b[5]); DEBUG_LOG(WII_IPC_WIIMOTE, " role: %s", s_szRole[pAcceptCon->role]); + + SendEventCommandStatus(HCI_CMD_ACCEPT_CON); + + // this connection wants to be the master + if (pAcceptCon->role == 0) + { + SendEventRoleChange(pAcceptCon->bdaddr, true); + } + + SendEventConnectionComplete(pAcceptCon->bdaddr); } void CWII_IPC_HLE_Device_usb_oh1_57e_305::CommandLinkKeyRep(u8* _Input) @@ -1476,38 +1306,33 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305::CommandLinkKeyNegRep(u8* _Input) void CWII_IPC_HLE_Device_usb_oh1_57e_305::CommandChangeConPacketType(u8* _Input) { - if(SendEventCommandStatus(HCI_CMD_CHANGE_CON_PACKET_TYPE)) - return; - // command parameters hci_change_con_pkt_type_cp* pChangePacketType = (hci_change_con_pkt_type_cp*)_Input; + // ntd stack sets packet type 0xcc18, which is HCI_PKT_DH5 | HCI_PKT_DM5 | HCI_PKT_DH1 | HCI_PKT_DM1 + // dunno what to do...run awayyyyyy! INFO_LOG(WII_IPC_WIIMOTE, "Command: HCI_CMD_CHANGE_CON_PACKET_TYPE"); DEBUG_LOG(WII_IPC_WIIMOTE, " ConnectionHandle: 0x%04x", pChangePacketType->con_handle); DEBUG_LOG(WII_IPC_WIIMOTE, " PacketType: 0x%04x", pChangePacketType->pkt_type); + SendEventCommandStatus(HCI_CMD_CHANGE_CON_PACKET_TYPE); SendEventConPacketTypeChange(pChangePacketType->con_handle, pChangePacketType->pkt_type); } void CWII_IPC_HLE_Device_usb_oh1_57e_305::CommandAuthenticationRequested(u8* _Input) { - if(SendEventCommandStatus(HCI_CMD_AUTH_REQ)) - return; - // command parameters hci_auth_req_cp* pAuthReq = (hci_auth_req_cp*)_Input; INFO_LOG(WII_IPC_WIIMOTE, "Command: HCI_CMD_AUTH_REQ"); DEBUG_LOG(WII_IPC_WIIMOTE, " ConnectionHandle: 0x%04x", pAuthReq->con_handle); + SendEventCommandStatus(HCI_CMD_AUTH_REQ); SendEventAuthenticationCompleted(pAuthReq->con_handle); } void CWII_IPC_HLE_Device_usb_oh1_57e_305::CommandRemoteNameReq(u8* _Input) { - if(SendEventCommandStatus(HCI_CMD_REMOTE_NAME_REQ)) - return; - // command parameters hci_remote_name_req_cp* pRemoteNameReq = (hci_remote_name_req_cp*)_Input; @@ -1519,69 +1344,59 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305::CommandRemoteNameReq(u8* _Input) DEBUG_LOG(WII_IPC_WIIMOTE, " page_scan_mode: %i", pRemoteNameReq->page_scan_mode); DEBUG_LOG(WII_IPC_WIIMOTE, " clock_offset: %i", pRemoteNameReq->clock_offset); + SendEventCommandStatus(HCI_CMD_REMOTE_NAME_REQ); SendEventRemoteNameReq(pRemoteNameReq->bdaddr); } void CWII_IPC_HLE_Device_usb_oh1_57e_305::CommandReadRemoteFeatures(u8* _Input) { - if(SendEventCommandStatus(HCI_CMD_READ_REMOTE_FEATURES)) - return; - // command parameters hci_read_remote_features_cp* pReadRemoteFeatures = (hci_read_remote_features_cp*)_Input; INFO_LOG(WII_IPC_WIIMOTE, "Command: HCI_CMD_READ_REMOTE_FEATURES"); DEBUG_LOG(WII_IPC_WIIMOTE, " ConnectionHandle: 0x%04x", pReadRemoteFeatures->con_handle); + SendEventCommandStatus(HCI_CMD_READ_REMOTE_FEATURES); SendEventReadRemoteFeatures(pReadRemoteFeatures->con_handle); } void CWII_IPC_HLE_Device_usb_oh1_57e_305::CommandReadRemoteVerInfo(u8* _Input) { - if(SendEventCommandStatus(HCI_CMD_READ_REMOTE_VER_INFO)) - return; - // command parameters hci_read_remote_ver_info_cp* pReadRemoteVerInfo = (hci_read_remote_ver_info_cp*)_Input; INFO_LOG(WII_IPC_WIIMOTE, "Command: HCI_CMD_READ_REMOTE_VER_INFO"); DEBUG_LOG(WII_IPC_WIIMOTE, " ConnectionHandle: 0x%02x", pReadRemoteVerInfo->con_handle); + SendEventCommandStatus(HCI_CMD_READ_REMOTE_VER_INFO); SendEventReadRemoteVerInfo(pReadRemoteVerInfo->con_handle); } void CWII_IPC_HLE_Device_usb_oh1_57e_305::CommandReadClockOffset(u8* _Input) { - if(SendEventCommandStatus(HCI_CMD_READ_CLOCK_OFFSET)) - return; - // command parameters hci_read_clock_offset_cp* pReadClockOffset = (hci_read_clock_offset_cp*)_Input; INFO_LOG(WII_IPC_WIIMOTE, "Command: HCI_CMD_READ_CLOCK_OFFSET"); DEBUG_LOG(WII_IPC_WIIMOTE, " ConnectionHandle: 0x%02x", pReadClockOffset->con_handle); + SendEventCommandStatus(HCI_CMD_READ_CLOCK_OFFSET); SendEventReadClockOffsetComplete(pReadClockOffset->con_handle); - - // CWII_IPC_HLE_WiiMote* pWiiMote = AccessWiiMote(pReadClockOffset->con_handle); - // SendEventRequestLinkKey(pWiiMote->GetBD()); } void CWII_IPC_HLE_Device_usb_oh1_57e_305::CommandSniffMode(u8* _Input) { - if(SendEventCommandStatus(HCI_CMD_SNIFF_MODE)) - return; - // command parameters hci_sniff_mode_cp* pSniffMode = (hci_sniff_mode_cp*)_Input; INFO_LOG(WII_IPC_WIIMOTE, "Command: HCI_CMD_SNIFF_MODE"); INFO_LOG(WII_IPC_WIIMOTE, " ConnectionHandle: 0x%04x", pSniffMode->con_handle); - DEBUG_LOG(WII_IPC_WIIMOTE, " max_interval: 0x%04x", pSniffMode->max_interval); - DEBUG_LOG(WII_IPC_WIIMOTE, " min_interval: 0x%04x", pSniffMode->min_interval); - DEBUG_LOG(WII_IPC_WIIMOTE, " attempt: 0x%04x", pSniffMode->attempt); - DEBUG_LOG(WII_IPC_WIIMOTE, " timeout: 0x%04x", pSniffMode->timeout); + DEBUG_LOG(WII_IPC_WIIMOTE, " max_interval: %f msec", pSniffMode->max_interval * .625); + DEBUG_LOG(WII_IPC_WIIMOTE, " min_interval: %f msec", pSniffMode->min_interval * .625); + DEBUG_LOG(WII_IPC_WIIMOTE, " attempt: %f msec", pSniffMode->attempt * 1.25); + DEBUG_LOG(WII_IPC_WIIMOTE, " timeout: %f msec", pSniffMode->timeout * 1.25); + SendEventCommandStatus(HCI_CMD_SNIFF_MODE); SendEventModeChange(pSniffMode->con_handle, 0x02, pSniffMode->max_interval); // 0x02 - sniff mode } @@ -1598,7 +1413,9 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305::CommandWriteLinkPolicy(u8* _Input) Reply.status = 0x00; Reply.con_handle = pLinkPolicy->con_handle; - SendEventCommandComplete(HCI_CMD_WRITE_LINK_POLICY_SETTINGS, &Reply, sizeof(hci_write_link_policy_settings_rp)); + SendEventCommandStatus(HCI_CMD_WRITE_LINK_POLICY_SETTINGS); + + //AccessWiiMote(pLinkPolicy->con_handle)->ResetChannels(); } void CWII_IPC_HLE_Device_usb_oh1_57e_305::CommandReset(u8* _Input) @@ -1616,8 +1433,6 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305::CommandSetEventFilter(u8* _Input) { // command parameters hci_set_event_filter_cp* pSetEventFilter = (hci_set_event_filter_cp*)_Input; - m_EventFilterType = pSetEventFilter->filter_type; - m_EventFilterCondition = pSetEventFilter->filter_condition_type; // reply hci_set_event_filter_rp Reply; @@ -1634,7 +1449,6 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305::CommandWritePinType(u8* _Input) { // command parameters hci_write_pin_type_cp* pWritePinType = (hci_write_pin_type_cp*)_Input; - m_PINType = pWritePinType->pin_type; // reply hci_write_pin_type_rp Reply; @@ -1653,33 +1467,17 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305::CommandReadStoredLinkKey(u8* _Input) // reply hci_read_stored_link_key_rp Reply; Reply.status = 0x00; - Reply.max_num_keys = 255; - if (ReadStoredLinkKey->read_all) + + if (ReadStoredLinkKey->read_all == 1) { Reply.num_keys_read = (u16)m_WiiMotes.size(); } else { - ERROR_LOG(WII_IPC_WIIMOTE, "CommandReadStoredLinkKey"); - PanicAlert("CommandReadStoredLinkKey"); + ERROR_LOG(WII_IPC_WIIMOTE, "CommandReadStoredLinkKey isn't looking for all devices"); } - // generate link key - // Let us have some fun :P - if(m_LastCmd < m_WiiMotes.size()) - { - SendEventLinkKeyNotification(m_WiiMotes[m_LastCmd]); - m_LastCmd++; - return; - } - else - { - SendEventCommandComplete(HCI_CMD_READ_STORED_LINK_KEY, &Reply, sizeof(hci_read_stored_link_key_rp)); - m_LastCmd = 0; - } - - // logging INFO_LOG(WII_IPC_WIIMOTE, "Command: HCI_CMD_READ_STORED_LINK_KEY:"); DEBUG_LOG(WII_IPC_WIIMOTE, "input:"); DEBUG_LOG(WII_IPC_WIIMOTE, " bd: %02x:%02x:%02x:%02x:%02x:%02x", @@ -1689,6 +1487,9 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305::CommandReadStoredLinkKey(u8* _Input) DEBUG_LOG(WII_IPC_WIIMOTE, "return:"); DEBUG_LOG(WII_IPC_WIIMOTE, " max_num_keys: %i", Reply.max_num_keys); DEBUG_LOG(WII_IPC_WIIMOTE, " num_keys_read: %i", Reply.num_keys_read); + + SendEventLinkKeyNotification((u8)Reply.num_keys_read); + SendEventCommandComplete(HCI_CMD_READ_STORED_LINK_KEY, &Reply, sizeof(hci_read_stored_link_key_rp)); } void CWII_IPC_HLE_Device_usb_oh1_57e_305::CommandDeleteStoredLinkKey(u8* _Input) @@ -1714,14 +1515,12 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305::CommandDeleteStoredLinkKey(u8* _Input) SendEventCommandComplete(HCI_CMD_DELETE_STORED_LINK_KEY, &Reply, sizeof(hci_delete_stored_link_key_rp)); ERROR_LOG(WII_IPC_WIIMOTE, "HCI: CommandDeleteStoredLinkKey... Probably the security for linking has failed. Could be a problem with loading the SCONF"); - PanicAlert("HCI: CommandDeleteStoredLinkKey... Probably the security for linking has failed. Could be a problem with loading the SCONF"); } void CWII_IPC_HLE_Device_usb_oh1_57e_305::CommandWriteLocalName(u8* _Input) { // command parameters hci_write_local_name_cp* pWriteLocalName = (hci_write_local_name_cp*)_Input; - memcpy(m_LocalName, pWriteLocalName->name, HCI_UNIT_NAME_SIZE); // reply hci_write_local_name_rp Reply; @@ -1779,9 +1578,6 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305::CommandWriteUnitClass(u8* _Input) { // command parameters hci_write_unit_class_cp* pWriteUnitClass = (hci_write_unit_class_cp*)_Input; - m_ClassOfDevice[0] = pWriteUnitClass->uclass[0]; - m_ClassOfDevice[1] = pWriteUnitClass->uclass[1]; - m_ClassOfDevice[2] = pWriteUnitClass->uclass[2]; // reply hci_write_unit_class_rp Reply; @@ -1799,10 +1595,6 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305::CommandHostBufferSize(u8* _Input) { // command parameters hci_host_buffer_size_cp* pHostBufferSize = (hci_host_buffer_size_cp*)_Input; - m_HostMaxACLSize = pHostBufferSize->max_acl_size; - m_HostMaxSCOSize = pHostBufferSize->max_sco_size; - m_HostNumACLPackets = pHostBufferSize->num_acl_pkts; - m_HostNumSCOPackets = pHostBufferSize->num_sco_pkts; // reply hci_host_buffer_size_rp Reply; @@ -1822,6 +1614,7 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305::CommandWriteLinkSupervisionTimeout(u8* // command parameters hci_write_link_supervision_timeout_cp* pSuperVision = (hci_write_link_supervision_timeout_cp*)_Input; + // timeout of 0 means timing out is disabled INFO_LOG(WII_IPC_WIIMOTE, "Command: HCI_CMD_WRITE_LINK_SUPERVISION_TIMEOUT"); DEBUG_LOG(WII_IPC_WIIMOTE, " con_handle: 0x%04x", pSuperVision->con_handle); DEBUG_LOG(WII_IPC_WIIMOTE, " timeout: 0x%02x", pSuperVision->timeout); @@ -1831,11 +1624,6 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305::CommandWriteLinkSupervisionTimeout(u8* Reply.con_handle = pSuperVision->con_handle; SendEventCommandComplete(HCI_CMD_WRITE_LINK_SUPERVISION_TIMEOUT, &Reply, sizeof(hci_write_link_supervision_timeout_rp)); - - // Now it is a good time to link channels - CWII_IPC_HLE_WiiMote* pWiimote = AccessWiiMote(pSuperVision->con_handle); - if (pWiimote) - pWiimote->EventConnectionAccepted(); } void CWII_IPC_HLE_Device_usb_oh1_57e_305::CommandWriteInquiryScanType(u8* _Input) @@ -2061,87 +1849,3 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305::LOG_LinkKey(const u8* _pLinkKey) , _pLinkKey[8], _pLinkKey[9], _pLinkKey[10], _pLinkKey[11], _pLinkKey[12], _pLinkKey[13], _pLinkKey[14], _pLinkKey[15]); } - - -// -// CWII_IPC_HLE_Device_usb_oh0 -// -CWII_IPC_HLE_Device_usb_oh0::CWII_IPC_HLE_Device_usb_oh0(u32 _DeviceID, const std::string& _rDeviceName) -: IWII_IPC_HLE_Device(_DeviceID, _rDeviceName) -{ -} - -CWII_IPC_HLE_Device_usb_oh0::~CWII_IPC_HLE_Device_usb_oh0() -{ -} - -bool CWII_IPC_HLE_Device_usb_oh0::Open(u32 _CommandAddress, u32 _Mode) -{ - Memory::Write_U32(GetDeviceID(), _CommandAddress+4); - m_Active = true; - return true; -} - -bool CWII_IPC_HLE_Device_usb_oh0::Close(u32 _CommandAddress, bool _bForce) -{ - if (!_bForce) - Memory::Write_U32(0, _CommandAddress + 0x4); - m_Active = false; - return true; -} - -bool CWII_IPC_HLE_Device_usb_oh0::IOCtl(u32 _CommandAddress) -{ - // write return value - Memory::Write_U32(0, _CommandAddress + 0x4); - return true; -} - -bool CWII_IPC_HLE_Device_usb_oh0::IOCtlV(u32 _CommandAddress) -{ - // write return value - Memory::Write_U32(0, _CommandAddress + 0x4); - return true; -} - - -// -// CWII_IPC_HLE_Device_usb_hid -// -CWII_IPC_HLE_Device_usb_hid::CWII_IPC_HLE_Device_usb_hid(u32 _DeviceID, const std::string& _rDeviceName) -: IWII_IPC_HLE_Device(_DeviceID, _rDeviceName) -{ -} - -CWII_IPC_HLE_Device_usb_hid::~CWII_IPC_HLE_Device_usb_hid() -{ -} - -bool CWII_IPC_HLE_Device_usb_hid::Open(u32 _CommandAddress, u32 _Mode) -{ - Memory::Write_U32(GetDeviceID(), _CommandAddress+4); - m_Active = true; - return true; -} - -bool CWII_IPC_HLE_Device_usb_hid::Close(u32 _CommandAddress, bool _bForce) -{ - if (!_bForce) - Memory::Write_U32(0, _CommandAddress+4); - m_Active = false; - return true; -} - -bool CWII_IPC_HLE_Device_usb_hid::IOCtl(u32 _CommandAddress) -{ - // write return value - Memory::Write_U32(0, _CommandAddress + 0x4); - return true; -} - -bool CWII_IPC_HLE_Device_usb_hid::IOCtlV(u32 _CommandAddress) -{ - // write return value - Memory::Write_U32(0, _CommandAddress + 0x4); - return true; -} diff --git a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_usb.h b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_usb.h index 1cc46217c4..6e8bcfb67c 100644 --- a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_usb.h +++ b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_usb.h @@ -15,8 +15,7 @@ // Official SVN repository and contact information can be found at // http://code.google.com/p/dolphin-emu/ -#ifndef _WII_IPC_HLE_DEVICE_USB_H_ -#define _WII_IPC_HLE_DEVICE_USB_H_ +#pragma once #include "hci.h" #include @@ -25,21 +24,6 @@ #include "WII_IPC_HLE_Device.h" #include "WII_IPC_HLE_WiiMote.h" -#define HCI_MAX_SIZE 128 -#define ACL_MAX_SIZE 128 - -union UACLHeader -{ - struct - { - unsigned ConnectionHandle : 12; - unsigned PBFlag : 2; - unsigned BCFlag : 2; - unsigned Size : 16; - }; - u32 Hex; -}; - struct SQueuedEvent { u8 m_buffer[1024]; @@ -55,6 +39,7 @@ struct SQueuedEvent // i know this code sux... PanicAlert("SQueuedEvent: allocate too big buffer!!"); } + memset(m_buffer, 0, 1024); } }; @@ -66,7 +51,6 @@ struct SQueuedEvent class CWII_IPC_HLE_Device_usb_oh1_57e_305 : public IWII_IPC_HLE_Device { public: - CWII_IPC_HLE_Device_usb_oh1_57e_305(u32 _DeviceID, const std::string& _rDeviceName); virtual ~CWII_IPC_HLE_Device_usb_oh1_57e_305(); @@ -79,16 +63,13 @@ public: virtual u32 Update(); + // Send ACL data back to bt stack void SendACLPacket(u16 _ConnectionHandle, u8* _pData, u32 _Size); - void PurgeACLPool(); - void PurgeHCIPool(); bool RemoteDisconnect(u16 _connectionHandle); - //hack for wiimote plugin - -public: - +// hack for wiimote plugin +public: std::vector m_WiiMotes; CWII_IPC_HLE_WiiMote* AccessWiiMote(const bdaddr_t& _rAddr); CWII_IPC_HLE_WiiMote* AccessWiiMote(u16 _ConnectionHandle); @@ -98,28 +79,22 @@ public: void NetPlay_WiimoteUpdate(int _number); private: - - enum + enum USBIOCtl { - USB_IOCTL_HCI_COMMAND_MESSAGE = 0, - USB_IOCTL_BLKMSG = 1, - USB_IOCTL_INTRMSG = 2, - USB_IOCTL_SUSPENDDEV = 5, - USB_IOCTL_RESUMEDEV = 6, - USB_IOCTL_GETDEVLIST = 12, - USB_IOCTL_DEVREMOVALHOOK = 26, - USB_IOCTL_DEVINSERTHOOK = 27, + USBV0_IOCTL_CTRLMSG = 0, + USBV0_IOCTL_BLKMSG = 1, + USBV0_IOCTL_INTRMSG = 2, }; - enum + enum USBEndpoint { - HCI_EVENT_ENDPOINT = 0x81, - ACL_DATA_BLK_OUT = 0x02, - ACL_DATA_ENDPOINT = 0x82, + HCI_CTRL = 0x00, + HCI_EVENT = 0x81, + ACL_DATA_IN = 0x82, + ACL_DATA_OUT = 0x02 }; - - struct SHCICommandMessage + struct SHCICommandMessage { u8 bRequestType; u8 bRequest; @@ -132,75 +107,75 @@ private: u32 m_Address; }; - struct ACLPool - { - u32 m_number; - u8 m_data[ACL_MAX_SIZE * 16]; - - ACLPool(int num) - : m_number(num) - { - } - }; - - struct HCIPool - { - u32 m_number; - u8 m_data[HCI_MAX_SIZE * 16]; - u8 m_size[16]; - - HCIPool(int num) - : m_number(num) - { - } - }; - - struct CtrlBuffer + // This is a lightweight/specialized version of SIOCtlVBuffer + struct CtrlBuffer { u32 m_address; u32 m_buffer; - CtrlBuffer(u32 _Address) - : m_address(_Address) + CtrlBuffer(u32 _Address) : m_address(_Address), m_buffer() { - if(_Address == 0) + if (m_address) { - m_buffer = 0; - } - else - { - u32 _BufferVector = Memory::Read_U32(_Address + 0x18); - u32 _InBufferNum = Memory::Read_U32(_Address + 0x10); - m_buffer = Memory::Read_U32(_BufferVector + _InBufferNum * 8); + u32 InBufferNum = Memory::Read_U32(m_address + 0x10); + u32 BufferVector = Memory::Read_U32(m_address + 0x18); + m_buffer = Memory::Read_U32( + BufferVector + InBufferNum * sizeof(SIOCtlVBuffer::SBuffer)); } } + + inline void FillBuffer(const void* src, const size_t size) const + { + memcpy(Memory::GetPointer(m_buffer), src, size); + } + + inline void SetRetVal(const u32 retval) const + { + Memory::Write_U32(retval, m_address + 4); + } + + inline bool IsValid() const + { + return m_address != 0; + } + + inline void Invalidate() + { + m_address = m_buffer = 0; + } }; bdaddr_t m_ControllerBD; - u8 m_ClassOfDevice[HCI_CLASS_SIZE]; - char m_LocalName[HCI_UNIT_NAME_SIZE]; - u8 m_PINType; + + // this is used to trigger connecting via ACL u8 m_ScanEnable; - u8 m_EventFilterType; - u8 m_EventFilterCondition; - - u16 m_HostMaxACLSize; - u8 m_HostMaxSCOSize; - u16 m_HostNumACLPackets; - u16 m_HostNumSCOPackets; - - // STATE_TO_SAVE SHCICommandMessage m_CtrlSetup; + CtrlBuffer m_HCIEndpoint; + std::queue m_EventQueue; + u32 m_ACLSetup; - CtrlBuffer m_HCIBuffer; - HCIPool m_HCIPool; - CtrlBuffer m_ACLBuffer; - ACLPool m_ACLPool; - u32 m_LastCmd; + CtrlBuffer m_ACLEndpoint; + struct ACLQ + { + u8* m_buffer; + size_t m_size; + u16 m_conn_handle; + ACLQ(const u8* data, const size_t size, const u16 conn_handle) + : m_size(size), m_conn_handle(conn_handle) + { + m_buffer = new u8[m_size]; + memcpy(m_buffer, data, m_size); + } + }; + std::queue m_ACLQ; + u32 m_PacketCount[4]; - u32 m_FreqDividerMote; - u32 m_FreqDividerSync; + u32 m_WiimoteUpdate_Freq; + u32 m_NumCompPackets_Freq; + + // Send ACL data to a device (wiimote) + void SendToDevice(u16 _ConnectionHandle, u8* _pData, u32 _Size); // Events void AddEventToQueue(const SQueuedEvent& _event); @@ -216,12 +191,12 @@ private: bool SendEventReadRemoteVerInfo(u16 _connectionHandle); bool SendEventReadRemoteFeatures(u16 _connectionHandle); bool SendEventRoleChange(bdaddr_t _bd, bool _master); - bool SendEventNumberOfCompletedPackets(u16 _connectionHandle, u16 _count); + bool SendEventNumberOfCompletedPackets(); bool SendEventAuthenticationCompleted(u16 _connectionHandle); bool SendEventModeChange(u16 _connectionHandle, u8 _mode, u16 _value); bool SendEventDisconnect(u16 _connectionHandle, u8 _Reason); bool SendEventRequestLinkKey(const bdaddr_t& _bd); - bool SendEventLinkKeyNotification(const CWII_IPC_HLE_WiiMote& _rWiiMote); + bool SendEventLinkKeyNotification(const u8 num_to_send); // Execute HCI Message void ExecuteHCICommandMessage(const SHCICommandMessage& _rCtrlMessage); @@ -271,45 +246,6 @@ private: void CommandVendorSpecific_FC4C(u8* _Input, u32 _Size); void CommandVendorSpecific_FC4F(u8* _Input, u32 _Size); - void SendToDevice(u16 _ConnectionHandle, u8* _pData, u32 _Size); - + // Debugging void LOG_LinkKey(const u8* _pLinkKey); }; - -class CWII_IPC_HLE_Device_usb_oh0 : public IWII_IPC_HLE_Device -{ -public: - - CWII_IPC_HLE_Device_usb_oh0(u32 _DeviceID, const std::string& _rDeviceName); - - virtual ~CWII_IPC_HLE_Device_usb_oh0(); - - virtual bool Open(u32 _CommandAddress, u32 _Mode); - virtual bool Close(u32 _CommandAddress, bool _bForce); // hermes' dsp demo - - virtual bool IOCtlV(u32 _CommandAddress); - virtual bool IOCtl(u32 _CommandAddress); - -// virtual u32 Update(); -}; - - -// Addresses Human Interface Devices via the Wii's USB 2.0 ports. -// Used by Rock Band 1 + 2 instruments. -class CWII_IPC_HLE_Device_usb_hid : public IWII_IPC_HLE_Device -{ -public: - CWII_IPC_HLE_Device_usb_hid(u32 _DeviceID, const std::string& _rDeviceName); - virtual ~CWII_IPC_HLE_Device_usb_hid(); - - virtual bool Open(u32 _CommandAddress, u32 _Mode); - virtual bool Close(u32 _CommandAddress, bool _bForce); - - virtual bool IOCtlV(u32 _CommandAddress); - virtual bool IOCtl(u32 _CommandAddress); - - // virtual u32 Update(); -}; - -#endif - diff --git a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_WiiMote.cpp b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_WiiMote.cpp index 132b4cc560..752ea3f3f7 100644 --- a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_WiiMote.cpp +++ b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_WiiMote.cpp @@ -24,7 +24,6 @@ #include "../ConfigManager.h" #include "../Host.h" #include "../Core.h" - #include "l2cap.h" // Local #include "WiiMote_HID_Attr.h" @@ -48,11 +47,11 @@ CWII_IPC_HLE_WiiMote::CWII_IPC_HLE_WiiMote(CWII_IPC_HLE_Device_usb_oh1_57e_305* , m_pHost(_pHost) { - INFO_LOG(WII_IPC_WIIMOTE, "Wiimote: #%i Constructed", _Number); + DEBUG_LOG(WII_IPC_WIIMOTE, "Wiimote: #%i Constructed", _Number); s_Usb = _pHost; - m_Connected = (ready) ? 0 : -1; + m_ConnectionState = (ready) ? CONN_READY : CONN_INACTIVE; m_ConnectionHandle = 0x100 + _Number; memset(m_LinkKey, 0xA0 + _Number, 16); @@ -82,7 +81,7 @@ CWII_IPC_HLE_WiiMote::CWII_IPC_HLE_WiiMote(CWII_IPC_HLE_Device_usb_oh1_57e_305* void CWII_IPC_HLE_WiiMote::DoState(PointerWrap &p) { - p.Do(m_Connected); + p.Do(m_ConnectionState); } // @@ -98,21 +97,21 @@ void CWII_IPC_HLE_WiiMote::DoState(PointerWrap &p) bool CWII_IPC_HLE_WiiMote::LinkChannel() { - if (m_Connected != 2) + if (m_ConnectionState != CONN_LINKING) return false; - // try to connect HID_CONTROL_CHANNEL + // try to connect L2CAP_PSM_HID_CNTL if (!m_HIDControlChannel_Connected) { if (m_HIDControlChannel_ConnectedWait) return false; m_HIDControlChannel_ConnectedWait = true; - SendConnectionRequest(0x0040, HID_CONTROL_CHANNEL); + SendConnectionRequest(0x0040, L2CAP_PSM_HID_CNTL); return true; } - // try to config HID_CONTROL_CHANNEL + // try to config L2CAP_PSM_HID_CNTL if (!m_HIDControlChannel_Config) { if (m_HIDControlChannel_ConfigWait) @@ -123,18 +122,18 @@ bool CWII_IPC_HLE_WiiMote::LinkChannel() return true; } - // try to connect HID_INTERRUPT_CHANNEL + // try to connect L2CAP_PSM_HID_INTR if (!m_HIDInterruptChannel_Connected) { if (m_HIDInterruptChannel_ConnectedWait) return false; m_HIDInterruptChannel_ConnectedWait = true; - SendConnectionRequest(0x0041, HID_INTERRUPT_CHANNEL); + SendConnectionRequest(0x0041, L2CAP_PSM_HID_INTR); return true; } - // try to config HID_INTERRUPT_CHANNEL + // try to config L2CAP_PSM_HID_INTR if (!m_HIDInterruptChannel_Config) { if (m_HIDInterruptChannel_ConfigWait) @@ -145,7 +144,8 @@ bool CWII_IPC_HLE_WiiMote::LinkChannel() return true; } - m_Connected = 3; + DEBUG_LOG(WII_IPC_WIIMOTE, "ConnectionState CONN_LINKING -> CONN_COMPLETE"); + m_ConnectionState = CONN_COMPLETE; return false; } @@ -162,9 +162,9 @@ bool CWII_IPC_HLE_WiiMote::LinkChannel() // void CWII_IPC_HLE_WiiMote::Activate(bool ready) { - if (ready && m_Connected == -1) + if (ready && (m_ConnectionState == CONN_INACTIVE)) { - m_Connected = 0; + m_ConnectionState = CONN_READY; } else if (!ready) { @@ -175,7 +175,8 @@ void CWII_IPC_HLE_WiiMote::Activate(bool ready) void CWII_IPC_HLE_WiiMote::EventConnectionAccepted() { - m_Connected = 2; + DEBUG_LOG(WII_IPC_WIIMOTE, "ConnectionState %x -> CONN_LINKING", m_ConnectionState); + m_ConnectionState = CONN_LINKING; } void CWII_IPC_HLE_WiiMote::EventDisconnect() @@ -184,21 +185,17 @@ void CWII_IPC_HLE_WiiMote::EventDisconnect() u8 Message = WIIMOTE_DISCONNECT; CPluginManager::GetInstance().GetWiimote()->Wiimote_ControlChannel(m_ConnectionHandle & 0xFF, 99, &Message, 0); - m_Connected = -1; + m_ConnectionState = CONN_INACTIVE; // Clear channel flags ResetChannels(); } bool CWII_IPC_HLE_WiiMote::EventPagingChanged(u8 _pageMode) { - if (m_Connected != 0) - return false; + if ((m_ConnectionState == CONN_READY) && (_pageMode & HCI_PAGE_SCAN_ENABLE)) + return true; - if ((_pageMode & 0x2) == 0) - return false; - - m_Connected = 1; - return true; + return false; } void CWII_IPC_HLE_WiiMote::ResetChannels() @@ -227,75 +224,69 @@ void CWII_IPC_HLE_WiiMote::ResetChannels() // -// =================================================== // This function receives L2CAP commands from the CPU -// It's called from SendToDevice() in WII_IPC_HLE_Device_usb.cpp. -// --------------------------------------------------- void CWII_IPC_HLE_WiiMote::ExecuteL2capCmd(u8* _pData, u32 _Size) { - // Debugger::PrintDataBuffer(LogTypes::WIIMOTE, _pData, _Size, "SendACLPacket: "); - // parse the command - SL2CAP_Header* pHeader = (SL2CAP_Header*)_pData; - u8* pData = _pData + sizeof(SL2CAP_Header); - u32 DataSize = _Size - sizeof(SL2CAP_Header); - INFO_LOG(WII_IPC_WIIMOTE, " CID 0x%04x, Len 0x%x, DataSize 0x%x", pHeader->CID, pHeader->Length, DataSize); + l2cap_hdr_t* pHeader = (l2cap_hdr_t*)_pData; + u8* pData = _pData + sizeof(l2cap_hdr_t); + u32 DataSize = _Size - sizeof(l2cap_hdr_t); + INFO_LOG(WII_IPC_WIIMOTE, " CID 0x%04x, Len 0x%x, DataSize 0x%x", pHeader->dcid, pHeader->length, DataSize); - if(pHeader->Length != DataSize) + if(pHeader->length != DataSize) { INFO_LOG(WII_IPC_WIIMOTE, "Faulty packet. It is dropped."); return; } - switch (pHeader->CID) + switch (pHeader->dcid) { - case 0x0001: + case L2CAP_SIGNAL_CID: SignalChannel(pData, DataSize); break; default: { - _dbg_assert_msg_(WII_IPC_WIIMOTE, DoesChannelExist(pHeader->CID), "L2CAP: SendACLPacket to unknown channel %i", pHeader->CID); - CChannelMap::iterator itr= m_Channel.find(pHeader->CID); + _dbg_assert_msg_(WII_IPC_WIIMOTE, DoesChannelExist(pHeader->dcid), "L2CAP: SendACLPacket to unknown channel %i", pHeader->dcid); + CChannelMap::iterator itr= m_Channel.find(pHeader->dcid); -#if defined(HAVE_WX) && HAVE_WX + #if defined(HAVE_WX) && HAVE_WX const int number = NetPlay_GetWiimoteNum(m_ConnectionHandle & 0xFF); -#else + #else const int number = 0; -#endif + #endif Common::PluginWiimote* mote = CPluginManager::GetInstance().GetWiimote(); if (itr != m_Channel.end()) { SChannel& rChannel = itr->second; - switch(rChannel.PSM) + switch (rChannel.PSM) { - case SDP_CHANNEL: - HandleSDP(pHeader->CID, pData, DataSize); + case L2CAP_PSM_SDP: + HandleSDP(pHeader->dcid, pData, DataSize); break; - case HID_CONTROL_CHANNEL: + case L2CAP_PSM_HID_CNTL: if (number < 4) - mote->Wiimote_ControlChannel(number, pHeader->CID, pData, DataSize); + mote->Wiimote_ControlChannel(number, pHeader->dcid, pData, DataSize); break; - case HID_INTERRUPT_CHANNEL: + case L2CAP_PSM_HID_INTR: { if (number < 4) { DEBUG_LOG(WIIMOTE, "Wiimote_InterruptChannel"); - DEBUG_LOG(WIIMOTE, " Channel ID: %04x", pHeader->CID); + DEBUG_LOG(WIIMOTE, " Channel ID: %04x", pHeader->dcid); std::string Temp = ArrayToString((const u8*)pData, DataSize); DEBUG_LOG(WIIMOTE, " Data: %s", Temp.c_str()); - mote->Wiimote_InterruptChannel(number, pHeader->CID, pData, DataSize); + mote->Wiimote_InterruptChannel(number, pHeader->dcid, pData, DataSize); } } break; default: - ERROR_LOG(WII_IPC_WIIMOTE, "channel 0x04%x has unknown PSM %x", pHeader->CID, rChannel.PSM); - PanicAlert("WIIMOTE: channel 0x04%x has unknown PSM %x", pHeader->CID, rChannel.PSM); + ERROR_LOG(WII_IPC_WIIMOTE, "channel 0x04%x has unknown PSM %x", pHeader->dcid, rChannel.PSM); break; } } @@ -303,55 +294,48 @@ void CWII_IPC_HLE_WiiMote::ExecuteL2capCmd(u8* _pData, u32 _Size) break; } } -// ================ void CWII_IPC_HLE_WiiMote::SignalChannel(u8* _pData, u32 _Size) { - while (_Size >= sizeof(SL2CAP_Command)) + while (_Size >= sizeof(l2cap_cmd_hdr_t)) { - SL2CAP_Command* pCommand = (SL2CAP_Command*)_pData; - _pData += sizeof(SL2CAP_Command); - _Size = _Size - sizeof(SL2CAP_Command) - pCommand->len; + l2cap_cmd_hdr_t* cmd_hdr = (l2cap_cmd_hdr_t*)_pData; + _pData += sizeof(l2cap_cmd_hdr_t); + _Size = _Size - sizeof(l2cap_cmd_hdr_t) - cmd_hdr->length; - switch(pCommand->code) + switch (cmd_hdr->code) { case L2CAP_COMMAND_REJ: ERROR_LOG(WII_IPC_WIIMOTE, "SignalChannel - L2CAP_COMMAND_REJ (something went wrong)." - "Try to replace your SYSCONF file with a new copy." - ,pCommand->code); - PanicAlert( - "SignalChannel - L2CAP_COMMAND_REJ (something went wrong)." - "Try to replace your SYSCONF file with a new copy." - ,pCommand->code); + "Try to replace your SYSCONF file with a new copy."); break; - case L2CAP_CONN_REQ: - ReceiveConnectionReq(pCommand->ident, _pData, pCommand->len); + case L2CAP_CONNECT_REQ: + ReceiveConnectionReq(cmd_hdr->ident, _pData, cmd_hdr->length); break; - case L2CAP_CONN_RSP: - ReceiveConnectionResponse(pCommand->ident, _pData, pCommand->len); + case L2CAP_CONNECT_RSP: + ReceiveConnectionResponse(cmd_hdr->ident, _pData, cmd_hdr->length); break; - case L2CAP_CONF_REQ: - ReceiveConfigurationReq(pCommand->ident, _pData, pCommand->len); + case L2CAP_CONFIG_REQ: + ReceiveConfigurationReq(cmd_hdr->ident, _pData, cmd_hdr->length); break; - case L2CAP_CONF_RSP: - ReceiveConfigurationResponse(pCommand->ident, _pData, pCommand->len); + case L2CAP_CONFIG_RSP: + ReceiveConfigurationResponse(cmd_hdr->ident, _pData, cmd_hdr->length); break; - case L2CAP_DISCONN_REQ: - ReceiveDisconnectionReq(pCommand->ident, _pData, pCommand->len); + case L2CAP_DISCONNECT_REQ: + ReceiveDisconnectionReq(cmd_hdr->ident, _pData, cmd_hdr->length); break; default: - ERROR_LOG(WII_IPC_WIIMOTE, " Unknown Command-Code (0x%02x)", pCommand->code); - PanicAlert("SignalChannel %x",pCommand->code); + ERROR_LOG(WII_IPC_WIIMOTE, " Unknown Command-Code (0x%02x)", cmd_hdr->code); return; } - _pData += pCommand->len; + _pData += cmd_hdr->length; } } @@ -368,7 +352,7 @@ void CWII_IPC_HLE_WiiMote::SignalChannel(u8* _pData, u32 _Size) void CWII_IPC_HLE_WiiMote::ReceiveConnectionReq(u8 _Ident, u8* _pData, u32 _Size) { - SL2CAP_CommandConnectionReq* pCommandConnectionReq = (SL2CAP_CommandConnectionReq*)_pData; + l2cap_con_req_cp* pCommandConnectionReq = (l2cap_con_req_cp*)_pData; // create the channel SChannel& rChannel = m_Channel[pCommandConnectionReq->scid]; @@ -383,21 +367,29 @@ void CWII_IPC_HLE_WiiMote::ReceiveConnectionReq(u8 _Ident, u8* _pData, u32 _Size DEBUG_LOG(WII_IPC_WIIMOTE, " DCID: 0x%04x", rChannel.DCID); // response - SL2CAP_ConnectionResponse Rsp; + l2cap_con_rsp_cp Rsp; Rsp.scid = rChannel.SCID; Rsp.dcid = rChannel.DCID; - Rsp.result = 0x00; - Rsp.status = 0x00; + Rsp.result = L2CAP_SUCCESS; + Rsp.status = L2CAP_NO_INFO; INFO_LOG(WII_IPC_WIIMOTE, "[L2CAP] SendConnectionResponse"); - SendCommandToACL(_Ident, L2CAP_CONN_RSP, sizeof(SL2CAP_ConnectionResponse), (u8*)&Rsp); + SendCommandToACL(_Ident, L2CAP_CONNECT_RSP, sizeof(l2cap_con_rsp_cp), (u8*)&Rsp); + + // update state machine + /* + if (rChannel.PSM == L2CAP_PSM_HID_CNTL) + m_HIDControlChannel_Connected = true; + else if (rChannel.PSM == L2CAP_PSM_HID_INTR) + m_HIDInterruptChannel_Connected = true; + */ } void CWII_IPC_HLE_WiiMote::ReceiveConnectionResponse(u8 _Ident, u8* _pData, u32 _Size) { - l2cap_conn_rsp* rsp = (l2cap_conn_rsp*)_pData; + l2cap_con_rsp_cp* rsp = (l2cap_con_rsp_cp*)_pData; - _dbg_assert_(WII_IPC_WIIMOTE, _Size == sizeof(l2cap_conn_rsp)); + _dbg_assert_(WII_IPC_WIIMOTE, _Size == sizeof(l2cap_con_rsp_cp)); INFO_LOG(WII_IPC_WIIMOTE, "[L2CAP] ReceiveConnectionResponse"); DEBUG_LOG(WII_IPC_WIIMOTE, " DCID: 0x%04x", rsp->dcid); @@ -405,32 +397,24 @@ void CWII_IPC_HLE_WiiMote::ReceiveConnectionResponse(u8 _Ident, u8* _pData, u32 DEBUG_LOG(WII_IPC_WIIMOTE, " Result: 0x%04x", rsp->result); DEBUG_LOG(WII_IPC_WIIMOTE, " Status: 0x%04x", rsp->status); - _dbg_assert_(WII_IPC_WIIMOTE, rsp->result == 0); - _dbg_assert_(WII_IPC_WIIMOTE, rsp->status == 0); + _dbg_assert_(WII_IPC_WIIMOTE, rsp->result == L2CAP_SUCCESS); + _dbg_assert_(WII_IPC_WIIMOTE, rsp->status == L2CAP_NO_INFO); _dbg_assert_(WII_IPC_WIIMOTE, DoesChannelExist(rsp->scid)); SChannel& rChannel = m_Channel[rsp->scid]; rChannel.DCID = rsp->dcid; - // - // AyuanX: I'm commenting this out because CPU thinks he is faster than WiiMote - // and basically CPU will take the initiative to config channel - // in any case we don't want to race against CPU, or we are doomed - // so we wait for CPU to request first - // - /* - if (rChannel.PSM == HID_CONTROL_CHANNEL) + // update state machine + if (rChannel.PSM == L2CAP_PSM_HID_CNTL) m_HIDControlChannel_Connected = true; - - if (rChannel.PSM == HID_INTERRUPT_CHANNEL) + else if (rChannel.PSM == L2CAP_PSM_HID_INTR) m_HIDInterruptChannel_Connected = true; - */ } void CWII_IPC_HLE_WiiMote::ReceiveConfigurationReq(u8 _Ident, u8* _pData, u32 _Size) { u32 Offset = 0; - SL2CAP_CommandConfigurationReq* pCommandConfigReq = (SL2CAP_CommandConfigurationReq*)_pData; + l2cap_cfg_req_cp* pCommandConfigReq = (l2cap_cfg_req_cp*)_pData; _dbg_assert_(WII_IPC_WIIMOTE, pCommandConfigReq->flags == 0x00); // 1 means that the options are send in multi-packets _dbg_assert_(WII_IPC_WIIMOTE, DoesChannelExist(pCommandConfigReq->dcid)); @@ -442,45 +426,41 @@ void CWII_IPC_HLE_WiiMote::ReceiveConfigurationReq(u8 _Ident, u8* _pData, u32 _S DEBUG_LOG(WII_IPC_WIIMOTE, " DCID: 0x%04x", pCommandConfigReq->dcid); DEBUG_LOG(WII_IPC_WIIMOTE, " Flags: 0x%04x", pCommandConfigReq->flags); - Offset += sizeof(SL2CAP_CommandConfigurationReq); + Offset += sizeof(l2cap_cfg_req_cp); u8 TempBuffer[1024]; u32 RespLen = 0; - SL2CAP_CommandConfigurationResponse* Rsp = (SL2CAP_CommandConfigurationResponse*)TempBuffer; + l2cap_cfg_rsp_cp* Rsp = (l2cap_cfg_rsp_cp*)TempBuffer; Rsp->scid = rChannel.DCID; Rsp->flags = 0x00; - Rsp->result = 0x00; + Rsp->result = L2CAP_SUCCESS; - RespLen += sizeof(SL2CAP_CommandConfigurationResponse); + RespLen += sizeof(l2cap_cfg_rsp_cp); // read configuration options while (Offset < _Size) { - SL2CAP_Options* pOptions = (SL2CAP_Options*)&_pData[Offset]; - Offset += sizeof(SL2CAP_Options); + l2cap_cfg_opt_t* pOptions = (l2cap_cfg_opt_t*)&_pData[Offset]; + Offset += sizeof(l2cap_cfg_opt_t); - switch(pOptions->type) + switch (pOptions->type) { - case 0x01: + case L2CAP_OPT_MTU: { - _dbg_assert_(WII_IPC_WIIMOTE, pOptions->length == 2); - SL2CAP_OptionsMTU* pMTU = (SL2CAP_OptionsMTU*)&_pData[Offset]; - rChannel.MTU = pMTU->MTU; - DEBUG_LOG(WII_IPC_WIIMOTE, " MTU: 0x%04x", pMTU->MTU); - // AyuanX: My experiment shows that the MTU is always set to 640 bytes - // This means that we only need temp_frame_size of 640B instead 1024B - // Actually I've never seen a frame bigger than 64B - // But... who cares of several KB mem today? Never mind + _dbg_assert_(WII_IPC_WIIMOTE, pOptions->length == L2CAP_OPT_MTU_SIZE); + l2cap_cfg_opt_val_t* pMTU = (l2cap_cfg_opt_val_t*)&_pData[Offset]; + rChannel.MTU = pMTU->mtu; + DEBUG_LOG(WII_IPC_WIIMOTE, " MTU: 0x%04x", pMTU->mtu); } break; - case 0x02: + case L2CAP_OPT_FLUSH_TIMO: { - _dbg_assert_(WII_IPC_WIIMOTE, pOptions->length == 2); - SL2CAP_OptionsFlushTimeOut* pFlushTimeOut = (SL2CAP_OptionsFlushTimeOut*)&_pData[Offset]; - rChannel.FlushTimeOut = pFlushTimeOut->TimeOut; - DEBUG_LOG(WII_IPC_WIIMOTE, " FlushTimeOut: 0x%04x", pFlushTimeOut->TimeOut); + _dbg_assert_(WII_IPC_WIIMOTE, pOptions->length == L2CAP_OPT_FLUSH_TIMO_SIZE); + l2cap_cfg_opt_val_t* pFlushTimeOut = (l2cap_cfg_opt_val_t*)&_pData[Offset]; + rChannel.FlushTimeOut = pFlushTimeOut->flush_timo; + DEBUG_LOG(WII_IPC_WIIMOTE, " FlushTimeOut: 0x%04x", pFlushTimeOut->flush_timo); } break; @@ -491,51 +471,44 @@ void CWII_IPC_HLE_WiiMote::ReceiveConfigurationReq(u8 _Ident, u8* _pData, u32 _S Offset += pOptions->length; - u32 OptionSize = sizeof(SL2CAP_Options) + pOptions->length; + u32 OptionSize = sizeof(l2cap_cfg_opt_t) + pOptions->length; memcpy(&TempBuffer[RespLen], pOptions, OptionSize); RespLen += OptionSize; } INFO_LOG(WII_IPC_WIIMOTE, "[L2CAP] SendConfigurationResponse"); - SendCommandToACL(_Ident, L2CAP_CONF_RSP, RespLen, TempBuffer); + SendCommandToACL(_Ident, L2CAP_CONFIG_RSP, RespLen, TempBuffer); // update state machine - if (rChannel.PSM == HID_CONTROL_CHANNEL) + if (rChannel.PSM == L2CAP_PSM_HID_CNTL) m_HIDControlChannel_Connected = true; - else if (rChannel.PSM == HID_INTERRUPT_CHANNEL) + else if (rChannel.PSM == L2CAP_PSM_HID_INTR) m_HIDInterruptChannel_Connected = true; - } void CWII_IPC_HLE_WiiMote::ReceiveConfigurationResponse(u8 _Ident, u8* _pData, u32 _Size) { - l2cap_conf_rsp* rsp = (l2cap_conf_rsp*)_pData; + l2cap_cfg_rsp_cp* rsp = (l2cap_cfg_rsp_cp*)_pData; INFO_LOG(WII_IPC_WIIMOTE, "[L2CAP] ReceiveConfigurationResponse"); DEBUG_LOG(WII_IPC_WIIMOTE, " SCID: 0x%04x", rsp->scid); DEBUG_LOG(WII_IPC_WIIMOTE, " Flags: 0x%04x", rsp->flags); DEBUG_LOG(WII_IPC_WIIMOTE, " Result: 0x%04x", rsp->result); - _dbg_assert_(WII_IPC_WIIMOTE, rsp->result == 0); + _dbg_assert_(WII_IPC_WIIMOTE, rsp->result == L2CAP_SUCCESS); // update state machine SChannel& rChannel = m_Channel[rsp->scid]; - if (rChannel.PSM == HID_CONTROL_CHANNEL) - { + if (rChannel.PSM == L2CAP_PSM_HID_CNTL) m_HIDControlChannel_Config = true; - INFO_LOG(WII_IPC_WIIMOTE, "Building HID_CONTROL_CHANNEL -- OK"); - } - else if (rChannel.PSM == HID_INTERRUPT_CHANNEL) - { + else if (rChannel.PSM == L2CAP_PSM_HID_INTR) m_HIDInterruptChannel_Config = true; - INFO_LOG(WII_IPC_WIIMOTE, "Building HID_INTERRUPT_CHANNEL -- OK"); - } } void CWII_IPC_HLE_WiiMote::ReceiveDisconnectionReq(u8 _Ident, u8* _pData, u32 _Size) { - SL2CAP_CommandDisconnectionReq* pCommandDisconnectionReq = (SL2CAP_CommandDisconnectionReq*)_pData; + l2cap_discon_req_cp* pCommandDisconnectionReq = (l2cap_discon_req_cp*)_pData; INFO_LOG(WII_IPC_WIIMOTE, "[L2CAP] ReceiveDisconnectionReq"); DEBUG_LOG(WII_IPC_WIIMOTE, " Ident: 0x%02x", _Ident); @@ -543,12 +516,12 @@ void CWII_IPC_HLE_WiiMote::ReceiveDisconnectionReq(u8 _Ident, u8* _pData, u32 _S DEBUG_LOG(WII_IPC_WIIMOTE, " SCID: 0x%04x", pCommandDisconnectionReq->scid); // response - SL2CAP_CommandDisconnectionResponse Rsp; + l2cap_discon_req_cp Rsp; Rsp.dcid = pCommandDisconnectionReq->dcid; Rsp.scid = pCommandDisconnectionReq->scid; INFO_LOG(WII_IPC_WIIMOTE, "[L2CAP] SendDisconnectionResponse"); - SendCommandToACL(_Ident, L2CAP_DISCONN_RSP, sizeof(SL2CAP_CommandDisconnectionResponse), (u8*)&Rsp); + SendCommandToACL(_Ident, L2CAP_DISCONNECT_RSP, sizeof(l2cap_discon_req_cp), (u8*)&Rsp); } // @@ -570,25 +543,24 @@ void CWII_IPC_HLE_WiiMote::SendConnectionRequest(u16 scid, u16 psm) rChannel.PSM = psm; rChannel.SCID = scid; - l2cap_conn_req cr; + l2cap_con_req_cp cr; cr.psm = psm; cr.scid = scid; - INFO_LOG(WII_IPC_WIIMOTE, "-----------------------------------------"); INFO_LOG(WII_IPC_WIIMOTE, "[L2CAP] SendConnectionRequest"); DEBUG_LOG(WII_IPC_WIIMOTE, " Psm: 0x%04x", cr.psm); DEBUG_LOG(WII_IPC_WIIMOTE, " Scid: 0x%04x", cr.scid); - SendCommandToACL(L2CAP_CONN_REQ, L2CAP_CONN_REQ, sizeof(l2cap_conn_req), (u8*)&cr); + SendCommandToACL(L2CAP_CONNECT_REQ, L2CAP_CONNECT_REQ, sizeof(l2cap_con_req_cp), (u8*)&cr); } -// We don't initiatively disconnet Wiimote though ... +// We don't initially disconnect Wiimote though ... void CWII_IPC_HLE_WiiMote::SendDisconnectRequest(u16 scid) { // create the channel SChannel& rChannel = m_Channel[scid]; - l2cap_disconn_req cr; + l2cap_discon_req_cp cr; cr.dcid = rChannel.DCID; cr.scid = rChannel.SCID; @@ -596,7 +568,7 @@ void CWII_IPC_HLE_WiiMote::SendDisconnectRequest(u16 scid) DEBUG_LOG(WII_IPC_WIIMOTE, " Dcid: 0x%04x", cr.dcid); DEBUG_LOG(WII_IPC_WIIMOTE, " Scid: 0x%04x", cr.scid); - SendCommandToACL(L2CAP_DISCONN_REQ, L2CAP_DISCONN_REQ, sizeof(l2cap_disconn_req), (u8*)&cr); + SendCommandToACL(L2CAP_DISCONNECT_REQ, L2CAP_DISCONNECT_REQ, sizeof(l2cap_discon_req_cp), (u8*)&cr); } void CWII_IPC_HLE_WiiMote::SendConfigurationRequest(u16 scid, u16 MTU, u16 FlushTimeOut) @@ -607,36 +579,43 @@ void CWII_IPC_HLE_WiiMote::SendConfigurationRequest(u16 scid, u16 MTU, u16 Flush u8 Buffer[1024]; int Offset = 0; - l2cap_conf_req* cr = (l2cap_conf_req*)&Buffer[Offset]; + l2cap_cfg_req_cp* cr = (l2cap_cfg_req_cp*)&Buffer[Offset]; cr->dcid = rChannel.DCID; - cr->flags = 0; - Offset += sizeof(l2cap_conf_req); - - SL2CAP_Options* pOptions; - - if (MTU == 0) MTU = rChannel.MTU; - pOptions = (SL2CAP_Options*)&Buffer[Offset]; - Offset += sizeof(SL2CAP_Options); - pOptions->type = 1; - pOptions->length = 2; - *(u16*)&Buffer[Offset] = MTU; - Offset += 2; - - if (FlushTimeOut == 0) FlushTimeOut = rChannel.FlushTimeOut; - pOptions = (SL2CAP_Options*)&Buffer[Offset]; - Offset += sizeof(SL2CAP_Options); - pOptions->type = 2; - pOptions->length = 2; - *(u16*)&Buffer[Offset] = FlushTimeOut; - Offset += 2; + cr->flags = 0; Offset += sizeof(l2cap_cfg_req_cp); INFO_LOG(WII_IPC_WIIMOTE, "[L2CAP] SendConfigurationRequest"); DEBUG_LOG(WII_IPC_WIIMOTE, " Dcid: 0x%04x", cr->dcid); DEBUG_LOG(WII_IPC_WIIMOTE, " Flags: 0x%04x", cr->flags); - DEBUG_LOG(WII_IPC_WIIMOTE, " MTU: 0x%04x", MTU); - DEBUG_LOG(WII_IPC_WIIMOTE, " FlushTimeOut: 0x%04x", FlushTimeOut); - SendCommandToACL(L2CAP_CONF_REQ, L2CAP_CONF_REQ, Offset, Buffer); + l2cap_cfg_opt_t* pOptions; + + // (shuffle2) currently we end up not appending options. this is because we don't + // negotiate after trying to set MTU = 0 fails (stack will respond with + // "configuration failed" msg...). This is still fine, we'll just use whatever the + // bt stack defaults to. + if (MTU || rChannel.MTU) + { + if (MTU == 0) + MTU = rChannel.MTU; + pOptions = (l2cap_cfg_opt_t*)&Buffer[Offset]; Offset += sizeof(l2cap_cfg_opt_t); + pOptions->type = L2CAP_OPT_MTU; + pOptions->length = L2CAP_OPT_MTU_SIZE; + *(u16*)&Buffer[Offset] = MTU; Offset += L2CAP_OPT_MTU_SIZE; + DEBUG_LOG(WII_IPC_WIIMOTE, " MTU: 0x%04x", MTU); + } + + if (FlushTimeOut || rChannel.FlushTimeOut) + { + if (FlushTimeOut == 0) + FlushTimeOut = rChannel.FlushTimeOut; + pOptions = (l2cap_cfg_opt_t*)&Buffer[Offset]; Offset += sizeof(l2cap_cfg_opt_t); + pOptions->type = L2CAP_OPT_FLUSH_TIMO; + pOptions->length = L2CAP_OPT_FLUSH_TIMO_SIZE; + *(u16*)&Buffer[Offset] = FlushTimeOut; Offset += L2CAP_OPT_FLUSH_TIMO_SIZE; + DEBUG_LOG(WII_IPC_WIIMOTE, " FlushTimeOut: 0x%04x", FlushTimeOut); + } + + SendCommandToACL(L2CAP_CONFIG_REQ, L2CAP_CONFIG_REQ, Offset, Buffer); } @@ -674,8 +653,8 @@ void CWII_IPC_HLE_WiiMote::SDPSendServiceSearchResponse(u16 cid, u16 Transaction CBigEndianBuffer buffer(DataFrame); int Offset = 0; - SL2CAP_Header* pHeader = (SL2CAP_Header*)&DataFrame[Offset]; Offset += sizeof(SL2CAP_Header); - pHeader->CID = cid; + l2cap_hdr_t* pHeader = (l2cap_hdr_t*)&DataFrame[Offset]; Offset += sizeof(l2cap_hdr_t); + pHeader->dcid = cid; buffer.Write8 (Offset, 0x03); Offset++; buffer.Write16(Offset, TransactionID); Offset += 2; // transaction ID @@ -686,8 +665,8 @@ void CWII_IPC_HLE_WiiMote::SDPSendServiceSearchResponse(u16 cid, u16 Transaction buffer.Write8(Offset, 0x00); Offset++; // no continuation state; - pHeader->Length = (u16)(Offset - sizeof(SL2CAP_Header)); - m_pHost->SendACLPacket(GetConnectionHandle(), DataFrame, pHeader->Length + sizeof(SL2CAP_Header)); + pHeader->length = (u16)(Offset - sizeof(l2cap_hdr_t)); + m_pHost->SendACLPacket(GetConnectionHandle(), DataFrame, pHeader->length + sizeof(l2cap_hdr_t)); } u32 ParseCont(u8* pCont) @@ -766,18 +745,18 @@ void CWII_IPC_HLE_WiiMote::SDPSendServiceAttributeResponse(u16 cid, u16 Transact CBigEndianBuffer buffer(DataFrame); int Offset = 0; - SL2CAP_Header* pHeader = (SL2CAP_Header*)&DataFrame[Offset]; Offset += sizeof(SL2CAP_Header); - pHeader->CID = cid; + l2cap_hdr_t* pHeader = (l2cap_hdr_t*)&DataFrame[Offset]; Offset += sizeof(l2cap_hdr_t); + pHeader->dcid = cid; buffer.Write8 (Offset, 0x05); Offset++; buffer.Write16(Offset, TransactionID); Offset += 2; // transaction ID memcpy(buffer.GetPointer(Offset), pPacket, packetSize); Offset += packetSize; - pHeader->Length = (u16)(Offset - sizeof(SL2CAP_Header)); - m_pHost->SendACLPacket(GetConnectionHandle(), DataFrame, pHeader->Length + sizeof(SL2CAP_Header)); + pHeader->length = (u16)(Offset - sizeof(l2cap_hdr_t)); + m_pHost->SendACLPacket(GetConnectionHandle(), DataFrame, pHeader->length + sizeof(l2cap_hdr_t)); - // Debugger::PrintDataBuffer(LogTypes::WIIMOTE, DataFrame, pHeader->Length + sizeof(SL2CAP_Header), "test response: "); + // Debugger::PrintDataBuffer(LogTypes::WIIMOTE, DataFrame, pHeader->length + sizeof(l2cap_hdr_t), "test response: "); } void CWII_IPC_HLE_WiiMote::HandleSDP(u16 cid, u8* _pData, u32 _Size) @@ -850,14 +829,14 @@ void CWII_IPC_HLE_WiiMote::SendCommandToACL(u8 _Ident, u8 _Code, u8 _CommandLeng u8 DataFrame[1024]; u32 Offset = 0; - SL2CAP_Header* pHeader = (SL2CAP_Header*)&DataFrame[Offset]; Offset += sizeof(SL2CAP_Header); - pHeader->Length = sizeof(SL2CAP_Command) + _CommandLength; - pHeader->CID = 0x0001; + l2cap_hdr_t* pHeader = (l2cap_hdr_t*)&DataFrame[Offset]; Offset += sizeof(l2cap_hdr_t); + pHeader->length = sizeof(l2cap_cmd_hdr_t) + _CommandLength; + pHeader->dcid = L2CAP_SIGNAL_CID; - SL2CAP_Command* pCommand = (SL2CAP_Command*)&DataFrame[Offset]; Offset += sizeof(SL2CAP_Command); + l2cap_cmd_hdr_t* pCommand = (l2cap_cmd_hdr_t*)&DataFrame[Offset]; Offset += sizeof(l2cap_cmd_hdr_t); pCommand->code = _Code; pCommand->ident = _Ident; - pCommand->len = _CommandLength; + pCommand->length = _CommandLength; memcpy(&DataFrame[Offset], _pCommandData, _CommandLength); @@ -866,36 +845,31 @@ void CWII_IPC_HLE_WiiMote::SendCommandToACL(u8 _Ident, u8 _Code, u8 _CommandLeng DEBUG_LOG(WII_IPC_WIIMOTE, " Code: 0x%02x", _Code); // send .... - m_pHost->SendACLPacket(GetConnectionHandle(), DataFrame, pHeader->Length + sizeof(SL2CAP_Header)); + m_pHost->SendACLPacket(GetConnectionHandle(), DataFrame, pHeader->length + sizeof(l2cap_hdr_t)); - // Debugger::PrintDataBuffer(LogTypes::WIIMOTE, DataFrame, pHeader->Length + sizeof(SL2CAP_Header), "m_pHost->SendACLPacket: "); + //Debugger::PrintDataBuffer(LogTypes::WIIMOTE, DataFrame, pHeader->length + sizeof(l2cap_hdr_t), "m_pHost->SendACLPacket: "); } - -// =================================================== -// On a second boot the _dbg_assert_(WII_IPC_WIIMOTE, DoesChannelExist(scid)) makes a report. -// However the game eventually starts and the Wiimote connects, but it takes at least ten seconds. -// --------------------------------------------------- void CWII_IPC_HLE_WiiMote::ReceiveL2capData(u16 scid, const void* _pData, u32 _Size) { -#if defined(HAVE_WX) && HAVE_WX + #if defined(HAVE_WX) && HAVE_WX if (NetPlay_WiimoteInput(m_ConnectionHandle & 0xFF, scid, _pData, _Size)) return; -#endif + #endif // Allocate DataFrame u8 DataFrame[1024]; u32 Offset = 0; - SL2CAP_Header* pHeader = (SL2CAP_Header*)DataFrame; - Offset += sizeof(SL2CAP_Header); + l2cap_hdr_t* pHeader = (l2cap_hdr_t*)DataFrame; + Offset += sizeof(l2cap_hdr_t); // Check if we are already reporting on this channel _dbg_assert_(WII_IPC_WIIMOTE, DoesChannelExist(scid)); SChannel& rChannel = m_Channel[scid]; - // Add an additonal 4 byte header to the Wiimote report - pHeader->CID = rChannel.DCID; - pHeader->Length = _Size; + // Add an additional 4 byte header to the Wiimote report + pHeader->dcid = rChannel.DCID; + pHeader->length = _Size; // Copy the Wiimote report to DataFrame memcpy(DataFrame + Offset, _pData, _Size); @@ -922,7 +896,7 @@ namespace Core INFO_LOG(WIIMOTE, "===================="); INFO_LOG(WIIMOTE, "Callback_WiimoteInterruptChannel: (Wiimote: #%i)", _number); DEBUG_LOG(WIIMOTE, " Data: %s", ArrayToString(pData, _Size, 0, 50).c_str()); - DEBUG_LOG(WIIMOTE, " Channel: %u", _channelID); + DEBUG_LOG(WIIMOTE, " Channel: %x", _channelID); s_Usb->m_WiiMotes[_number].ReceiveL2capData(_channelID, _pData, _Size); } diff --git a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_WiiMote.h b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_WiiMote.h index 4f561fa19e..50ba2eb414 100644 --- a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_WiiMote.h +++ b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_WiiMote.h @@ -26,111 +26,6 @@ class CWII_IPC_HLE_Device_usb_oh1_57e_305; CWII_IPC_HLE_Device_usb_oh1_57e_305* GetUsbPointer(); -enum -{ - SDP_CHANNEL = 0x01, - HID_CONTROL_CHANNEL = 0x11, - HID_INTERRUPT_CHANNEL= 0x13, - - // L2CAP command codes - L2CAP_COMMAND_REJ = 0x01, - L2CAP_CONN_REQ = 0x02, - L2CAP_CONN_RSP = 0x03, - L2CAP_CONF_REQ = 0x04, - L2CAP_CONF_RSP = 0x05, - L2CAP_DISCONN_REQ = 0x06, - L2CAP_DISCONN_RSP = 0x07, - L2CAP_ECHO_REQ = 0x08, - L2CAP_ECHO_RSP = 0x09, - L2CAP_INFO_REQ = 0x0a, - L2CAP_INFO_RSP = 0x0b, - - // connect result - L2CAP_CR_SUCCESS = 0x0000, - L2CAP_CR_PEND = 0x0001, - L2CAP_CR_BAD_PSM = 0x0002, - L2CAP_CR_SEC_BLOCK = 0x0003, - L2CAP_CR_NO_MEM = 0x0004, - - //connect status - L2CAP_CS_NO_INFO = 0x0000, - L2CAP_CS_AUTHEN_PEND = 0x0001, - L2CAP_CS_AUTHOR_PEND = 0x0002, -}; - -#pragma pack(push, 1) - -struct SL2CAP_Header -{ - u16 Length; - u16 CID; -}; - -struct SL2CAP_Command -{ - u8 code; - u8 ident; - u16 len; -}; - -struct SL2CAP_CommandConnectionReq // 0x02 -{ - u16 psm; - u16 scid; -}; - -struct SL2CAP_ConnectionResponse // 0x03 -{ - u16 dcid; - u16 scid; - u16 result; - u16 status; -}; - -struct SL2CAP_Options -{ - u8 type; - u8 length; -}; - -struct SL2CAP_OptionsMTU -{ - u16 MTU; -}; - -struct SL2CAP_OptionsFlushTimeOut -{ - u16 TimeOut; -}; - -struct SL2CAP_CommandConfigurationReq // 0x04 -{ - u16 dcid; - u16 flags; -}; - -struct SL2CAP_CommandConfigurationResponse // 0x05 -{ - u16 scid; - u16 flags; - u16 result; -}; - -struct SL2CAP_CommandDisconnectionReq // 0x06 -{ - u16 dcid; - u16 scid; -}; - -struct SL2CAP_CommandDisconnectionResponse // 0x07 -{ - u16 dcid; - u16 scid; -}; - -#pragma pack(pop) - - class CBigEndianBuffer { public: @@ -163,7 +58,7 @@ public: // ugly Host handling.... // we really have to clean all this code - int IsConnected() const { return m_Connected; } + bool IsConnected() const { return m_ConnectionState == CONN_COMPLETE; } bool LinkChannel(); void ResetChannels(); void Activate(bool ready); @@ -188,8 +83,14 @@ public: const u8* GetLinkKey() const { return m_LinkKey; } private: - // -1: inactive, 0: ready, 1: connecting 2: linking 3: connected & linked - int m_Connected; + enum ConnectionState + { + CONN_INACTIVE = -1, + CONN_READY, + CONN_LINKING, + CONN_COMPLETE + }; + ConnectionState m_ConnectionState; bool m_HIDControlChannel_Connected; bool m_HIDControlChannel_ConnectedWait; @@ -207,7 +108,7 @@ private: u8 features[HCI_FEATURES_SIZE]; u8 lmp_version; u16 lmp_subversion; - u8 m_LinkKey[16]; + u8 m_LinkKey[HCI_KEY_SIZE]; std::string m_Name; CWII_IPC_HLE_Device_usb_oh1_57e_305* m_pHost; diff --git a/Source/Core/Core/Src/IPC_HLE/hci.h b/Source/Core/Core/Src/IPC_HLE/hci.h index 721f498e0e..c3fb538b07 100644 --- a/Source/Core/Core/Src/IPC_HLE/hci.h +++ b/Source/Core/Core/Src/IPC_HLE/hci.h @@ -1,118 +1,122 @@ -#ifndef _NETBT_HCI_H_ -#define _NETBT_HCI_H_ +// Dolphin notes: +// Added some info from bluetooth.h +// All packet headers have had the packet type field removed. This is because +// IOS adds the packet type to the header, and strips it before returning the +// packet to the overlying bt stack. +/* $NetBSD: hci.h,v 1.33 2009/09/11 18:35:50 plunky Exp $ */ + +/*- + * Copyright (c) 2005 Iain Hibbert. + * Copyright (c) 2006 Itronix Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of Itronix Inc. may not be used to endorse + * or promote products derived from this software without specific + * prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY ITRONIX INC. ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ITRONIX INC. BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ +/*- + * Copyright (c) 2001 Maksim Yevmenkin + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $Id: hci.h,v 1.33 2009/09/11 18:35:50 plunky Exp $ + * $FreeBSD: src/sys/netgraph/bluetooth/include/ng_hci.h,v 1.6 2005/01/07 01:45:43 imp Exp $ + */ + +/* + * This file contains everything that applications need to know from + * Host Controller Interface (HCI). Information taken from Bluetooth + * Core Specifications (v1.1, v2.0 and v2.1) + * + * This file can be included by both kernel and userland applications. + * + * NOTE: Here and after Bluetooth device is called a "unit". Bluetooth + * specification refers to both devices and units. They are the + * same thing (I think), so to be consistent word "unit" will be + * used. + */ + +#pragma once + +// All structs in this file are packed #pragma pack(push, 1) -typedef u8 uint8_t; -#ifdef _WIN32 - typedef s8 int8_t; -#endif -typedef u16 uint16_t; -typedef s16 int16_t; -typedef u32 uint32_t; -typedef s32 int32_t; - - -#ifdef __cplusplus -extern "C" { +// This is not needed >= msvc10 +#ifdef _MSC_VER + typedef u8 uint8_t; + typedef s8 int8_t; + typedef u16 uint16_t; + typedef s16 int16_t; + typedef u32 uint32_t; + typedef s32 int32_t; #endif - /* - * Bluetooth Address Family Protocol Numbers - */ -#define BTPROTO_HCI 1 -#define BTPROTO_L2CAP 2 -#define BTPROTO_RFCOMM 3 -#define BTPROTO_SCO 4 +/* + * Bluetooth Address Family Protocol Numbers + */ +#define BTPROTO_HCI 1 +#define BTPROTO_L2CAP 2 +#define BTPROTO_RFCOMM 3 +#define BTPROTO_SCO 4 -#define BLUETOOTH_BDADDR_SIZE 6 +/* All sizes are in bytes */ +#define BLUETOOTH_BDADDR_SIZE 6 - typedef struct { - u8 b[BLUETOOTH_BDADDR_SIZE]; - } bdaddr_t; +/* + * Bluetooth device address + */ +typedef struct { + uint8_t b[BLUETOOTH_BDADDR_SIZE]; +} bdaddr_t; #define BDADDR_ANY {0, 0, 0, 0, 0, 0} - /* $NetBSD: hci.h,v 1.23 2008/03/06 20:56:26 plunky Exp $ */ - - /*- - * Copyright (c) 2005 Iain Hibbert. - * Copyright (c) 2006 Itronix Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of Itronix Inc. may not be used to endorse - * or promote products derived from this software without specific - * prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY ITRONIX INC. ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ITRONIX INC. BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - /*- - * Copyright (c) 2001 Maksim Yevmenkin - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $Id: hci.h,v 1.23 2008/03/06 20:56:26 plunky Exp $ - * $FreeBSD: src/sys/netgraph/bluetooth/include/ng_hci.h,v 1.6 2005/01/07 01:45:43 imp Exp $ - */ - - /* - * This file contains everything that applications need to know from - * Host Controller Interface (HCI). Information taken from Bluetooth - * Core Specifications (v1.1, v2.0 and v2.1) - * - * This file can be included by both kernel and userland applications. - * - * NOTE: Here and after Bluetooth device is called a "unit". Bluetooth - * specification refers to both devices and units. They are the - * same thing (I think), so to be consistent word "unit" will be - * used. - */ - - - - /************************************************************************** - ************************************************************************** - ** Common defines and types (HCI) - ************************************************************************** - **************************************************************************/ +/************************************************************************** + ************************************************************************** + ** Common defines and types (HCI) + ************************************************************************** + **************************************************************************/ #define HCI_LAP_SIZE 3 /* unit LAP */ #define HCI_KEY_SIZE 16 /* link key */ @@ -124,16 +128,17 @@ extern "C" { #define HCI_DEVNAME_SIZE 16 /* same as dv_xname */ #define HCI_COMMANDS_SIZE 64 /* supported commands mask */ - /* HCI specification */ -#define HCI_SPEC_V10 0x00 /* v1.0 */ +/* HCI specification */ +#define HCI_SPEC_V10 0x00 /* v1.0b */ #define HCI_SPEC_V11 0x01 /* v1.1 */ #define HCI_SPEC_V12 0x02 /* v1.2 */ -#define HCI_SPEC_V20 0x03 /* v2.0 */ -#define HCI_SPEC_V21 0x04 /* v2.1 */ - /* 0x05 - 0xFF - reserved for future use */ +#define HCI_SPEC_V20 0x03 /* v2.0 + EDR */ +#define HCI_SPEC_V21 0x04 /* v2.1 + EDR */ +#define HCI_SPEC_V30 0x05 /* v3.0 + HS */ +/* 0x06 - 0xFF - reserved for future use */ - /* LMP features (and page 0 of extended features) */ - /* ------------------- byte 0 --------------------*/ +/* LMP features (and page 0 of extended features) */ +/* ------------------- byte 0 --------------------*/ #define HCI_LMP_3SLOT 0x01 #define HCI_LMP_5SLOT 0x02 #define HCI_LMP_ENCRYPTION 0x04 @@ -142,7 +147,7 @@ extern "C" { #define HCI_LMP_ROLE_SWITCH 0x20 #define HCI_LMP_HOLD_MODE 0x40 #define HCI_LMP_SNIFF_MODE 0x80 - /* ------------------- byte 1 --------------------*/ +/* ------------------- byte 1 --------------------*/ #define HCI_LMP_PARK_MODE 0x01 #define HCI_LMP_RSSI 0x02 #define HCI_LMP_CHANNEL_QUALITY 0x04 @@ -151,7 +156,7 @@ extern "C" { #define HCI_LMP_HV3_PKT 0x20 #define HCI_LMP_ULAW_LOG 0x40 #define HCI_LMP_ALAW_LOG 0x80 - /* ------------------- byte 2 --------------------*/ +/* ------------------- byte 2 --------------------*/ #define HCI_LMP_CVSD 0x01 #define HCI_LMP_PAGISCHEME 0x02 #define HCI_LMP_POWER_CONTROL 0x04 @@ -160,8 +165,8 @@ extern "C" { #define HCI_LMP_FLOW_CONTROL_LAG1 0x20 #define HCI_LMP_FLOW_CONTROL_LAG2 0x40 #define HCI_LMP_BC_ENCRYPTION 0x80 - /* ------------------- byte 3 --------------------*/ - /* reserved 0x01 */ +/* ------------------- byte 3 --------------------*/ +/* reserved 0x01 */ #define HCI_LMP_EDR_ACL_2MBPS 0x02 #define HCI_LMP_EDR_ACL_3MBPS 0x04 #define HCI_LMP_ENHANCED_ISCAN 0x08 @@ -169,16 +174,16 @@ extern "C" { #define HCI_LMP_INTERLACED_PSCAN 0x20 #define HCI_LMP_RSSI_INQUIRY 0x40 #define HCI_LMP_EV3_PKT 0x80 - /* ------------------- byte 4 --------------------*/ +/* ------------------- byte 4 --------------------*/ #define HCI_LMP_EV4_PKT 0x01 #define HCI_LMP_EV5_PKT 0x02 - /* reserved 0x04 */ +/* reserved 0x04 */ #define HCI_LMP_AFH_CAPABLE_SLAVE 0x08 #define HCI_LMP_AFH_CLASS_SLAVE 0x10 - /* reserved 0x20 */ - /* reserved 0x40 */ +/* reserved 0x20 */ +/* reserved 0x40 */ #define HCI_LMP_3SLOT_EDR_ACL 0x80 - /* ------------------- byte 5 --------------------*/ +/* ------------------- byte 5 --------------------*/ #define HCI_LMP_5SLOT_EDR_ACL 0x01 #define HCI_LMP_SNIFF_SUBRATING 0x02 #define HCI_LMP_PAUSE_ENCRYPTION 0x04 @@ -187,32 +192,37 @@ extern "C" { #define HCI_LMP_EDR_eSCO_2MBPS 0x20 #define HCI_LMP_EDR_eSCO_3MBPS 0x40 #define HCI_LMP_3SLOT_EDR_eSCO 0x80 - /* ------------------- byte 6 --------------------*/ +/* ------------------- byte 6 --------------------*/ #define HCI_LMP_EXTENDED_INQUIRY 0x01 - /* reserved 0x02 */ - /* reserved 0x04 */ +/* reserved 0x02 */ +/* reserved 0x04 */ #define HCI_LMP_SIMPLE_PAIRING 0x08 #define HCI_LMP_ENCAPSULATED_PDU 0x10 #define HCI_LMP_ERRDATA_REPORTING 0x20 #define HCI_LMP_NOFLUSH_PB_FLAG 0x40 - /* reserved 0x80 */ - /* ------------------- byte 7 --------------------*/ +/* reserved 0x80 */ +/* ------------------- byte 7 --------------------*/ #define HCI_LMP_LINK_SUPERVISION_TO 0x01 #define HCI_LMP_INQ_RSP_TX_POWER 0x02 +#define HCI_LMP_ENHANCED_POWER_CONTROL 0x04 #define HCI_LMP_EXTENDED_FEATURES 0x80 - /* Link types */ +/* page 1 of extended features */ +/* ------------------- byte 0 --------------------*/ +#define HCI_LMP_SSP 0x01 + +/* Link types */ #define HCI_LINK_SCO 0x00 /* Voice */ #define HCI_LINK_ACL 0x01 /* Data */ #define HCI_LINK_eSCO 0x02 /* eSCO */ - /* 0x03 - 0xFF - reserved for future use */ +/* 0x03 - 0xFF - reserved for future use */ - /* - * ACL/SCO packet type bits are set to enable the - * packet type, except for 2MBPS and 3MBPS when they - * are unset to enable the packet type. - */ - /* ACL Packet types for "Create Connection" */ +/* + * ACL/SCO packet type bits are set to enable the + * packet type, except for 2MBPS and 3MBPS when they + * are unset to enable the packet type. + */ +/* ACL Packet types for "Create Connection" */ #define HCI_PKT_2MBPS_DH1 0x0002 #define HCI_PKT_3MBPS_DH1 0x0004 #define HCI_PKT_DM1 0x0008 @@ -226,7 +236,7 @@ extern "C" { #define HCI_PKT_DM5 0x4000 #define HCI_PKT_DH5 0x8000 - /* SCO Packet types for "Setup Synchronous Connection" */ +/* SCO Packet types for "Setup Synchronous Connection" */ #define HCI_PKT_HV1 0x0001 #define HCI_PKT_HV2 0x0002 #define HCI_PKT_HV3 0x0004 @@ -238,87 +248,87 @@ extern "C" { #define HCI_PKT_2MBPS_EV5 0x0100 #define HCI_PKT_3MBPS_EV5 0x0200 - /* - * Connection modes/Unit modes - * - * This is confusing. It means that one of the units change its mode - * for the specific connection. For example one connection was put on - * hold (but i could be wrong :) - */ +/* + * Connection modes/Unit modes + * + * This is confusing. It means that one of the units change its mode + * for the specific connection. For example one connection was put on + * hold (but i could be wrong :) + */ - /* Page scan modes (are deprecated) */ +/* Page scan modes (are deprecated) */ #define HCI_MANDATORY_PAGE_SCAN_MODE 0x00 #define HCI_OPTIONAL_PAGE_SCAN_MODE1 0x01 #define HCI_OPTIONAL_PAGE_SCAN_MODE2 0x02 #define HCI_OPTIONAL_PAGE_SCAN_MODE3 0x03 - /* 0x04 - 0xFF - reserved for future use */ +/* 0x04 - 0xFF - reserved for future use */ - /* Page scan repetition modes */ +/* Page scan repetition modes */ #define HCI_SCAN_REP_MODE0 0x00 #define HCI_SCAN_REP_MODE1 0x01 #define HCI_SCAN_REP_MODE2 0x02 - /* 0x03 - 0xFF - reserved for future use */ +/* 0x03 - 0xFF - reserved for future use */ - /* Page scan period modes */ +/* Page scan period modes */ #define HCI_PAGE_SCAN_PERIOD_MODE0 0x00 #define HCI_PAGE_SCAN_PERIOD_MODE1 0x01 #define HCI_PAGE_SCAN_PERIOD_MODE2 0x02 - /* 0x03 - 0xFF - reserved for future use */ +/* 0x03 - 0xFF - reserved for future use */ - /* Scan enable */ +/* Scan enable */ #define HCI_NO_SCAN_ENABLE 0x00 #define HCI_INQUIRY_SCAN_ENABLE 0x01 #define HCI_PAGE_SCAN_ENABLE 0x02 - /* 0x04 - 0xFF - reserved for future use */ +/* 0x04 - 0xFF - reserved for future use */ - /* Hold mode activities */ +/* Hold mode activities */ #define HCI_HOLD_MODE_NO_CHANGE 0x00 #define HCI_HOLD_MODE_SUSPEND_PAGE_SCAN 0x01 #define HCI_HOLD_MODE_SUSPEND_INQUIRY_SCAN 0x02 #define HCI_HOLD_MODE_SUSPEND_PERIOD_INQUIRY 0x04 - /* 0x08 - 0x80 - reserved for future use */ +/* 0x08 - 0x80 - reserved for future use */ - /* Connection roles */ +/* Connection roles */ #define HCI_ROLE_MASTER 0x00 #define HCI_ROLE_SLAVE 0x01 - /* 0x02 - 0xFF - reserved for future use */ +/* 0x02 - 0xFF - reserved for future use */ - /* Key flags */ +/* Key flags */ #define HCI_USE_SEMI_PERMANENT_LINK_KEYS 0x00 #define HCI_USE_TEMPORARY_LINK_KEY 0x01 - /* 0x02 - 0xFF - reserved for future use */ +/* 0x02 - 0xFF - reserved for future use */ - /* Pin types */ +/* Pin types */ #define HCI_PIN_TYPE_VARIABLE 0x00 #define HCI_PIN_TYPE_FIXED 0x01 - /* Link key types */ +/* Link key types */ #define HCI_LINK_KEY_TYPE_COMBINATION_KEY 0x00 #define HCI_LINK_KEY_TYPE_LOCAL_UNIT_KEY 0x01 #define HCI_LINK_KEY_TYPE_REMOTE_UNIT_KEY 0x02 - /* 0x03 - 0xFF - reserved for future use */ +/* 0x03 - 0xFF - reserved for future use */ - /* Encryption modes */ +/* Encryption modes */ #define HCI_ENCRYPTION_MODE_NONE 0x00 #define HCI_ENCRYPTION_MODE_P2P 0x01 #define HCI_ENCRYPTION_MODE_ALL 0x02 - /* 0x03 - 0xFF - reserved for future use */ +/* 0x03 - 0xFF - reserved for future use */ - /* Quality of service types */ +/* Quality of service types */ #define HCI_SERVICE_TYPE_NO_TRAFFIC 0x00 #define HCI_SERVICE_TYPE_BEST_EFFORT 0x01 #define HCI_SERVICE_TYPE_GUARANTEED 0x02 - /* 0x03 - 0xFF - reserved for future use */ +/* 0x03 - 0xFF - reserved for future use */ - /* Link policy settings */ +/* Link policy settings */ #define HCI_LINK_POLICY_DISABLE_ALL_LM_MODES 0x0000 #define HCI_LINK_POLICY_ENABLE_ROLE_SWITCH 0x0001 /* Master/Slave switch */ #define HCI_LINK_POLICY_ENABLE_HOLD_MODE 0x0002 #define HCI_LINK_POLICY_ENABLE_SNIFF_MODE 0x0004 #define HCI_LINK_POLICY_ENABLE_PARK_MODE 0x0008 - /* 0x0010 - 0x8000 - reserved for future use */ +/* 0x0010 - 0x8000 - reserved for future use */ - /* Event masks */ +/* Event masks */ #define HCI_EVMSK_ALL 0x00000000ffffffff #define HCI_EVMSK_NONE 0x0000000000000000 #define HCI_EVMSK_INQUIRY_COMPL 0x0000000000000001 @@ -353,1961 +363,1966 @@ extern "C" { #define HCI_EVMSK_QOS_VIOLATION 0x0000000020000000 #define HCI_EVMSK_PAGE_SCAN_MODE_CHANGE 0x0000000040000000 #define HCI_EVMSK_PAGE_SCAN_REP_MODE_CHANGE 0x0000000080000000 - /* 0x0000000100000000 - 0x8000000000000000 - reserved for future use */ +/* 0x0000000100000000 - 0x8000000000000000 - reserved for future use */ - /* Filter types */ +/* Filter types */ #define HCI_FILTER_TYPE_NONE 0x00 #define HCI_FILTER_TYPE_INQUIRY_RESULT 0x01 #define HCI_FILTER_TYPE_CON_SETUP 0x02 - /* 0x03 - 0xFF - reserved for future use */ +/* 0x03 - 0xFF - reserved for future use */ - /* Filter condition types for HCI_FILTER_TYPE_INQUIRY_RESULT */ +/* Filter condition types for HCI_FILTER_TYPE_INQUIRY_RESULT */ #define HCI_FILTER_COND_INQUIRY_NEW_UNIT 0x00 #define HCI_FILTER_COND_INQUIRY_UNIT_CLASS 0x01 #define HCI_FILTER_COND_INQUIRY_BDADDR 0x02 - /* 0x03 - 0xFF - reserved for future use */ +/* 0x03 - 0xFF - reserved for future use */ - /* Filter condition types for HCI_FILTER_TYPE_CON_SETUP */ +/* Filter condition types for HCI_FILTER_TYPE_CON_SETUP */ #define HCI_FILTER_COND_CON_ANY_UNIT 0x00 #define HCI_FILTER_COND_CON_UNIT_CLASS 0x01 #define HCI_FILTER_COND_CON_BDADDR 0x02 - /* 0x03 - 0xFF - reserved for future use */ +/* 0x03 - 0xFF - reserved for future use */ - /* Xmit level types */ +/* Xmit level types */ #define HCI_XMIT_LEVEL_CURRENT 0x00 #define HCI_XMIT_LEVEL_MAXIMUM 0x01 - /* 0x02 - 0xFF - reserved for future use */ +/* 0x02 - 0xFF - reserved for future use */ - /* Host Controller to Host flow control */ +/* Host Controller to Host flow control */ #define HCI_HC2H_FLOW_CONTROL_NONE 0x00 #define HCI_HC2H_FLOW_CONTROL_ACL 0x01 #define HCI_HC2H_FLOW_CONTROL_SCO 0x02 #define HCI_HC2H_FLOW_CONTROL_BOTH 0x03 - /* 0x04 - 0xFF - reserved future use */ +/* 0x04 - 0xFF - reserved future use */ - /* Loopback modes */ +/* Loopback modes */ #define HCI_LOOPBACK_NONE 0x00 #define HCI_LOOPBACK_LOCAL 0x01 #define HCI_LOOPBACK_REMOTE 0x02 - /* 0x03 - 0xFF - reserved future use */ +/* 0x03 - 0xFF - reserved future use */ - /************************************************************************** - ************************************************************************** - ** Link level defines, headers and types - ************************************************************************** - **************************************************************************/ +/************************************************************************** + ************************************************************************** + ** Link level defines, headers and types + ************************************************************************** + **************************************************************************/ - /* - * Macro(s) to combine OpCode and extract OGF (OpCode Group Field) - * and OCF (OpCode Command Field) from OpCode. - */ +/* + * Macro(s) to combine OpCode and extract OGF (OpCode Group Field) + * and OCF (OpCode Command Field) from OpCode. + */ #define HCI_OPCODE(gf,cf) ((((gf) & 0x3f) << 10) | ((cf) & 0x3ff)) #define HCI_OCF(op) ((op) & 0x3ff) #define HCI_OGF(op) (((op) >> 10) & 0x3f) - /* - * Macro(s) to extract/combine connection handle, BC (Broadcast) and - * PB (Packet boundary) flags. - */ +/* + * Macro(s) to extract/combine connection handle, BC (Broadcast) and + * PB (Packet boundary) flags. + */ #define HCI_CON_HANDLE(h) ((h) & 0x0fff) #define HCI_PB_FLAG(h) (((h) & 0x3000) >> 12) #define HCI_BC_FLAG(h) (((h) & 0xc000) >> 14) #define HCI_MK_CON_HANDLE(h, pb, bc) \ - (((h) & 0x0fff) | (((pb) & 3) << 12) | (((bc) & 3) << 14)) + (((h) & 0x0fff) | (((pb) & 3) << 12) | (((bc) & 3) << 14)) - /* PB flag values */ - /* 00 - reserved for future use */ +/* PB flag values */ + /* 00 - reserved for future use */ #define HCI_PACKET_FRAGMENT 0x1 #define HCI_PACKET_START 0x2 - /* 11 - reserved for future use */ + /* 11 - reserved for future use */ - /* BC flag values */ +/* BC flag values */ #define HCI_POINT2POINT 0x0 /* only Host controller to Host */ #define HCI_BROADCAST_ACTIVE 0x1 /* both directions */ #define HCI_BROADCAST_PICONET 0x2 /* both directions */ - /* 11 - reserved for future use */ + /* 11 - reserved for future use */ - /* HCI command packet header */ - typedef struct { - uint8_t type; /* MUST be 0x01 */ - uint16_t opcode; /* OpCode */ - uint8_t length; /* parameter(s) length in bytes */ - } hci_cmd_hdr_t; +/* HCI command packet header */ +typedef struct { + //uint8_t type; /* MUST be 0x01 */ + uint16_t opcode; /* OpCode */ + uint8_t length; /* parameter(s) length in bytes */ +} hci_cmd_hdr_t; #define HCI_CMD_PKT 0x01 #define HCI_CMD_PKT_SIZE (sizeof(hci_cmd_hdr_t) + 0xff) - /* ACL data packet header */ - typedef struct { - uint8_t type; /* MUST be 0x02 */ - uint16_t con_handle; /* connection handle + PB + BC flags */ - uint16_t length; /* payload length in bytes */ - } hci_acldata_hdr_t; +/* ACL data packet header */ +typedef struct { + //uint8_t type; /* MUST be 0x02 */ + uint16_t con_handle; /* connection handle + PB + BC flags */ + uint16_t length; /* payload length in bytes */ +} hci_acldata_hdr_t; #define HCI_ACL_DATA_PKT 0x02 #define HCI_ACL_PKT_SIZE (sizeof(hci_acldata_hdr_t) + 0xffff) - /* SCO data packet header */ - typedef struct { - uint8_t type; /* MUST be 0x03 */ - uint16_t con_handle; /* connection handle + reserved bits */ - uint8_t length; /* payload length in bytes */ - } hci_scodata_hdr_t; +/* SCO data packet header */ +typedef struct { + //uint8_t type; /* MUST be 0x03 */ + uint16_t con_handle; /* connection handle + reserved bits */ + uint8_t length; /* payload length in bytes */ +} hci_scodata_hdr_t; #define HCI_SCO_DATA_PKT 0x03 #define HCI_SCO_PKT_SIZE (sizeof(hci_scodata_hdr_t) + 0xff) - /* HCI event packet header */ - typedef struct { - uint8_t type; /* MUST be 0x04 */ - uint8_t event; /* event */ - uint8_t length; /* parameter(s) length in bytes */ - } hci_event_hdr_t; +/* HCI event packet header */ +typedef struct { + //uint8_t type; /* MUST be 0x04 */ + uint8_t event; /* event */ + uint8_t length; /* parameter(s) length in bytes */ +} hci_event_hdr_t; #define HCI_EVENT_PKT 0x04 #define HCI_EVENT_PKT_SIZE (sizeof(hci_event_hdr_t) + 0xff) - /* HCI status return parameter */ - typedef struct { - uint8_t status; /* 0x00 - success */ - } hci_status_rp; +/* HCI status return parameter */ +typedef struct { + uint8_t status; /* 0x00 - success */ +} hci_status_rp; - /************************************************************************** - ************************************************************************** - ** OGF 0x01 Link control commands and return parameters - ************************************************************************** - **************************************************************************/ +/************************************************************************** + ************************************************************************** + ** OGF 0x01 Link control commands and return parameters + ************************************************************************** + **************************************************************************/ #define HCI_OGF_LINK_CONTROL 0x01 #define HCI_OCF_INQUIRY 0x0001 #define HCI_CMD_INQUIRY 0x0401 - typedef struct { - uint8_t lap[HCI_LAP_SIZE]; /* LAP */ - uint8_t inquiry_length; /* (N x 1.28) sec */ - uint8_t num_responses; /* Max. # of responses */ - } hci_inquiry_cp; - /* No return parameter(s) */ +typedef struct { + uint8_t lap[HCI_LAP_SIZE]; /* LAP */ + uint8_t inquiry_length; /* (N x 1.28) sec */ + uint8_t num_responses; /* Max. # of responses */ +} hci_inquiry_cp; +/* No return parameter(s) */ #define HCI_OCF_INQUIRY_CANCEL 0x0002 #define HCI_CMD_INQUIRY_CANCEL 0x0402 - /* No command parameter(s) */ - typedef hci_status_rp hci_inquiry_cancel_rp; +/* No command parameter(s) */ +typedef hci_status_rp hci_inquiry_cancel_rp; #define HCI_OCF_PERIODIC_INQUIRY 0x0003 #define HCI_CMD_PERIODIC_INQUIRY 0x0403 - typedef struct { - uint16_t max_period_length; /* Max. and min. amount of time */ - uint16_t min_period_length; /* between consecutive inquiries */ - uint8_t lap[HCI_LAP_SIZE]; /* LAP */ - uint8_t inquiry_length; /* (inquiry_length * 1.28) sec */ - uint8_t num_responses; /* Max. # of responses */ - } hci_periodic_inquiry_cp; +typedef struct { + uint16_t max_period_length; /* Max. and min. amount of time */ + uint16_t min_period_length; /* between consecutive inquiries */ + uint8_t lap[HCI_LAP_SIZE]; /* LAP */ + uint8_t inquiry_length; /* (inquiry_length * 1.28) sec */ + uint8_t num_responses; /* Max. # of responses */ +} hci_periodic_inquiry_cp; - typedef hci_status_rp hci_periodic_inquiry_rp; +typedef hci_status_rp hci_periodic_inquiry_rp; #define HCI_OCF_EXIT_PERIODIC_INQUIRY 0x0004 #define HCI_CMD_EXIT_PERIODIC_INQUIRY 0x0404 - /* No command parameter(s) */ - typedef hci_status_rp hci_exit_periodic_inquiry_rp; +/* No command parameter(s) */ +typedef hci_status_rp hci_exit_periodic_inquiry_rp; #define HCI_OCF_CREATE_CON 0x0005 #define HCI_CMD_CREATE_CON 0x0405 - typedef struct { - bdaddr_t bdaddr; /* destination address */ - uint16_t pkt_type; /* packet type */ - uint8_t page_scan_rep_mode; /* page scan repetition mode */ - uint8_t page_scan_mode; /* reserved - set to 0x00 */ - uint16_t clock_offset; /* clock offset */ - uint8_t accept_role_switch; /* accept role switch? 0x00 == No */ - } hci_create_con_cp; - /* No return parameter(s) */ +typedef struct { + bdaddr_t bdaddr; /* destination address */ + uint16_t pkt_type; /* packet type */ + uint8_t page_scan_rep_mode; /* page scan repetition mode */ + uint8_t page_scan_mode; /* reserved - set to 0x00 */ + uint16_t clock_offset; /* clock offset */ + uint8_t accept_role_switch; /* accept role switch? 0x00 == No */ +} hci_create_con_cp; +/* No return parameter(s) */ #define HCI_OCF_DISCONNECT 0x0006 #define HCI_CMD_DISCONNECT 0x0406 - typedef struct { - uint16_t con_handle; /* connection handle */ - uint8_t reason; /* reason to disconnect */ - } hci_discon_cp; - /* No return parameter(s) */ +typedef struct { + uint16_t con_handle; /* connection handle */ + uint8_t reason; /* reason to disconnect */ +} hci_discon_cp; +/* No return parameter(s) */ - /* Add SCO Connection is deprecated */ +/* Add SCO Connection is deprecated */ #define HCI_OCF_ADD_SCO_CON 0x0007 #define HCI_CMD_ADD_SCO_CON 0x0407 - typedef struct { - uint16_t con_handle; /* connection handle */ - uint16_t pkt_type; /* packet type */ - } hci_add_sco_con_cp; - /* No return parameter(s) */ +typedef struct { + uint16_t con_handle; /* connection handle */ + uint16_t pkt_type; /* packet type */ +} hci_add_sco_con_cp; +/* No return parameter(s) */ #define HCI_OCF_CREATE_CON_CANCEL 0x0008 #define HCI_CMD_CREATE_CON_CANCEL 0x0408 - typedef struct { - bdaddr_t bdaddr; /* destination address */ - } hci_create_con_cancel_cp; +typedef struct { + bdaddr_t bdaddr; /* destination address */ +} hci_create_con_cancel_cp; - typedef struct { - uint8_t status; /* 0x00 - success */ - bdaddr_t bdaddr; /* destination address */ - } hci_create_con_cancel_rp; +typedef struct { + uint8_t status; /* 0x00 - success */ + bdaddr_t bdaddr; /* destination address */ +} hci_create_con_cancel_rp; #define HCI_OCF_ACCEPT_CON 0x0009 #define HCI_CMD_ACCEPT_CON 0x0409 - typedef struct { - bdaddr_t bdaddr; /* address of unit to be connected */ - uint8_t role; /* connection role */ - } hci_accept_con_cp; - /* No return parameter(s) */ +typedef struct { + bdaddr_t bdaddr; /* address of unit to be connected */ + uint8_t role; /* connection role */ +} hci_accept_con_cp; +/* No return parameter(s) */ #define HCI_OCF_REJECT_CON 0x000a #define HCI_CMD_REJECT_CON 0x040A - typedef struct { - bdaddr_t bdaddr; /* remote address */ - uint8_t reason; /* reason to reject */ - } hci_reject_con_cp; - /* No return parameter(s) */ +typedef struct { + bdaddr_t bdaddr; /* remote address */ + uint8_t reason; /* reason to reject */ +} hci_reject_con_cp; +/* No return parameter(s) */ #define HCI_OCF_LINK_KEY_REP 0x000b #define HCI_CMD_LINK_KEY_REP 0x040B - typedef struct { - bdaddr_t bdaddr; /* remote address */ - uint8_t key[HCI_KEY_SIZE]; /* key */ - } hci_link_key_rep_cp; +typedef struct { + bdaddr_t bdaddr; /* remote address */ + uint8_t key[HCI_KEY_SIZE]; /* key */ +} hci_link_key_rep_cp; - typedef struct { - uint8_t status; /* 0x00 - success */ - bdaddr_t bdaddr; /* unit address */ - } hci_link_key_rep_rp; +typedef struct { + uint8_t status; /* 0x00 - success */ + bdaddr_t bdaddr; /* unit address */ +} hci_link_key_rep_rp; #define HCI_OCF_LINK_KEY_NEG_REP 0x000c #define HCI_CMD_LINK_KEY_NEG_REP 0x040C - typedef struct { - bdaddr_t bdaddr; /* remote address */ - } hci_link_key_neg_rep_cp; +typedef struct { + bdaddr_t bdaddr; /* remote address */ +} hci_link_key_neg_rep_cp; - typedef struct { - uint8_t status; /* 0x00 - success */ - bdaddr_t bdaddr; /* unit address */ - } hci_link_key_neg_rep_rp; +typedef struct { + uint8_t status; /* 0x00 - success */ + bdaddr_t bdaddr; /* unit address */ +} hci_link_key_neg_rep_rp; #define HCI_OCF_PIN_CODE_REP 0x000d #define HCI_CMD_PIN_CODE_REP 0x040D - typedef struct { - bdaddr_t bdaddr; /* remote address */ - uint8_t pin_size; /* pin code length (in bytes) */ - uint8_t pin[HCI_PIN_SIZE]; /* pin code */ - } hci_pin_code_rep_cp; +typedef struct { + bdaddr_t bdaddr; /* remote address */ + uint8_t pin_size; /* pin code length (in bytes) */ + uint8_t pin[HCI_PIN_SIZE]; /* pin code */ +} hci_pin_code_rep_cp; - typedef struct { - uint8_t status; /* 0x00 - success */ - bdaddr_t bdaddr; /* unit address */ - } hci_pin_code_rep_rp; +typedef struct { + uint8_t status; /* 0x00 - success */ + bdaddr_t bdaddr; /* unit address */ +} hci_pin_code_rep_rp; #define HCI_OCF_PIN_CODE_NEG_REP 0x000e #define HCI_CMD_PIN_CODE_NEG_REP 0x040E - typedef struct { - bdaddr_t bdaddr; /* remote address */ - } hci_pin_code_neg_rep_cp; +typedef struct { + bdaddr_t bdaddr; /* remote address */ +} hci_pin_code_neg_rep_cp; - typedef struct { - uint8_t status; /* 0x00 - success */ - bdaddr_t bdaddr; /* unit address */ - } hci_pin_code_neg_rep_rp; +typedef struct { + uint8_t status; /* 0x00 - success */ + bdaddr_t bdaddr; /* unit address */ +} hci_pin_code_neg_rep_rp; #define HCI_OCF_CHANGE_CON_PACKET_TYPE 0x000f #define HCI_CMD_CHANGE_CON_PACKET_TYPE 0x040F - typedef struct { - uint16_t con_handle; /* connection handle */ - uint16_t pkt_type; /* packet type */ - } hci_change_con_pkt_type_cp; - /* No return parameter(s) */ +typedef struct { + uint16_t con_handle; /* connection handle */ + uint16_t pkt_type; /* packet type */ +} hci_change_con_pkt_type_cp; +/* No return parameter(s) */ #define HCI_OCF_AUTH_REQ 0x0011 #define HCI_CMD_AUTH_REQ 0x0411 - typedef struct { - uint16_t con_handle; /* connection handle */ - } hci_auth_req_cp; - /* No return parameter(s) */ +typedef struct { + uint16_t con_handle; /* connection handle */ +} hci_auth_req_cp; +/* No return parameter(s) */ #define HCI_OCF_SET_CON_ENCRYPTION 0x0013 #define HCI_CMD_SET_CON_ENCRYPTION 0x0413 - typedef struct { - uint16_t con_handle; /* connection handle */ - uint8_t encryption_enable; /* 0x00 - disable, 0x01 - enable */ - } hci_set_con_encryption_cp; - /* No return parameter(s) */ +typedef struct { + uint16_t con_handle; /* connection handle */ + uint8_t encryption_enable; /* 0x00 - disable, 0x01 - enable */ +} hci_set_con_encryption_cp; +/* No return parameter(s) */ #define HCI_OCF_CHANGE_CON_LINK_KEY 0x0015 #define HCI_CMD_CHANGE_CON_LINK_KEY 0x0415 - typedef struct { - uint16_t con_handle; /* connection handle */ - } hci_change_con_link_key_cp; - /* No return parameter(s) */ +typedef struct { + uint16_t con_handle; /* connection handle */ +} hci_change_con_link_key_cp; +/* No return parameter(s) */ #define HCI_OCF_MASTER_LINK_KEY 0x0017 #define HCI_CMD_MASTER_LINK_KEY 0x0417 - typedef struct { - uint8_t key_flag; /* key flag */ - } hci_master_link_key_cp; - /* No return parameter(s) */ +typedef struct { + uint8_t key_flag; /* key flag */ +} hci_master_link_key_cp; +/* No return parameter(s) */ #define HCI_OCF_REMOTE_NAME_REQ 0x0019 #define HCI_CMD_REMOTE_NAME_REQ 0x0419 - typedef struct { - bdaddr_t bdaddr; /* remote address */ - uint8_t page_scan_rep_mode; /* page scan repetition mode */ - uint8_t page_scan_mode; /* page scan mode */ - uint16_t clock_offset; /* clock offset */ - } hci_remote_name_req_cp; - /* No return parameter(s) */ +typedef struct { + bdaddr_t bdaddr; /* remote address */ + uint8_t page_scan_rep_mode; /* page scan repetition mode */ + uint8_t page_scan_mode; /* page scan mode */ + uint16_t clock_offset; /* clock offset */ +} hci_remote_name_req_cp; +/* No return parameter(s) */ #define HCI_OCF_REMOTE_NAME_REQ_CANCEL 0x001a #define HCI_CMD_REMOTE_NAME_REQ_CANCEL 0x041A - typedef struct { - bdaddr_t bdaddr; /* remote address */ - } hci_remote_name_req_cancel_cp; +typedef struct { + bdaddr_t bdaddr; /* remote address */ +} hci_remote_name_req_cancel_cp; - typedef struct { - uint8_t status; /* 0x00 - success */ - bdaddr_t bdaddr; /* remote address */ - } hci_remote_name_req_cancel_rp; +typedef struct { + uint8_t status; /* 0x00 - success */ + bdaddr_t bdaddr; /* remote address */ +} hci_remote_name_req_cancel_rp; #define HCI_OCF_READ_REMOTE_FEATURES 0x001b #define HCI_CMD_READ_REMOTE_FEATURES 0x041B - typedef struct { - uint16_t con_handle; /* connection handle */ - } hci_read_remote_features_cp; - /* No return parameter(s) */ +typedef struct { + uint16_t con_handle; /* connection handle */ +} hci_read_remote_features_cp; +/* No return parameter(s) */ #define HCI_OCF_READ_REMOTE_EXTENDED_FEATURES 0x001c #define HCI_CMD_READ_REMOTE_EXTENDED_FEATURES 0x041C - typedef struct { - uint16_t con_handle; /* connection handle */ - uint8_t page; /* page number */ - } hci_read_remote_extended_features_cp; - /* No return parameter(s) */ +typedef struct { + uint16_t con_handle; /* connection handle */ + uint8_t page; /* page number */ +} hci_read_remote_extended_features_cp; +/* No return parameter(s) */ #define HCI_OCF_READ_REMOTE_VER_INFO 0x001d #define HCI_CMD_READ_REMOTE_VER_INFO 0x041D - typedef struct { - uint16_t con_handle; /* connection handle */ - } hci_read_remote_ver_info_cp; - /* No return parameter(s) */ +typedef struct { + uint16_t con_handle; /* connection handle */ +} hci_read_remote_ver_info_cp; +/* No return parameter(s) */ #define HCI_OCF_READ_CLOCK_OFFSET 0x001f #define HCI_CMD_READ_CLOCK_OFFSET 0x041F - typedef struct { - uint16_t con_handle; /* connection handle */ - } hci_read_clock_offset_cp; - /* No return parameter(s) */ +typedef struct { + uint16_t con_handle; /* connection handle */ +} hci_read_clock_offset_cp; +/* No return parameter(s) */ #define HCI_OCF_READ_LMP_HANDLE 0x0020 #define HCI_CMD_READ_LMP_HANDLE 0x0420 - typedef struct { - uint16_t con_handle; /* connection handle */ - } hci_read_lmp_handle_cp; +typedef struct { + uint16_t con_handle; /* connection handle */ +} hci_read_lmp_handle_cp; - typedef struct { - uint8_t status; /* 0x00 - success */ - uint16_t con_handle; /* connection handle */ - uint8_t lmp_handle; /* LMP handle */ - uint32_t reserved; /* reserved */ - } hci_read_lmp_handle_rp; +typedef struct { + uint8_t status; /* 0x00 - success */ + uint16_t con_handle; /* connection handle */ + uint8_t lmp_handle; /* LMP handle */ + uint32_t reserved; /* reserved */ +} hci_read_lmp_handle_rp; #define HCI_OCF_SETUP_SCO_CON 0x0028 #define HCI_CMD_SETUP_SCO_CON 0x0428 - typedef struct { - uint16_t con_handle; /* connection handle */ - uint32_t tx_bandwidth; /* transmit bandwidth */ - uint32_t rx_bandwidth; /* receive bandwidth */ - uint16_t latency; /* maximum latency */ - uint16_t voice; /* voice setting */ - uint8_t rt_effort; /* retransmission effort */ - uint16_t pkt_type; /* packet types */ - } hci_setup_sco_con_cp; - /* No return parameter(s) */ +typedef struct { + uint16_t con_handle; /* connection handle */ + uint32_t tx_bandwidth; /* transmit bandwidth */ + uint32_t rx_bandwidth; /* receive bandwidth */ + uint16_t latency; /* maximum latency */ + uint16_t voice; /* voice setting */ + uint8_t rt_effort; /* retransmission effort */ + uint16_t pkt_type; /* packet types */ +} hci_setup_sco_con_cp; +/* No return parameter(s) */ #define HCI_OCF_ACCEPT_SCO_CON_REQ 0x0029 #define HCI_CMD_ACCEPT_SCO_CON_REQ 0x0429 - typedef struct { - bdaddr_t bdaddr; /* remote address */ - uint32_t tx_bandwidth; /* transmit bandwidth */ - uint32_t rx_bandwidth; /* receive bandwidth */ - uint16_t latency; /* maximum latency */ - uint16_t content; /* voice setting */ - uint8_t rt_effort; /* retransmission effort */ - uint16_t pkt_type; /* packet types */ - } hci_accept_sco_con_req_cp; - /* No return parameter(s) */ +typedef struct { + bdaddr_t bdaddr; /* remote address */ + uint32_t tx_bandwidth; /* transmit bandwidth */ + uint32_t rx_bandwidth; /* receive bandwidth */ + uint16_t latency; /* maximum latency */ + uint16_t content; /* voice setting */ + uint8_t rt_effort; /* retransmission effort */ + uint16_t pkt_type; /* packet types */ +} hci_accept_sco_con_req_cp; +/* No return parameter(s) */ #define HCI_OCF_REJECT_SCO_CON_REQ 0x002a #define HCI_CMD_REJECT_SCO_CON_REQ 0x042a - typedef struct { - bdaddr_t bdaddr; /* remote address */ - uint8_t reason; /* reject error code */ - } hci_reject_sco_con_req_cp; - /* No return parameter(s) */ +typedef struct { + bdaddr_t bdaddr; /* remote address */ + uint8_t reason; /* reject error code */ +} hci_reject_sco_con_req_cp; +/* No return parameter(s) */ #define HCI_OCF_IO_CAPABILITY_REP 0x002b #define HCI_CMD_IO_CAPABILITY_REP 0x042a - typedef struct { - bdaddr_t bdaddr; /* remote address */ - uint8_t io_cap; /* IO capability */ - uint8_t oob_data; /* OOB data present */ - uint8_t auth_req; /* auth requirements */ - } hci_io_capability_rep_cp; +typedef struct { + bdaddr_t bdaddr; /* remote address */ + uint8_t io_cap; /* IO capability */ + uint8_t oob_data; /* OOB data present */ + uint8_t auth_req; /* auth requirements */ +} hci_io_capability_rep_cp; - typedef struct { - uint8_t status; /* 0x00 - success */ - bdaddr_t bdaddr; /* remote address */ - } hci_io_capability_rep_rp; +typedef struct { + uint8_t status; /* 0x00 - success */ + bdaddr_t bdaddr; /* remote address */ +} hci_io_capability_rep_rp; #define HCI_OCF_USER_CONFIRM_REP 0x002c #define HCI_CMD_USER_CONFIRM_REP 0x042c - typedef struct { - bdaddr_t bdaddr; /* remote address */ - } hci_user_confirm_rep_cp; +typedef struct { + bdaddr_t bdaddr; /* remote address */ +} hci_user_confirm_rep_cp; - typedef struct { - uint8_t status; /* 0x00 - success */ - bdaddr_t bdaddr; /* remote address */ - } hci_user_confirm_rep_rp; +typedef struct { + uint8_t status; /* 0x00 - success */ + bdaddr_t bdaddr; /* remote address */ +} hci_user_confirm_rep_rp; #define HCI_OCF_USER_CONFIRM_NEG_REP 0x002d #define HCI_CMD_USER_CONFIRM_NEG_REP 0x042d - typedef struct { - bdaddr_t bdaddr; /* remote address */ - } hci_user_confirm_neg_rep_cp; +typedef struct { + bdaddr_t bdaddr; /* remote address */ +} hci_user_confirm_neg_rep_cp; - typedef struct { - uint8_t status; /* 0x00 - success */ - bdaddr_t bdaddr; /* remote address */ - } hci_user_confirm_neg_rep_rp; +typedef struct { + uint8_t status; /* 0x00 - success */ + bdaddr_t bdaddr; /* remote address */ +} hci_user_confirm_neg_rep_rp; #define HCI_OCF_USER_PASSKEY_REP 0x002e #define HCI_CMD_USER_PASSKEY_REP 0x042e - typedef struct { - bdaddr_t bdaddr; /* remote address */ - uint32_t value; /* 000000 - 999999 */ - } hci_user_passkey_rep_cp; +typedef struct { + bdaddr_t bdaddr; /* remote address */ + uint32_t value; /* 000000 - 999999 */ +} hci_user_passkey_rep_cp; - typedef struct { - uint8_t status; /* 0x00 - success */ - bdaddr_t bdaddr; /* remote address */ - } hci_user_passkey_rep_rp; +typedef struct { + uint8_t status; /* 0x00 - success */ + bdaddr_t bdaddr; /* remote address */ +} hci_user_passkey_rep_rp; #define HCI_OCF_USER_PASSKEY_NEG_REP 0x002f #define HCI_CMD_USER_PASSKEY_NEG_REP 0x042f - typedef struct { - bdaddr_t bdaddr; /* remote address */ - } hci_user_passkey_neg_rep_cp; +typedef struct { + bdaddr_t bdaddr; /* remote address */ +} hci_user_passkey_neg_rep_cp; - typedef struct { - uint8_t status; /* 0x00 - success */ - bdaddr_t bdaddr; /* remote address */ - } hci_user_passkey_neg_rep_rp; +typedef struct { + uint8_t status; /* 0x00 - success */ + bdaddr_t bdaddr; /* remote address */ +} hci_user_passkey_neg_rep_rp; #define HCI_OCF_OOB_DATA_REP 0x0030 #define HCI_CMD_OOB_DATA_REP 0x0430 - typedef struct { - bdaddr_t bdaddr; /* remote address */ - uint8_t c[16]; /* pairing hash */ - uint8_t r[16]; /* pairing randomizer */ - } hci_user_oob_data_rep_cp; +typedef struct { + bdaddr_t bdaddr; /* remote address */ + uint8_t c[16]; /* pairing hash */ + uint8_t r[16]; /* pairing randomizer */ +} hci_user_oob_data_rep_cp; - typedef struct { - uint8_t status; /* 0x00 - success */ - bdaddr_t bdaddr; /* remote address */ - } hci_user_oob_data_rep_rp; +typedef struct { + uint8_t status; /* 0x00 - success */ + bdaddr_t bdaddr; /* remote address */ +} hci_user_oob_data_rep_rp; #define HCI_OCF_OOB_DATA_NEG_REP 0x0033 #define HCI_CMD_OOB_DATA_NEG_REP 0x0433 - typedef struct { - bdaddr_t bdaddr; /* remote address */ - } hci_user_oob_data_neg_rep_cp; +typedef struct { + bdaddr_t bdaddr; /* remote address */ +} hci_user_oob_data_neg_rep_cp; - typedef struct { - uint8_t status; /* 0x00 - success */ - bdaddr_t bdaddr; /* remote address */ - } hci_user_oob_data_neg_rep_rp; +typedef struct { + uint8_t status; /* 0x00 - success */ + bdaddr_t bdaddr; /* remote address */ +} hci_user_oob_data_neg_rep_rp; #define HCI_OCF_IO_CAPABILITY_NEG_REP 0x0034 #define HCI_CMD_IO_CAPABILITY_NEG_REP 0x0434 - typedef struct { - bdaddr_t bdaddr; /* remote address */ - uint8_t reason; /* error code */ - } hci_io_capability_neg_rep_cp; +typedef struct { + bdaddr_t bdaddr; /* remote address */ + uint8_t reason; /* error code */ +} hci_io_capability_neg_rep_cp; - typedef struct { - uint8_t status; /* 0x00 - success */ - bdaddr_t bdaddr; /* remote address */ - } hci_io_capability_neg_rep_rp; +typedef struct { + uint8_t status; /* 0x00 - success */ + bdaddr_t bdaddr; /* remote address */ +} hci_io_capability_neg_rep_rp; - /************************************************************************** - ************************************************************************** - ** OGF 0x02 Link policy commands and return parameters - ************************************************************************** - **************************************************************************/ +/************************************************************************** + ************************************************************************** + ** OGF 0x02 Link policy commands and return parameters + ************************************************************************** + **************************************************************************/ #define HCI_OGF_LINK_POLICY 0x02 #define HCI_OCF_HOLD_MODE 0x0001 #define HCI_CMD_HOLD_MODE 0x0801 - typedef struct { - uint16_t con_handle; /* connection handle */ - uint16_t max_interval; /* (max_interval * 0.625) msec */ - uint16_t min_interval; /* (max_interval * 0.625) msec */ - } hci_hold_mode_cp; - /* No return parameter(s) */ +typedef struct { + uint16_t con_handle; /* connection handle */ + uint16_t max_interval; /* (max_interval * 0.625) msec */ + uint16_t min_interval; /* (max_interval * 0.625) msec */ +} hci_hold_mode_cp; +/* No return parameter(s) */ #define HCI_OCF_SNIFF_MODE 0x0003 #define HCI_CMD_SNIFF_MODE 0x0803 - typedef struct { - uint16_t con_handle; /* connection handle */ - uint16_t max_interval; /* (max_interval * 0.625) msec */ - uint16_t min_interval; /* (max_interval * 0.625) msec */ - uint16_t attempt; /* (2 * attempt - 1) * 0.625 msec */ - uint16_t timeout; /* (2 * attempt - 1) * 0.625 msec */ - } hci_sniff_mode_cp; - /* No return parameter(s) */ +typedef struct { + uint16_t con_handle; /* connection handle */ + uint16_t max_interval; /* (max_interval * 0.625) msec */ + uint16_t min_interval; /* (max_interval * 0.625) msec */ + uint16_t attempt; /* (2 * attempt - 1) * 0.625 msec */ + uint16_t timeout; /* (2 * attempt - 1) * 0.625 msec */ +} hci_sniff_mode_cp; +/* No return parameter(s) */ #define HCI_OCF_EXIT_SNIFF_MODE 0x0004 #define HCI_CMD_EXIT_SNIFF_MODE 0x0804 - typedef struct { - uint16_t con_handle; /* connection handle */ - } hci_exit_sniff_mode_cp; - /* No return parameter(s) */ +typedef struct { + uint16_t con_handle; /* connection handle */ +} hci_exit_sniff_mode_cp; +/* No return parameter(s) */ #define HCI_OCF_PARK_MODE 0x0005 #define HCI_CMD_PARK_MODE 0x0805 - typedef struct { - uint16_t con_handle; /* connection handle */ - uint16_t max_interval; /* (max_interval * 0.625) msec */ - uint16_t min_interval; /* (max_interval * 0.625) msec */ - } hci_park_mode_cp; - /* No return parameter(s) */ +typedef struct { + uint16_t con_handle; /* connection handle */ + uint16_t max_interval; /* (max_interval * 0.625) msec */ + uint16_t min_interval; /* (max_interval * 0.625) msec */ +} hci_park_mode_cp; +/* No return parameter(s) */ #define HCI_OCF_EXIT_PARK_MODE 0x0006 #define HCI_CMD_EXIT_PARK_MODE 0x0806 - typedef struct { - uint16_t con_handle; /* connection handle */ - } hci_exit_park_mode_cp; - /* No return parameter(s) */ +typedef struct { + uint16_t con_handle; /* connection handle */ +} hci_exit_park_mode_cp; +/* No return parameter(s) */ #define HCI_OCF_QOS_SETUP 0x0007 #define HCI_CMD_QOS_SETUP 0x0807 - typedef struct { - uint16_t con_handle; /* connection handle */ - uint8_t flags; /* reserved for future use */ - uint8_t service_type; /* service type */ - uint32_t token_rate; /* bytes per second */ - uint32_t peak_bandwidth; /* bytes per second */ - uint32_t latency; /* microseconds */ - uint32_t delay_variation; /* microseconds */ - } hci_qos_setup_cp; - /* No return parameter(s) */ +typedef struct { + uint16_t con_handle; /* connection handle */ + uint8_t flags; /* reserved for future use */ + uint8_t service_type; /* service type */ + uint32_t token_rate; /* bytes per second */ + uint32_t peak_bandwidth; /* bytes per second */ + uint32_t latency; /* microseconds */ + uint32_t delay_variation; /* microseconds */ +} hci_qos_setup_cp; +/* No return parameter(s) */ #define HCI_OCF_ROLE_DISCOVERY 0x0009 #define HCI_CMD_ROLE_DISCOVERY 0x0809 - typedef struct { - uint16_t con_handle; /* connection handle */ - } hci_role_discovery_cp; +typedef struct { + uint16_t con_handle; /* connection handle */ +} hci_role_discovery_cp; - typedef struct { - uint8_t status; /* 0x00 - success */ - uint16_t con_handle; /* connection handle */ - uint8_t role; /* role for the connection handle */ - } hci_role_discovery_rp; +typedef struct { + uint8_t status; /* 0x00 - success */ + uint16_t con_handle; /* connection handle */ + uint8_t role; /* role for the connection handle */ +} hci_role_discovery_rp; #define HCI_OCF_SWITCH_ROLE 0x000b #define HCI_CMD_SWITCH_ROLE 0x080B - typedef struct { - bdaddr_t bdaddr; /* remote address */ - uint8_t role; /* new local role */ - } hci_switch_role_cp; - /* No return parameter(s) */ +typedef struct { + bdaddr_t bdaddr; /* remote address */ + uint8_t role; /* new local role */ +} hci_switch_role_cp; +/* No return parameter(s) */ #define HCI_OCF_READ_LINK_POLICY_SETTINGS 0x000c #define HCI_CMD_READ_LINK_POLICY_SETTINGS 0x080C - typedef struct { - uint16_t con_handle; /* connection handle */ - } hci_read_link_policy_settings_cp; +typedef struct { + uint16_t con_handle; /* connection handle */ +} hci_read_link_policy_settings_cp; - typedef struct { - uint8_t status; /* 0x00 - success */ - uint16_t con_handle; /* connection handle */ - uint16_t settings; /* link policy settings */ - } hci_read_link_policy_settings_rp; +typedef struct { + uint8_t status; /* 0x00 - success */ + uint16_t con_handle; /* connection handle */ + uint16_t settings; /* link policy settings */ +} hci_read_link_policy_settings_rp; #define HCI_OCF_WRITE_LINK_POLICY_SETTINGS 0x000d #define HCI_CMD_WRITE_LINK_POLICY_SETTINGS 0x080D - typedef struct { - uint16_t con_handle; /* connection handle */ - uint16_t settings; /* link policy settings */ - } hci_write_link_policy_settings_cp; +typedef struct { + uint16_t con_handle; /* connection handle */ + uint16_t settings; /* link policy settings */ +} hci_write_link_policy_settings_cp; - typedef struct { - uint8_t status; /* 0x00 - success */ - uint16_t con_handle; /* connection handle */ - } hci_write_link_policy_settings_rp; +typedef struct { + uint8_t status; /* 0x00 - success */ + uint16_t con_handle; /* connection handle */ +} hci_write_link_policy_settings_rp; #define HCI_OCF_READ_DEFAULT_LINK_POLICY_SETTINGS 0x000e #define HCI_CMD_READ_DEFAULT_LINK_POLICY_SETTINGS 0x080E - /* No command parameter(s) */ - typedef struct { - uint8_t status; /* 0x00 - success */ - uint16_t settings; /* link policy settings */ - } hci_read_default_link_policy_settings_rp; +/* No command parameter(s) */ +typedef struct { + uint8_t status; /* 0x00 - success */ + uint16_t settings; /* link policy settings */ +} hci_read_default_link_policy_settings_rp; #define HCI_OCF_WRITE_DEFAULT_LINK_POLICY_SETTINGS 0x000f #define HCI_CMD_WRITE_DEFAULT_LINK_POLICY_SETTINGS 0x080F - typedef struct { - uint16_t settings; /* link policy settings */ - } hci_write_default_link_policy_settings_cp; +typedef struct { + uint16_t settings; /* link policy settings */ +} hci_write_default_link_policy_settings_cp; - typedef hci_status_rp hci_write_default_link_policy_settings_rp; +typedef hci_status_rp hci_write_default_link_policy_settings_rp; #define HCI_OCF_FLOW_SPECIFICATION 0x0010 #define HCI_CMD_FLOW_SPECIFICATION 0x0810 - typedef struct { - uint16_t con_handle; /* connection handle */ - uint8_t flags; /* reserved */ - uint8_t flow_direction; - uint8_t service_type; - uint32_t token_rate; - uint32_t token_bucket; - uint32_t peak_bandwidth; - uint32_t latency; - } hci_flow_specification_cp; - /* No return parameter(s) */ +typedef struct { + uint16_t con_handle; /* connection handle */ + uint8_t flags; /* reserved */ + uint8_t flow_direction; + uint8_t service_type; + uint32_t token_rate; + uint32_t token_bucket; + uint32_t peak_bandwidth; + uint32_t latency; +} hci_flow_specification_cp; +/* No return parameter(s) */ #define HCI_OCF_SNIFF_SUBRATING 0x0011 #define HCI_CMD_SNIFF_SUBRATING 0x0810 - typedef struct { - uint16_t con_handle; /* connection handle */ - uint16_t max_latency; - uint16_t max_timeout; /* max remote timeout */ - uint16_t min_timeout; /* min local timeout */ - } hci_sniff_subrating_cp; +typedef struct { + uint16_t con_handle; /* connection handle */ + uint16_t max_latency; + uint16_t max_timeout; /* max remote timeout */ + uint16_t min_timeout; /* min local timeout */ +} hci_sniff_subrating_cp; - typedef struct { - uint8_t status; /* 0x00 - success */ - uint16_t con_handle; /* connection handle */ - } hci_sniff_subrating_rp; +typedef struct { + uint8_t status; /* 0x00 - success */ + uint16_t con_handle; /* connection handle */ +} hci_sniff_subrating_rp; - /************************************************************************** - ************************************************************************** - ** OGF 0x03 Host Controller and Baseband commands and return parameters - ************************************************************************** - **************************************************************************/ +/************************************************************************** + ************************************************************************** + ** OGF 0x03 Host Controller and Baseband commands and return parameters + ************************************************************************** + **************************************************************************/ #define HCI_OGF_HC_BASEBAND 0x03 #define HCI_OCF_SET_EVENT_MASK 0x0001 #define HCI_CMD_SET_EVENT_MASK 0x0C01 - typedef struct { - uint8_t event_mask[HCI_EVENT_MASK_SIZE]; /* event_mask */ - } hci_set_event_mask_cp; +typedef struct { + uint8_t event_mask[HCI_EVENT_MASK_SIZE]; /* event_mask */ +} hci_set_event_mask_cp; - typedef hci_status_rp hci_set_event_mask_rp; +typedef hci_status_rp hci_set_event_mask_rp; #define HCI_OCF_RESET 0x0003 #define HCI_CMD_RESET 0x0C03 - /* No command parameter(s) */ - typedef hci_status_rp hci_reset_rp; +/* No command parameter(s) */ +typedef hci_status_rp hci_reset_rp; #define HCI_OCF_SET_EVENT_FILTER 0x0005 #define HCI_CMD_SET_EVENT_FILTER 0x0C05 - typedef struct { - uint8_t filter_type; /* filter type */ - uint8_t filter_condition_type; /* filter condition type */ - /* variable size condition - uint8_t condition[]; -- conditions */ - } hci_set_event_filter_cp; +typedef struct { + uint8_t filter_type; /* filter type */ + uint8_t filter_condition_type; /* filter condition type */ +/* variable size condition + uint8_t condition[]; -- conditions */ +} hci_set_event_filter_cp; - typedef hci_status_rp hci_set_event_filter_rp; +typedef hci_status_rp hci_set_event_filter_rp; #define HCI_OCF_FLUSH 0x0008 #define HCI_CMD_FLUSH 0x0C08 - typedef struct { - uint16_t con_handle; /* connection handle */ - } hci_flush_cp; +typedef struct { + uint16_t con_handle; /* connection handle */ +} hci_flush_cp; - typedef struct { - uint8_t status; /* 0x00 - success */ - uint16_t con_handle; /* connection handle */ - } hci_flush_rp; +typedef struct { + uint8_t status; /* 0x00 - success */ + uint16_t con_handle; /* connection handle */ +} hci_flush_rp; #define HCI_OCF_READ_PIN_TYPE 0x0009 #define HCI_CMD_READ_PIN_TYPE 0x0C09 - /* No command parameter(s) */ - typedef struct { - uint8_t status; /* 0x00 - success */ - uint8_t pin_type; /* PIN type */ - } hci_read_pin_type_rp; +/* No command parameter(s) */ +typedef struct { + uint8_t status; /* 0x00 - success */ + uint8_t pin_type; /* PIN type */ +} hci_read_pin_type_rp; #define HCI_OCF_WRITE_PIN_TYPE 0x000a #define HCI_CMD_WRITE_PIN_TYPE 0x0C0A - typedef struct { - uint8_t pin_type; /* PIN type */ - } hci_write_pin_type_cp; +typedef struct { + uint8_t pin_type; /* PIN type */ +} hci_write_pin_type_cp; - typedef hci_status_rp hci_write_pin_type_rp; +typedef hci_status_rp hci_write_pin_type_rp; #define HCI_OCF_CREATE_NEW_UNIT_KEY 0x000b #define HCI_CMD_CREATE_NEW_UNIT_KEY 0x0C0B - /* No command parameter(s) */ - typedef hci_status_rp hci_create_new_unit_key_rp; +/* No command parameter(s) */ +typedef hci_status_rp hci_create_new_unit_key_rp; #define HCI_OCF_READ_STORED_LINK_KEY 0x000d #define HCI_CMD_READ_STORED_LINK_KEY 0x0C0D - typedef struct { - bdaddr_t bdaddr; /* address */ - uint8_t read_all; /* read all keys? 0x01 - yes */ - } hci_read_stored_link_key_cp; +typedef struct { + bdaddr_t bdaddr; /* address */ + uint8_t read_all; /* read all keys? 0x01 - yes */ +} hci_read_stored_link_key_cp; - typedef struct { - uint8_t status; /* 0x00 - success */ - uint16_t max_num_keys; /* Max. number of keys */ - uint16_t num_keys_read; /* Number of stored keys */ - } hci_read_stored_link_key_rp; +typedef struct { + uint8_t status; /* 0x00 - success */ + uint16_t max_num_keys; /* Max. number of keys */ + uint16_t num_keys_read; /* Number of stored keys */ +} hci_read_stored_link_key_rp; #define HCI_OCF_WRITE_STORED_LINK_KEY 0x0011 #define HCI_CMD_WRITE_STORED_LINK_KEY 0x0C11 - typedef struct { - uint8_t num_keys_write; /* # of keys to write */ - /* these are repeated "num_keys_write" times - bdaddr_t bdaddr; --- remote address(es) - uint8_t key[HCI_KEY_SIZE]; --- key(s) */ - } hci_write_stored_link_key_cp; +typedef struct { + uint8_t num_keys_write; /* # of keys to write */ +/* these are repeated "num_keys_write" times + bdaddr_t bdaddr; --- remote address(es) + uint8_t key[HCI_KEY_SIZE]; --- key(s) */ +} hci_write_stored_link_key_cp; - typedef struct { - uint8_t status; /* 0x00 - success */ - uint8_t num_keys_written; /* # of keys successfully written */ - } hci_write_stored_link_key_rp; +typedef struct { + uint8_t status; /* 0x00 - success */ + uint8_t num_keys_written; /* # of keys successfully written */ +} hci_write_stored_link_key_rp; #define HCI_OCF_DELETE_STORED_LINK_KEY 0x0012 #define HCI_CMD_DELETE_STORED_LINK_KEY 0x0C12 - typedef struct { - bdaddr_t bdaddr; /* address */ - uint8_t delete_all; /* delete all keys? 0x01 - yes */ - } hci_delete_stored_link_key_cp; +typedef struct { + bdaddr_t bdaddr; /* address */ + uint8_t delete_all; /* delete all keys? 0x01 - yes */ +} hci_delete_stored_link_key_cp; - typedef struct { - uint8_t status; /* 0x00 - success */ - uint16_t num_keys_deleted; /* Number of keys deleted */ - } hci_delete_stored_link_key_rp; +typedef struct { + uint8_t status; /* 0x00 - success */ + uint16_t num_keys_deleted; /* Number of keys deleted */ +} hci_delete_stored_link_key_rp; #define HCI_OCF_WRITE_LOCAL_NAME 0x0013 #define HCI_CMD_WRITE_LOCAL_NAME 0x0C13 - typedef struct { - char name[HCI_UNIT_NAME_SIZE]; /* new unit name */ - } hci_write_local_name_cp; +typedef struct { + char name[HCI_UNIT_NAME_SIZE]; /* new unit name */ +} hci_write_local_name_cp; - typedef hci_status_rp hci_write_local_name_rp; +typedef hci_status_rp hci_write_local_name_rp; #define HCI_OCF_READ_LOCAL_NAME 0x0014 #define HCI_CMD_READ_LOCAL_NAME 0x0C14 - /* No command parameter(s) */ - typedef struct { - uint8_t status; /* 0x00 - success */ - char name[HCI_UNIT_NAME_SIZE]; /* unit name */ - } hci_read_local_name_rp; +/* No command parameter(s) */ +typedef struct { + uint8_t status; /* 0x00 - success */ + char name[HCI_UNIT_NAME_SIZE]; /* unit name */ +} hci_read_local_name_rp; #define HCI_OCF_READ_CON_ACCEPT_TIMEOUT 0x0015 #define HCI_CMD_READ_CON_ACCEPT_TIMEOUT 0x0C15 - /* No command parameter(s) */ - typedef struct { - uint8_t status; /* 0x00 - success */ - uint16_t timeout; /* (timeout * 0.625) msec */ - } hci_read_con_accept_timeout_rp; +/* No command parameter(s) */ +typedef struct { + uint8_t status; /* 0x00 - success */ + uint16_t timeout; /* (timeout * 0.625) msec */ +} hci_read_con_accept_timeout_rp; #define HCI_OCF_WRITE_CON_ACCEPT_TIMEOUT 0x0016 #define HCI_CMD_WRITE_CON_ACCEPT_TIMEOUT 0x0C16 - typedef struct { - uint16_t timeout; /* (timeout * 0.625) msec */ - } hci_write_con_accept_timeout_cp; +typedef struct { + uint16_t timeout; /* (timeout * 0.625) msec */ +} hci_write_con_accept_timeout_cp; - typedef hci_status_rp hci_write_con_accept_timeout_rp; +typedef hci_status_rp hci_write_con_accept_timeout_rp; #define HCI_OCF_READ_PAGE_TIMEOUT 0x0017 #define HCI_CMD_READ_PAGE_TIMEOUT 0x0C17 - /* No command parameter(s) */ - typedef struct { - uint8_t status; /* 0x00 - success */ - uint16_t timeout; /* (timeout * 0.625) msec */ - } hci_read_page_timeout_rp; +/* No command parameter(s) */ +typedef struct { + uint8_t status; /* 0x00 - success */ + uint16_t timeout; /* (timeout * 0.625) msec */ +} hci_read_page_timeout_rp; #define HCI_OCF_WRITE_PAGE_TIMEOUT 0x0018 #define HCI_CMD_WRITE_PAGE_TIMEOUT 0x0C18 - typedef struct { - uint16_t timeout; /* (timeout * 0.625) msec */ - } hci_write_page_timeout_cp; +typedef struct { + uint16_t timeout; /* (timeout * 0.625) msec */ +} hci_write_page_timeout_cp; - typedef hci_status_rp hci_write_page_timeout_rp; +typedef hci_status_rp hci_write_page_timeout_rp; #define HCI_OCF_READ_SCAN_ENABLE 0x0019 #define HCI_CMD_READ_SCAN_ENABLE 0x0C19 - /* No command parameter(s) */ - typedef struct { - uint8_t status; /* 0x00 - success */ - uint8_t scan_enable; /* Scan enable */ - } hci_read_scan_enable_rp; +/* No command parameter(s) */ +typedef struct { + uint8_t status; /* 0x00 - success */ + uint8_t scan_enable; /* Scan enable */ +} hci_read_scan_enable_rp; #define HCI_OCF_WRITE_SCAN_ENABLE 0x001a #define HCI_CMD_WRITE_SCAN_ENABLE 0x0C1A - typedef struct { - uint8_t scan_enable; /* Scan enable */ - } hci_write_scan_enable_cp; +typedef struct { + uint8_t scan_enable; /* Scan enable */ +} hci_write_scan_enable_cp; - typedef hci_status_rp hci_write_scan_enable_rp; +typedef hci_status_rp hci_write_scan_enable_rp; #define HCI_OCF_READ_PAGE_SCAN_ACTIVITY 0x001b #define HCI_CMD_READ_PAGE_SCAN_ACTIVITY 0x0C1B - /* No command parameter(s) */ - typedef struct { - uint8_t status; /* 0x00 - success */ - uint16_t page_scan_interval; /* interval * 0.625 msec */ - uint16_t page_scan_window; /* window * 0.625 msec */ - } hci_read_page_scan_activity_rp; +/* No command parameter(s) */ +typedef struct { + uint8_t status; /* 0x00 - success */ + uint16_t page_scan_interval; /* interval * 0.625 msec */ + uint16_t page_scan_window; /* window * 0.625 msec */ +} hci_read_page_scan_activity_rp; #define HCI_OCF_WRITE_PAGE_SCAN_ACTIVITY 0x001c #define HCI_CMD_WRITE_PAGE_SCAN_ACTIVITY 0x0C1C - typedef struct { - uint16_t page_scan_interval; /* interval * 0.625 msec */ - uint16_t page_scan_window; /* window * 0.625 msec */ - } hci_write_page_scan_activity_cp; +typedef struct { + uint16_t page_scan_interval; /* interval * 0.625 msec */ + uint16_t page_scan_window; /* window * 0.625 msec */ +} hci_write_page_scan_activity_cp; - typedef hci_status_rp hci_write_page_scan_activity_rp; +typedef hci_status_rp hci_write_page_scan_activity_rp; #define HCI_OCF_READ_INQUIRY_SCAN_ACTIVITY 0x001d #define HCI_CMD_READ_INQUIRY_SCAN_ACTIVITY 0x0C1D - /* No command parameter(s) */ - typedef struct { - uint8_t status; /* 0x00 - success */ - uint16_t inquiry_scan_interval; /* interval * 0.625 msec */ - uint16_t inquiry_scan_window; /* window * 0.625 msec */ - } hci_read_inquiry_scan_activity_rp; +/* No command parameter(s) */ +typedef struct { + uint8_t status; /* 0x00 - success */ + uint16_t inquiry_scan_interval; /* interval * 0.625 msec */ + uint16_t inquiry_scan_window; /* window * 0.625 msec */ +} hci_read_inquiry_scan_activity_rp; #define HCI_OCF_WRITE_INQUIRY_SCAN_ACTIVITY 0x001e #define HCI_CMD_WRITE_INQUIRY_SCAN_ACTIVITY 0x0C1E - typedef struct { - uint16_t inquiry_scan_interval; /* interval * 0.625 msec */ - uint16_t inquiry_scan_window; /* window * 0.625 msec */ - } hci_write_inquiry_scan_activity_cp; +typedef struct { + uint16_t inquiry_scan_interval; /* interval * 0.625 msec */ + uint16_t inquiry_scan_window; /* window * 0.625 msec */ +} hci_write_inquiry_scan_activity_cp; - typedef hci_status_rp hci_write_inquiry_scan_activity_rp; +typedef hci_status_rp hci_write_inquiry_scan_activity_rp; #define HCI_OCF_READ_AUTH_ENABLE 0x001f #define HCI_CMD_READ_AUTH_ENABLE 0x0C1F - /* No command parameter(s) */ - typedef struct { - uint8_t status; /* 0x00 - success */ - uint8_t auth_enable; /* 0x01 - enabled */ - } hci_read_auth_enable_rp; +/* No command parameter(s) */ +typedef struct { + uint8_t status; /* 0x00 - success */ + uint8_t auth_enable; /* 0x01 - enabled */ +} hci_read_auth_enable_rp; #define HCI_OCF_WRITE_AUTH_ENABLE 0x0020 #define HCI_CMD_WRITE_AUTH_ENABLE 0x0C20 - typedef struct { - uint8_t auth_enable; /* 0x01 - enabled */ - } hci_write_auth_enable_cp; +typedef struct { + uint8_t auth_enable; /* 0x01 - enabled */ +} hci_write_auth_enable_cp; - typedef hci_status_rp hci_write_auth_enable_rp; +typedef hci_status_rp hci_write_auth_enable_rp; - /* Read Encryption Mode is deprecated */ +/* Read Encryption Mode is deprecated */ #define HCI_OCF_READ_ENCRYPTION_MODE 0x0021 #define HCI_CMD_READ_ENCRYPTION_MODE 0x0C21 - /* No command parameter(s) */ - typedef struct { - uint8_t status; /* 0x00 - success */ - uint8_t encryption_mode; /* encryption mode */ - } hci_read_encryption_mode_rp; +/* No command parameter(s) */ +typedef struct { + uint8_t status; /* 0x00 - success */ + uint8_t encryption_mode; /* encryption mode */ +} hci_read_encryption_mode_rp; - /* Write Encryption Mode is deprecated */ +/* Write Encryption Mode is deprecated */ #define HCI_OCF_WRITE_ENCRYPTION_MODE 0x0022 #define HCI_CMD_WRITE_ENCRYPTION_MODE 0x0C22 - typedef struct { - uint8_t encryption_mode; /* encryption mode */ - } hci_write_encryption_mode_cp; +typedef struct { + uint8_t encryption_mode; /* encryption mode */ +} hci_write_encryption_mode_cp; - typedef hci_status_rp hci_write_encryption_mode_rp; +typedef hci_status_rp hci_write_encryption_mode_rp; #define HCI_OCF_READ_UNIT_CLASS 0x0023 #define HCI_CMD_READ_UNIT_CLASS 0x0C23 - /* No command parameter(s) */ - typedef struct { - uint8_t status; /* 0x00 - success */ - uint8_t uclass[HCI_CLASS_SIZE]; /* unit class */ - } hci_read_unit_class_rp; +/* No command parameter(s) */ +typedef struct { + uint8_t status; /* 0x00 - success */ + uint8_t uclass[HCI_CLASS_SIZE]; /* unit class */ +} hci_read_unit_class_rp; #define HCI_OCF_WRITE_UNIT_CLASS 0x0024 #define HCI_CMD_WRITE_UNIT_CLASS 0x0C24 - typedef struct { - uint8_t uclass[HCI_CLASS_SIZE]; /* unit class */ - } hci_write_unit_class_cp; +typedef struct { + uint8_t uclass[HCI_CLASS_SIZE]; /* unit class */ +} hci_write_unit_class_cp; - typedef hci_status_rp hci_write_unit_class_rp; +typedef hci_status_rp hci_write_unit_class_rp; #define HCI_OCF_READ_VOICE_SETTING 0x0025 #define HCI_CMD_READ_VOICE_SETTING 0x0C25 - /* No command parameter(s) */ - typedef struct { - uint8_t status; /* 0x00 - success */ - uint16_t settings; /* voice settings */ - } hci_read_voice_setting_rp; +/* No command parameter(s) */ +typedef struct { + uint8_t status; /* 0x00 - success */ + uint16_t settings; /* voice settings */ +} hci_read_voice_setting_rp; #define HCI_OCF_WRITE_VOICE_SETTING 0x0026 #define HCI_CMD_WRITE_VOICE_SETTING 0x0C26 - typedef struct { - uint16_t settings; /* voice settings */ - } hci_write_voice_setting_cp; +typedef struct { + uint16_t settings; /* voice settings */ +} hci_write_voice_setting_cp; - typedef hci_status_rp hci_write_voice_setting_rp; +typedef hci_status_rp hci_write_voice_setting_rp; #define HCI_OCF_READ_AUTO_FLUSH_TIMEOUT 0x0027 #define HCI_CMD_READ_AUTO_FLUSH_TIMEOUT 0x0C27 - typedef struct { - uint16_t con_handle; /* connection handle */ - } hci_read_auto_flush_timeout_cp; +typedef struct { + uint16_t con_handle; /* connection handle */ +} hci_read_auto_flush_timeout_cp; - typedef struct { - uint8_t status; /* 0x00 - success */ - uint16_t con_handle; /* connection handle */ - uint16_t timeout; /* 0x00 - no flush, timeout * 0.625 msec */ - } hci_read_auto_flush_timeout_rp; +typedef struct { + uint8_t status; /* 0x00 - success */ + uint16_t con_handle; /* connection handle */ + uint16_t timeout; /* 0x00 - no flush, timeout * 0.625 msec */ +} hci_read_auto_flush_timeout_rp; #define HCI_OCF_WRITE_AUTO_FLUSH_TIMEOUT 0x0028 #define HCI_CMD_WRITE_AUTO_FLUSH_TIMEOUT 0x0C28 - typedef struct { - uint16_t con_handle; /* connection handle */ - uint16_t timeout; /* 0x00 - no flush, timeout * 0.625 msec */ - } hci_write_auto_flush_timeout_cp; +typedef struct { + uint16_t con_handle; /* connection handle */ + uint16_t timeout; /* 0x00 - no flush, timeout * 0.625 msec */ +} hci_write_auto_flush_timeout_cp; - typedef struct { - uint8_t status; /* 0x00 - success */ - uint16_t con_handle; /* connection handle */ - } hci_write_auto_flush_timeout_rp; +typedef struct { + uint8_t status; /* 0x00 - success */ + uint16_t con_handle; /* connection handle */ +} hci_write_auto_flush_timeout_rp; #define HCI_OCF_READ_NUM_BROADCAST_RETRANS 0x0029 #define HCI_CMD_READ_NUM_BROADCAST_RETRANS 0x0C29 - /* No command parameter(s) */ - typedef struct { - uint8_t status; /* 0x00 - success */ - uint8_t counter; /* number of broadcast retransmissions */ - } hci_read_num_broadcast_retrans_rp; +/* No command parameter(s) */ +typedef struct { + uint8_t status; /* 0x00 - success */ + uint8_t counter; /* number of broadcast retransmissions */ +} hci_read_num_broadcast_retrans_rp; #define HCI_OCF_WRITE_NUM_BROADCAST_RETRANS 0x002a #define HCI_CMD_WRITE_NUM_BROADCAST_RETRANS 0x0C2A - typedef struct { - uint8_t counter; /* number of broadcast retransmissions */ - } hci_write_num_broadcast_retrans_cp; +typedef struct { + uint8_t counter; /* number of broadcast retransmissions */ +} hci_write_num_broadcast_retrans_cp; - typedef hci_status_rp hci_write_num_broadcast_retrans_rp; +typedef hci_status_rp hci_write_num_broadcast_retrans_rp; #define HCI_OCF_READ_HOLD_MODE_ACTIVITY 0x002b #define HCI_CMD_READ_HOLD_MODE_ACTIVITY 0x0C2B - /* No command parameter(s) */ - typedef struct { - uint8_t status; /* 0x00 - success */ - uint8_t hold_mode_activity; /* Hold mode activities */ - } hci_read_hold_mode_activity_rp; +/* No command parameter(s) */ +typedef struct { + uint8_t status; /* 0x00 - success */ + uint8_t hold_mode_activity; /* Hold mode activities */ +} hci_read_hold_mode_activity_rp; #define HCI_OCF_WRITE_HOLD_MODE_ACTIVITY 0x002c #define HCI_CMD_WRITE_HOLD_MODE_ACTIVITY 0x0C2C - typedef struct { - uint8_t hold_mode_activity; /* Hold mode activities */ - } hci_write_hold_mode_activity_cp; +typedef struct { + uint8_t hold_mode_activity; /* Hold mode activities */ +} hci_write_hold_mode_activity_cp; - typedef hci_status_rp hci_write_hold_mode_activity_rp; +typedef hci_status_rp hci_write_hold_mode_activity_rp; #define HCI_OCF_READ_XMIT_LEVEL 0x002d #define HCI_CMD_READ_XMIT_LEVEL 0x0C2D - typedef struct { - uint16_t con_handle; /* connection handle */ - uint8_t type; /* Xmit level type */ - } hci_read_xmit_level_cp; +typedef struct { + uint16_t con_handle; /* connection handle */ + uint8_t type; /* Xmit level type */ +} hci_read_xmit_level_cp; - typedef struct { - uint8_t status; /* 0x00 - success */ - uint16_t con_handle; /* connection handle */ - char level; /* -30 <= level <= 30 dBm */ - } hci_read_xmit_level_rp; +typedef struct { + uint8_t status; /* 0x00 - success */ + uint16_t con_handle; /* connection handle */ + char level; /* -30 <= level <= 30 dBm */ +} hci_read_xmit_level_rp; #define HCI_OCF_READ_SCO_FLOW_CONTROL 0x002e #define HCI_CMD_READ_SCO_FLOW_CONTROL 0x0C2E - /* No command parameter(s) */ - typedef struct { - uint8_t status; /* 0x00 - success */ - uint8_t flow_control; /* 0x00 - disabled */ - } hci_read_sco_flow_control_rp; +/* No command parameter(s) */ +typedef struct { + uint8_t status; /* 0x00 - success */ + uint8_t flow_control; /* 0x00 - disabled */ +} hci_read_sco_flow_control_rp; #define HCI_OCF_WRITE_SCO_FLOW_CONTROL 0x002f #define HCI_CMD_WRITE_SCO_FLOW_CONTROL 0x0C2F - typedef struct { - uint8_t flow_control; /* 0x00 - disabled */ - } hci_write_sco_flow_control_cp; +typedef struct { + uint8_t flow_control; /* 0x00 - disabled */ +} hci_write_sco_flow_control_cp; - typedef hci_status_rp hci_write_sco_flow_control_rp; +typedef hci_status_rp hci_write_sco_flow_control_rp; #define HCI_OCF_HC2H_FLOW_CONTROL 0x0031 #define HCI_CMD_HC2H_FLOW_CONTROL 0x0C31 - typedef struct { - uint8_t hc2h_flow; /* Host Controller to Host flow control */ - } hci_hc2h_flow_control_cp; +typedef struct { + uint8_t hc2h_flow; /* Host Controller to Host flow control */ +} hci_hc2h_flow_control_cp; - typedef hci_status_rp hci_h2hc_flow_control_rp; +typedef hci_status_rp hci_h2hc_flow_control_rp; #define HCI_OCF_HOST_BUFFER_SIZE 0x0033 #define HCI_CMD_HOST_BUFFER_SIZE 0x0C33 - typedef struct { - uint16_t max_acl_size; /* Max. size of ACL packet (bytes) */ - uint8_t max_sco_size; /* Max. size of SCO packet (bytes) */ - uint16_t num_acl_pkts; /* Max. number of ACL packets */ - uint16_t num_sco_pkts; /* Max. number of SCO packets */ - } hci_host_buffer_size_cp; +typedef struct { + uint16_t max_acl_size; /* Max. size of ACL packet (bytes) */ + uint8_t max_sco_size; /* Max. size of SCO packet (bytes) */ + uint16_t num_acl_pkts; /* Max. number of ACL packets */ + uint16_t num_sco_pkts; /* Max. number of SCO packets */ +} hci_host_buffer_size_cp; - typedef hci_status_rp hci_host_buffer_size_rp; +typedef hci_status_rp hci_host_buffer_size_rp; #define HCI_OCF_HOST_NUM_COMPL_PKTS 0x0035 #define HCI_CMD_HOST_NUM_COMPL_PKTS 0x0C35 - typedef struct { - uint8_t nu_con_handles; /* # of connection handles */ - /* these are repeated "num_con_handles" times - uint16_t con_handle; --- connection handle(s) - uint16_t compl_pkts; --- # of completed packets */ - } hci_host_num_compl_pkts_cp; - /* No return parameter(s) */ +typedef struct { + uint8_t nu_con_handles; /* # of connection handles */ +/* these are repeated "num_con_handles" times + uint16_t con_handle; --- connection handle(s) + uint16_t compl_pkts; --- # of completed packets */ +} hci_host_num_compl_pkts_cp; +/* No return parameter(s) */ #define HCI_OCF_READ_LINK_SUPERVISION_TIMEOUT 0x0036 #define HCI_CMD_READ_LINK_SUPERVISION_TIMEOUT 0x0C36 - typedef struct { - uint16_t con_handle; /* connection handle */ - } hci_read_link_supervision_timeout_cp; +typedef struct { + uint16_t con_handle; /* connection handle */ +} hci_read_link_supervision_timeout_cp; - typedef struct { - uint8_t status; /* 0x00 - success */ - uint16_t con_handle; /* connection handle */ - uint16_t timeout; /* Link supervision timeout * 0.625 msec */ - } hci_read_link_supervision_timeout_rp; +typedef struct { + uint8_t status; /* 0x00 - success */ + uint16_t con_handle; /* connection handle */ + uint16_t timeout; /* Link supervision timeout * 0.625 msec */ +} hci_read_link_supervision_timeout_rp; #define HCI_OCF_WRITE_LINK_SUPERVISION_TIMEOUT 0x0037 #define HCI_CMD_WRITE_LINK_SUPERVISION_TIMEOUT 0x0C37 - typedef struct { - uint16_t con_handle; /* connection handle */ - uint16_t timeout; /* Link supervision timeout * 0.625 msec */ - } hci_write_link_supervision_timeout_cp; +typedef struct { + uint16_t con_handle; /* connection handle */ + uint16_t timeout; /* Link supervision timeout * 0.625 msec */ +} hci_write_link_supervision_timeout_cp; - typedef struct { - uint8_t status; /* 0x00 - success */ - uint16_t con_handle; /* connection handle */ - } hci_write_link_supervision_timeout_rp; +typedef struct { + uint8_t status; /* 0x00 - success */ + uint16_t con_handle; /* connection handle */ +} hci_write_link_supervision_timeout_rp; #define HCI_OCF_READ_NUM_SUPPORTED_IAC 0x0038 #define HCI_CMD_READ_NUM_SUPPORTED_IAC 0x0C38 - /* No command parameter(s) */ - typedef struct { - uint8_t status; /* 0x00 - success */ - uint8_t num_iac; /* # of supported IAC during scan */ - } hci_read_num_supported_iac_rp; +/* No command parameter(s) */ +typedef struct { + uint8_t status; /* 0x00 - success */ + uint8_t num_iac; /* # of supported IAC during scan */ +} hci_read_num_supported_iac_rp; #define HCI_OCF_READ_IAC_LAP 0x0039 #define HCI_CMD_READ_IAC_LAP 0x0C39 - /* No command parameter(s) */ - typedef struct { - uint8_t status; /* 0x00 - success */ - uint8_t num_iac; /* # of IAC */ - /* these are repeated "num_iac" times - uint8_t laps[HCI_LAP_SIZE]; --- LAPs */ - } hci_read_iac_lap_rp; +/* No command parameter(s) */ +typedef struct { + uint8_t status; /* 0x00 - success */ + uint8_t num_iac; /* # of IAC */ +/* these are repeated "num_iac" times + uint8_t laps[HCI_LAP_SIZE]; --- LAPs */ +} hci_read_iac_lap_rp; #define HCI_OCF_WRITE_IAC_LAP 0x003a #define HCI_CMD_WRITE_IAC_LAP 0x0C3A - typedef struct { - uint8_t num_iac; /* # of IAC */ - /* these are repeated "num_iac" times - uint8_t laps[HCI_LAP_SIZE]; --- LAPs */ - } hci_write_iac_lap_cp; +typedef struct { + uint8_t num_iac; /* # of IAC */ +/* these are repeated "num_iac" times + uint8_t laps[HCI_LAP_SIZE]; --- LAPs */ +} hci_write_iac_lap_cp; - typedef hci_status_rp hci_write_iac_lap_rp; +typedef hci_status_rp hci_write_iac_lap_rp; - /* Read Page Scan Period Mode is deprecated */ +/* Read Page Scan Period Mode is deprecated */ #define HCI_OCF_READ_PAGE_SCAN_PERIOD 0x003b #define HCI_CMD_READ_PAGE_SCAN_PERIOD 0x0C3B - /* No command parameter(s) */ - typedef struct { - uint8_t status; /* 0x00 - success */ - uint8_t page_scan_period_mode; /* Page scan period mode */ - } hci_read_page_scan_period_rp; +/* No command parameter(s) */ +typedef struct { + uint8_t status; /* 0x00 - success */ + uint8_t page_scan_period_mode; /* Page scan period mode */ +} hci_read_page_scan_period_rp; - /* Write Page Scan Period Mode is deprecated */ +/* Write Page Scan Period Mode is deprecated */ #define HCI_OCF_WRITE_PAGE_SCAN_PERIOD 0x003c #define HCI_CMD_WRITE_PAGE_SCAN_PERIOD 0x0C3C - typedef struct { - uint8_t page_scan_period_mode; /* Page scan period mode */ - } hci_write_page_scan_period_cp; +typedef struct { + uint8_t page_scan_period_mode; /* Page scan period mode */ +} hci_write_page_scan_period_cp; - typedef hci_status_rp hci_write_page_scan_period_rp; +typedef hci_status_rp hci_write_page_scan_period_rp; - /* Read Page Scan Mode is deprecated */ +/* Read Page Scan Mode is deprecated */ #define HCI_OCF_READ_PAGE_SCAN 0x003d #define HCI_CMD_READ_PAGE_SCAN 0x0C3D - /* No command parameter(s) */ - typedef struct { - uint8_t status; /* 0x00 - success */ - uint8_t page_scan_mode; /* Page scan mode */ - } hci_read_page_scan_rp; +/* No command parameter(s) */ +typedef struct { + uint8_t status; /* 0x00 - success */ + uint8_t page_scan_mode; /* Page scan mode */ +} hci_read_page_scan_rp; - /* Write Page Scan Mode is deprecated */ +/* Write Page Scan Mode is deprecated */ #define HCI_OCF_WRITE_PAGE_SCAN 0x003e #define HCI_CMD_WRITE_PAGE_SCAN 0x0C3E - typedef struct { - uint8_t page_scan_mode; /* Page scan mode */ - } hci_write_page_scan_cp; +typedef struct { + uint8_t page_scan_mode; /* Page scan mode */ +} hci_write_page_scan_cp; - typedef hci_status_rp hci_write_page_scan_rp; +typedef hci_status_rp hci_write_page_scan_rp; #define HCI_OCF_SET_AFH_CLASSIFICATION 0x003f #define HCI_CMD_SET_AFH_CLASSIFICATION 0x0C3F - typedef struct { - uint8_t classification[10]; - } hci_set_afh_classification_cp; +typedef struct { + uint8_t classification[10]; +} hci_set_afh_classification_cp; - typedef hci_status_rp hci_set_afh_classification_rp; +typedef hci_status_rp hci_set_afh_classification_rp; #define HCI_OCF_READ_INQUIRY_SCAN_TYPE 0x0042 #define HCI_CMD_READ_INQUIRY_SCAN_TYPE 0x0C42 - /* No command parameter(s) */ +/* No command parameter(s) */ - typedef struct { - uint8_t status; /* 0x00 - success */ - uint8_t type; /* inquiry scan type */ - } hci_read_inquiry_scan_type_rp; +typedef struct { + uint8_t status; /* 0x00 - success */ + uint8_t type; /* inquiry scan type */ +} hci_read_inquiry_scan_type_rp; #define HCI_OCF_WRITE_INQUIRY_SCAN_TYPE 0x0043 #define HCI_CMD_WRITE_INQUIRY_SCAN_TYPE 0x0C43 - typedef struct { - uint8_t type; /* inquiry scan type */ - } hci_write_inquiry_scan_type_cp; +typedef struct { + uint8_t type; /* inquiry scan type */ +} hci_write_inquiry_scan_type_cp; - typedef hci_status_rp hci_write_inquiry_scan_type_rp; +typedef hci_status_rp hci_write_inquiry_scan_type_rp; #define HCI_OCF_READ_INQUIRY_MODE 0x0044 #define HCI_CMD_READ_INQUIRY_MODE 0x0C44 - /* No command parameter(s) */ +/* No command parameter(s) */ - typedef struct { - uint8_t status; /* 0x00 - success */ - uint8_t mode; /* inquiry mode */ - } hci_read_inquiry_mode_rp; +typedef struct { + uint8_t status; /* 0x00 - success */ + uint8_t mode; /* inquiry mode */ +} hci_read_inquiry_mode_rp; #define HCI_OCF_WRITE_INQUIRY_MODE 0x0045 #define HCI_CMD_WRITE_INQUIRY_MODE 0x0C45 - typedef struct { - uint8_t mode; /* inquiry mode */ - } hci_write_inquiry_mode_cp; +typedef struct { + uint8_t mode; /* inquiry mode */ +} hci_write_inquiry_mode_cp; - typedef hci_status_rp hci_write_inquiry_mode_rp; +typedef hci_status_rp hci_write_inquiry_mode_rp; #define HCI_OCF_READ_PAGE_SCAN_TYPE 0x0046 #define HCI_CMD_READ_PAGE_SCAN_TYPE 0x0C46 - /* No command parameter(s) */ +/* No command parameter(s) */ - typedef struct { - uint8_t status; /* 0x00 - success */ - uint8_t type; /* page scan type */ - } hci_read_page_scan_type_rp; +typedef struct { + uint8_t status; /* 0x00 - success */ + uint8_t type; /* page scan type */ +} hci_read_page_scan_type_rp; #define HCI_OCF_WRITE_PAGE_SCAN_TYPE 0x0047 #define HCI_CMD_WRITE_PAGE_SCAN_TYPE 0x0C47 - typedef struct { - uint8_t type; /* page scan type */ - } hci_write_page_scan_type_cp; +typedef struct { + uint8_t type; /* page scan type */ +} hci_write_page_scan_type_cp; - typedef hci_status_rp hci_write_page_scan_type_rp; +typedef hci_status_rp hci_write_page_scan_type_rp; #define HCI_OCF_READ_AFH_ASSESSMENT 0x0048 #define HCI_CMD_READ_AFH_ASSESSMENT 0x0C48 - /* No command parameter(s) */ +/* No command parameter(s) */ - typedef struct { - uint8_t status; /* 0x00 - success */ - uint8_t mode; /* assessment mode */ - } hci_read_afh_assessment_rp; +typedef struct { + uint8_t status; /* 0x00 - success */ + uint8_t mode; /* assessment mode */ +} hci_read_afh_assessment_rp; #define HCI_OCF_WRITE_AFH_ASSESSMENT 0x0049 #define HCI_CMD_WRITE_AFH_ASSESSMENT 0x0C49 - typedef struct { - uint8_t mode; /* assessment mode */ - } hci_write_afh_assessment_cp; +typedef struct { + uint8_t mode; /* assessment mode */ +} hci_write_afh_assessment_cp; - typedef hci_status_rp hci_write_afh_assessment_rp; +typedef hci_status_rp hci_write_afh_assessment_rp; #define HCI_OCF_READ_EXTENDED_INQUIRY_RSP 0x0051 #define HCI_CMD_READ_EXTENDED_INQUIRY_RSP 0x0C51 - /* No command parameter(s) */ +/* No command parameter(s) */ - typedef struct { - uint8_t status; /* 0x00 - success */ - uint8_t fec_required; - uint8_t response[240]; - } hci_read_extended_inquiry_rsp_rp; +typedef struct { + uint8_t status; /* 0x00 - success */ + uint8_t fec_required; + uint8_t response[240]; +} hci_read_extended_inquiry_rsp_rp; #define HCI_OCF_WRITE_EXTENDED_INQUIRY_RSP 0x0052 #define HCI_CMD_WRITE_EXTENDED_INQUIRY_RSP 0x0C52 - typedef struct { - uint8_t fec_required; - uint8_t response[240]; - } hci_write_extended_inquiry_rsp_cp; +typedef struct { + uint8_t fec_required; + uint8_t response[240]; +} hci_write_extended_inquiry_rsp_cp; - typedef hci_status_rp hci_write_extended_inquiry_rsp_rp; +typedef hci_status_rp hci_write_extended_inquiry_rsp_rp; #define HCI_OCF_REFRESH_ENCRYPTION_KEY 0x0053 #define HCI_CMD_REFRESH_ENCRYPTION_KEY 0x0C53 - typedef struct { - uint16_t con_handle; /* connection handle */ - } hci_refresh_encryption_key_cp; +typedef struct { + uint16_t con_handle; /* connection handle */ +} hci_refresh_encryption_key_cp; - typedef hci_status_rp hci_refresh_encryption_key_rp; +typedef hci_status_rp hci_refresh_encryption_key_rp; #define HCI_OCF_READ_SIMPLE_PAIRING_MODE 0x0055 #define HCI_CMD_READ_SIMPLE_PAIRING_MODE 0x0C55 - /* No command parameter(s) */ +/* No command parameter(s) */ - typedef struct { - uint8_t status; /* 0x00 - success */ - uint8_t mode; /* simple pairing mode */ - } hci_read_simple_pairing_mode_rp; +typedef struct { + uint8_t status; /* 0x00 - success */ + uint8_t mode; /* simple pairing mode */ +} hci_read_simple_pairing_mode_rp; #define HCI_OCF_WRITE_SIMPLE_PAIRING_MODE 0x0056 #define HCI_CMD_WRITE_SIMPLE_PAIRING_MODE 0x0C56 - typedef struct { - uint8_t mode; /* simple pairing mode */ - } hci_write_simple_pairing_mode_cp; +typedef struct { + uint8_t mode; /* simple pairing mode */ +} hci_write_simple_pairing_mode_cp; - typedef hci_status_rp hci_write_simple_pairing_mode_rp; +typedef hci_status_rp hci_write_simple_pairing_mode_rp; #define HCI_OCF_READ_LOCAL_OOB_DATA 0x0057 #define HCI_CMD_READ_LOCAL_OOB_DATA 0x0C57 - /* No command parameter(s) */ +/* No command parameter(s) */ - typedef struct { - uint8_t status; /* 0x00 - success */ - uint8_t c[16]; /* pairing hash */ - uint8_t r[16]; /* pairing randomizer */ - } hci_read_local_oob_data_rp; +typedef struct { + uint8_t status; /* 0x00 - success */ + uint8_t c[16]; /* pairing hash */ + uint8_t r[16]; /* pairing randomizer */ +} hci_read_local_oob_data_rp; #define HCI_OCF_READ_INQUIRY_RSP_XMIT_POWER 0x0058 #define HCI_CMD_READ_INQUIRY_RSP_XMIT_POWER 0x0C58 - /* No command parameter(s) */ +/* No command parameter(s) */ - typedef struct { - uint8_t status; /* 0x00 - success */ - int8_t power; /* TX power */ - } hci_read_inquiry_rsp_xmit_power_rp; +typedef struct { + uint8_t status; /* 0x00 - success */ + int8_t power; /* TX power */ +} hci_read_inquiry_rsp_xmit_power_rp; #define HCI_OCF_WRITE_INQUIRY_RSP_XMIT_POWER 0x0059 #define HCI_CMD_WRITE_INQUIRY_RSP_XMIT_POWER 0x0C59 - typedef struct { - int8_t power; /* TX power */ - } hci_write_inquiry_rsp_xmit_power_cp; +typedef struct { + int8_t power; /* TX power */ +} hci_write_inquiry_rsp_xmit_power_cp; - typedef hci_status_rp hci_write_inquiry_rsp_xmit_power_rp; +typedef hci_status_rp hci_write_inquiry_rsp_xmit_power_rp; #define HCI_OCF_READ_DEFAULT_ERRDATA_REPORTING 0x005A #define HCI_CMD_READ_DEFAULT_ERRDATA_REPORTING 0x0C5A - /* No command parameter(s) */ +/* No command parameter(s) */ - typedef struct { - uint8_t status; /* 0x00 - success */ - uint8_t reporting; /* erroneous data reporting */ - } hci_read_default_errdata_reporting_rp; +typedef struct { + uint8_t status; /* 0x00 - success */ + uint8_t reporting; /* erroneous data reporting */ +} hci_read_default_errdata_reporting_rp; #define HCI_OCF_WRITE_DEFAULT_ERRDATA_REPORTING 0x005B #define HCI_CMD_WRITE_DEFAULT_ERRDATA_REPORTING 0x0C5B - typedef struct { - uint8_t reporting; /* erroneous data reporting */ - } hci_write_default_errdata_reporting_cp; +typedef struct { + uint8_t reporting; /* erroneous data reporting */ +} hci_write_default_errdata_reporting_cp; - typedef hci_status_rp hci_write_default_errdata_reporting_rp; +typedef hci_status_rp hci_write_default_errdata_reporting_rp; #define HCI_OCF_ENHANCED_FLUSH 0x005F #define HCI_CMD_ENHANCED_FLUSH 0x0C5F - typedef struct { - uint16_t con_handle; /* connection handle */ - uint8_t packet_type; - } hci_enhanced_flush_cp; +typedef struct { + uint16_t con_handle; /* connection handle */ + uint8_t packet_type; +} hci_enhanced_flush_cp; - /* No response parameter(s) */ +/* No response parameter(s) */ #define HCI_OCF_SEND_KEYPRESS_NOTIFICATION 0x0060 #define HCI_CMD_SEND_KEYPRESS_NOTIFICATION 0x0C60 - typedef struct { - bdaddr_t bdaddr; /* remote address */ - uint8_t type; /* notification type */ - } hci_send_keypress_notification_cp; +typedef struct { + bdaddr_t bdaddr; /* remote address */ + uint8_t type; /* notification type */ +} hci_send_keypress_notification_cp; - typedef struct { - uint8_t status; /* 0x00 - success */ - bdaddr_t bdaddr; /* remote address */ - } hci_send_keypress_notification_rp; +typedef struct { + uint8_t status; /* 0x00 - success */ + bdaddr_t bdaddr; /* remote address */ +} hci_send_keypress_notification_rp; - /************************************************************************** - ************************************************************************** - ** OGF 0x04 Informational commands and return parameters - ************************************************************************** - **************************************************************************/ +/************************************************************************** + ************************************************************************** + ** OGF 0x04 Informational commands and return parameters + ************************************************************************** + **************************************************************************/ #define HCI_OGF_INFO 0x04 #define HCI_OCF_READ_LOCAL_VER 0x0001 #define HCI_CMD_READ_LOCAL_VER 0x1001 - /* No command parameter(s) */ - typedef struct { - uint8_t status; /* 0x00 - success */ - uint8_t hci_version; /* HCI version */ - uint16_t hci_revision; /* HCI revision */ - uint8_t lmp_version; /* LMP version */ - uint16_t manufacturer; /* Hardware manufacturer name */ - uint16_t lmp_subversion; /* LMP sub-version */ - } hci_read_local_ver_rp; +/* No command parameter(s) */ +typedef struct { + uint8_t status; /* 0x00 - success */ + uint8_t hci_version; /* HCI version */ + uint16_t hci_revision; /* HCI revision */ + uint8_t lmp_version; /* LMP version */ + uint16_t manufacturer; /* Hardware manufacturer name */ + uint16_t lmp_subversion; /* LMP sub-version */ +} hci_read_local_ver_rp; #define HCI_OCF_READ_LOCAL_COMMANDS 0x0002 #define HCI_CMD_READ_LOCAL_COMMANDS 0x1002 - /* No command parameter(s) */ - typedef struct { - uint8_t status; /* 0x00 - success */ - uint8_t commands[HCI_COMMANDS_SIZE]; /* opcode bitmask */ - } hci_read_local_commands_rp; +/* No command parameter(s) */ +typedef struct { + uint8_t status; /* 0x00 - success */ + uint8_t commands[HCI_COMMANDS_SIZE]; /* opcode bitmask */ +} hci_read_local_commands_rp; #define HCI_OCF_READ_LOCAL_FEATURES 0x0003 #define HCI_CMD_READ_LOCAL_FEATURES 0x1003 - /* No command parameter(s) */ - typedef struct { - uint8_t status; /* 0x00 - success */ - uint8_t features[HCI_FEATURES_SIZE]; /* LMP features bitmsk*/ - } hci_read_local_features_rp; +/* No command parameter(s) */ +typedef struct { + uint8_t status; /* 0x00 - success */ + uint8_t features[HCI_FEATURES_SIZE]; /* LMP features bitmsk*/ +} hci_read_local_features_rp; #define HCI_OCF_READ_LOCAL_EXTENDED_FEATURES 0x0004 #define HCI_CMD_READ_LOCAL_EXTENDED_FEATURES 0x1004 - typedef struct { - uint8_t page; /* page number */ - } hci_read_local_extended_features_cp; +typedef struct { + uint8_t page; /* page number */ +} hci_read_local_extended_features_cp; - typedef struct { - uint8_t status; /* 0x00 - success */ - uint8_t page; /* page number */ - uint8_t max_page; /* maximum page number */ - uint8_t features[HCI_FEATURES_SIZE]; /* LMP features */ - } hci_read_local_extended_features_rp; +typedef struct { + uint8_t status; /* 0x00 - success */ + uint8_t page; /* page number */ + uint8_t max_page; /* maximum page number */ + uint8_t features[HCI_FEATURES_SIZE]; /* LMP features */ +} hci_read_local_extended_features_rp; #define HCI_OCF_READ_BUFFER_SIZE 0x0005 #define HCI_CMD_READ_BUFFER_SIZE 0x1005 - /* No command parameter(s) */ - typedef struct { - uint8_t status; /* 0x00 - success */ - uint16_t max_acl_size; /* Max. size of ACL packet (bytes) */ - uint8_t max_sco_size; /* Max. size of SCO packet (bytes) */ - uint16_t num_acl_pkts; /* Max. number of ACL packets */ - uint16_t num_sco_pkts; /* Max. number of SCO packets */ - } hci_read_buffer_size_rp; +/* No command parameter(s) */ +typedef struct { + uint8_t status; /* 0x00 - success */ + uint16_t max_acl_size; /* Max. size of ACL packet (bytes) */ + uint8_t max_sco_size; /* Max. size of SCO packet (bytes) */ + uint16_t num_acl_pkts; /* Max. number of ACL packets */ + uint16_t num_sco_pkts; /* Max. number of SCO packets */ +} hci_read_buffer_size_rp; - /* Read Country Code is deprecated */ +/* Read Country Code is deprecated */ #define HCI_OCF_READ_COUNTRY_CODE 0x0007 #define HCI_CMD_READ_COUNTRY_CODE 0x1007 - /* No command parameter(s) */ - typedef struct { - uint8_t status; /* 0x00 - success */ - uint8_t country_code; /* 0x00 - NAM, EUR, JP; 0x01 - France */ - } hci_read_country_code_rp; +/* No command parameter(s) */ +typedef struct { + uint8_t status; /* 0x00 - success */ + uint8_t country_code; /* 0x00 - NAM, EUR, JP; 0x01 - France */ +} hci_read_country_code_rp; #define HCI_OCF_READ_BDADDR 0x0009 #define HCI_CMD_READ_BDADDR 0x1009 - /* No command parameter(s) */ - typedef struct { - uint8_t status; /* 0x00 - success */ - bdaddr_t bdaddr; /* unit address */ - } hci_read_bdaddr_rp; +/* No command parameter(s) */ +typedef struct { + uint8_t status; /* 0x00 - success */ + bdaddr_t bdaddr; /* unit address */ +} hci_read_bdaddr_rp; - /************************************************************************** - ************************************************************************** - ** OGF 0x05 Status commands and return parameters - ************************************************************************** - **************************************************************************/ +/************************************************************************** + ************************************************************************** + ** OGF 0x05 Status commands and return parameters + ************************************************************************** + **************************************************************************/ #define HCI_OGF_STATUS 0x05 #define HCI_OCF_READ_FAILED_CONTACT_CNTR 0x0001 #define HCI_CMD_READ_FAILED_CONTACT_CNTR 0x1401 - typedef struct { - uint16_t con_handle; /* connection handle */ - } hci_read_failed_contact_cntr_cp; +typedef struct { + uint16_t con_handle; /* connection handle */ +} hci_read_failed_contact_cntr_cp; - typedef struct { - uint8_t status; /* 0x00 - success */ - uint16_t con_handle; /* connection handle */ - uint16_t counter; /* number of consecutive failed contacts */ - } hci_read_failed_contact_cntr_rp; +typedef struct { + uint8_t status; /* 0x00 - success */ + uint16_t con_handle; /* connection handle */ + uint16_t counter; /* number of consecutive failed contacts */ +} hci_read_failed_contact_cntr_rp; #define HCI_OCF_RESET_FAILED_CONTACT_CNTR 0x0002 #define HCI_CMD_RESET_FAILED_CONTACT_CNTR 0x1402 - typedef struct { - uint16_t con_handle; /* connection handle */ - } hci_reset_failed_contact_cntr_cp; +typedef struct { + uint16_t con_handle; /* connection handle */ +} hci_reset_failed_contact_cntr_cp; - typedef struct { - uint8_t status; /* 0x00 - success */ - uint16_t con_handle; /* connection handle */ - } hci_reset_failed_contact_cntr_rp; +typedef struct { + uint8_t status; /* 0x00 - success */ + uint16_t con_handle; /* connection handle */ +} hci_reset_failed_contact_cntr_rp; #define HCI_OCF_READ_LINK_QUALITY 0x0003 #define HCI_CMD_READ_LINK_QUALITY 0x1403 - typedef struct { - uint16_t con_handle; /* connection handle */ - } hci_read_link_quality_cp; +typedef struct { + uint16_t con_handle; /* connection handle */ +} hci_read_link_quality_cp; - typedef struct { - uint8_t status; /* 0x00 - success */ - uint16_t con_handle; /* connection handle */ - uint8_t quality; /* higher value means better quality */ - } hci_read_link_quality_rp; +typedef struct { + uint8_t status; /* 0x00 - success */ + uint16_t con_handle; /* connection handle */ + uint8_t quality; /* higher value means better quality */ +} hci_read_link_quality_rp; #define HCI_OCF_READ_RSSI 0x0005 #define HCI_CMD_READ_RSSI 0x1405 - typedef struct { - uint16_t con_handle; /* connection handle */ - } hci_read_rssi_cp; +typedef struct { + uint16_t con_handle; /* connection handle */ +} hci_read_rssi_cp; - typedef struct { - uint8_t status; /* 0x00 - success */ - uint16_t con_handle; /* connection handle */ - char rssi; /* -127 <= rssi <= 127 dB */ - } hci_read_rssi_rp; +typedef struct { + uint8_t status; /* 0x00 - success */ + uint16_t con_handle; /* connection handle */ + char rssi; /* -127 <= rssi <= 127 dB */ +} hci_read_rssi_rp; #define HCI_OCF_READ_AFH_CHANNEL_MAP 0x0006 #define HCI_CMD_READ_AFH_CHANNEL_MAP 0x1406 - typedef struct { - uint16_t con_handle; /* connection handle */ - } hci_read_afh_channel_map_cp; +typedef struct { + uint16_t con_handle; /* connection handle */ +} hci_read_afh_channel_map_cp; - typedef struct { - uint8_t status; /* 0x00 - success */ - uint16_t con_handle; /* connection handle */ - uint8_t mode; /* AFH mode */ - uint8_t map[10]; /* AFH Channel Map */ - } hci_read_afh_channel_map_rp; +typedef struct { + uint8_t status; /* 0x00 - success */ + uint16_t con_handle; /* connection handle */ + uint8_t mode; /* AFH mode */ + uint8_t map[10]; /* AFH Channel Map */ +} hci_read_afh_channel_map_rp; #define HCI_OCF_READ_CLOCK 0x0007 #define HCI_CMD_READ_CLOCK 0x1407 - typedef struct { - uint16_t con_handle; /* connection handle */ - uint8_t clock; /* which clock */ - } hci_read_clock_cp; +typedef struct { + uint16_t con_handle; /* connection handle */ + uint8_t clock; /* which clock */ +} hci_read_clock_cp; - typedef struct { - uint8_t status; /* 0x00 - success */ - uint16_t con_handle; /* connection handle */ - uint32_t clock; /* clock value */ - uint16_t accuracy; /* clock accuracy */ - } hci_read_clock_rp; +typedef struct { + uint8_t status; /* 0x00 - success */ + uint16_t con_handle; /* connection handle */ + uint32_t clock; /* clock value */ + uint16_t accuracy; /* clock accuracy */ +} hci_read_clock_rp; - /************************************************************************** - ************************************************************************** - ** OGF 0x06 Testing commands and return parameters - ************************************************************************** - **************************************************************************/ +/************************************************************************** + ************************************************************************** + ** OGF 0x06 Testing commands and return parameters + ************************************************************************** + **************************************************************************/ #define HCI_OGF_TESTING 0x06 #define HCI_OCF_READ_LOOPBACK_MODE 0x0001 #define HCI_CMD_READ_LOOPBACK_MODE 0x1801 - /* No command parameter(s) */ - typedef struct { - uint8_t status; /* 0x00 - success */ - uint8_t lbmode; /* loopback mode */ - } hci_read_loopback_mode_rp; +/* No command parameter(s) */ +typedef struct { + uint8_t status; /* 0x00 - success */ + uint8_t lbmode; /* loopback mode */ +} hci_read_loopback_mode_rp; #define HCI_OCF_WRITE_LOOPBACK_MODE 0x0002 #define HCI_CMD_WRITE_LOOPBACK_MODE 0x1802 - typedef struct { - uint8_t lbmode; /* loopback mode */ - } hci_write_loopback_mode_cp; +typedef struct { + uint8_t lbmode; /* loopback mode */ +} hci_write_loopback_mode_cp; - typedef hci_status_rp hci_write_loopback_mode_rp; +typedef hci_status_rp hci_write_loopback_mode_rp; #define HCI_OCF_ENABLE_UNIT_UNDER_TEST 0x0003 #define HCI_CMD_ENABLE_UNIT_UNDER_TEST 0x1803 - /* No command parameter(s) */ - typedef hci_status_rp hci_enable_unit_under_test_rp; +/* No command parameter(s) */ +typedef hci_status_rp hci_enable_unit_under_test_rp; #define HCI_OCF_WRITE_SIMPLE_PAIRING_DEBUG_MODE 0x0004 #define HCI_CMD_WRITE_SIMPLE_PAIRING_DEBUG_MODE 0x1804 - typedef struct { - uint8_t mode; /* simple pairing debug mode */ - } hci_write_simple_pairing_debug_mode_cp; +typedef struct { + uint8_t mode; /* simple pairing debug mode */ +} hci_write_simple_pairing_debug_mode_cp; - typedef hci_status_rp hci_write_simple_pairing_debug_mode_rp; +typedef hci_status_rp hci_write_simple_pairing_debug_mode_rp; - /************************************************************************** - ************************************************************************** - ** OGF 0x3e Bluetooth Logo Testing - ** OGF 0x3f Vendor Specific - ************************************************************************** - **************************************************************************/ +/************************************************************************** + ************************************************************************** + ** OGF 0x3e Bluetooth Logo Testing + ** OGF 0x3f Vendor Specific + ************************************************************************** + **************************************************************************/ #define HCI_OGF_BT_LOGO 0x3e #define HCI_OGF_VENDOR 0x3f - /* Ericsson specific FC */ +/* Ericsson specific FC */ #define HCI_CMD_ERICSSON_WRITE_PCM_SETTINGS 0xFC07 #define HCI_CMD_ERICSSON_SET_UART_BAUD_RATE 0xFC09 #define HCI_CMD_ERICSSON_SET_SCO_DATA_PATH 0xFC1D - /* Cambridge Silicon Radio specific FC */ +/* Cambridge Silicon Radio specific FC */ #define HCI_CMD_CSR_EXTN 0xFC00 - /************************************************************************** - ************************************************************************** - ** Events and event parameters - ************************************************************************** - **************************************************************************/ +/************************************************************************** + ************************************************************************** + ** Events and event parameters + ************************************************************************** + **************************************************************************/ #define HCI_EVENT_INQUIRY_COMPL 0x01 - typedef struct { - uint8_t status; /* 0x00 - success */ - } hci_inquiry_compl_ep; +typedef struct { + uint8_t status; /* 0x00 - success */ +} hci_inquiry_compl_ep; #define HCI_EVENT_INQUIRY_RESULT 0x02 - typedef struct { - uint8_t num_responses; /* number of responses */ - /* hci_inquiry_response[num_responses] -- see below */ - } hci_inquiry_result_ep; +typedef struct { + uint8_t num_responses; /* number of responses */ +/* hci_inquiry_response[num_responses] -- see below */ +} hci_inquiry_result_ep; - typedef struct { - bdaddr_t bdaddr; /* unit address */ - uint8_t page_scan_rep_mode; /* page scan rep. mode */ - uint8_t page_scan_period_mode; /* page scan period mode */ - uint8_t page_scan_mode; /* page scan mode */ - uint8_t uclass[HCI_CLASS_SIZE]; /* unit class */ - uint16_t clock_offset; /* clock offset */ - } hci_inquiry_response; +typedef struct { + bdaddr_t bdaddr; /* unit address */ + uint8_t page_scan_rep_mode; /* page scan rep. mode */ + uint8_t page_scan_period_mode; /* page scan period mode */ + uint8_t page_scan_mode; /* page scan mode */ + uint8_t uclass[HCI_CLASS_SIZE]; /* unit class */ + uint16_t clock_offset; /* clock offset */ +} hci_inquiry_response; #define HCI_EVENT_CON_COMPL 0x03 - typedef struct { - uint8_t status; /* 0x00 - success */ - uint16_t con_handle; /* Connection handle */ - bdaddr_t bdaddr; /* remote unit address */ - uint8_t link_type; /* Link type */ - uint8_t encryption_mode; /* Encryption mode */ - } hci_con_compl_ep; +typedef struct { + uint8_t status; /* 0x00 - success */ + uint16_t con_handle; /* Connection handle */ + bdaddr_t bdaddr; /* remote unit address */ + uint8_t link_type; /* Link type */ + uint8_t encryption_mode; /* Encryption mode */ +} hci_con_compl_ep; #define HCI_EVENT_CON_REQ 0x04 - typedef struct { - bdaddr_t bdaddr; /* remote unit address */ - uint8_t uclass[HCI_CLASS_SIZE]; /* remote unit class */ - uint8_t link_type; /* link type */ - } hci_con_req_ep; +typedef struct { + bdaddr_t bdaddr; /* remote unit address */ + uint8_t uclass[HCI_CLASS_SIZE]; /* remote unit class */ + uint8_t link_type; /* link type */ +} hci_con_req_ep; #define HCI_EVENT_DISCON_COMPL 0x05 - typedef struct { - uint8_t status; /* 0x00 - success */ - uint16_t con_handle; /* connection handle */ - uint8_t reason; /* reason to disconnect */ - } hci_discon_compl_ep; +typedef struct { + uint8_t status; /* 0x00 - success */ + uint16_t con_handle; /* connection handle */ + uint8_t reason; /* reason to disconnect */ +} hci_discon_compl_ep; #define HCI_EVENT_AUTH_COMPL 0x06 - typedef struct { - uint8_t status; /* 0x00 - success */ - uint16_t con_handle; /* connection handle */ - } hci_auth_compl_ep; +typedef struct { + uint8_t status; /* 0x00 - success */ + uint16_t con_handle; /* connection handle */ +} hci_auth_compl_ep; #define HCI_EVENT_REMOTE_NAME_REQ_COMPL 0x07 - typedef struct { - uint8_t status; /* 0x00 - success */ - bdaddr_t bdaddr; /* remote unit address */ - char name[HCI_UNIT_NAME_SIZE]; /* remote unit name */ - } hci_remote_name_req_compl_ep; +typedef struct { + uint8_t status; /* 0x00 - success */ + bdaddr_t bdaddr; /* remote unit address */ + char name[HCI_UNIT_NAME_SIZE]; /* remote unit name */ +} hci_remote_name_req_compl_ep; #define HCI_EVENT_ENCRYPTION_CHANGE 0x08 - typedef struct { - uint8_t status; /* 0x00 - success */ - uint16_t con_handle; /* Connection handle */ - uint8_t encryption_enable; /* 0x00 - disable */ - } hci_encryption_change_ep; +typedef struct { + uint8_t status; /* 0x00 - success */ + uint16_t con_handle; /* Connection handle */ + uint8_t encryption_enable; /* 0x00 - disable */ +} hci_encryption_change_ep; #define HCI_EVENT_CHANGE_CON_LINK_KEY_COMPL 0x09 - typedef struct { - uint8_t status; /* 0x00 - success */ - uint16_t con_handle; /* Connection handle */ - } hci_change_con_link_key_compl_ep; +typedef struct { + uint8_t status; /* 0x00 - success */ + uint16_t con_handle; /* Connection handle */ +} hci_change_con_link_key_compl_ep; #define HCI_EVENT_MASTER_LINK_KEY_COMPL 0x0a - typedef struct { - uint8_t status; /* 0x00 - success */ - uint16_t con_handle; /* Connection handle */ - uint8_t key_flag; /* Key flag */ - } hci_master_link_key_compl_ep; +typedef struct { + uint8_t status; /* 0x00 - success */ + uint16_t con_handle; /* Connection handle */ + uint8_t key_flag; /* Key flag */ +} hci_master_link_key_compl_ep; #define HCI_EVENT_READ_REMOTE_FEATURES_COMPL 0x0b - typedef struct { - uint8_t status; /* 0x00 - success */ - uint16_t con_handle; /* Connection handle */ - uint8_t features[HCI_FEATURES_SIZE]; /* LMP features bitmsk*/ - } hci_read_remote_features_compl_ep; +typedef struct { + uint8_t status; /* 0x00 - success */ + uint16_t con_handle; /* Connection handle */ + uint8_t features[HCI_FEATURES_SIZE]; /* LMP features bitmsk*/ +} hci_read_remote_features_compl_ep; #define HCI_EVENT_READ_REMOTE_VER_INFO_COMPL 0x0c - typedef struct { - uint8_t status; /* 0x00 - success */ - uint16_t con_handle; /* Connection handle */ - uint8_t lmp_version; /* LMP version */ - uint16_t manufacturer; /* Hardware manufacturer name */ - uint16_t lmp_subversion; /* LMP sub-version */ - } hci_read_remote_ver_info_compl_ep; +typedef struct { + uint8_t status; /* 0x00 - success */ + uint16_t con_handle; /* Connection handle */ + uint8_t lmp_version; /* LMP version */ + uint16_t manufacturer; /* Hardware manufacturer name */ + uint16_t lmp_subversion; /* LMP sub-version */ +} hci_read_remote_ver_info_compl_ep; #define HCI_EVENT_QOS_SETUP_COMPL 0x0d - typedef struct { - uint8_t status; /* 0x00 - success */ - uint16_t con_handle; /* connection handle */ - uint8_t flags; /* reserved for future use */ - uint8_t service_type; /* service type */ - uint32_t token_rate; /* bytes per second */ - uint32_t peak_bandwidth; /* bytes per second */ - uint32_t latency; /* microseconds */ - uint32_t delay_variation; /* microseconds */ - } hci_qos_setup_compl_ep; +typedef struct { + uint8_t status; /* 0x00 - success */ + uint16_t con_handle; /* connection handle */ + uint8_t flags; /* reserved for future use */ + uint8_t service_type; /* service type */ + uint32_t token_rate; /* bytes per second */ + uint32_t peak_bandwidth; /* bytes per second */ + uint32_t latency; /* microseconds */ + uint32_t delay_variation; /* microseconds */ +} hci_qos_setup_compl_ep; #define HCI_EVENT_COMMAND_COMPL 0x0e - typedef struct { - uint8_t num_cmd_pkts; /* # of HCI command packets */ - uint16_t opcode; /* command OpCode */ - /* command return parameters (if any) */ - } hci_command_compl_ep; +typedef struct { + uint8_t num_cmd_pkts; /* # of HCI command packets */ + uint16_t opcode; /* command OpCode */ + /* command return parameters (if any) */ +} hci_command_compl_ep; #define HCI_EVENT_COMMAND_STATUS 0x0f - typedef struct { - uint8_t status; /* 0x00 - pending */ - uint8_t num_cmd_pkts; /* # of HCI command packets */ - uint16_t opcode; /* command OpCode */ - } hci_command_status_ep; +typedef struct { + uint8_t status; /* 0x00 - pending */ + uint8_t num_cmd_pkts; /* # of HCI command packets */ + uint16_t opcode; /* command OpCode */ +} hci_command_status_ep; #define HCI_EVENT_HARDWARE_ERROR 0x10 - typedef struct { - uint8_t hardware_code; /* hardware error code */ - } hci_hardware_error_ep; +typedef struct { + uint8_t hardware_code; /* hardware error code */ +} hci_hardware_error_ep; #define HCI_EVENT_FLUSH_OCCUR 0x11 - typedef struct { - uint16_t con_handle; /* connection handle */ - } hci_flush_occur_ep; +typedef struct { + uint16_t con_handle; /* connection handle */ +} hci_flush_occur_ep; #define HCI_EVENT_ROLE_CHANGE 0x12 - typedef struct { - uint8_t status; /* 0x00 - success */ - bdaddr_t bdaddr; /* address of remote unit */ - uint8_t role; /* new connection role */ - } hci_role_change_ep; +typedef struct { + uint8_t status; /* 0x00 - success */ + bdaddr_t bdaddr; /* address of remote unit */ + uint8_t role; /* new connection role */ +} hci_role_change_ep; #define HCI_EVENT_NUM_COMPL_PKTS 0x13 - typedef struct { - uint8_t num_con_handles; /* # of connection handles */ - /* these are repeated "num_con_handles" times - uint16_t con_handle; --- connection handle(s) - uint16_t compl_pkts; --- # of completed packets */ - } hci_num_compl_pkts_ep; +typedef struct { + uint8_t num_con_handles; /* # of connection handles */ +/* these are repeated "num_con_handles" times + uint16_t con_handle; --- connection handle(s) + uint16_t compl_pkts; --- # of completed packets */ +} hci_num_compl_pkts_ep; + +typedef struct { + uint16_t con_handle; + uint16_t compl_pkts; +} hci_num_compl_pkts_info; #define HCI_EVENT_MODE_CHANGE 0x14 - typedef struct { - uint8_t status; /* 0x00 - success */ - uint16_t con_handle; /* connection handle */ - uint8_t unit_mode; /* remote unit mode */ - uint16_t interval; /* interval * 0.625 msec */ - } hci_mode_change_ep; +typedef struct { + uint8_t status; /* 0x00 - success */ + uint16_t con_handle; /* connection handle */ + uint8_t unit_mode; /* remote unit mode */ + uint16_t interval; /* interval * 0.625 msec */ +} hci_mode_change_ep; #define HCI_EVENT_RETURN_LINK_KEYS 0x15 - typedef struct { - uint8_t num_keys; /* # of keys */ - /* these are repeated "num_keys" times - bdaddr_t bdaddr; --- remote address(es) - uint8_t key[HCI_KEY_SIZE]; --- key(s) */ - } hci_return_link_keys_ep; +typedef struct { + uint8_t num_keys; /* # of keys */ +/* these are repeated "num_keys" times + bdaddr_t bdaddr; --- remote address(es) + uint8_t key[HCI_KEY_SIZE]; --- key(s) */ +} hci_return_link_keys_ep; #define HCI_EVENT_PIN_CODE_REQ 0x16 - typedef struct { - bdaddr_t bdaddr; /* remote unit address */ - } hci_pin_code_req_ep; +typedef struct { + bdaddr_t bdaddr; /* remote unit address */ +} hci_pin_code_req_ep; #define HCI_EVENT_LINK_KEY_REQ 0x17 - typedef struct { - bdaddr_t bdaddr; /* remote unit address */ - } hci_link_key_req_ep; +typedef struct { + bdaddr_t bdaddr; /* remote unit address */ +} hci_link_key_req_ep; #define HCI_EVENT_LINK_KEY_NOTIFICATION 0x18 - typedef struct { - bdaddr_t bdaddr; /* remote unit address */ - uint8_t key[HCI_KEY_SIZE]; /* link key */ - uint8_t key_type; /* type of the key */ - } hci_link_key_notification_ep; +typedef struct { + bdaddr_t bdaddr; /* remote unit address */ + uint8_t key[HCI_KEY_SIZE]; /* link key */ + uint8_t key_type; /* type of the key */ +} hci_link_key_notification_ep; #define HCI_EVENT_LOOPBACK_COMMAND 0x19 - typedef hci_cmd_hdr_t hci_loopback_command_ep; +typedef hci_cmd_hdr_t hci_loopback_command_ep; #define HCI_EVENT_DATA_BUFFER_OVERFLOW 0x1a - typedef struct { - uint8_t link_type; /* Link type */ - } hci_data_buffer_overflow_ep; +typedef struct { + uint8_t link_type; /* Link type */ +} hci_data_buffer_overflow_ep; #define HCI_EVENT_MAX_SLOT_CHANGE 0x1b - typedef struct { - uint16_t con_handle; /* connection handle */ - uint8_t lmp_max_slots; /* Max. # of slots allowed */ - } hci_max_slot_change_ep; +typedef struct { + uint16_t con_handle; /* connection handle */ + uint8_t lmp_max_slots; /* Max. # of slots allowed */ +} hci_max_slot_change_ep; #define HCI_EVENT_READ_CLOCK_OFFSET_COMPL 0x1c - typedef struct { - uint8_t status; /* 0x00 - success */ - uint16_t con_handle; /* Connection handle */ - uint16_t clock_offset; /* Clock offset */ - } hci_read_clock_offset_compl_ep; +typedef struct { + uint8_t status; /* 0x00 - success */ + uint16_t con_handle; /* Connection handle */ + uint16_t clock_offset; /* Clock offset */ +} hci_read_clock_offset_compl_ep; #define HCI_EVENT_CON_PKT_TYPE_CHANGED 0x1d - typedef struct { - uint8_t status; /* 0x00 - success */ - uint16_t con_handle; /* connection handle */ - uint16_t pkt_type; /* packet type */ - } hci_con_pkt_type_changed_ep; +typedef struct { + uint8_t status; /* 0x00 - success */ + uint16_t con_handle; /* connection handle */ + uint16_t pkt_type; /* packet type */ +} hci_con_pkt_type_changed_ep; #define HCI_EVENT_QOS_VIOLATION 0x1e - typedef struct { - uint16_t con_handle; /* connection handle */ - } hci_qos_violation_ep; +typedef struct { + uint16_t con_handle; /* connection handle */ +} hci_qos_violation_ep; - /* Page Scan Mode Change Event is deprecated */ +/* Page Scan Mode Change Event is deprecated */ #define HCI_EVENT_PAGE_SCAN_MODE_CHANGE 0x1f - typedef struct { - bdaddr_t bdaddr; /* destination address */ - uint8_t page_scan_mode; /* page scan mode */ - } hci_page_scan_mode_change_ep; +typedef struct { + bdaddr_t bdaddr; /* destination address */ + uint8_t page_scan_mode; /* page scan mode */ +} hci_page_scan_mode_change_ep; #define HCI_EVENT_PAGE_SCAN_REP_MODE_CHANGE 0x20 - typedef struct { - bdaddr_t bdaddr; /* destination address */ - uint8_t page_scan_rep_mode; /* page scan repetition mode */ - } hci_page_scan_rep_mode_change_ep; +typedef struct { + bdaddr_t bdaddr; /* destination address */ + uint8_t page_scan_rep_mode; /* page scan repetition mode */ +} hci_page_scan_rep_mode_change_ep; #define HCI_EVENT_FLOW_SPECIFICATION_COMPL 0x21 - typedef struct { - uint8_t status; /* 0x00 - success */ - uint16_t con_handle; /* connection handle */ - uint8_t flags; /* reserved */ - uint8_t direction; /* flow direction */ - uint8_t type; /* service type */ - uint32_t token_rate; /* token rate */ - uint32_t bucket_size; /* token bucket size */ - uint32_t peak_bandwidth; /* peak bandwidth */ - uint32_t latency; /* access latency */ - } hci_flow_specification_compl_ep; +typedef struct { + uint8_t status; /* 0x00 - success */ + uint16_t con_handle; /* connection handle */ + uint8_t flags; /* reserved */ + uint8_t direction; /* flow direction */ + uint8_t type; /* service type */ + uint32_t token_rate; /* token rate */ + uint32_t bucket_size; /* token bucket size */ + uint32_t peak_bandwidth; /* peak bandwidth */ + uint32_t latency; /* access latency */ +} hci_flow_specification_compl_ep; #define HCI_EVENT_RSSI_RESULT 0x22 - typedef struct { - uint8_t num_responses; /* number of responses */ - /* hci_rssi_response[num_responses] -- see below */ - } hci_rssi_result_ep; +typedef struct { + uint8_t num_responses; /* number of responses */ +/* hci_rssi_response[num_responses] -- see below */ +} hci_rssi_result_ep; - typedef struct { - bdaddr_t bdaddr; /* unit address */ - uint8_t page_scan_rep_mode; /* page scan rep. mode */ - uint8_t blank; /* reserved */ - uint8_t uclass[HCI_CLASS_SIZE]; /* unit class */ - uint16_t clock_offset; /* clock offset */ - int8_t rssi; /* rssi */ - } hci_rssi_response; +typedef struct { + bdaddr_t bdaddr; /* unit address */ + uint8_t page_scan_rep_mode; /* page scan rep. mode */ + uint8_t blank; /* reserved */ + uint8_t uclass[HCI_CLASS_SIZE]; /* unit class */ + uint16_t clock_offset; /* clock offset */ + int8_t rssi; /* rssi */ +} hci_rssi_response; #define HCI_EVENT_READ_REMOTE_EXTENDED_FEATURES 0x23 - typedef struct { - uint8_t status; /* 0x00 - success */ - uint16_t con_handle; /* connection handle */ - uint8_t page; /* page number */ - uint8_t max; /* max page number */ - uint8_t features[HCI_FEATURES_SIZE]; /* LMP features bitmsk*/ - } hci_read_remote_extended_features_ep; +typedef struct { + uint8_t status; /* 0x00 - success */ + uint16_t con_handle; /* connection handle */ + uint8_t page; /* page number */ + uint8_t max; /* max page number */ + uint8_t features[HCI_FEATURES_SIZE]; /* LMP features bitmsk*/ +} hci_read_remote_extended_features_ep; #define HCI_EVENT_SCO_CON_COMPL 0x2c - typedef struct { - uint8_t status; /* 0x00 - success */ - uint16_t con_handle; /* connection handle */ - bdaddr_t bdaddr; /* unit address */ - uint8_t link_type; /* link type */ - uint8_t interval; /* transmission interval */ - uint8_t window; /* retransmission window */ - uint16_t rxlen; /* rx packet length */ - uint16_t txlen; /* tx packet length */ - uint8_t mode; /* air mode */ - } hci_sco_con_compl_ep; +typedef struct { + uint8_t status; /* 0x00 - success */ + uint16_t con_handle; /* connection handle */ + bdaddr_t bdaddr; /* unit address */ + uint8_t link_type; /* link type */ + uint8_t interval; /* transmission interval */ + uint8_t window; /* retransmission window */ + uint16_t rxlen; /* rx packet length */ + uint16_t txlen; /* tx packet length */ + uint8_t mode; /* air mode */ +} hci_sco_con_compl_ep; #define HCI_EVENT_SCO_CON_CHANGED 0x2d - typedef struct { - uint8_t status; /* 0x00 - success */ - uint16_t con_handle; /* connection handle */ - uint8_t interval; /* transmission interval */ - uint8_t window; /* retransmission window */ - uint16_t rxlen; /* rx packet length */ - uint16_t txlen; /* tx packet length */ - } hci_sco_con_changed_ep; +typedef struct { + uint8_t status; /* 0x00 - success */ + uint16_t con_handle; /* connection handle */ + uint8_t interval; /* transmission interval */ + uint8_t window; /* retransmission window */ + uint16_t rxlen; /* rx packet length */ + uint16_t txlen; /* tx packet length */ +} hci_sco_con_changed_ep; #define HCI_EVENT_SNIFF_SUBRATING 0x2e - typedef struct { - uint8_t status; /* 0x00 - success */ - uint16_t con_handle; /* connection handle */ - uint16_t tx_latency; /* max transmit latency */ - uint16_t rx_latency; /* max receive latency */ - uint16_t remote_timeout; /* remote timeout */ - uint16_t local_timeout; /* local timeout */ - } hci_sniff_subrating_ep; +typedef struct { + uint8_t status; /* 0x00 - success */ + uint16_t con_handle; /* connection handle */ + uint16_t tx_latency; /* max transmit latency */ + uint16_t rx_latency; /* max receive latency */ + uint16_t remote_timeout; /* remote timeout */ + uint16_t local_timeout; /* local timeout */ +} hci_sniff_subrating_ep; #define HCI_EVENT_EXTENDED_RESULT 0x2f - typedef struct { - uint8_t num_responses; /* must be 0x01 */ - bdaddr_t bdaddr; /* remote device address */ - uint8_t page_scan_rep_mode; - uint8_t reserved; - uint8_t uclass[HCI_CLASS_SIZE]; - uint16_t clock_offset; - int8_t rssi; - uint8_t response[240]; /* extended inquiry response */ - } hci_extended_result_ep; +typedef struct { + uint8_t num_responses; /* must be 0x01 */ + bdaddr_t bdaddr; /* remote device address */ + uint8_t page_scan_rep_mode; + uint8_t reserved; + uint8_t uclass[HCI_CLASS_SIZE]; + uint16_t clock_offset; + int8_t rssi; + uint8_t response[240]; /* extended inquiry response */ +} hci_extended_result_ep; #define HCI_EVENT_ENCRYPTION_KEY_REFRESH 0x30 - typedef struct { - uint8_t status; /* 0x00 - success */ - uint16_t con_handle; /* connection handle */ - } hci_encryption_key_refresh_ep; +typedef struct { + uint8_t status; /* 0x00 - success */ + uint16_t con_handle; /* connection handle */ +} hci_encryption_key_refresh_ep; #define HCI_EVENT_IO_CAPABILITY_REQ 0x31 - typedef struct { - bdaddr_t bdaddr; /* remote device address */ - } hci_io_capability_req_ep; +typedef struct { + bdaddr_t bdaddr; /* remote device address */ +} hci_io_capability_req_ep; #define HCI_EVENT_IO_CAPABILITY_RSP 0x32 - typedef struct { - bdaddr_t bdaddr; /* remote device address */ - uint8_t io_capability; - uint8_t oob_data_present; - uint8_t auth_requirement; - } hci_io_capability_rsp_ep; +typedef struct { + bdaddr_t bdaddr; /* remote device address */ + uint8_t io_capability; + uint8_t oob_data_present; + uint8_t auth_requirement; +} hci_io_capability_rsp_ep; #define HCI_EVENT_USER_CONFIRM_REQ 0x33 - typedef struct { - bdaddr_t bdaddr; /* remote device address */ - uint32_t value; /* 000000 - 999999 */ - } hci_user_confirm_req_ep; +typedef struct { + bdaddr_t bdaddr; /* remote device address */ + uint32_t value; /* 000000 - 999999 */ +} hci_user_confirm_req_ep; #define HCI_EVENT_USER_PASSKEY_REQ 0x34 - typedef struct { - bdaddr_t bdaddr; /* remote device address */ - } hci_user_passkey_req_ep; +typedef struct { + bdaddr_t bdaddr; /* remote device address */ +} hci_user_passkey_req_ep; #define HCI_EVENT_REMOTE_OOB_DATA_REQ 0x35 - typedef struct { - bdaddr_t bdaddr; /* remote device address */ - } hci_remote_oob_data_req_ep; +typedef struct { + bdaddr_t bdaddr; /* remote device address */ +} hci_remote_oob_data_req_ep; #define HCI_EVENT_SIMPLE_PAIRING_COMPL 0x36 - typedef struct { - uint8_t status; /* 0x00 - success */ - bdaddr_t bdaddr; /* remote device address */ - } hci_simple_pairing_compl_ep; +typedef struct { + uint8_t status; /* 0x00 - success */ + bdaddr_t bdaddr; /* remote device address */ +} hci_simple_pairing_compl_ep; #define HCI_EVENT_LINK_SUPERVISION_TO_CHANGED 0x38 - typedef struct { - uint16_t con_handle; /* connection handle */ - uint16_t timeout; /* link supervision timeout */ - } hci_link_supervision_to_changed_ep; +typedef struct { + uint16_t con_handle; /* connection handle */ + uint16_t timeout; /* link supervision timeout */ +} hci_link_supervision_to_changed_ep; #define HCI_EVENT_ENHANCED_FLUSH_COMPL 0x39 - typedef struct { - uint16_t con_handle; /* connection handle */ - } hci_enhanced_flush_compl_ep; +typedef struct { + uint16_t con_handle; /* connection handle */ +} hci_enhanced_flush_compl_ep; #define HCI_EVENT_USER_PASSKEY_NOTIFICATION 0x3b - typedef struct { - bdaddr_t bdaddr; /* remote device address */ - uint32_t value; /* 000000 - 999999 */ - } hci_user_passkey_notification_ep; +typedef struct { + bdaddr_t bdaddr; /* remote device address */ + uint32_t value; /* 000000 - 999999 */ +} hci_user_passkey_notification_ep; #define HCI_EVENT_KEYPRESS_NOTIFICATION 0x3c - typedef struct { - bdaddr_t bdaddr; /* remote device address */ - uint8_t notification_type; - } hci_keypress_notification_ep; +typedef struct { + bdaddr_t bdaddr; /* remote device address */ + uint8_t notification_type; +} hci_keypress_notification_ep; #define HCI_EVENT_REMOTE_FEATURES_NOTIFICATION 0x3d - typedef struct { - bdaddr_t bdaddr; /* remote device address */ - uint8_t features[HCI_FEATURES_SIZE]; /* LMP features bitmsk*/ - } hci_remote_features_notification_ep; +typedef struct { + bdaddr_t bdaddr; /* remote device address */ + uint8_t features[HCI_FEATURES_SIZE]; /* LMP features bitmsk*/ +} hci_remote_features_notification_ep; #define HCI_EVENT_BT_LOGO 0xfe #define HCI_EVENT_VENDOR 0xff - /************************************************************************** - ************************************************************************** - ** HCI Socket Definitions - ************************************************************************** - **************************************************************************/ +/************************************************************************** + ************************************************************************** + ** HCI Socket Definitions + ************************************************************************** + **************************************************************************/ - /* HCI socket options */ +/* HCI socket options */ #define SO_HCI_EVT_FILTER 1 /* get/set event filter */ #define SO_HCI_PKT_FILTER 2 /* get/set packet filter */ #define SO_HCI_DIRECTION 3 /* packet direction indicator */ - /* Control Messages */ +/* Control Messages */ #define SCM_HCI_DIRECTION SO_HCI_DIRECTION - /* - * HCI socket filter and get/set routines - * - * for ease of use, we filter 256 possible events/packets - */ - struct hci_filter { - uint32_t mask[8]; /* 256 bits */ - }; +/* + * HCI socket filter and get/set routines + * + * for ease of use, we filter 256 possible events/packets + */ +struct hci_filter { + uint32_t mask[8]; /* 256 bits */ +}; - static __inline void - hci_filter_set(uint8_t bit, struct hci_filter *filter) - { - uint8_t off = bit - 1; +static __inline void +hci_filter_set(uint8_t bit, struct hci_filter *filter) +{ + uint8_t off = bit - 1; - off >>= 5; - filter->mask[off] |= (1 << ((bit - 1) & 0x1f)); - } + off >>= 5; + filter->mask[off] |= (1 << ((bit - 1) & 0x1f)); +} - static __inline void - hci_filter_clr(uint8_t bit, struct hci_filter *filter) - { - uint8_t off = bit - 1; +static __inline void +hci_filter_clr(uint8_t bit, struct hci_filter *filter) +{ + uint8_t off = bit - 1; - off >>= 5; - filter->mask[off] &= ~(1 << ((bit - 1) & 0x1f)); - } + off >>= 5; + filter->mask[off] &= ~(1 << ((bit - 1) & 0x1f)); +} - static __inline int - hci_filter_test(uint8_t bit, struct hci_filter *filter) - { - uint8_t off = bit - 1; +static __inline int +hci_filter_test(uint8_t bit, const struct hci_filter *filter) +{ + uint8_t off = bit - 1; - off >>= 5; - return (filter->mask[off] & (1 << ((bit - 1) & 0x1f))); - } + off >>= 5; + return (filter->mask[off] & (1 << ((bit - 1) & 0x1f))); +} - /* - * HCI socket ioctl's - * - * Apart from GBTINFOA, these are all indexed on the unit name - */ +/* + * HCI socket ioctl's + * + * Apart from GBTINFOA, these are all indexed on the unit name + */ #define SIOCGBTINFO _IOWR('b', 5, struct btreq) /* get unit info */ #define SIOCGBTINFOA _IOWR('b', 6, struct btreq) /* get info by address */ @@ -2323,37 +2338,37 @@ extern "C" { #define SIOCBTDUMP _IOW('b', 13, struct btreq) /* print debug info */ #define SIOCSBTSCOMTU _IOWR('b', 17, struct btreq) /* set sco_mtu value */ - struct bt_stats { - uint32_t err_tx; - uint32_t err_rx; - uint32_t cmd_tx; - uint32_t evt_rx; - uint32_t acl_tx; - uint32_t acl_rx; - uint32_t sco_tx; - uint32_t sco_rx; - uint32_t byte_tx; - uint32_t byte_rx; - }; +struct bt_stats { + uint32_t err_tx; + uint32_t err_rx; + uint32_t cmd_tx; + uint32_t evt_rx; + uint32_t acl_tx; + uint32_t acl_rx; + uint32_t sco_tx; + uint32_t sco_rx; + uint32_t byte_tx; + uint32_t byte_rx; +}; - struct btreq { - char btr_name[HCI_DEVNAME_SIZE]; /* device name */ +struct btreq { + char btr_name[HCI_DEVNAME_SIZE]; /* device name */ - union { - struct { - bdaddr_t btri_bdaddr; /* device bdaddr */ - uint16_t btri_flags; /* flags */ - uint16_t btri_num_cmd; /* # of free cmd buffers */ - uint16_t btri_num_acl; /* # of free ACL buffers */ - uint16_t btri_num_sco; /* # of free SCO buffers */ - uint16_t btri_acl_mtu; /* ACL mtu */ - uint16_t btri_sco_mtu; /* SCO mtu */ - uint16_t btri_link_policy; /* Link Policy */ - uint16_t btri_packet_type; /* Packet Type */ - } btri; - struct bt_stats btrs; /* unit stats */ - } btru; - }; + union { + struct { + bdaddr_t btri_bdaddr; /* device bdaddr */ + uint16_t btri_flags; /* flags */ + uint16_t btri_num_cmd; /* # of free cmd buffers */ + uint16_t btri_num_acl; /* # of free ACL buffers */ + uint16_t btri_num_sco; /* # of free SCO buffers */ + uint16_t btri_acl_mtu; /* ACL mtu */ + uint16_t btri_sco_mtu; /* SCO mtu */ + uint16_t btri_link_policy; /* Link Policy */ + uint16_t btri_packet_type; /* Packet Type */ + } btri; + struct bt_stats btrs; /* unit stats */ + } btru; +}; #define btr_flags btru.btri.btri_flags #define btr_bdaddr btru.btri.btri_bdaddr @@ -2366,7 +2381,7 @@ extern "C" { #define btr_packet_type btru.btri.btri_packet_type #define btr_stats btru.btrs - /* hci_unit & btr_flags */ +/* hci_unit & btr_flags */ #define BTF_UP (1<<0) /* unit is up */ #define BTF_RUNNING (1<<1) /* unit is running */ #define BTF_XMIT_CMD (1<<2) /* unit is transmitting CMD packets */ @@ -2378,28 +2393,27 @@ extern "C" { #define BTF_INIT_FEATURES (1<<7) /* waiting for features */ #define BTF_POWER_UP_NOOP (1<<8) /* should wait for No-op on power up */ #define BTF_INIT_COMMANDS (1<<9) /* waiting for supported commands */ +#define BTF_MASTER (1<<10) /* request Master role */ #define BTF_INIT (BTF_INIT_BDADDR \ - | BTF_INIT_BUFFER_SIZE \ - | BTF_INIT_FEATURES \ - | BTF_INIT_COMMANDS) - - -// ================================================================================== -// own but i want them inside the pragma .... -// we have to clean it btw :) + | BTF_INIT_BUFFER_SIZE \ + | BTF_INIT_FEATURES \ + | BTF_INIT_COMMANDS) +////////////////////////////////////////////////////////////////////////// +// Dolphin-custom structs (to kill) +////////////////////////////////////////////////////////////////////////// struct SCommandMessage { - u16 Opcode; - u8 len; + u16 Opcode; + u8 len; }; struct SHCIEventCommand { - u8 EventType; + u8 EventType; u8 PayloadLength; - u8 PacketIndicator; + u8 PacketIndicator; u16 Opcode; }; @@ -2414,25 +2428,25 @@ struct SHCIEventStatus struct SHCIEventInquiryResult { - u8 EventType; + u8 EventType; u8 PayloadLength; - u8 num_responses; + u8 num_responses; }; struct SHCIEventInquiryComplete { - u8 EventType; + u8 EventType; u8 PayloadLength; - u8 EventStatus; + u8 EventStatus; }; struct SHCIEventReadClockOffsetComplete { - u8 EventType; - u8 PayloadLength; - u8 EventStatus; - u16 ConnectionHandle; - u16 ClockOffset; + u8 EventType; + u8 PayloadLength; + u8 EventStatus; + u16 ConnectionHandle; + u16 ClockOffset; }; struct SHCIEventConPacketTypeChange @@ -2446,22 +2460,22 @@ struct SHCIEventConPacketTypeChange struct SHCIEventReadRemoteVerInfo { - u8 EventType; - u8 PayloadLength; - u8 EventStatus; - u16 ConnectionHandle; - u8 lmp_version; - u16 manufacturer; - u16 lmp_subversion; + u8 EventType; + u8 PayloadLength; + u8 EventStatus; + u16 ConnectionHandle; + u8 lmp_version; + u16 manufacturer; + u16 lmp_subversion; }; struct SHCIEventReadRemoteFeatures { - u8 EventType; - u8 PayloadLength; - u8 EventStatus; - u16 ConnectionHandle; - u8 features[HCI_FEATURES_SIZE]; + u8 EventType; + u8 PayloadLength; + u8 EventStatus; + u16 ConnectionHandle; + u8 features[HCI_FEATURES_SIZE]; }; struct SHCIEventRemoteNameReq @@ -2470,7 +2484,7 @@ struct SHCIEventRemoteNameReq u8 PayloadLength; u8 EventStatus; bdaddr_t bdaddr; - u8 RemoteName[248]; + u8 RemoteName[HCI_UNIT_NAME_SIZE]; }; struct SHCIEventRequestConnection @@ -2502,15 +2516,6 @@ struct SHCIEventRoleChange u8 NewRole; }; -struct SHCIEventNumberOfCompletedPackets -{ - u8 EventType; - u8 PayloadLength; - u8 NumberOfHandles; - u16 Connection_Handle; - u16 Number_Of_Completed_Packets; -}; - struct SHCIEventAuthenticationCompleted { u8 EventType; @@ -2519,7 +2524,6 @@ struct SHCIEventAuthenticationCompleted u16 Connection_Handle; }; - struct SHCIEventModeChange { u8 EventType; @@ -2553,13 +2557,8 @@ struct SHCIEventLinkKeyNotification u8 PayloadLength; u8 numKeys; bdaddr_t bdaddr; - u8 LinkKey[16]; + u8 LinkKey[HCI_KEY_SIZE]; }; - -#ifdef __cplusplus -} -#endif +////////////////////////////////////////////////////////////////////////// #pragma pack(pop) - -#endif /* _NETBT_HCI_H */ diff --git a/Source/Core/Core/Src/IPC_HLE/l2cap.h b/Source/Core/Core/Src/IPC_HLE/l2cap.h index 5302a2a62c..5b1092c201 100644 --- a/Source/Core/Core/Src/IPC_HLE/l2cap.h +++ b/Source/Core/Core/Src/IPC_HLE/l2cap.h @@ -1,353 +1,353 @@ -/* -BlueZ - Bluetooth protocol stack for Linux -Copyright (C) 2000-2001 Qualcomm Incorporated +/* $NetBSD: l2cap.h,v 1.9 2009/09/13 18:45:11 pooka Exp $ */ -Written 2000,2001 by Maxim Krasnyansky - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License version 2 as -published by the Free Software Foundation; - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. -IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY -CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS, -COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS -SOFTWARE IS DISCLAIMED. +/*- +* Copyright (c) 2005 Iain Hibbert. +* Copyright (c) 2006 Itronix Inc. +* All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* 1. Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* 2. Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* 3. The name of Itronix Inc. may not be used to endorse +* or promote products derived from this software without specific +* prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY ITRONIX INC. ``AS IS'' AND +* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ITRONIX INC. BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN +* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +* POSSIBILITY OF SUCH DAMAGE. +*/ +/*- +* Copyright (c) Maksim Yevmenkin +* All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* 1. Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* 2. Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* +* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +* SUCH DAMAGE. +* +* $Id: l2cap.h,v 1.9 2009/09/13 18:45:11 pooka Exp $ +* $FreeBSD: src/sys/netgraph/bluetooth/include/l2cap.h,v 1.4 2005/08/31 18:13:23 emax Exp $ */ -#ifndef __L2CAP_H -#define __L2CAP_H +/* +* This file contains everything that application needs to know about +* Link Layer Control and Adaptation Protocol (L2CAP). All information +* was obtained from Bluetooth Specification Books (v1.1 and up) +* +* This file can be included by both kernel and userland applications. +*/ -//Dolphin - define missing types -typedef unsigned short __le16; -typedef unsigned short __u16; -typedef unsigned char __u8; -typedef unsigned long __u32; +#pragma once -#pragma pack(push) -#pragma pack(1) +/************************************************************************** +************************************************************************** +** Common defines and types (L2CAP) +************************************************************************** +**************************************************************************/ -#ifdef _MSC_VER -#pragma warning(push) -#pragma warning(disable:4200) -#endif +/* +* Channel IDs are assigned per machine. So the total number of channels that +* a machine can have open at the same time is 0xffff - 0x0040 = 0xffbf (65471). +* This number does not depend on number of HCI connections. +*/ -/* L2CAP defaults */ -#define L2CAP_DEFAULT_MTU 672 -#define L2CAP_DEFAULT_FLUSH_TO 0xFFFF +#define L2CAP_NULL_CID 0x0000 /* DO NOT USE THIS CID */ +#define L2CAP_SIGNAL_CID 0x0001 /* signaling channel ID */ +#define L2CAP_CLT_CID 0x0002 /* connectionless channel ID */ +/* 0x0003 - 0x003f Reserved */ +#define L2CAP_FIRST_CID 0x0040 /* dynamically alloc. (start) */ +#define L2CAP_LAST_CID 0xffff /* dynamically alloc. (end) */ -#define L2CAP_CONN_TIMEOUT (40000) /* 40 seconds */ -#define L2CAP_INFO_TIMEOUT (4000) /* 4 seconds */ +/* L2CAP MTU */ +#define L2CAP_MTU_MINIMUM 48 +#define L2CAP_MTU_DEFAULT 672 +#define L2CAP_MTU_MAXIMUM 0xffff -/* L2CAP socket address */ -#ifdef NOT_DOLPHIN -struct sockaddr_l2 { - sa_family_t l2_family; - __le16 l2_psm; - bdaddr_t l2_bdaddr; -}; -#endif +/* L2CAP flush and link timeouts */ +#define L2CAP_FLUSH_TIMO_DEFAULT 0xffff /* always retransmit */ +#define L2CAP_LINK_TIMO_DEFAULT 0xffff -/* L2CAP socket options */ -#define L2CAP_OPTIONS 0x01 -struct l2cap_options { - __u16 omtu; - __u16 imtu; - __u16 flush_to; - __u8 mode; -}; +/* L2CAP Command Reject reasons */ +#define L2CAP_REJ_NOT_UNDERSTOOD 0x0000 +#define L2CAP_REJ_MTU_EXCEEDED 0x0001 +#define L2CAP_REJ_INVALID_CID 0x0002 +/* 0x0003 - 0xffff - reserved for future use */ -#define L2CAP_CONNINFO 0x02 -struct l2cap_conninfo { - __u16 hci_handle; - __u8 dev_class[3]; -}; +/* Protocol/Service Multiplexor (PSM) values */ +#define L2CAP_PSM_ANY 0x0000 /* Any/Invalid PSM */ +#define L2CAP_PSM_SDP 0x0001 /* Service Discovery Protocol */ +#define L2CAP_PSM_RFCOMM 0x0003 /* RFCOMM protocol */ +#define L2CAP_PSM_TCP 0x0005 /* Telephony Control Protocol */ +#define L2CAP_PSM_TCS 0x0007 /* TCS cordless */ +#define L2CAP_PSM_BNEP 0x000f /* Bluetooth Network */ +/* Encapsulation Protocol*/ +#define L2CAP_PSM_HID_CNTL 0x0011 /* HID Control */ +#define L2CAP_PSM_HID_INTR 0x0013 /* HID Interrupt */ +#define L2CAP_PSM_ESDP 0x0015 /* Extended Service */ +/* Discovery Profile */ +#define L2CAP_PSM_AVCTP 0x0017 /* Audio/Visual Control */ +/* Transport Protocol */ +#define L2CAP_PSM_AVDTP 0x0019 /* Audio/Visual Distribution */ +/* Transport Protocol */ +/* 0x0019 - 0x1000 - reserved for future use */ -#define L2CAP_LM 0x03 -#define L2CAP_LM_MASTER 0x0001 -#define L2CAP_LM_AUTH 0x0002 -#define L2CAP_LM_ENCRYPT 0x0004 -#define L2CAP_LM_TRUSTED 0x0008 -#define L2CAP_LM_RELIABLE 0x0010 -#define L2CAP_LM_SECURE 0x0020 +#define L2CAP_PSM_INVALID(psm) (((psm) & 0x0101) != 0x0001) -/* L2CAP command codes */ -#define L2CAP_COMMAND_REJ 0x01 -#define L2CAP_CONN_REQ 0x02 -#define L2CAP_CONN_RSP 0x03 -#define L2CAP_CONF_REQ 0x04 -#define L2CAP_CONF_RSP 0x05 -#define L2CAP_DISCONN_REQ 0x06 -#define L2CAP_DISCONN_RSP 0x07 -#define L2CAP_ECHO_REQ 0x08 -#define L2CAP_ECHO_RSP 0x09 -#define L2CAP_INFO_REQ 0x0a -#define L2CAP_INFO_RSP 0x0b +/* L2CAP Connection response command result codes */ +#define L2CAP_SUCCESS 0x0000 +#define L2CAP_PENDING 0x0001 +#define L2CAP_PSM_NOT_SUPPORTED 0x0002 +#define L2CAP_SECURITY_BLOCK 0x0003 +#define L2CAP_NO_RESOURCES 0x0004 +#define L2CAP_TIMEOUT 0xeeee +#define L2CAP_UNKNOWN 0xffff +/* 0x0005 - 0xffff - reserved for future use */ -/* L2CAP structures */ -struct l2cap_hdr { - __le16 len; - __le16 cid; -}; -#define L2CAP_HDR_SIZE 4 +/* L2CAP Connection response status codes */ +#define L2CAP_NO_INFO 0x0000 +#define L2CAP_AUTH_PENDING 0x0001 +#define L2CAP_AUTZ_PENDING 0x0002 +/* 0x0003 - 0xffff - reserved for future use */ -struct l2cap_cmd_hdr { - __u8 code; - __u8 ident; - __le16 len; -}; -#define L2CAP_CMD_HDR_SIZE 4 +/* L2CAP Configuration response result codes */ +#define L2CAP_UNACCEPTABLE_PARAMS 0x0001 +#define L2CAP_REJECT 0x0002 +#define L2CAP_UNKNOWN_OPTION 0x0003 +/* 0x0003 - 0xffff - reserved for future use */ -struct l2cap_cmd_rej { - __le16 reason; -}; +/* L2CAP Configuration options */ +#define L2CAP_OPT_CFLAG_BIT 0x0001 +#define L2CAP_OPT_CFLAG(flags) ((flags) & L2CAP_OPT_CFLAG_BIT) +#define L2CAP_OPT_HINT_BIT 0x80 +#define L2CAP_OPT_HINT(type) ((type) & L2CAP_OPT_HINT_BIT) +#define L2CAP_OPT_HINT_MASK 0x7f +#define L2CAP_OPT_MTU 0x01 +#define L2CAP_OPT_MTU_SIZE sizeof(uint16_t) +#define L2CAP_OPT_FLUSH_TIMO 0x02 +#define L2CAP_OPT_FLUSH_TIMO_SIZE sizeof(uint16_t) +#define L2CAP_OPT_QOS 0x03 +#define L2CAP_OPT_QOS_SIZE sizeof(l2cap_qos_t) +#define L2CAP_OPT_RFC 0x04 +#define L2CAP_OPT_RFC_SIZE sizeof(l2cap_rfc_t) +/* 0x05 - 0xff - reserved for future use */ -struct l2cap_conn_req { - __le16 psm; - __le16 scid; -}; +/* L2CAP Information request type codes */ +#define L2CAP_CONNLESS_MTU 0x0001 +#define L2CAP_EXTENDED_FEATURES 0x0002 +/* 0x0003 - 0xffff - reserved for future use */ -struct l2cap_conn_rsp { - __le16 dcid; - __le16 scid; - __le16 result; - __le16 status; -}; +/* L2CAP Information response codes */ +#define L2CAP_NOT_SUPPORTED 0x0001 +/* 0x0002 - 0xffff - reserved for future use */ -/* connect result */ -#define L2CAP_CR_SUCCESS 0x0000 -#define L2CAP_CR_PEND 0x0001 -#define L2CAP_CR_BAD_PSM 0x0002 -#define L2CAP_CR_SEC_BLOCK 0x0003 -#define L2CAP_CR_NO_MEM 0x0004 +#pragma pack(push, 1) -/* connect status */ -#define L2CAP_CS_NO_INFO 0x0000 -#define L2CAP_CS_AUTHEN_PEND 0x0001 -#define L2CAP_CS_AUTHOR_PEND 0x0002 +/* L2CAP Quality of Service option */ +typedef struct { + uint8_t flags; /* reserved for future use */ + uint8_t service_type; /* service type */ + uint32_t token_rate; /* bytes per second */ + uint32_t token_bucket_size; /* bytes */ + uint32_t peak_bandwidth; /* bytes per second */ + uint32_t latency; /* microseconds */ + uint32_t delay_variation; /* microseconds */ +} l2cap_qos_t; -struct l2cap_conf_req { - __le16 dcid; - __le16 flags; - __u8 data[0]; -}; +/* L2CAP QoS type */ +#define L2CAP_QOS_NO_TRAFFIC 0x00 +#define L2CAP_QOS_BEST_EFFORT 0x01 /* (default) */ +#define L2CAP_QOS_GUARANTEED 0x02 +/* 0x03 - 0xff - reserved for future use */ -struct l2cap_conf_rsp { - __le16 scid; - __le16 flags; - __le16 result; - __u8 data[0]; -}; +/* L2CAP Retransmission & Flow Control option */ +typedef struct { + uint8_t mode; /* RFC mode */ + uint8_t window_size; /* bytes */ + uint8_t max_transmit; /* max retransmissions */ + uint16_t retransmit_timo; /* milliseconds */ + uint16_t monitor_timo; /* milliseconds */ + uint16_t max_pdu_size; /* bytes */ +} l2cap_rfc_t; -#define L2CAP_CONF_SUCCESS 0x0000 -#define L2CAP_CONF_UNACCEPT 0x0001 -#define L2CAP_CONF_REJECT 0x0002 -#define L2CAP_CONF_UNKNOWN 0x0003 +/* L2CAP RFC mode */ +#define L2CAP_RFC_BASIC 0x00 /* (default) */ +#define L2CAP_RFC_RETRANSMIT 0x01 +#define L2CAP_RFC_FLOW 0x02 +/* 0x03 - 0xff - reserved for future use */ -struct l2cap_conf_opt { - __u8 type; - __u8 len; - __u8 val[0]; -}; -#define L2CAP_CONF_OPT_SIZE 2 +/************************************************************************** +************************************************************************** +** Link level defines, headers and types +************************************************************************** +**************************************************************************/ -#define L2CAP_CONF_MTU 0x01 -#define L2CAP_CONF_FLUSH_TO 0x02 -#define L2CAP_CONF_QOS 0x03 -#define L2CAP_CONF_RFC 0x04 +/* L2CAP header */ +typedef struct { + uint16_t length; /* payload size */ + uint16_t dcid; /* destination channel ID */ +} l2cap_hdr_t; -#define L2CAP_CONF_MAX_SIZE 22 +/* L2CAP ConnectionLess Traffic (dcid == L2CAP_CLT_CID) */ +typedef struct { + uint16_t psm; /* Protocol/Service Multiplexor */ +} l2cap_clt_hdr_t; -struct l2cap_conf_rfc { - __u8 mode; - __u8 txwin_size; - __u8 max_transmit; - __le16 retrans_timeout; - __le16 monitor_timeout; - __le16 max_pdu_size; -}; +#define L2CAP_CLT_MTU_MAXIMUM \ + (L2CAP_MTU_MAXIMUM - sizeof(l2cap_clt_hdr_t)) -#define L2CAP_MODE_BASIC 0x00 -#define L2CAP_MODE_RETRANS 0x01 -#define L2CAP_MODE_FLOWCTL 0x02 +/* L2CAP Command header (dcid == L2CAP_SIGNAL_CID) */ +typedef struct { + uint8_t code; /* command OpCode */ + uint8_t ident; /* identifier to match request and response */ + uint16_t length; /* command parameters length */ +} l2cap_cmd_hdr_t; -struct l2cap_disconn_req { - __le16 dcid; - __le16 scid; -}; +/* L2CAP Command Reject */ +#define L2CAP_COMMAND_REJ 0x01 +typedef struct { + uint16_t reason; /* reason to reject command */ + uint16_t data[2];/* optional data */ +} l2cap_cmd_rej_cp; -struct l2cap_disconn_rsp { - __le16 dcid; - __le16 scid; -}; +/* L2CAP Connection Request */ +#define L2CAP_CONNECT_REQ 0x02 +typedef struct { + uint16_t psm; /* Protocol/Service Multiplexor (PSM) */ + uint16_t scid; /* source channel ID */ +} l2cap_con_req_cp; -struct l2cap_info_req { - __le16 type; -}; +/* L2CAP Connection Response */ +#define L2CAP_CONNECT_RSP 0x03 +typedef struct { + uint16_t dcid; /* destination channel ID */ + uint16_t scid; /* source channel ID */ + uint16_t result; /* 0x00 - success */ + uint16_t status; /* more info if result != 0x00 */ +} l2cap_con_rsp_cp; -struct l2cap_info_rsp { - __le16 type; - __le16 result; - __u8 data[0]; -}; +/* L2CAP Configuration Request */ +#define L2CAP_CONFIG_REQ 0x04 +typedef struct { + uint16_t dcid; /* destination channel ID */ + uint16_t flags; /* flags */ + /* uint8_t options[] -- options */ +} l2cap_cfg_req_cp; -/* info type */ -#define L2CAP_IT_CL_MTU 0x0001 -#define L2CAP_IT_FEAT_MASK 0x0002 +/* L2CAP Configuration Response */ +#define L2CAP_CONFIG_RSP 0x05 +typedef struct { + uint16_t scid; /* source channel ID */ + uint16_t flags; /* flags */ + uint16_t result; /* 0x00 - success */ + /* uint8_t options[] -- options */ +} l2cap_cfg_rsp_cp; -/* info result */ -#define L2CAP_IR_SUCCESS 0x0000 -#define L2CAP_IR_NOTSUPP 0x0001 +/* L2CAP configuration option */ +typedef struct { + uint8_t type; + uint8_t length; + /* uint8_t value[] -- option value (depends on type) */ +} l2cap_cfg_opt_t; + +/* L2CAP configuration option value */ +typedef union { + uint16_t mtu; /* L2CAP_OPT_MTU */ + uint16_t flush_timo; /* L2CAP_OPT_FLUSH_TIMO */ + l2cap_qos_t qos; /* L2CAP_OPT_QOS */ + l2cap_rfc_t rfc; /* L2CAP_OPT_RFC */ +} l2cap_cfg_opt_val_t; + +/* L2CAP Disconnect Request */ +#define L2CAP_DISCONNECT_REQ 0x06 +typedef struct { + uint16_t dcid; /* destination channel ID */ + uint16_t scid; /* source channel ID */ +} l2cap_discon_req_cp; + +/* L2CAP Disconnect Response */ +#define L2CAP_DISCONNECT_RSP 0x07 +typedef l2cap_discon_req_cp l2cap_discon_rsp_cp; + +/* L2CAP Echo Request */ +#define L2CAP_ECHO_REQ 0x08 +/* No command parameters, only optional data */ + +/* L2CAP Echo Response */ +#define L2CAP_ECHO_RSP 0x09 +#define L2CAP_MAX_ECHO_SIZE \ + (L2CAP_MTU_MAXIMUM - sizeof(l2cap_cmd_hdr_t)) +/* No command parameters, only optional data */ + +/* L2CAP Information Request */ +#define L2CAP_INFO_REQ 0x0a +typedef struct { + uint16_t type; /* requested information type */ +} l2cap_info_req_cp; + +/* L2CAP Information Response */ +#define L2CAP_INFO_RSP 0x0b +typedef struct { + uint16_t type; /* requested information type */ + uint16_t result; /* 0x00 - success */ + /* uint8_t info[] -- info data (depends on type) + * + * L2CAP_CONNLESS_MTU - 2 bytes connectionless MTU + */ +} l2cap_info_rsp_cp; + +typedef union { + /* L2CAP_CONNLESS_MTU */ + struct { + uint16_t mtu; + } mtu; +} l2cap_info_rsp_data_t; -#ifdef _MSC_VER -#pragma warning(pop) -#endif #pragma pack(pop) -struct value_string -{ - u32 value; - char* string; -}; +/************************************************************************** +************************************************************************** +** L2CAP Socket Definitions +************************************************************************** +**************************************************************************/ -static const value_string command_code_vals[] = { - { 0x01, (char *)"Command Reject" }, - { 0x02, (char *)"Connection Request" }, - { 0x03, (char *)"Connection Response" }, - { 0x04, (char *)"Configure Request" }, - { 0x05, (char *)"Configure Response" }, - { 0x06, (char *)"Disconnect Request" }, - { 0x07, (char *)"Disconnect Response" }, - { 0x08, (char *)"Echo Request" }, - { 0x09, (char *)"Echo Response" }, - { 0x0A, (char *)"Information Request" }, - { 0x0B, (char *)"Information Response" }, - { 0, NULL } -}; +/* Socket options */ +#define SO_L2CAP_IMTU 1 /* incoming MTU */ +#define SO_L2CAP_OMTU 2 /* outgoing MTU */ +#define SO_L2CAP_IQOS 3 /* incoming QoS */ +#define SO_L2CAP_OQOS 4 /* outgoing QoS */ +#define SO_L2CAP_FLUSH 5 /* flush timeout */ +#define SO_L2CAP_LM 6 /* link mode */ - - -static const value_string psm_vals[] = { - { 0x0001, (char *)"SDP" }, - { 0x0003, (char *)"RFCOMM" }, - { 0x0005, (char *)"TCS-BIN" }, - { 0x0007, (char *)"TCS-BIN-CORDLESS" }, - { 0x000F, (char *)"BNEP" }, - { 0x0011, (char *)"HID_CONTROL" }, - { 0x0013, (char *)"HID_INTERRUPT" }, - { 0x0015, (char *)"UPnP" }, - { 0x0017, (char *)"AVCTP" }, - { 0x0019, (char *)"AVDTP" }, - { 0x001D, (char *)"UDI_C-Plane" }, - { 0, NULL } -}; - - -static const value_string result_vals[] = { - { 0x0000, (char *)"Connection successful" }, - { 0x0001, (char *)"Connection pending" }, - { 0x0002, (char *)"Connection Refused - PSM not supported" }, - { 0x0003, (char *)"Connection refused - security block" }, - { 0x0004, (char *)"Connection refused - no resources available" }, - { 0, NULL } -}; - - -static const value_string status_vals[] = { - { 0x0000, (char *)"No further information available" }, - { 0x0001, (char *)"Authentication panding" }, - { 0x0002, (char *)"Authorization pending" }, - { 0, NULL } -}; - - - - - - - - -#ifdef NOT_DOLPHIN - -/* ----- L2CAP connections ----- */ -struct l2cap_chan_list { - struct sock *head; - rwlock_t lock; - long num; -}; - -struct l2cap_conn { - struct hci_conn *hcon; - - bdaddr_t *dst; - bdaddr_t *src; - - unsigned int mtu; - - __u32 feat_mask; - - __u8 info_state; - __u8 info_ident; - - struct timer_list info_timer; - - spinlock_t lock; - - struct sk_buff *rx_skb; - __u32 rx_len; - __u8 rx_ident; - __u8 tx_ident; - - struct l2cap_chan_list chan_list; -}; - -#define L2CAP_INFO_CL_MTU_REQ_SENT 0x01 -#define L2CAP_INFO_FEAT_MASK_REQ_SENT 0x02 - -/* ----- L2CAP channel and socket info ----- */ -#define l2cap_pi(sk) ((struct l2cap_pinfo *) sk) - -struct l2cap_pinfo { - struct bt_sock bt; - __le16 psm; - __u16 dcid; - __u16 scid; - - __u16 imtu; - __u16 omtu; - __u16 flush_to; - - __u32 link_mode; - - __u8 conf_req[64]; - __u8 conf_len; - __u8 conf_state; - __u8 conf_retry; - - __u8 ident; - - __le16 sport; - - struct l2cap_conn *conn; - struct sock *next_c; - struct sock *prev_c; -}; - -#define L2CAP_CONF_REQ_SENT 0x01 -#define L2CAP_CONF_INPUT_DONE 0x02 -#define L2CAP_CONF_OUTPUT_DONE 0x04 - -#define L2CAP_CONF_MAX_RETRIES 2 - -void l2cap_load(void); - -#endif //NOT_DOLPHIN - -#endif /* __L2CAP_H */ +/* L2CAP link mode flags */ +#define L2CAP_LM_AUTH (1<<0) /* want authentication */ +#define L2CAP_LM_ENCRYPT (1<<1) /* want encryption */ +#define L2CAP_LM_SECURE (1<<2) /* want secured link */ diff --git a/Source/Core/DolphinWX/Src/FrameTools.cpp b/Source/Core/DolphinWX/Src/FrameTools.cpp index a80ea00e92..0a49ace45a 100644 --- a/Source/Core/DolphinWX/Src/FrameTools.cpp +++ b/Source/Core/DolphinWX/Src/FrameTools.cpp @@ -1335,13 +1335,13 @@ void CFrame::UpdateGUI() if (Initialized && SConfig::GetInstance().m_LocalCoreStartupParameter.bWii) { GetMenuBar()->FindItem(IDM_CONNECT_WIIMOTE1)->Check(GetUsbPointer()-> - AccessWiiMote(0x0100)->IsConnected() == 3); + AccessWiiMote(0x0100)->IsConnected()); GetMenuBar()->FindItem(IDM_CONNECT_WIIMOTE2)->Check(GetUsbPointer()-> - AccessWiiMote(0x0101)->IsConnected() == 3); + AccessWiiMote(0x0101)->IsConnected()); GetMenuBar()->FindItem(IDM_CONNECT_WIIMOTE3)->Check(GetUsbPointer()-> - AccessWiiMote(0x0102)->IsConnected() == 3); + AccessWiiMote(0x0102)->IsConnected()); GetMenuBar()->FindItem(IDM_CONNECT_WIIMOTE4)->Check(GetUsbPointer()-> - AccessWiiMote(0x0103)->IsConnected() == 3); + AccessWiiMote(0x0103)->IsConnected()); } if (Running) diff --git a/Source/Plugins/Plugin_Wiimote/Src/DataReports.cpp b/Source/Plugins/Plugin_Wiimote/Src/DataReports.cpp index 0fe466c3e6..f9a7c9541d 100644 --- a/Source/Plugins/Plugin_Wiimote/Src/DataReports.cpp +++ b/Source/Plugins/Plugin_Wiimote/Src/DataReports.cpp @@ -117,8 +117,6 @@ void SendReportCore(u16 _channelID) DEBUG_LOG(WIIMOTE, " Size: %08x", Offset); g_WiimoteInitialize.pWiimoteInterruptChannel(g_ID, _channelID, DataFrame, Offset); - // Debugging - //ReadDebugging(true, DataFrame, Offset); } @@ -142,9 +140,6 @@ void SendReportCoreAccel(u16 _channelID) DEBUG_LOG(WIIMOTE, " Size: %08x", Offset); g_WiimoteInitialize.pWiimoteInterruptChannel(g_ID, _channelID, DataFrame, Offset); - - // Debugging - //ReadDebugging(true, DataFrame, Offset); } @@ -171,9 +166,6 @@ void SendReportCoreAccelIr12(u16 _channelID) { DEBUG_LOG(WIIMOTE, " Size: %08x", Offset); g_WiimoteInitialize.pWiimoteInterruptChannel(g_ID, _channelID, DataFrame, Offset); - - // Debugging - //ReadDebugging(true, DataFrame, Offset); } @@ -216,9 +208,6 @@ void SendReportCoreAccelExt16(u16 _channelID) DEBUG_LOG(WIIMOTE, " Size: %08x", Offset); g_WiimoteInitialize.pWiimoteInterruptChannel(g_ID, _channelID, DataFrame, Offset); - - // Debugging - //ReadDebugging(true, DataFrame, Offset); } @@ -291,9 +280,6 @@ void SendReportCoreAccelIr10Ext(u16 _channelID) DEBUG_LOG(WIIMOTE, " Size: %08x", Offset); g_WiimoteInitialize.pWiimoteInterruptChannel(g_ID, _channelID, DataFrame, Offset); - - // Debugging - //ReadDebugging(true, DataFrame, Offset); } diff --git a/Source/Plugins/Plugin_Wiimote/Src/EmuMain.cpp b/Source/Plugins/Plugin_Wiimote/Src/EmuMain.cpp index 7e33b9835e..2297afb320 100644 --- a/Source/Plugins/Plugin_Wiimote/Src/EmuMain.cpp +++ b/Source/Plugins/Plugin_Wiimote/Src/EmuMain.cpp @@ -605,11 +605,6 @@ void DoState(PointerWrap &p) response to Output from the Wii. */ void InterruptChannel(int _number, u16 _channelID, const void* _pData, u32 _Size) { - /* Debugging. We have not yet decided how much of 'data' we will use, it's - not determined by sizeof(data). We have to determine it by looking at - the data cases. */ - //InterruptDebugging(true, (const void*)_pData); - g_ID = _number; hid_packet* hidp = (hid_packet*)_pData; @@ -673,13 +668,11 @@ void ControlChannel(int _number, u16 _channelID, const void* _pData, u32 _Size) else { // AyuanX: My experiment shows Control Channel is never used - // shuffle2: but homebrew uses this, so we'll do what we must :) + // shuffle2: but lwbt uses this, so we'll do what we must :) HidOutputReport(_channelID, (wm_report*)hidp->data); u8 handshake = HID_HANDSHAKE_SUCCESS; g_WiimoteInitialize.pWiimoteInterruptChannel(g_ID, _channelID, &handshake, 1); - - PanicAlert("HID_TYPE_DATA - OUTPUT: Ambiguous Control Channel Report!"); } break; diff --git a/Source/Plugins/Plugin_Wiimote/Src/EmuSubroutines.cpp b/Source/Plugins/Plugin_Wiimote/Src/EmuSubroutines.cpp index 80df11e656..1dd3114e45 100644 --- a/Source/Plugins/Plugin_Wiimote/Src/EmuSubroutines.cpp +++ b/Source/Plugins/Plugin_Wiimote/Src/EmuSubroutines.cpp @@ -179,9 +179,6 @@ void WmSendAck(u16 _channelID, u8 _reportID) DEBUG_LOG(WIIMOTE, " Report ID: %02x", _reportID); g_WiimoteInitialize.pWiimoteInterruptChannel(g_ID, _channelID, DataFrame, Offset); - - // Debugging - //ReadDebugging(true, DataFrame, Offset); } @@ -367,9 +364,6 @@ void SendReadDataReply(u16 _channelID, void* _Base, u16 _Address, u8 _AddressHI, // Update the size that is left _Size -= copySize; - - // Debugging - //ReadDebugging(true, DataFrame, Offset); } } @@ -542,9 +536,6 @@ void WmRequestStatus(u16 _channelID, wm_request_status* rs, int Extension) g_WiimoteInitialize.pWiimoteInterruptChannel(g_ID, _channelID, DataFrame, Offset); - - // Debugging - //ReadDebugging(true, DataFrame, Offset); } //http://snzgoo.blogspot.com for more details on what this is doing diff --git a/Source/Plugins/Plugin_Wiimote/Src/main.h b/Source/Plugins/Plugin_Wiimote/Src/main.h index a61289240f..ca7b9349ee 100644 --- a/Source/Plugins/Plugin_Wiimote/Src/main.h +++ b/Source/Plugins/Plugin_Wiimote/Src/main.h @@ -18,7 +18,7 @@ #ifndef MAIN_H #define MAIN_H -#include // System +#include #include #include "CommonTypes.h" @@ -30,10 +30,8 @@ #include extern Display* WMdisplay; #endif -// Definitions and declarations + bool IsFocus(); -//void InterruptDebugging(bool Emu, const void* _pData); -//void ReadDebugging(bool Emu, const void* _pData, int Size); // Movement recording #define RECORDING_ROWS 15 diff --git a/Source/Plugins/Plugin_Wiimote/Src/wiimote_real.cpp b/Source/Plugins/Plugin_Wiimote/Src/wiimote_real.cpp index 9e3a60010f..a84cee5b71 100644 --- a/Source/Plugins/Plugin_Wiimote/Src/wiimote_real.cpp +++ b/Source/Plugins/Plugin_Wiimote/Src/wiimote_real.cpp @@ -127,10 +127,6 @@ void SendData(u16 _channelID, const u8* _pData, u32 _Size) memcpy(WriteEvent.m_PayLoad, _pData, _Size); WriteEvent._Size = _Size; m_EventWriteQueue.push(WriteEvent); - - // Debugging - //std::string Temp = ArrayToString(WriteEvent.m_PayLoad, 28, 0, 30); - //DEBUG_LOG(WIIMOTE, "Wiimote Write:\n%s", Temp.c_str()); } m_pCriticalSection->Leave(); } @@ -147,9 +143,10 @@ void ReadData() // Send data to the Wiimote if (!m_EventWriteQueue.empty()) { - //DEBUG_LOG(WIIMOTE, "Writing data to the Wiimote"); - SEvent& rEvent = m_EventWriteQueue.front(); + const SEvent& rEvent = m_EventWriteQueue.front(); wiiuse_io_write(m_pWiiMote, (byte*)rEvent.m_PayLoad, rEvent._Size); + //std::string Temp = ArrayToString(rEvent.m_PayLoad, rEvent._Size); + //DEBUG_LOG(WIIMOTE, "Wiimote Write:\n%s:%d", Temp.c_str(), ret); #ifdef _WIN32 if (m_pWiiMote->event == WIIUSE_UNEXPECTED_DISCONNECT) { @@ -157,8 +154,6 @@ void ReadData() } #endif m_EventWriteQueue.pop(); - - // InterruptDebugging(false, rEvent.m_PayLoad); } m_pCriticalSection->Leave(); @@ -168,6 +163,8 @@ void ReadData() if (wiiuse_io_read(m_pWiiMote)) { const byte* pBuffer = m_pWiiMote->event_buf; + //std::string Temp = ArrayToString(pBuffer, 20); + //DEBUG_LOG(WIIMOTE, "Wiimote Read:\n%s", Temp.c_str()); // Check if we have a channel (connection) if so save the data... if (m_channelID > 0) { @@ -191,6 +188,8 @@ void ReadData() } m_pCriticalSection->Leave(); } + + memset((void*)&m_pWiiMote->event_buf,0,sizeof(m_pWiiMote->event_buf)); } #ifdef _WIN32 else if (m_pWiiMote->event == WIIUSE_UNEXPECTED_DISCONNECT) @@ -277,9 +276,6 @@ void SendEvent(SEvent& _rEvent) // Send it g_WiimoteInitialize.pWiimoteInterruptChannel(m_WiimoteNumber, m_channelID, Buffer, Offset); - - // Debugging - // ReadDebugging(false, Buffer, Offset); } }; @@ -541,8 +537,14 @@ void InterruptChannel(int _WiimoteNumber, u16 _channelID, const void* _pData, u3 void ControlChannel(int _WiimoteNumber, u16 _channelID, const void* _pData, u32 _Size) { - //DEBUG_LOG(WIIMOTE, "Real ControlChannel on WiiMote #%i", _WiimoteNumber); g_WiiMotes[_WiimoteNumber]->SendData(_channelID, (const u8*)_pData, _Size); + + const hid_packet* const hidp = (hid_packet*)_pData; + if (hidp->type == HID_TYPE_SET_REPORT) + { + u8 handshake_ok = HID_HANDSHAKE_SUCCESS; + g_WiimoteInitialize.pWiimoteInterruptChannel(_WiimoteNumber, _channelID, &handshake_ok, sizeof(handshake_ok)); + } } diff --git a/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/EmuSubroutines.cpp b/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/EmuSubroutines.cpp index 441d642671..b330f9fe4b 100644 --- a/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/EmuSubroutines.cpp +++ b/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/EmuSubroutines.cpp @@ -68,9 +68,6 @@ void Wiimote::ReportMode(const wm_report_mode* const dr) // reset IR camera //memset(m_reg_ir, 0, sizeof(*m_reg_ir)); //ugly hack - if (false == m_reporting_auto) - PanicAlert("Wiimote: Reporting is set to OFF! Everything should be fine, but games never do this."); - if (dr->mode > 0x37) PanicAlert("Wiimote: Unsupported Reporting mode."); else if (dr->mode < WM_REPORT_CORE) diff --git a/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/WiimoteEmu.cpp b/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/WiimoteEmu.cpp index e876445257..45088a08b5 100644 --- a/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/WiimoteEmu.cpp +++ b/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/WiimoteEmu.cpp @@ -763,7 +763,7 @@ void Wiimote::ControlChannel(const u16 _channelID, const void* _pData, u32 _Size INFO_LOG(WIIMOTE, "Emu ControlChannel (page: %i, type: 0x%02x, param: 0x%02x)", m_index, hidp->type, hidp->param); - switch(hidp->type) + switch (hidp->type) { case HID_TYPE_HANDSHAKE : PanicAlert("HID_TYPE_HANDSHAKE - %s", (hidp->param == HID_PARAM_INPUT) ? "INPUT" : "OUPUT"); @@ -777,13 +777,11 @@ void Wiimote::ControlChannel(const u16 _channelID, const void* _pData, u32 _Size else { // AyuanX: My experiment shows Control Channel is never used - // shuffle2: but homebrew uses this, so we'll do what we must :) + // shuffle2: but lwbt uses this, so we'll do what we must :) HidOutputReport((wm_report*)hidp->data); u8 handshake = HID_HANDSHAKE_SUCCESS; g_WiimoteInitialize.pWiimoteInterruptChannel(m_index, _channelID, &handshake, 1); - - PanicAlert("HID_TYPE_DATA - OUTPUT: Ambiguous Control Channel Report!"); } break; diff --git a/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteReal/WiimoteReal.cpp b/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteReal/WiimoteReal.cpp index 13562419ea..be2cc345c6 100644 --- a/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteReal/WiimoteReal.cpp +++ b/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteReal/WiimoteReal.cpp @@ -118,7 +118,15 @@ void Wiimote::ControlChannel(const u16 channel, const void* const data, const u3 if (99 == channel) Disconnect(); else + { InterruptChannel(channel, data, size); + const hid_packet* const hidp = (hid_packet*)data; + if (hidp->type == HID_TYPE_SET_REPORT) + { + u8 handshake_ok = HID_HANDSHAKE_SUCCESS; + g_WiimoteInitialize.pWiimoteInterruptChannel(index, channel, &handshake_ok, sizeof(handshake_ok)); + } + } } void Wiimote::InterruptChannel(const u16 channel, const void* const data, const u32 size)