USB Host WAN Dongle library

Fork of USBHostWANDongle_bleedingedge by Donatien Garnier

Revision:
22:bec61bcc9c25
Parent:
21:dcc8c866ccbb
Child:
23:8f2d9a244224
--- a/USB3GModule/WANDongleInitializer.cpp	Tue Dec 18 13:56:10 2012 +0000
+++ b/USB3GModule/WANDongleInitializer.cpp	Tue Dec 18 15:31:57 2012 +0000
@@ -160,10 +160,6 @@
 }
 
 //Huawei MU509 (Module)
-// Switching from mass storage device string is: "55 53 42 43 12 34 56 78 00 00 00 00 00 00 00 11 06 20 00 00 01 00 00 00 00 00 00 00 00 00 00"
-static uint8_t vodafone_mu509_switch_packet[] = {
-    //0x55, 0x53, 0x42, 0x43, 0x12, 0x34, 0x56, 0x78, 0, 0, 0, 0, 0, 0, 0, 0x11, 0x06, 0x20, 0, 0, 0x01, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
-};
 
 VodafoneMU509Initializer::VodafoneMU509Initializer(USBHost* pHost) : WANDongleInitializer(pHost)
 {
@@ -171,27 +167,14 @@
 }
 
 uint16_t VodafoneMU509Initializer::getMSDVid()      { return 0x12D1; }
-uint16_t VodafoneMU509Initializer::getMSDPid()      { return 0x1001; }
+uint16_t VodafoneMU509Initializer::getMSDPid()      { return 0x0000; } //No MSD mode (presumably)
 
 uint16_t VodafoneMU509Initializer::getSerialVid()   { return 0x12D1; }
 uint16_t VodafoneMU509Initializer::getSerialPid()   { return 0x1001; }
 
 bool VodafoneMU509Initializer::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 ) 
-      {
-        DBG("MSD descriptor found on device %p, intf %d, will now try to switch into serial mode", (void *)pDev, i);
-        m_pHost->bulkWrite(pDev, pEp, vodafone_mu509_switch_packet, 31);
-        return true;
-      }
-    }  
-  }
-  return false;
+  return true; //No MSD mode
 }
 
 USBEndpoint* VodafoneMU509Initializer::getEp(USBDeviceConnected* pDev, int serialPortNumber, bool tx)
@@ -201,65 +184,35 @@
 
 int VodafoneMU509Initializer::getSerialPortCount()
 {
-  return 3;
+  return 2;
 }
 
 /*virtual*/ void VodafoneMU509Initializer::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;
-    }
+  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
 {
-  if( m_hasSwitched )
+  if( intf_class == 0xFF )
   {
-    if( intf_class == 0xFF )
+    if( (m_currentSerialIntf == 0) || (m_currentSerialIntf == 1) )
     {
-      if( (m_currentSerialIntf == 0) || (m_currentSerialIntf == 4) )
-      {
-        m_currentSerialIntf++;
-        return true;
-      }
       m_currentSerialIntf++;
-    }
-  }
-  else
-  {
-    if( (intf_nb == 0) && (intf_class == MSD_CLASS) )
-    {
       return true;
     }
+    m_currentSerialIntf++;
   }
   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
 {
-  if( m_hasSwitched )
+  if( (type == BULK_ENDPOINT) && m_endpointsToFetch )
   {
-    if( (type == BULK_ENDPOINT) && m_endpointsToFetch )
-    {
-      m_endpointsToFetch--;
-      return true;
-    }
-  }
-  else
-  {
-    if( (type == BULK_ENDPOINT) && (dir == OUT) && m_endpointsToFetch )
-    {
-      m_endpointsToFetch--;
-      return true;
-    }
+    m_endpointsToFetch--;
+    return true;
   }
   return false;
 }