Changes to support Vodafone K4606
Fork of USBHostWANDongle by
Embed:
(wiki syntax)
Show/hide line numbers
WANDongleInitializer.cpp
00001 /* Copyright (c) 2010-2012 mbed.org, MIT License 00002 * 00003 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 00004 * and associated documentation files (the "Software"), to deal in the Software without 00005 * restriction, including without limitation the rights to use, copy, modify, merge, publish, 00006 * distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the 00007 * Software is furnished to do so, subject to the following conditions: 00008 * 00009 * The above copyright notice and this permission notice shall be included in all copies or 00010 * substantial portions of the Software. 00011 * 00012 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING 00013 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 00014 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 00015 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 00016 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 00017 */ 00018 00019 #define __DEBUG__ 0 00020 #ifndef __MODULE__ 00021 #define __MODULE__ "WANDongleInitializer.cpp" 00022 #endif 00023 00024 #include "core/dbg.h" 00025 00026 #include <cstdint> 00027 using std::uint16_t; 00028 00029 #include "WANDongleInitializer.h" 00030 00031 00032 WANDongleInitializer::WANDongleInitializer(USBHost* pHost) : m_pHost(pHost) 00033 { 00034 } 00035 00036 WANDongleInitializer** WANDongleInitializer::getInitializers(USBHost* pHost) 00037 { 00038 static VodafoneK3770Initializer vodafoneK3770(pHost); 00039 static VodafoneK3772ZInitializer vodafoneK3772Z(pHost); 00040 static VodafoneK3772Initializer vodafoneK3772(pHost); 00041 static VodafoneK3773Initializer vodafoneK3773(pHost); 00042 static HuaweiMU509Initializer huaweiMU509(pHost); 00043 static UbloxLISAU200Initializer ubloxLISAU200(pHost); 00044 static VodafoneK4606Initializer vodafoneK4606(pHost); 00045 00046 const static WANDongleInitializer* list[] = { 00047 &vodafoneK3770, 00048 &vodafoneK3772Z, 00049 &vodafoneK3772, 00050 &vodafoneK3773, 00051 &huaweiMU509, 00052 &ubloxLISAU200, 00053 &vodafoneK4606, 00054 NULL 00055 }; 00056 return (WANDongleInitializer**)list; 00057 } 00058 00059 //Huawei K3770 (Vodafone) 00060 // 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" 00061 static uint8_t vodafone_k3770_switch_packet[] = { 00062 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 00063 }; 00064 00065 VodafoneK3770Initializer::VodafoneK3770Initializer(USBHost* pHost) : WANDongleInitializer(pHost) 00066 { 00067 00068 } 00069 00070 uint16_t VodafoneK3770Initializer::getMSDVid() { return 0x12D1; } 00071 uint16_t VodafoneK3770Initializer::getMSDPid() { return 0x14D1; } 00072 00073 uint16_t VodafoneK3770Initializer::getSerialVid() { return 0x12D1; } 00074 uint16_t VodafoneK3770Initializer::getSerialPid() { return 0x14C9; } 00075 00076 bool VodafoneK3770Initializer::switchMode(USBDeviceConnected* pDev) 00077 { 00078 for (int i = 0; i < pDev->getNbInterface(); i++) 00079 { 00080 if (pDev->getInterface(i)->intf_class == MSD_CLASS) 00081 { 00082 USBEndpoint* pEp = pDev->getEndpoint(i, BULK_ENDPOINT, OUT); 00083 if ( pEp != NULL ) 00084 { 00085 DBG("MSD descriptor found on device %p, intf %d, will now try to switch into serial mode", (void *)pDev, i); 00086 m_pHost->bulkWrite(pDev, pEp, vodafone_k3770_switch_packet, 31); 00087 return true; 00088 } 00089 } 00090 } 00091 return false; 00092 } 00093 00094 USBEndpoint* VodafoneK3770Initializer::getEp(USBDeviceConnected* pDev, int serialPortNumber, bool tx) 00095 { 00096 return pDev->getEndpoint(serialPortNumber, BULK_ENDPOINT, tx?OUT:IN, 0); 00097 } 00098 00099 int VodafoneK3770Initializer::getSerialPortCount() 00100 { 00101 return 2; 00102 } 00103 00104 /*virtual*/ void VodafoneK3770Initializer::setVidPid(uint16_t vid, uint16_t pid) 00105 { 00106 if( (vid == getSerialVid() ) && ( pid == getSerialPid() ) ) 00107 { 00108 m_hasSwitched = true; 00109 m_currentSerialIntf = 0; 00110 m_endpointsToFetch = 4; 00111 } 00112 else 00113 { 00114 m_hasSwitched = false; 00115 m_endpointsToFetch = 1; 00116 } 00117 } 00118 00119 /*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 00120 { 00121 if( m_hasSwitched ) 00122 { 00123 if( intf_class == 0xFF ) 00124 { 00125 if( (m_currentSerialIntf == 0) || (m_currentSerialIntf == 4) ) 00126 { 00127 m_currentSerialIntf++; 00128 return true; 00129 } 00130 m_currentSerialIntf++; 00131 } 00132 } 00133 else 00134 { 00135 if( (intf_nb == 0) && (intf_class == MSD_CLASS) ) 00136 { 00137 return true; 00138 } 00139 } 00140 return false; 00141 } 00142 00143 /*virtual*/ bool VodafoneK3770Initializer::useEndpoint(uint8_t intf_nb, ENDPOINT_TYPE type, ENDPOINT_DIRECTION dir) //Must return true if the endpoint will be used 00144 { 00145 if( m_hasSwitched ) 00146 { 00147 if( (type == BULK_ENDPOINT) && m_endpointsToFetch ) 00148 { 00149 m_endpointsToFetch--; 00150 return true; 00151 } 00152 } 00153 else 00154 { 00155 if( (type == BULK_ENDPOINT) && (dir == OUT) && m_endpointsToFetch ) 00156 { 00157 m_endpointsToFetch--; 00158 return true; 00159 } 00160 } 00161 return false; 00162 } 00163 00164 /*virtual*/ WAN_DONGLE_TYPE VodafoneK3770Initializer::getType() 00165 { 00166 return WAN_DONGLE_TYPE_VODAFONE_K3770; 00167 } 00168 00169 //Huawei MU509 (Module) 00170 00171 HuaweiMU509Initializer::HuaweiMU509Initializer(USBHost* pHost) : WANDongleInitializer(pHost) 00172 { 00173 00174 } 00175 00176 uint16_t HuaweiMU509Initializer::getMSDVid() { return 0x12D1; } 00177 uint16_t HuaweiMU509Initializer::getMSDPid() { return 0x0000; } //No MSD mode (presumably) 00178 00179 uint16_t HuaweiMU509Initializer::getSerialVid() { return 0x12D1; } 00180 uint16_t HuaweiMU509Initializer::getSerialPid() { return 0x1001; } 00181 00182 bool HuaweiMU509Initializer::switchMode(USBDeviceConnected* pDev) 00183 { 00184 return true; //No MSD mode 00185 } 00186 00187 USBEndpoint* HuaweiMU509Initializer::getEp(USBDeviceConnected* pDev, int serialPortNumber, bool tx) 00188 { 00189 /* 00190 int sPort = serialPortNumber; 00191 if(sPort==1) 00192 sPort = 0; 00193 if(sPort==2) 00194 sPort = 1; 00195 if(sPort==0) 00196 sPort = 2; 00197 return pDev->getEndpoint(sPort, BULK_ENDPOINT, tx?OUT:IN, 0); 00198 */ 00199 return pDev->getEndpoint(serialPortNumber, BULK_ENDPOINT, tx?OUT:IN, 0); 00200 //return pDev->getEndpoint((serialPortNumber==1)?0:1, BULK_ENDPOINT, tx?OUT:IN, 0); 00201 } 00202 00203 int HuaweiMU509Initializer::getSerialPortCount() 00204 { 00205 return 2; 00206 } 00207 00208 /*virtual*/ void HuaweiMU509Initializer::setVidPid(uint16_t vid, uint16_t pid) 00209 { 00210 m_currentSerialIntf = 0; 00211 m_endpointsToFetch = 4; 00212 } 00213 00214 /*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 00215 { 00216 if( intf_class == 0xFF ) 00217 { 00218 if( (m_currentSerialIntf == 0) || (m_currentSerialIntf == 2) ) 00219 { 00220 m_currentSerialIntf++; 00221 return true; 00222 } 00223 m_currentSerialIntf++; 00224 } 00225 return false; 00226 } 00227 00228 /*virtual*/ bool HuaweiMU509Initializer::useEndpoint(uint8_t intf_nb, ENDPOINT_TYPE type, ENDPOINT_DIRECTION dir) //Must return true if the endpoint will be used 00229 { 00230 if( (type == BULK_ENDPOINT) && m_endpointsToFetch ) 00231 { 00232 DBG("new endpoint"); 00233 m_endpointsToFetch--; 00234 return true; 00235 } 00236 return false; 00237 } 00238 00239 /*virtual*/ WAN_DONGLE_TYPE HuaweiMU509Initializer::getType() 00240 { 00241 return WAN_DONGLE_TYPE_HUAWEI_MU509; 00242 } 00243 00244 //Huawei K3773 (Vodafone) 00245 // 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" 00246 static uint8_t vodafone_k3773_switch_packet[] = { 00247 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 00248 }; 00249 00250 VodafoneK3773Initializer::VodafoneK3773Initializer(USBHost* pHost) : WANDongleInitializer(pHost) 00251 { 00252 00253 } 00254 00255 uint16_t VodafoneK3773Initializer::getMSDVid() { return 0x12D1; } 00256 uint16_t VodafoneK3773Initializer::getMSDPid() { return 0x1506; } 00257 00258 uint16_t VodafoneK3773Initializer::getSerialVid() { return 0x12D1; } 00259 uint16_t VodafoneK3773Initializer::getSerialPid() { return 0x1506; } 00260 00261 bool VodafoneK3773Initializer::switchMode(USBDeviceConnected* pDev) 00262 { 00263 for (int i = 0; i < pDev->getNbInterface(); i++) 00264 { 00265 if (pDev->getInterface(i)->intf_class == MSD_CLASS) 00266 { 00267 USBEndpoint* pEp = pDev->getEndpoint(i, BULK_ENDPOINT, OUT); 00268 if ( pEp != NULL ) 00269 { 00270 DBG("MSD descriptor found on device %p, intf %d, will now try to switch into serial mode", (void *)pDev, i); 00271 m_pHost->bulkWrite(pDev, pEp, vodafone_k3773_switch_packet, 31); 00272 return true; 00273 } 00274 } 00275 } 00276 return false; 00277 } 00278 00279 USBEndpoint* VodafoneK3773Initializer::getEp(USBDeviceConnected* pDev, int serialPortNumber, bool tx) 00280 { 00281 return pDev->getEndpoint(serialPortNumber, BULK_ENDPOINT, tx?OUT:IN, 0); 00282 } 00283 00284 int VodafoneK3773Initializer::getSerialPortCount() 00285 { 00286 return 2; 00287 } 00288 00289 /*virtual*/ void VodafoneK3773Initializer::setVidPid(uint16_t vid, uint16_t pid) 00290 { 00291 if( (vid == getSerialVid() ) && ( pid == getSerialPid() ) ) 00292 { 00293 m_hasSwitched = true; 00294 m_currentSerialIntf = 0; 00295 m_endpointsToFetch = 4; 00296 } 00297 else 00298 { 00299 m_hasSwitched = false; 00300 m_endpointsToFetch = 1; 00301 } 00302 } 00303 00304 /*virtual*/ bool VodafoneK3773Initializer::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 00305 { 00306 if( m_hasSwitched ) 00307 { 00308 if( intf_class == 0xFF ) 00309 { 00310 if( (m_currentSerialIntf == 0) || (m_currentSerialIntf == 4) ) 00311 { 00312 m_currentSerialIntf++; 00313 return true; 00314 } 00315 m_currentSerialIntf++; 00316 } 00317 } 00318 else 00319 { 00320 if( (intf_nb == 0) && (intf_class == MSD_CLASS) ) 00321 { 00322 return true; 00323 } 00324 } 00325 return false; 00326 } 00327 00328 /*virtual*/ bool VodafoneK3773Initializer::useEndpoint(uint8_t intf_nb, ENDPOINT_TYPE type, ENDPOINT_DIRECTION dir) //Must return true if the endpoint will be used 00329 { 00330 if( m_hasSwitched ) 00331 { 00332 if( (type == BULK_ENDPOINT) && m_endpointsToFetch ) 00333 { 00334 m_endpointsToFetch--; 00335 return true; 00336 } 00337 } 00338 else 00339 { 00340 if( (type == BULK_ENDPOINT) && (dir == OUT) && m_endpointsToFetch ) 00341 { 00342 m_endpointsToFetch--; 00343 return true; 00344 } 00345 } 00346 return false; 00347 } 00348 00349 /*virtual*/ WAN_DONGLE_TYPE VodafoneK3773Initializer::getType() 00350 { 00351 return WAN_DONGLE_TYPE_VODAFONE_K3773; 00352 } 00353 00354 // NVIDIA (ICERA) /ZTE K3772-Z (Vodafone) 00355 // Switching from mass storage device string is: "55 53 42 43 12 34 56 78 00 00 00 00 00 00 06 1b 00 00 00 02 00 00 00 00 00 00 00 00 00 00 00" 00356 static uint8_t vodafone_k3772_z_switch_packet[] = { 00357 0x55, 0x53, 0x42, 0x43, 0x12, 0x34, 0x56, 0x78, 0, 0, 0, 0, 0, 0, 0x06, 0x1b, 0, 0, 0, 0x02, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 00358 }; 00359 00360 VodafoneK3772ZInitializer::VodafoneK3772ZInitializer(USBHost* pHost) : WANDongleInitializer(pHost) 00361 { 00362 00363 } 00364 00365 uint16_t VodafoneK3772ZInitializer::getMSDVid() { return 0x19D2; } 00366 uint16_t VodafoneK3772ZInitializer::getMSDPid() { return 0x1179; } 00367 00368 uint16_t VodafoneK3772ZInitializer::getSerialVid() { return 0x19D2; } 00369 uint16_t VodafoneK3772ZInitializer::getSerialPid() { return 0x1181; } 00370 00371 bool VodafoneK3772ZInitializer::switchMode(USBDeviceConnected* pDev) 00372 { 00373 for (int i = 0; i < pDev->getNbInterface(); i++) 00374 { 00375 if (pDev->getInterface(i)->intf_class == MSD_CLASS) 00376 { 00377 USBEndpoint* pEp = pDev->getEndpoint(i, BULK_ENDPOINT, OUT); 00378 if ( pEp != NULL ) 00379 { 00380 DBG("MSD descriptor found on device %p, intf %d, will now try to switch into serial mode", (void *)pDev, i); 00381 m_pHost->bulkWrite(pDev, pEp, vodafone_k3772_z_switch_packet, 31); 00382 return true; 00383 } 00384 } 00385 } 00386 return false; 00387 } 00388 00389 USBEndpoint* VodafoneK3772ZInitializer::getEp(USBDeviceConnected* pDev, int serialPortNumber, bool tx) 00390 { 00391 return pDev->getEndpoint((serialPortNumber==1)?0:1, BULK_ENDPOINT, tx?OUT:IN, 0); 00392 } 00393 00394 int VodafoneK3772ZInitializer::getSerialPortCount() 00395 { 00396 return 2; 00397 } 00398 00399 /*virtual*/ void VodafoneK3772ZInitializer::setVidPid(uint16_t vid, uint16_t pid) 00400 { 00401 if( (vid == getSerialVid() ) && ( pid == getSerialPid() ) ) 00402 { 00403 m_hasSwitched = true; 00404 m_currentSerialIntf = 0; 00405 m_endpointsToFetch = 4; 00406 } 00407 else 00408 { 00409 m_hasSwitched = false; 00410 m_endpointsToFetch = 1; 00411 } 00412 } 00413 00414 /*virtual*/ bool VodafoneK3772ZInitializer::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 00415 { 00416 if( m_hasSwitched ) 00417 { 00418 DBG("Interface #%d; Class:%02x; SubClass:%02x; Protocol:%02x", intf_nb, intf_class, intf_subclass, intf_protocol); 00419 if( intf_class == 0x0A ) 00420 { 00421 if( (m_currentSerialIntf == 0) || (m_currentSerialIntf == 1) ) 00422 { 00423 m_currentSerialIntf++; 00424 return true; 00425 } 00426 m_currentSerialIntf++; 00427 } 00428 } 00429 else 00430 { 00431 if( (intf_nb == 0) && (intf_class == MSD_CLASS) ) 00432 { 00433 return true; 00434 } 00435 } 00436 return false; 00437 } 00438 00439 /*virtual*/ bool VodafoneK3772ZInitializer::useEndpoint(uint8_t intf_nb, ENDPOINT_TYPE type, ENDPOINT_DIRECTION dir) //Must return true if the endpoint will be used 00440 { 00441 if( m_hasSwitched ) 00442 { 00443 DBG("USBEndpoint on Inteface #%d; Type:%d; Direction:%d", intf_nb, type, dir); 00444 if( (type == BULK_ENDPOINT) && m_endpointsToFetch ) 00445 { 00446 m_endpointsToFetch--; 00447 return true; 00448 } 00449 } 00450 else 00451 { 00452 if( (type == BULK_ENDPOINT) && (dir == OUT) && m_endpointsToFetch ) 00453 { 00454 m_endpointsToFetch--; 00455 return true; 00456 } 00457 } 00458 return false; 00459 } 00460 00461 00462 /*virtual*/ WAN_DONGLE_TYPE VodafoneK3772ZInitializer::getType() 00463 { 00464 return WAN_DONGLE_TYPE_VODAFONE_K3772Z; 00465 } 00466 00467 //Huawei K3772 (Vodafone) 00468 // Switching from mass storage device string is: "55 53 42 43 12 34 56 78 00 02 00 00 80 00 0a 11 06 20 00 00 00 00 00 01 00 00 00 00 00 00 00" 00469 static uint8_t vodafone_k3772_switch_packet[] = { 00470 0x55, 0x53, 0x42, 0x43, 0x12, 0x34, 0x56, 0x78, 0, 0x02, 0, 0, 0x80, 0, 0x0a, 0x11, 0x06, 0x20, 0, 0, 0, 0, 0, 0x01, 0, 0, 0, 0, 0, 0, 0 00471 }; 00472 00473 00474 VodafoneK3772Initializer::VodafoneK3772Initializer(USBHost* pHost) : WANDongleInitializer(pHost) 00475 { 00476 00477 } 00478 00479 uint16_t VodafoneK3772Initializer::getMSDVid() { return 0x12D1; } 00480 uint16_t VodafoneK3772Initializer::getMSDPid() { return 0x1526; } 00481 00482 uint16_t VodafoneK3772Initializer::getSerialVid() { return 0x12D1; } 00483 uint16_t VodafoneK3772Initializer::getSerialPid() { return 0x14CF; } 00484 00485 bool VodafoneK3772Initializer::switchMode(USBDeviceConnected* pDev) 00486 { 00487 for (int i = 0; i < pDev->getNbInterface(); i++) 00488 { 00489 if (pDev->getInterface(i)->intf_class == MSD_CLASS) 00490 { 00491 USBEndpoint* pEp = pDev->getEndpoint(i, BULK_ENDPOINT, OUT); 00492 if ( pEp != NULL ) 00493 { 00494 DBG("MSD descriptor found on device %p, intf %d, will now try to switch into serial mode", (void *)pDev, i); 00495 m_pHost->bulkWrite(pDev, pEp, vodafone_k3772_switch_packet, 31); 00496 return true; 00497 } 00498 } 00499 } 00500 return false; 00501 } 00502 00503 USBEndpoint* VodafoneK3772Initializer::getEp(USBDeviceConnected* pDev, int serialPortNumber, bool tx) 00504 { 00505 return pDev->getEndpoint(serialPortNumber, BULK_ENDPOINT, tx?OUT:IN, 0); 00506 } 00507 00508 int VodafoneK3772Initializer::getSerialPortCount() 00509 { 00510 return 2; 00511 } 00512 00513 /*virtual*/ void VodafoneK3772Initializer::setVidPid(uint16_t vid, uint16_t pid) 00514 { 00515 if( (vid == getSerialVid() ) && ( pid == getSerialPid() ) ) 00516 { 00517 m_hasSwitched = true; 00518 m_currentSerialIntf = 0; 00519 m_endpointsToFetch = 4; 00520 } 00521 else 00522 { 00523 m_hasSwitched = false; 00524 m_endpointsToFetch = 1; 00525 } 00526 } 00527 00528 /*virtual*/ bool VodafoneK3772Initializer::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 00529 { 00530 if( m_hasSwitched ) 00531 { 00532 if( intf_class == 0xFF ) 00533 { 00534 if( (m_currentSerialIntf == 0) || (m_currentSerialIntf == 2) ) 00535 { 00536 m_currentSerialIntf++; 00537 return true; 00538 } 00539 m_currentSerialIntf++; 00540 } 00541 } 00542 else 00543 { 00544 if( (intf_nb == 0) && (intf_class == MSD_CLASS) ) 00545 { 00546 return true; 00547 } 00548 } 00549 return false; 00550 } 00551 00552 /*virtual*/ bool VodafoneK3772Initializer::useEndpoint(uint8_t intf_nb, ENDPOINT_TYPE type, ENDPOINT_DIRECTION dir) //Must return true if the endpoint will be used 00553 { 00554 if( m_hasSwitched ) 00555 { 00556 if( (type == BULK_ENDPOINT) && m_endpointsToFetch ) 00557 { 00558 m_endpointsToFetch--; 00559 return true; 00560 } 00561 } 00562 else 00563 { 00564 if( (type == BULK_ENDPOINT) && (dir == OUT) && m_endpointsToFetch ) 00565 { 00566 m_endpointsToFetch--; 00567 return true; 00568 } 00569 } 00570 return false; 00571 } 00572 00573 /*virtual*/ WAN_DONGLE_TYPE VodafoneK3772Initializer::getType() 00574 { 00575 return WAN_DONGLE_TYPE_VODAFONE_K3772; 00576 } 00577 00578 00579 //----------------------------------------------------------------------- 00580 // mamm, u-blox Modem 00581 //----------------------------------------------------------------------- 00582 00583 UbloxLISAU200Initializer::UbloxLISAU200Initializer(USBHost* pHost) : WANDongleInitializer(pHost) 00584 { 00585 00586 } 00587 00588 uint16_t UbloxLISAU200Initializer::getMSDVid() { return 0x1546; } 00589 uint16_t UbloxLISAU200Initializer::getMSDPid() { return 0x0000; } 00590 00591 uint16_t UbloxLISAU200Initializer::getSerialVid() { return 0x1546; } 00592 uint16_t UbloxLISAU200Initializer::getSerialPid() { return 0x1102; } 00593 00594 bool UbloxLISAU200Initializer::switchMode(USBDeviceConnected* pDev) 00595 { 00596 for (int i = 0; i < pDev->getNbInterface(); i++) 00597 { 00598 if (pDev->getInterface(i)->intf_class == MSD_CLASS) 00599 { 00600 USBEndpoint* pEp = pDev->getEndpoint(i, BULK_ENDPOINT, OUT); 00601 if ( pEp != NULL ) 00602 { 00603 ERR("MSD descriptor found on device %p, intf %d", (void *)pDev, i); 00604 } 00605 } 00606 } 00607 return false; 00608 } 00609 00610 USBEndpoint* UbloxLISAU200Initializer::getEp(USBDeviceConnected* pDev, int serialPortNumber, bool tx) 00611 { 00612 return pDev->getEndpoint(serialPortNumber, BULK_ENDPOINT, tx?OUT:IN, 0); 00613 } 00614 00615 #define UBX_SERIALCOUNT 7 00616 00617 int UbloxLISAU200Initializer::getSerialPortCount() 00618 { 00619 return UBX_SERIALCOUNT; 00620 } 00621 00622 /*virtual*/ void UbloxLISAU200Initializer::setVidPid(uint16_t vid, uint16_t pid) 00623 { 00624 if( (vid == getSerialVid() ) && ( pid == getSerialPid() ) ) 00625 { 00626 m_hasSwitched = true; 00627 m_currentSerialIntf = 0; 00628 m_endpointsToFetch = UBX_SERIALCOUNT*2; 00629 } 00630 else 00631 { 00632 m_hasSwitched = false; 00633 m_endpointsToFetch = 1; 00634 } 00635 } 00636 00637 /*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 00638 { 00639 if( m_hasSwitched ) 00640 { 00641 DBG("Interface #%d; Class:%02x; SubClass:%02x; Protocol:%02x", intf_nb, intf_class, intf_subclass, intf_protocol); 00642 if( intf_class == 0x0A ) 00643 { 00644 if( (m_currentSerialIntf == 0) || (m_currentSerialIntf == 1) ) 00645 { 00646 m_currentSerialIntf++; 00647 return true; 00648 } 00649 m_currentSerialIntf++; 00650 } 00651 } 00652 else 00653 { 00654 if( (intf_nb == 0) && (intf_class == MSD_CLASS) ) 00655 { 00656 return true; 00657 } 00658 } 00659 return false; 00660 } 00661 00662 /*virtual*/ bool UbloxLISAU200Initializer::useEndpoint(uint8_t intf_nb, ENDPOINT_TYPE type, ENDPOINT_DIRECTION dir) //Must return true if the endpoint will be used 00663 { 00664 if( m_hasSwitched ) 00665 { 00666 DBG("USBEndpoint on Interface #%d; Type:%d; Direction:%d", intf_nb, type, dir); 00667 if( (type == BULK_ENDPOINT) && m_endpointsToFetch ) 00668 { 00669 m_endpointsToFetch--; 00670 return true; 00671 } 00672 } 00673 else 00674 { 00675 if( (type == BULK_ENDPOINT) && (dir == OUT) && m_endpointsToFetch ) 00676 { 00677 m_endpointsToFetch--; 00678 return true; 00679 } 00680 } 00681 return false; 00682 } 00683 00684 /*virtual*/ WAN_DONGLE_TYPE UbloxLISAU200Initializer::getType() 00685 { 00686 return WAN_DONGLE_TYPE_UBLOX_LISAU200; 00687 } 00688 00689 00690 //----------------------------------------------------------------------- 00691 // Huawei K4606 (Vodafone) 00692 //----------------------------------------------------------------------- 00693 // 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" 00694 static uint8_t vodafone_k4606_switch_packet[] = { 00695 0x55, 0x53, 0x42, 0x43, 0x12, 0x34, 0x56, 0x78, 0, 0, 0, 0, 0, 0, 0, 0x11, 0x06, 0x00, 0, 0, 0x00, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 00696 }; 00697 00698 VodafoneK4606Initializer::VodafoneK4606Initializer(USBHost* pHost) : WANDongleInitializer(pHost) 00699 { 00700 } 00701 00702 uint16_t VodafoneK4606Initializer::getMSDVid() { return 0x12D1; } 00703 uint16_t VodafoneK4606Initializer::getMSDPid() { return 0x1F19; } 00704 00705 uint16_t VodafoneK4606Initializer::getSerialVid() { return 0x12D1; } 00706 uint16_t VodafoneK4606Initializer::getSerialPid() { return 0x1001;} 00707 00708 bool VodafoneK4606Initializer::switchMode(USBDeviceConnected* pDev) 00709 { 00710 for (int i = 0; i < pDev->getNbInterface(); i++) 00711 { 00712 if (pDev->getInterface(i)->intf_class == MSD_CLASS) 00713 { 00714 USBEndpoint* pEp = pDev->getEndpoint(i, BULK_ENDPOINT, OUT); 00715 if ( pEp != NULL ) 00716 { 00717 DBG("Vodafone K4606 MSD descriptor found on device %p, intf %d, will now try to switch into serial mode", (void *)pDev, i); 00718 m_pHost->bulkWrite(pDev, pEp, vodafone_k4606_switch_packet, 31); 00719 return true; 00720 } 00721 } 00722 } 00723 return false; 00724 } 00725 00726 USBEndpoint* VodafoneK4606Initializer::getEp(USBDeviceConnected* pDev, int serialPortNumber, bool tx) 00727 { 00728 return pDev->getEndpoint(serialPortNumber, BULK_ENDPOINT, tx?OUT:IN, 0); 00729 } 00730 00731 int VodafoneK4606Initializer::getSerialPortCount() 00732 { 00733 return 2; 00734 } 00735 00736 void VodafoneK4606Initializer::setVidPid(uint16_t vid, uint16_t pid) 00737 { 00738 if( (vid == getSerialVid() ) && ( pid == getSerialPid() ) ) 00739 { 00740 m_hasSwitched = true; 00741 m_currentSerialIntf = 0; 00742 m_endpointsToFetch = 4; 00743 } 00744 else 00745 { 00746 m_hasSwitched = false; 00747 m_endpointsToFetch = 1; 00748 } 00749 } 00750 00751 bool VodafoneK4606Initializer::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 00752 { 00753 if( m_hasSwitched ) 00754 { 00755 DBG("*K4606 parsing intf %d, intf_class %d, m_currentSerialIntf %d", intf_nb, intf_class, m_currentSerialIntf); 00756 00757 if( intf_class == 0x2 ) 00758 { 00759 if( (m_currentSerialIntf == 0) || (m_currentSerialIntf == 2) ) 00760 { 00761 m_currentSerialIntf++; 00762 return true; 00763 } 00764 m_currentSerialIntf++; 00765 } 00766 } 00767 else 00768 { 00769 if( (intf_nb == 0) && (intf_class == MSD_CLASS) ) 00770 { 00771 return true; 00772 } 00773 } 00774 return false; 00775 } 00776 00777 bool VodafoneK4606Initializer::useEndpoint(uint8_t intf_nb, ENDPOINT_TYPE type, ENDPOINT_DIRECTION dir) //Must return true if the endpoint will be used 00778 { 00779 if( m_hasSwitched ) 00780 { 00781 if( (type == BULK_ENDPOINT) && m_endpointsToFetch ) 00782 { 00783 m_endpointsToFetch--; 00784 return true; 00785 } 00786 } 00787 else 00788 { 00789 if( (type == BULK_ENDPOINT) && (dir == OUT) && m_endpointsToFetch ) 00790 { 00791 m_endpointsToFetch--; 00792 return true; 00793 } 00794 } 00795 return false; 00796 } 00797 00798 WAN_DONGLE_TYPE VodafoneK4606Initializer::getType() 00799 { 00800 return WAN_DONGLE_TYPE_VODAFONE_K4606; 00801 }
Generated on Thu Jul 14 2022 09:11:27 by 1.7.2