USB Host WAN Dongle library
Fork of USBHostWANDongle_bleedingedge by
Revision 27:980fe31c14f7, committed 2013-09-20
- Comitter:
- ashleymills
- Date:
- Fri Sep 20 10:40:15 2013 +0000
- Parent:
- 26:b241a57c465b
- Commit message:
- Added support for Ublox LISA U200 module
Changed in this revision
diff -r b241a57c465b -r 980fe31c14f7 USB3GModule/WANDongleInitializer.cpp --- a/USB3GModule/WANDongleInitializer.cpp Thu Apr 18 11:22:57 2013 +0000 +++ b/USB3GModule/WANDongleInitializer.cpp Fri Sep 20 10:40:15 2013 +0000 @@ -39,13 +39,15 @@ static VodafoneK3772ZInitializer vodafoneK3772Z(pHost); static VodafoneK3772Initializer vodafoneK3772(pHost); static VodafoneK3773Initializer vodafoneK3773(pHost); - static VodafoneMU509Initializer vodafoneMU509(pHost); + static HuaweiMU509Initializer huaweiMU509(pHost); + static UbloxLISAU200Initializer ubloxLISAU200(pHost); const static WANDongleInitializer* list[] = { &vodafoneK3770, &vodafoneK3772Z, &vodafoneK3772, &vodafoneK3773, - &vodafoneMU509, + &huaweiMU509, + &ubloxLISAU200, NULL }; return (WANDongleInitializer**)list; @@ -158,28 +160,28 @@ /*virtual*/ WAN_DONGLE_TYPE VodafoneK3770Initializer::getType() { - return WAN_DONGLE_TYPE_VODAFONEK3770; + return WAN_DONGLE_TYPE_VODAFONE_K3770; } //Huawei MU509 (Module) -VodafoneMU509Initializer::VodafoneMU509Initializer(USBHost* pHost) : WANDongleInitializer(pHost) +HuaweiMU509Initializer::HuaweiMU509Initializer(USBHost* pHost) : WANDongleInitializer(pHost) { } -uint16_t VodafoneMU509Initializer::getMSDVid() { return 0x12D1; } -uint16_t VodafoneMU509Initializer::getMSDPid() { return 0x0000; } //No MSD mode (presumably) +uint16_t HuaweiMU509Initializer::getMSDVid() { return 0x12D1; } +uint16_t HuaweiMU509Initializer::getMSDPid() { return 0x0000; } //No MSD mode (presumably) -uint16_t VodafoneMU509Initializer::getSerialVid() { return 0x12D1; } -uint16_t VodafoneMU509Initializer::getSerialPid() { return 0x1001; } +uint16_t HuaweiMU509Initializer::getSerialVid() { return 0x12D1; } +uint16_t HuaweiMU509Initializer::getSerialPid() { return 0x1001; } -bool VodafoneMU509Initializer::switchMode(USBDeviceConnected* pDev) +bool HuaweiMU509Initializer::switchMode(USBDeviceConnected* pDev) { return true; //No MSD mode } -USBEndpoint* VodafoneMU509Initializer::getEp(USBDeviceConnected* pDev, int serialPortNumber, bool tx) +USBEndpoint* HuaweiMU509Initializer::getEp(USBDeviceConnected* pDev, int serialPortNumber, bool tx) { /* int sPort = serialPortNumber; @@ -195,18 +197,18 @@ //return pDev->getEndpoint((serialPortNumber==1)?0:1, BULK_ENDPOINT, tx?OUT:IN, 0); } -int VodafoneMU509Initializer::getSerialPortCount() +int HuaweiMU509Initializer::getSerialPortCount() { return 2; } -/*virtual*/ void VodafoneMU509Initializer::setVidPid(uint16_t vid, uint16_t pid) +/*virtual*/ void HuaweiMU509Initializer::setVidPid(uint16_t vid, uint16_t pid) { m_currentSerialIntf = 0; m_endpointsToFetch = 4; } -/*virtual*/ bool VodafoneMU509Initializer::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 +/*virtual*/ bool HuaweiMU509Initializer::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( intf_class == 0xFF ) { @@ -220,7 +222,7 @@ return false; } -/*virtual*/ bool VodafoneMU509Initializer::useEndpoint(uint8_t intf_nb, ENDPOINT_TYPE type, ENDPOINT_DIRECTION dir) //Must return true if the endpoint will be used +/*virtual*/ bool HuaweiMU509Initializer::useEndpoint(uint8_t intf_nb, ENDPOINT_TYPE type, ENDPOINT_DIRECTION dir) //Must return true if the endpoint will be used { if( (type == BULK_ENDPOINT) && m_endpointsToFetch ) { @@ -231,9 +233,9 @@ return false; } -/*virtual*/ WAN_DONGLE_TYPE VodafoneMU509Initializer::getType() +/*virtual*/ WAN_DONGLE_TYPE HuaweiMU509Initializer::getType() { - return WAN_DONGLE_TYPE_VODAFONEMU509; + return WAN_DONGLE_TYPE_HUAWEI_MU509; } //Huawei K3773 (Vodafone) @@ -343,7 +345,7 @@ /*virtual*/ WAN_DONGLE_TYPE VodafoneK3773Initializer::getType() { - return WAN_DONGLE_TYPE_VODAFONEK3773; + return WAN_DONGLE_TYPE_VODAFONE_K3773; } // NVIDIA (ICERA) /ZTE K3772-Z (Vodafone) @@ -456,7 +458,7 @@ /*virtual*/ WAN_DONGLE_TYPE VodafoneK3772ZInitializer::getType() { - return WAN_DONGLE_TYPE_VODAFONEK3772Z; + return WAN_DONGLE_TYPE_VODAFONE_K3772Z; } //Huawei K3772 (Vodafone) @@ -567,5 +569,116 @@ /*virtual*/ WAN_DONGLE_TYPE VodafoneK3772Initializer::getType() { - return WAN_DONGLE_TYPE_VODAFONEK3772; + return WAN_DONGLE_TYPE_VODAFONE_K3772; +} + + +//----------------------------------------------------------------------- +// mamm, u-blox Modem +//----------------------------------------------------------------------- + +UbloxLISAU200Initializer::UbloxLISAU200Initializer(USBHost* pHost) : WANDongleInitializer(pHost) +{ + +} + +uint16_t UbloxLISAU200Initializer::getMSDVid() { return 0x1546; } +uint16_t UbloxLISAU200Initializer::getMSDPid() { return 0x0000; } + +uint16_t UbloxLISAU200Initializer::getSerialVid() { return 0x1546; } +uint16_t UbloxLISAU200Initializer::getSerialPid() { return 0x1102; } + +bool UbloxLISAU200Initializer::switchMode(USBDeviceConnected* pDev) +{ + for (int i = 0; i < pDev->getNbInterface(); i++) + { + if (pDev->getInterface(i)->intf_class == MSD_CLASS) + { + USBEndpoint* pEp = pDev->getEndpoint(i, BULK_ENDPOINT, OUT); + if ( pEp != NULL ) + { + ERR("MSD descriptor found on device %p, intf %d", (void *)pDev, i); + } + } + } + return false; +} + +USBEndpoint* UbloxLISAU200Initializer::getEp(USBDeviceConnected* pDev, int serialPortNumber, bool tx) +{ + return pDev->getEndpoint(serialPortNumber, BULK_ENDPOINT, tx?OUT:IN, 0); +} + +#define UBX_SERIALCOUNT 7 + +int UbloxLISAU200Initializer::getSerialPortCount() +{ + return UBX_SERIALCOUNT; +} + +/*virtual*/ void UbloxLISAU200Initializer::setVidPid(uint16_t vid, uint16_t pid) +{ + if( (vid == getSerialVid() ) && ( pid == getSerialPid() ) ) + { + m_hasSwitched = true; + m_currentSerialIntf = 0; + m_endpointsToFetch = UBX_SERIALCOUNT*2; + } + else + { + m_hasSwitched = false; + m_endpointsToFetch = 1; + } +} + +/*virtual*/ bool UbloxLISAU200Initializer::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 ) + { + DBG("Interface #%d; Class:%02x; SubClass:%02x; Protocol:%02x", intf_nb, intf_class, intf_subclass, intf_protocol); + if( intf_class == 0x0A ) + { + if( (m_currentSerialIntf == 0) || (m_currentSerialIntf == 1) ) + { + m_currentSerialIntf++; + return true; + } + m_currentSerialIntf++; + } + } + else + { + if( (intf_nb == 0) && (intf_class == MSD_CLASS) ) + { + return true; + } + } + return false; +} + +/*virtual*/ bool UbloxLISAU200Initializer::useEndpoint(uint8_t intf_nb, ENDPOINT_TYPE type, ENDPOINT_DIRECTION dir) //Must return true if the endpoint will be used +{ + if( m_hasSwitched ) + { + DBG("USBEndpoint on Interface #%d; Type:%d; Direction:%d", intf_nb, type, dir); + 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; +} + +/*virtual*/ WAN_DONGLE_TYPE UbloxLISAU200Initializer::getType() +{ + return WAN_DONGLE_TYPE_UBLOX_LISAU200; } \ No newline at end of file
diff -r b241a57c465b -r 980fe31c14f7 USB3GModule/WANDongleInitializer.h --- a/USB3GModule/WANDongleInitializer.h Thu Apr 18 11:22:57 2013 +0000 +++ b/USB3GModule/WANDongleInitializer.h Fri Sep 20 10:40:15 2013 +0000 @@ -28,12 +28,13 @@ enum WAN_DONGLE_TYPE { - WAN_DONGLE_TYPE_UNKNOWN = -1, - WAN_DONGLE_TYPE_VODAFONEK3770 = 0, - WAN_DONGLE_TYPE_VODAFONEK3772Z = 1, - WAN_DONGLE_TYPE_VODAFONEK3772 = 2, - WAN_DONGLE_TYPE_VODAFONEK3773 = 3, - WAN_DONGLE_TYPE_VODAFONEMU509 = 4, + WAN_DONGLE_TYPE_UNKNOWN = -1, + WAN_DONGLE_TYPE_VODAFONE_K3770 = 0, + WAN_DONGLE_TYPE_VODAFONE_K3772Z = 1, + WAN_DONGLE_TYPE_VODAFONE_K3772 = 2, + WAN_DONGLE_TYPE_VODAFONE_K3773 = 3, + WAN_DONGLE_TYPE_HUAWEI_MU509 = 4, + WAN_DONGLE_TYPE_UBLOX_LISAU200 = 5 }; class WANDongleInitializer : public IUSBEnumerator @@ -162,10 +163,10 @@ int m_endpointsToFetch; }; -class VodafoneMU509Initializer : public WANDongleInitializer +class HuaweiMU509Initializer : public WANDongleInitializer { public: - VodafoneMU509Initializer(USBHost* pHost); + HuaweiMU509Initializer(USBHost* pHost); virtual uint16_t getMSDVid(); virtual uint16_t getMSDPid(); @@ -225,5 +226,41 @@ int m_endpointsToFetch; }; +//----------------------------------------------------------------------- +// mamm, u-blox Modem +//----------------------------------------------------------------------- + +class UbloxLISAU200Initializer : public WANDongleInitializer +{ +public: + UbloxLISAU200Initializer(USBHost* pHost); + + virtual uint16_t getMSDVid(); + virtual uint16_t getMSDPid(); + + virtual uint16_t getSerialVid(); + virtual uint16_t getSerialPid(); + + virtual bool switchMode(USBDeviceConnected* pDev); + + virtual USBEndpoint* getEp(USBDeviceConnected* pDev, int serialPortNumber, bool tx); + + virtual int getSerialPortCount(); + + virtual void setVidPid(uint16_t vid, uint16_t pid); + + virtual bool 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 + + virtual bool useEndpoint(uint8_t intf_nb, ENDPOINT_TYPE type, ENDPOINT_DIRECTION dir); //Must return true if the endpoint will be used + + virtual WAN_DONGLE_TYPE getType(); + +private: + + bool m_hasSwitched; + int m_currentSerialIntf; + int m_endpointsToFetch; +}; + #endif
diff -r b241a57c465b -r 980fe31c14f7 USBHost/USBHost.cpp --- a/USBHost/USBHost.cpp Thu Apr 18 11:22:57 2013 +0000 +++ b/USBHost/USBHost.cpp Fri Sep 20 10:40:15 2013 +0000 @@ -561,7 +561,7 @@ // enumerate a device with the control USBEndpoint USB_TYPE USBHost::enumerate(USBDeviceConnected * dev, IUSBEnumerator* pEnumerator) { - uint8_t data[384]; + uint8_t data[415]; uint16_t total_conf_descr_length = 0; USB_TYPE res;