// //Start the control channel of NCM // TInt CNcmCommunicationInterface::Start() { OstTraceFunctionEntry1( CNCMCOMMUNICATIONINTERFACE_START_ENTRY, this ); if (iStarted) { OstTrace0( TRACE_WARNING, CNCMCOMMUNICATIONINTERFACE_START, "CNcmCommunicationInterface, already started!" ); OstTraceFunctionExit1( CNCMCOMMUNICATIONINTERFACE_START_EXIT, this ); return KErrInUse; } TInt ret = GetInterfaceNumber(); if (ret != KErrNone) { OstTrace1( TRACE_FATAL, CNCMCOMMUNICATIONINTERFACE_START1, "GetInterfaceNumber failed ret=%d", ret); OstTraceFunctionExit1( CNCMCOMMUNICATIONINTERFACE_START_EXIT_DUP1, this ); return ret; } iStarted = ETrue; iRWState = EStateInitial; iSenderAndReceiver->Start(); //force a call to RunL SetActive(); TRequestStatus* status=&iStatus; User::RequestComplete(status, KErrNone); OstTraceFunctionExit1( CNCMCOMMUNICATIONINTERFACE_START_EXIT_DUP2, this ); return KErrNone; }
boolean CUSBKeyboardDevice::SetLEDs (u8 ucStatus) { u8 Buffer[1] = {ucStatus}; if (GetHost ()->ControlMessage (GetEndpoint0 (), REQUEST_OUT | REQUEST_CLASS | REQUEST_TO_INTERFACE, SET_REPORT, REPORT_TYPE_OUTPUT << 8, GetInterfaceNumber (), Buffer, sizeof Buffer) < 0) { return FALSE; } return TRUE; }
boolean CUSBHIDDevice::Configure (void) { if (GetNumEndpoints () < 1) { ConfigurationError (FromUSBHID); return FALSE; } TUSBEndpointDescriptor *pEndpointDesc = (TUSBEndpointDescriptor *) GetDescriptor (DESCRIPTOR_ENDPOINT); if ( pEndpointDesc == 0 || (pEndpointDesc->bEndpointAddress & 0x80) != 0x80 // Input EP || (pEndpointDesc->bmAttributes & 0x3F) != 0x03) // Interrupt EP { ConfigurationError (FromUSBHID); return FALSE; } assert (m_pReportEndpoint == 0); m_pReportEndpoint = new CUSBEndpoint (GetDevice (), pEndpointDesc); assert (m_pReportEndpoint != 0); if (!CUSBFunction::Configure ()) { CLogger::Get ()->Write (FromUSBHID, LogError, "Cannot set interface"); return FALSE; } if (GetHost ()->ControlMessage (GetEndpoint0 (), REQUEST_OUT | REQUEST_CLASS | REQUEST_TO_INTERFACE, SET_PROTOCOL, BOOT_PROTOCOL, GetInterfaceNumber (), 0, 0) < 0) { CLogger::Get ()->Write (FromUSBHID, LogError, "Cannot set boot protocol"); return FALSE; } return StartRequest (); }
boolean CUSBBluetoothDevice::Configure (void) { if (GetInterfaceNumber () != 0) { CLogger::Get ()->Write (FromBluetooth, LogWarning, "Voice channels are not supported"); return FALSE; } if (GetNumEndpoints () != 3) { ConfigurationError (FromBluetooth); return FALSE; } const TUSBEndpointDescriptor *pEndpointDesc; while ((pEndpointDesc = (TUSBEndpointDescriptor *) GetDescriptor (DESCRIPTOR_ENDPOINT)) != 0) { if ((pEndpointDesc->bmAttributes & 0x3F) == 0x02) // Bulk { if ((pEndpointDesc->bEndpointAddress & 0x80) == 0x80) // Input { if (m_pEndpointBulkIn != 0) { ConfigurationError (FromBluetooth); return FALSE; } m_pEndpointBulkIn = new CUSBEndpoint (GetDevice (), pEndpointDesc); } else // Output { if (m_pEndpointBulkOut != 0) { ConfigurationError (FromBluetooth); return FALSE; } m_pEndpointBulkOut = new CUSBEndpoint (GetDevice (), pEndpointDesc); } } else if ((pEndpointDesc->bmAttributes & 0x3F) == 0x03) // Interrupt { if (m_pEndpointInterrupt != 0) { ConfigurationError (FromBluetooth); return FALSE; } m_pEndpointInterrupt = new CUSBEndpoint (GetDevice (), pEndpointDesc); } } if ( m_pEndpointBulkIn == 0 || m_pEndpointBulkOut == 0 || m_pEndpointInterrupt == 0) { ConfigurationError (FromBluetooth); return FALSE; } if (!CUSBFunction::Configure ()) { CLogger::Get ()->Write (FromBluetooth, LogError, "Cannot set interface"); return FALSE; } m_pEventBuffer = new u8[m_pEndpointInterrupt->GetMaxPacketSize ()]; assert (m_pEventBuffer != 0); CString DeviceName; DeviceName.Format ("ubt%u", s_nDeviceNumber++); CDeviceNameService::Get ()->AddDevice (DeviceName, this, FALSE); return TRUE; }
boolean CUSBHIDDevice::Configure (unsigned nMaxReportSize) { if (GetNumEndpoints () < 1) { ConfigurationError (FromUSBHID); return FALSE; } const TUSBEndpointDescriptor *pEndpointDesc; while ((pEndpointDesc = (TUSBEndpointDescriptor *) GetDescriptor (DESCRIPTOR_ENDPOINT)) != 0) { if ((pEndpointDesc->bmAttributes & 0x3F) == 0x03) // Interrupt EP { if ((pEndpointDesc->bEndpointAddress & 0x80) == 0x80) // Input EP { if (m_pReportEndpoint != 0) { ConfigurationError (FromUSBHID); return FALSE; } m_pReportEndpoint = new CUSBEndpoint (GetDevice (), pEndpointDesc); } else // Output EP { if (m_pEndpointOut != 0) { ConfigurationError (FromUSBHID); return FALSE; } m_pEndpointOut = new CUSBEndpoint (GetDevice (), pEndpointDesc); } } } if (m_pReportEndpoint == 0) { ConfigurationError (FromUSBHID); return FALSE; } if (!CUSBFunction::Configure ()) { CLogger::Get ()->Write (FromUSBHID, LogError, "Cannot set interface"); return FALSE; } if ( GetInterfaceClass () == 3 // HID class && GetInterfaceSubClass () == 1) // boot class { if (GetHost ()->ControlMessage (GetEndpoint0 (), REQUEST_OUT | REQUEST_CLASS | REQUEST_TO_INTERFACE, SET_PROTOCOL, BOOT_PROTOCOL, GetInterfaceNumber (), 0, 0) < 0) { CLogger::Get ()->Write (FromUSBHID, LogError, "Cannot set boot protocol"); return FALSE; } } if (m_nMaxReportSize == 0) { m_nMaxReportSize = nMaxReportSize; assert (m_nMaxReportSize > 0); assert (m_pReportBuffer == 0); m_pReportBuffer = new u8[m_nMaxReportSize]; } assert (m_pReportBuffer != 0); return TRUE; }