Ashley Mills / USBHostWANDongle_bleedingedge

Dependents:   VodafoneUSBModem_bleedingedge2

Fork of USBHostWANDongle_bleedingedge by Donatien Garnier

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers WANDongleInitializer.h Source File

WANDongleInitializer.h

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 #ifndef WANDONGLEINITIALIZER_H
00020 #define WANDONGLEINITIALIZER_H
00021 
00022 #include <cstdint>
00023 using std::uint16_t;
00024 using std::uint32_t;
00025 
00026 #include "USBHost.h"
00027 #include "IUSBEnumerator.h"
00028 
00029 enum WAN_DONGLE_TYPE
00030 {
00031   WAN_DONGLE_TYPE_UNKNOWN        = -1,
00032   WAN_DONGLE_TYPE_VODAFONEK3770  =  0,
00033   WAN_DONGLE_TYPE_VODAFONEK3772Z =  1,
00034   WAN_DONGLE_TYPE_VODAFONEK3772  =  2,
00035   WAN_DONGLE_TYPE_VODAFONEK3773  =  3,
00036   WAN_DONGLE_TYPE_VODAFONEMU509  =  4,
00037 };
00038 
00039 class WANDongleInitializer : public IUSBEnumerator
00040 {
00041 protected:
00042     WANDongleInitializer(USBHost* pHost);
00043     USBHost* m_pHost;
00044     
00045 public:
00046     virtual uint16_t getMSDVid() = 0;
00047     virtual uint16_t getMSDPid() = 0;
00048     
00049     virtual uint16_t getSerialVid() = 0;
00050     virtual uint16_t getSerialPid() = 0;
00051     
00052     virtual bool switchMode(USBDeviceConnected* pDev) = 0;
00053     
00054     virtual USBEndpoint* getEp(USBDeviceConnected* pDev, int serialPortNumber, bool tx) = 0;
00055     
00056     virtual int getSerialPortCount() = 0;
00057     
00058     virtual void setVidPid(uint16_t vid, uint16_t pid) = 0;
00059     
00060     virtual bool parseInterface(uint8_t intf_nb, uint8_t intf_class, uint8_t intf_subclass, uint8_t intf_protocol) = 0; //Must return true if the interface should be parsed
00061     
00062     virtual bool useEndpoint(uint8_t intf_nb, ENDPOINT_TYPE type, ENDPOINT_DIRECTION dir) = 0; //Must return true if the endpoint will be used
00063     
00064     virtual WAN_DONGLE_TYPE getType() = 0;
00065     
00066     static WANDongleInitializer** getInitializers(USBHost* pHost);
00067 };
00068 
00069 class VodafoneK3770Initializer : public WANDongleInitializer
00070 {
00071 public:
00072     VodafoneK3770Initializer(USBHost* pHost);
00073     
00074     virtual uint16_t getMSDVid();
00075     virtual uint16_t getMSDPid();
00076     
00077     virtual uint16_t getSerialVid();
00078     virtual uint16_t getSerialPid();
00079     
00080     virtual bool switchMode(USBDeviceConnected* pDev);
00081     
00082     virtual USBEndpoint* getEp(USBDeviceConnected* pDev, int serialPortNumber, bool tx);
00083     
00084     virtual int getSerialPortCount();
00085     
00086     virtual void setVidPid(uint16_t vid, uint16_t pid);
00087     
00088     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
00089     
00090     virtual bool useEndpoint(uint8_t intf_nb, ENDPOINT_TYPE type, ENDPOINT_DIRECTION dir); //Must return true if the endpoint will be used
00091     
00092     virtual WAN_DONGLE_TYPE getType();
00093     
00094 private:
00095 
00096   bool m_hasSwitched;
00097   int m_currentSerialIntf;
00098   int m_endpointsToFetch;
00099 };
00100 
00101 class VodafoneK3773Initializer : public WANDongleInitializer
00102 {
00103 public:
00104     VodafoneK3773Initializer(USBHost* pHost);
00105     
00106     virtual uint16_t getMSDVid();
00107     virtual uint16_t getMSDPid();
00108     
00109     virtual uint16_t getSerialVid();
00110     virtual uint16_t getSerialPid();
00111     
00112     virtual bool switchMode(USBDeviceConnected* pDev);
00113     
00114     virtual USBEndpoint* getEp(USBDeviceConnected* pDev, int serialPortNumber, bool tx);
00115     
00116     virtual int getSerialPortCount();
00117     
00118     virtual void setVidPid(uint16_t vid, uint16_t pid);
00119     
00120     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
00121     
00122     virtual bool useEndpoint(uint8_t intf_nb, ENDPOINT_TYPE type, ENDPOINT_DIRECTION dir); //Must return true if the endpoint will be used
00123     
00124     virtual WAN_DONGLE_TYPE getType();
00125     
00126 private:
00127 
00128   bool m_hasSwitched;
00129   int m_currentSerialIntf;
00130   int m_endpointsToFetch;
00131 };
00132 
00133 class VodafoneK3772ZInitializer : public WANDongleInitializer
00134 {
00135 public:
00136     VodafoneK3772ZInitializer(USBHost* pHost);
00137     
00138     virtual uint16_t getMSDVid();
00139     virtual uint16_t getMSDPid();
00140     
00141     virtual uint16_t getSerialVid();
00142     virtual uint16_t getSerialPid();
00143     
00144     virtual bool switchMode(USBDeviceConnected* pDev);
00145     
00146     virtual USBEndpoint* getEp(USBDeviceConnected* pDev, int serialPortNumber, bool tx);
00147     
00148     virtual int getSerialPortCount();
00149     
00150     virtual void setVidPid(uint16_t vid, uint16_t pid);
00151     
00152     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
00153     
00154     virtual bool useEndpoint(uint8_t intf_nb, ENDPOINT_TYPE type, ENDPOINT_DIRECTION dir); //Must return true if the endpoint will be used
00155     
00156     virtual WAN_DONGLE_TYPE getType();
00157     
00158 private:
00159 
00160   bool m_hasSwitched;
00161   int m_currentSerialIntf;
00162   int m_endpointsToFetch;
00163 };
00164 
00165 class VodafoneMU509Initializer : public WANDongleInitializer
00166 {
00167 public:
00168     VodafoneMU509Initializer(USBHost* pHost);
00169     
00170     virtual uint16_t getMSDVid();
00171     virtual uint16_t getMSDPid();
00172     
00173     virtual uint16_t getSerialVid();
00174     virtual uint16_t getSerialPid();
00175     
00176     virtual bool switchMode(USBDeviceConnected* pDev);
00177     
00178     virtual USBEndpoint* getEp(USBDeviceConnected* pDev, int serialPortNumber, bool tx);
00179     
00180     virtual int getSerialPortCount();
00181     
00182     virtual void setVidPid(uint16_t vid, uint16_t pid);
00183     
00184     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
00185     
00186     virtual bool useEndpoint(uint8_t intf_nb, ENDPOINT_TYPE type, ENDPOINT_DIRECTION dir); //Must return true if the endpoint will be used
00187     
00188     virtual WAN_DONGLE_TYPE getType();
00189     
00190 private:
00191 
00192   int m_currentSerialIntf;
00193   int m_endpointsToFetch;
00194 };
00195 
00196 class VodafoneK3772Initializer : public WANDongleInitializer
00197 {
00198 public:
00199     VodafoneK3772Initializer(USBHost* pHost);
00200     
00201     virtual uint16_t getMSDVid();
00202     virtual uint16_t getMSDPid();
00203     
00204     virtual uint16_t getSerialVid();
00205     virtual uint16_t getSerialPid();
00206     
00207     virtual bool switchMode(USBDeviceConnected* pDev);
00208     
00209     virtual USBEndpoint* getEp(USBDeviceConnected* pDev, int serialPortNumber, bool tx);
00210     
00211     virtual int getSerialPortCount();
00212     
00213     virtual void setVidPid(uint16_t vid, uint16_t pid);
00214     
00215     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
00216     
00217     virtual bool useEndpoint(uint8_t intf_nb, ENDPOINT_TYPE type, ENDPOINT_DIRECTION dir); //Must return true if the endpoint will be used
00218     
00219     virtual WAN_DONGLE_TYPE getType();
00220     
00221 private:
00222 
00223   bool m_hasSwitched;
00224   int m_currentSerialIntf;
00225   int m_endpointsToFetch;
00226 };
00227 
00228 #endif
00229