Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of USBHostWANDongle by
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_VODAFONE_K3770 = 0, 00033 WAN_DONGLE_TYPE_VODAFONE_K3772Z = 1, 00034 WAN_DONGLE_TYPE_VODAFONE_K3772 = 2, 00035 WAN_DONGLE_TYPE_VODAFONE_K3773 = 3, 00036 WAN_DONGLE_TYPE_HUAWEI_MU509 = 4, 00037 WAN_DONGLE_TYPE_UBLOX_LISAU200 = 5, 00038 WAN_DONGLE_TYPE_VODAFONE_K4606 = 6 00039 }; 00040 00041 class WANDongleInitializer : public IUSBEnumerator 00042 { 00043 protected: 00044 WANDongleInitializer(USBHost* pHost); 00045 USBHost* m_pHost; 00046 00047 public: 00048 virtual uint16_t getMSDVid() = 0; 00049 virtual uint16_t getMSDPid() = 0; 00050 00051 virtual uint16_t getSerialVid() = 0; 00052 virtual uint16_t getSerialPid() = 0; 00053 00054 virtual bool switchMode(USBDeviceConnected* pDev) = 0; 00055 00056 virtual USBEndpoint* getEp(USBDeviceConnected* pDev, int serialPortNumber, bool tx) = 0; 00057 00058 virtual int getSerialPortCount() = 0; 00059 00060 virtual void setVidPid(uint16_t vid, uint16_t pid) = 0; 00061 00062 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 00063 00064 virtual bool useEndpoint(uint8_t intf_nb, ENDPOINT_TYPE type, ENDPOINT_DIRECTION dir) = 0; //Must return true if the endpoint will be used 00065 00066 virtual WAN_DONGLE_TYPE getType() = 0; 00067 00068 static WANDongleInitializer** getInitializers(USBHost* pHost); 00069 }; 00070 00071 class VodafoneK3770Initializer : public WANDongleInitializer 00072 { 00073 public: 00074 VodafoneK3770Initializer(USBHost* pHost); 00075 00076 virtual uint16_t getMSDVid(); 00077 virtual uint16_t getMSDPid(); 00078 00079 virtual uint16_t getSerialVid(); 00080 virtual uint16_t getSerialPid(); 00081 00082 virtual bool switchMode(USBDeviceConnected* pDev); 00083 00084 virtual USBEndpoint* getEp(USBDeviceConnected* pDev, int serialPortNumber, bool tx); 00085 00086 virtual int getSerialPortCount(); 00087 00088 virtual void setVidPid(uint16_t vid, uint16_t pid); 00089 00090 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 00091 00092 virtual bool useEndpoint(uint8_t intf_nb, ENDPOINT_TYPE type, ENDPOINT_DIRECTION dir); //Must return true if the endpoint will be used 00093 00094 virtual WAN_DONGLE_TYPE getType(); 00095 00096 private: 00097 00098 bool m_hasSwitched; 00099 int m_currentSerialIntf; 00100 int m_endpointsToFetch; 00101 }; 00102 00103 class VodafoneK3773Initializer : public WANDongleInitializer 00104 { 00105 public: 00106 VodafoneK3773Initializer(USBHost* pHost); 00107 00108 virtual uint16_t getMSDVid(); 00109 virtual uint16_t getMSDPid(); 00110 00111 virtual uint16_t getSerialVid(); 00112 virtual uint16_t getSerialPid(); 00113 00114 virtual bool switchMode(USBDeviceConnected* pDev); 00115 00116 virtual USBEndpoint* getEp(USBDeviceConnected* pDev, int serialPortNumber, bool tx); 00117 00118 virtual int getSerialPortCount(); 00119 00120 virtual void setVidPid(uint16_t vid, uint16_t pid); 00121 00122 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 00123 00124 virtual bool useEndpoint(uint8_t intf_nb, ENDPOINT_TYPE type, ENDPOINT_DIRECTION dir); //Must return true if the endpoint will be used 00125 00126 virtual WAN_DONGLE_TYPE getType(); 00127 00128 private: 00129 00130 bool m_hasSwitched; 00131 int m_currentSerialIntf; 00132 int m_endpointsToFetch; 00133 }; 00134 00135 class VodafoneK3772ZInitializer : public WANDongleInitializer 00136 { 00137 public: 00138 VodafoneK3772ZInitializer(USBHost* pHost); 00139 00140 virtual uint16_t getMSDVid(); 00141 virtual uint16_t getMSDPid(); 00142 00143 virtual uint16_t getSerialVid(); 00144 virtual uint16_t getSerialPid(); 00145 00146 virtual bool switchMode(USBDeviceConnected* pDev); 00147 00148 virtual USBEndpoint* getEp(USBDeviceConnected* pDev, int serialPortNumber, bool tx); 00149 00150 virtual int getSerialPortCount(); 00151 00152 virtual void setVidPid(uint16_t vid, uint16_t pid); 00153 00154 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 00155 00156 virtual bool useEndpoint(uint8_t intf_nb, ENDPOINT_TYPE type, ENDPOINT_DIRECTION dir); //Must return true if the endpoint will be used 00157 00158 virtual WAN_DONGLE_TYPE getType(); 00159 00160 private: 00161 00162 bool m_hasSwitched; 00163 int m_currentSerialIntf; 00164 int m_endpointsToFetch; 00165 }; 00166 00167 class HuaweiMU509Initializer : public WANDongleInitializer 00168 { 00169 public: 00170 HuaweiMU509Initializer(USBHost* pHost); 00171 00172 virtual uint16_t getMSDVid(); 00173 virtual uint16_t getMSDPid(); 00174 00175 virtual uint16_t getSerialVid(); 00176 virtual uint16_t getSerialPid(); 00177 00178 virtual bool switchMode(USBDeviceConnected* pDev); 00179 00180 virtual USBEndpoint* getEp(USBDeviceConnected* pDev, int serialPortNumber, bool tx); 00181 00182 virtual int getSerialPortCount(); 00183 00184 virtual void setVidPid(uint16_t vid, uint16_t pid); 00185 00186 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 00187 00188 virtual bool useEndpoint(uint8_t intf_nb, ENDPOINT_TYPE type, ENDPOINT_DIRECTION dir); //Must return true if the endpoint will be used 00189 00190 virtual WAN_DONGLE_TYPE getType(); 00191 00192 private: 00193 00194 int m_currentSerialIntf; 00195 int m_endpointsToFetch; 00196 }; 00197 00198 class VodafoneK3772Initializer : public WANDongleInitializer 00199 { 00200 public: 00201 VodafoneK3772Initializer(USBHost* pHost); 00202 00203 virtual uint16_t getMSDVid(); 00204 virtual uint16_t getMSDPid(); 00205 00206 virtual uint16_t getSerialVid(); 00207 virtual uint16_t getSerialPid(); 00208 00209 virtual bool switchMode(USBDeviceConnected* pDev); 00210 00211 virtual USBEndpoint* getEp(USBDeviceConnected* pDev, int serialPortNumber, bool tx); 00212 00213 virtual int getSerialPortCount(); 00214 00215 virtual void setVidPid(uint16_t vid, uint16_t pid); 00216 00217 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 00218 00219 virtual bool useEndpoint(uint8_t intf_nb, ENDPOINT_TYPE type, ENDPOINT_DIRECTION dir); //Must return true if the endpoint will be used 00220 00221 virtual WAN_DONGLE_TYPE getType(); 00222 00223 private: 00224 00225 bool m_hasSwitched; 00226 int m_currentSerialIntf; 00227 int m_endpointsToFetch; 00228 }; 00229 00230 //----------------------------------------------------------------------- 00231 // mamm, u-blox Modem 00232 //----------------------------------------------------------------------- 00233 00234 class UbloxLISAU200Initializer : public WANDongleInitializer 00235 { 00236 public: 00237 UbloxLISAU200Initializer(USBHost* pHost); 00238 00239 virtual uint16_t getMSDVid(); 00240 virtual uint16_t getMSDPid(); 00241 00242 virtual uint16_t getSerialVid(); 00243 virtual uint16_t getSerialPid(); 00244 00245 virtual bool switchMode(USBDeviceConnected* pDev); 00246 00247 virtual USBEndpoint* getEp(USBDeviceConnected* pDev, int serialPortNumber, bool tx); 00248 00249 virtual int getSerialPortCount(); 00250 00251 virtual void setVidPid(uint16_t vid, uint16_t pid); 00252 00253 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 00254 00255 virtual bool useEndpoint(uint8_t intf_nb, ENDPOINT_TYPE type, ENDPOINT_DIRECTION dir); //Must return true if the endpoint will be used 00256 00257 virtual WAN_DONGLE_TYPE getType(); 00258 00259 private: 00260 00261 bool m_hasSwitched; 00262 int m_currentSerialIntf; 00263 int m_endpointsToFetch; 00264 }; 00265 00266 00267 class VodafoneK4606Initializer : public WANDongleInitializer 00268 { 00269 public: 00270 VodafoneK4606Initializer(USBHost* pHost); 00271 00272 virtual uint16_t getMSDVid(); 00273 virtual uint16_t getMSDPid(); 00274 00275 virtual uint16_t getSerialVid(); 00276 virtual uint16_t getSerialPid(); 00277 00278 virtual bool switchMode(USBDeviceConnected* pDev); 00279 00280 virtual USBEndpoint* getEp(USBDeviceConnected* pDev, int serialPortNumber, bool tx); 00281 00282 virtual int getSerialPortCount(); 00283 00284 virtual void setVidPid(uint16_t vid, uint16_t pid); 00285 00286 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 00287 00288 virtual bool useEndpoint(uint8_t intf_nb, ENDPOINT_TYPE type, ENDPOINT_DIRECTION dir); //Must return true if the endpoint will be used 00289 00290 virtual WAN_DONGLE_TYPE getType(); 00291 00292 private: 00293 00294 bool m_hasSwitched; 00295 int m_currentSerialIntf; 00296 int m_endpointsToFetch; 00297 }; 00298 00299 00300 #endif 00301
Generated on Thu Jul 14 2022 09:11:27 by
1.7.2
