USB Host WAN Dongle library

Fork of USBHostWANDongle_bleedingedge by Donatien Garnier

Committer:
donatien
Date:
Mon Feb 25 11:48:26 2013 +0000
Revision:
18:7d5242aa7b95
Parent:
10:08bce4cd973a
Child:
25:3184f71557bf
Added support for Huawei K3772 dongle (this is what seems to be in the VF stores these days) - PPP tested OK

Who changed what in which revision?

UserRevisionLine numberNew contents of line
donatien 10:08bce4cd973a 1 /* Copyright (c) 2010-2012 mbed.org, MIT License
donatien 8:0d1ec493842c 2 *
donatien 8:0d1ec493842c 3 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
donatien 8:0d1ec493842c 4 * and associated documentation files (the "Software"), to deal in the Software without
donatien 8:0d1ec493842c 5 * restriction, including without limitation the rights to use, copy, modify, merge, publish,
donatien 8:0d1ec493842c 6 * distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
donatien 8:0d1ec493842c 7 * Software is furnished to do so, subject to the following conditions:
donatien 8:0d1ec493842c 8 *
donatien 8:0d1ec493842c 9 * The above copyright notice and this permission notice shall be included in all copies or
donatien 8:0d1ec493842c 10 * substantial portions of the Software.
donatien 8:0d1ec493842c 11 *
donatien 8:0d1ec493842c 12 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
donatien 8:0d1ec493842c 13 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
donatien 8:0d1ec493842c 14 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
donatien 8:0d1ec493842c 15 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
donatien 8:0d1ec493842c 16 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
donatien 8:0d1ec493842c 17 */
donatien 8:0d1ec493842c 18
donatien 8:0d1ec493842c 19 #ifndef WANDONGLEINITIALIZER_H
donatien 8:0d1ec493842c 20 #define WANDONGLEINITIALIZER_H
donatien 8:0d1ec493842c 21
donatien 8:0d1ec493842c 22 #include <cstdint>
donatien 8:0d1ec493842c 23 using std::uint16_t;
donatien 8:0d1ec493842c 24 using std::uint32_t;
donatien 8:0d1ec493842c 25
donatien 8:0d1ec493842c 26 #include "USBHost.h"
donatien 8:0d1ec493842c 27 #include "IUSBEnumerator.h"
donatien 8:0d1ec493842c 28
donatien 8:0d1ec493842c 29 enum WAN_DONGLE_TYPE
donatien 8:0d1ec493842c 30 {
donatien 8:0d1ec493842c 31 WAN_DONGLE_TYPE_UNKNOWN = -1,
donatien 8:0d1ec493842c 32 WAN_DONGLE_TYPE_VODAFONEK3770 = 0,
donatien 8:0d1ec493842c 33 WAN_DONGLE_TYPE_VODAFONEK3772Z = 1,
donatien 18:7d5242aa7b95 34 WAN_DONGLE_TYPE_VODAFONEK3772 = 2,
donatien 8:0d1ec493842c 35 };
donatien 8:0d1ec493842c 36
donatien 8:0d1ec493842c 37 class WANDongleInitializer : public IUSBEnumerator
donatien 8:0d1ec493842c 38 {
donatien 8:0d1ec493842c 39 protected:
donatien 8:0d1ec493842c 40 WANDongleInitializer(USBHost* pHost);
donatien 8:0d1ec493842c 41 USBHost* m_pHost;
donatien 8:0d1ec493842c 42
donatien 8:0d1ec493842c 43 public:
donatien 8:0d1ec493842c 44 virtual uint16_t getMSDVid() = 0;
donatien 8:0d1ec493842c 45 virtual uint16_t getMSDPid() = 0;
donatien 8:0d1ec493842c 46
donatien 8:0d1ec493842c 47 virtual uint16_t getSerialVid() = 0;
donatien 8:0d1ec493842c 48 virtual uint16_t getSerialPid() = 0;
donatien 8:0d1ec493842c 49
donatien 8:0d1ec493842c 50 virtual bool switchMode(USBDeviceConnected* pDev) = 0;
donatien 8:0d1ec493842c 51
donatien 9:c9e9817c398c 52 virtual USBEndpoint* getEp(USBDeviceConnected* pDev, int serialPortNumber, bool tx) = 0;
donatien 8:0d1ec493842c 53
donatien 8:0d1ec493842c 54 virtual int getSerialPortCount() = 0;
donatien 8:0d1ec493842c 55
donatien 8:0d1ec493842c 56 virtual void setVidPid(uint16_t vid, uint16_t pid) = 0;
donatien 8:0d1ec493842c 57
donatien 8:0d1ec493842c 58 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
donatien 8:0d1ec493842c 59
donatien 8:0d1ec493842c 60 virtual bool useEndpoint(uint8_t intf_nb, ENDPOINT_TYPE type, ENDPOINT_DIRECTION dir) = 0; //Must return true if the endpoint will be used
donatien 8:0d1ec493842c 61
donatien 8:0d1ec493842c 62 virtual WAN_DONGLE_TYPE getType() = 0;
donatien 8:0d1ec493842c 63
donatien 8:0d1ec493842c 64 static WANDongleInitializer** getInitializers(USBHost* pHost);
donatien 8:0d1ec493842c 65 };
donatien 8:0d1ec493842c 66
donatien 8:0d1ec493842c 67 class VodafoneK3770Initializer : public WANDongleInitializer
donatien 8:0d1ec493842c 68 {
donatien 8:0d1ec493842c 69 public:
donatien 8:0d1ec493842c 70 VodafoneK3770Initializer(USBHost* pHost);
donatien 8:0d1ec493842c 71
donatien 8:0d1ec493842c 72 virtual uint16_t getMSDVid();
donatien 8:0d1ec493842c 73 virtual uint16_t getMSDPid();
donatien 8:0d1ec493842c 74
donatien 8:0d1ec493842c 75 virtual uint16_t getSerialVid();
donatien 8:0d1ec493842c 76 virtual uint16_t getSerialPid();
donatien 8:0d1ec493842c 77
donatien 8:0d1ec493842c 78 virtual bool switchMode(USBDeviceConnected* pDev);
donatien 8:0d1ec493842c 79
donatien 9:c9e9817c398c 80 virtual USBEndpoint* getEp(USBDeviceConnected* pDev, int serialPortNumber, bool tx);
donatien 8:0d1ec493842c 81
donatien 8:0d1ec493842c 82 virtual int getSerialPortCount();
donatien 8:0d1ec493842c 83
donatien 8:0d1ec493842c 84 virtual void setVidPid(uint16_t vid, uint16_t pid);
donatien 8:0d1ec493842c 85
donatien 8:0d1ec493842c 86 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
donatien 8:0d1ec493842c 87
donatien 8:0d1ec493842c 88 virtual bool useEndpoint(uint8_t intf_nb, ENDPOINT_TYPE type, ENDPOINT_DIRECTION dir); //Must return true if the endpoint will be used
donatien 8:0d1ec493842c 89
donatien 8:0d1ec493842c 90 virtual WAN_DONGLE_TYPE getType();
donatien 8:0d1ec493842c 91
donatien 8:0d1ec493842c 92 private:
donatien 8:0d1ec493842c 93
donatien 8:0d1ec493842c 94 bool m_hasSwitched;
donatien 8:0d1ec493842c 95 int m_currentSerialIntf;
donatien 8:0d1ec493842c 96 int m_endpointsToFetch;
donatien 8:0d1ec493842c 97 };
donatien 8:0d1ec493842c 98
donatien 18:7d5242aa7b95 99 class VodafoneK3772Initializer : public WANDongleInitializer
donatien 18:7d5242aa7b95 100 {
donatien 18:7d5242aa7b95 101 public:
donatien 18:7d5242aa7b95 102 VodafoneK3772Initializer(USBHost* pHost);
donatien 18:7d5242aa7b95 103
donatien 18:7d5242aa7b95 104 virtual uint16_t getMSDVid();
donatien 18:7d5242aa7b95 105 virtual uint16_t getMSDPid();
donatien 18:7d5242aa7b95 106
donatien 18:7d5242aa7b95 107 virtual uint16_t getSerialVid();
donatien 18:7d5242aa7b95 108 virtual uint16_t getSerialPid();
donatien 18:7d5242aa7b95 109
donatien 18:7d5242aa7b95 110 virtual bool switchMode(USBDeviceConnected* pDev);
donatien 18:7d5242aa7b95 111
donatien 18:7d5242aa7b95 112 virtual USBEndpoint* getEp(USBDeviceConnected* pDev, int serialPortNumber, bool tx);
donatien 18:7d5242aa7b95 113
donatien 18:7d5242aa7b95 114 virtual int getSerialPortCount();
donatien 18:7d5242aa7b95 115
donatien 18:7d5242aa7b95 116 virtual void setVidPid(uint16_t vid, uint16_t pid);
donatien 18:7d5242aa7b95 117
donatien 18:7d5242aa7b95 118 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
donatien 18:7d5242aa7b95 119
donatien 18:7d5242aa7b95 120 virtual bool useEndpoint(uint8_t intf_nb, ENDPOINT_TYPE type, ENDPOINT_DIRECTION dir); //Must return true if the endpoint will be used
donatien 18:7d5242aa7b95 121
donatien 18:7d5242aa7b95 122 virtual WAN_DONGLE_TYPE getType();
donatien 18:7d5242aa7b95 123
donatien 18:7d5242aa7b95 124 private:
donatien 18:7d5242aa7b95 125
donatien 18:7d5242aa7b95 126 bool m_hasSwitched;
donatien 18:7d5242aa7b95 127 int m_currentSerialIntf;
donatien 18:7d5242aa7b95 128 int m_endpointsToFetch;
donatien 18:7d5242aa7b95 129 };
donatien 18:7d5242aa7b95 130
donatien 18:7d5242aa7b95 131
donatien 8:0d1ec493842c 132 class VodafoneK3772ZInitializer : public WANDongleInitializer
donatien 8:0d1ec493842c 133 {
donatien 8:0d1ec493842c 134 public:
donatien 8:0d1ec493842c 135 VodafoneK3772ZInitializer(USBHost* pHost);
donatien 8:0d1ec493842c 136
donatien 8:0d1ec493842c 137 virtual uint16_t getMSDVid();
donatien 8:0d1ec493842c 138 virtual uint16_t getMSDPid();
donatien 8:0d1ec493842c 139
donatien 8:0d1ec493842c 140 virtual uint16_t getSerialVid();
donatien 8:0d1ec493842c 141 virtual uint16_t getSerialPid();
donatien 8:0d1ec493842c 142
donatien 8:0d1ec493842c 143 virtual bool switchMode(USBDeviceConnected* pDev);
donatien 8:0d1ec493842c 144
donatien 9:c9e9817c398c 145 virtual USBEndpoint* getEp(USBDeviceConnected* pDev, int serialPortNumber, bool tx);
donatien 8:0d1ec493842c 146
donatien 8:0d1ec493842c 147 virtual int getSerialPortCount();
donatien 8:0d1ec493842c 148
donatien 8:0d1ec493842c 149 virtual void setVidPid(uint16_t vid, uint16_t pid);
donatien 8:0d1ec493842c 150
donatien 8:0d1ec493842c 151 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
donatien 8:0d1ec493842c 152
donatien 8:0d1ec493842c 153 virtual bool useEndpoint(uint8_t intf_nb, ENDPOINT_TYPE type, ENDPOINT_DIRECTION dir); //Must return true if the endpoint will be used
donatien 8:0d1ec493842c 154
donatien 8:0d1ec493842c 155 virtual WAN_DONGLE_TYPE getType();
donatien 8:0d1ec493842c 156
donatien 8:0d1ec493842c 157 private:
donatien 8:0d1ec493842c 158
donatien 8:0d1ec493842c 159 bool m_hasSwitched;
donatien 8:0d1ec493842c 160 int m_currentSerialIntf;
donatien 8:0d1ec493842c 161 int m_endpointsToFetch;
donatien 8:0d1ec493842c 162 };
donatien 8:0d1ec493842c 163
donatien 8:0d1ec493842c 164 #endif