1 /* Copyright (c) 2010-2012 mbed.org, MIT License
3 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
4 * and associated documentation files (the "Software"), to deal in the Software without
5 * restriction, including without limitation the rights to use, copy, modify, merge, publish,
6 * distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
7 * Software is furnished to do so, subject to the following conditions:
9 * The above copyright notice and this permission notice shall be included in all copies or
10 * substantial portions of the Software.
12 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
13 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
14 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
15 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19 #include "UbloxGSMModemInitializer.h"
24 #define __MODULE__ "UbloxGSMModemInitializer.cpp"
27 //-----------------------------------------------------------------------
29 //-----------------------------------------------------------------------
31 UbloxGSMModemInitializer::UbloxGSMModemInitializer(USBHost
* pHost
) : WANDongleInitializer(pHost
)
36 uint16_t UbloxGSMModemInitializer::getMSDVid() { return 0x1546; }
37 uint16_t UbloxGSMModemInitializer::getMSDPid() { return 0x0000; }
39 uint16_t UbloxGSMModemInitializer::getSerialVid() { return 0x1546; }
40 uint16_t UbloxGSMModemInitializer::getSerialPid() { return 0x1102; }
42 bool UbloxGSMModemInitializer::switchMode(USBDeviceConnected
* pDev
)
44 for (int i
= 0; i
< pDev
->getNbIntf(); i
++)
46 if (pDev
->getInterface(i
)->intf_class
== MSD_CLASS
)
48 USBEndpoint
* pEp
= pDev
->getEndpoint(i
, BULK_ENDPOINT
, OUT
);
51 ERR("MSD descriptor found on device %p, intf %d", (void *)pDev
, i
);
58 #define UBX_SERIALCOUNT 7
60 int UbloxGSMModemInitializer::getSerialPortCount()
62 return UBX_SERIALCOUNT
;
65 /*virtual*/ void UbloxGSMModemInitializer::setVidPid(uint16_t vid
, uint16_t pid
)
67 if( (vid
== getSerialVid() ) && ( pid
== getSerialPid() ) )
70 m_currentSerialIntf
= 0;
71 m_endpointsToFetch
= UBX_SERIALCOUNT
*2;
75 m_hasSwitched
= false;
76 m_endpointsToFetch
= 1;
80 /*virtual*/ bool UbloxGSMModemInitializer::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
84 DBG("Interface #%d; Class:%02x; SubClass:%02x; Protocol:%02x", intf_nb
, intf_class
, intf_subclass
, intf_protocol
);
85 if( intf_class
== 0x0A )
87 if( (m_currentSerialIntf
== 0) || (m_currentSerialIntf
== 1) )
89 m_serialIntfMap
[m_currentSerialIntf
++] = intf_nb
;
92 m_currentSerialIntf
++;
97 if( (intf_nb
== 0) && (intf_class
== MSD_CLASS
) )
105 /*virtual*/ bool UbloxGSMModemInitializer::useEndpoint(uint8_t intf_nb
, ENDPOINT_TYPE type
, ENDPOINT_DIRECTION dir
) //Must return true if the endpoint will be used
109 DBG("USBEndpoint on Interface #%d; Type:%d; Direction:%d", intf_nb
, type
, dir
);
110 if( (type
== BULK_ENDPOINT
) && m_endpointsToFetch
)
112 m_endpointsToFetch
--;
118 if( (type
== BULK_ENDPOINT
) && (dir
== OUT
) && m_endpointsToFetch
)
120 m_endpointsToFetch
--;
127 /*virtual*/ int UbloxGSMModemInitializer::getType()
129 return WAN_DONGLE_TYPE_UBLOX_LISAU200
;