Changes to support Vodafone K4606
Fork of USBHostWANDongle by
Diff: USB3GModule/WANDongleInitializer.cpp
- Revision:
- 6:075e36a3463e
- Parent:
- 5:3189db174f6b
- Child:
- 8:0d1ec493842c
diff -r 3189db174f6b -r 075e36a3463e USB3GModule/WANDongleInitializer.cpp --- a/USB3GModule/WANDongleInitializer.cpp Wed Jul 25 11:13:50 2012 +0000 +++ b/USB3GModule/WANDongleInitializer.cpp Fri Jul 27 16:14:07 2012 +0000 @@ -85,12 +85,70 @@ Endpoint* VodafoneK3770Initializer::getEp(USBDeviceConnected* pDev, int serialPortNumber, bool tx) { - const int intf[3] = {0,4,2}; - return pDev->getEndpoint(intf[serialPortNumber], BULK_ENDPOINT, tx?OUT:IN, 0); + return pDev->getEndpoint(serialPortNumber, BULK_ENDPOINT, tx?OUT:IN, 0); } int VodafoneK3770Initializer::getSerialPortCount() { - return 3; + return 2; +} + +/*virtual*/ void VodafoneK3770Initializer::setVidPid(uint16_t vid, uint16_t pid) +{ + if( (vid == getSerialVid() ) && ( pid == getSerialPid() ) ) + { + m_hasSwitched = true; + m_currentSerialIntf = 0; + m_endpointsToFetch = 4; + } + else + { + m_hasSwitched = false; + m_endpointsToFetch = 1; + } } +/*virtual*/ bool VodafoneK3770Initializer::parseInterface(uint8_t intf_nb, uint8_t intf_class, uint8_t intf_subclass, uint8_t intf_protocol) //Must return true if the interface should be parsed +{ + if( m_hasSwitched ) + { + if( intf_class == 0xFF ) + { + if( (m_currentSerialIntf == 0) || (m_currentSerialIntf == 4) ) + { + m_currentSerialIntf++; + return true; + } + m_currentSerialIntf++; + } + } + else + { + if( (intf_nb == 0) && (intf_class == MSD_CLASS) ) + { + return true; + } + } + return false; +} + +/*virtual*/ bool VodafoneK3770Initializer::useEndpoint(uint8_t intf_nb, ENDPOINT_TYPE type, ENDPOINT_DIRECTION dir) //Must return true if the endpoint will be used +{ + if( m_hasSwitched ) + { + if( (type == BULK_ENDPOINT) && m_endpointsToFetch ) + { + m_endpointsToFetch--; + return true; + } + } + else + { + if( (type == BULK_ENDPOINT) && (dir == OUT) && m_endpointsToFetch ) + { + m_endpointsToFetch--; + return true; + } + } + return false; +}