USB Host WAN Dongle library

Fork of USBHostWANDongle_bleedingedge by Donatien Garnier

Committer:
donatien
Date:
Tue Jul 31 10:37:16 2012 +0000
Revision:
9:c9e9817c398c
Parent:
8:0d1ec493842c
Child:
10:08bce4cd973a
Renamed Endpoint->USBEndpoint because it conflicted with the Socket API! Made some weird symbols mixups happen that made everything explode when the first USB endpoint was allocated.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
donatien 8:0d1ec493842c 1 /* Copyright (c) 2010-2011 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 8:0d1ec493842c 34 };
donatien 8:0d1ec493842c 35
donatien 8:0d1ec493842c 36 class WANDongleInitializer : public IUSBEnumerator
donatien 8:0d1ec493842c 37 {
donatien 8:0d1ec493842c 38 protected:
donatien 8:0d1ec493842c 39 WANDongleInitializer(USBHost* pHost);
donatien 8:0d1ec493842c 40 USBHost* m_pHost;
donatien 8:0d1ec493842c 41
donatien 8:0d1ec493842c 42 public:
donatien 8:0d1ec493842c 43 virtual uint16_t getMSDVid() = 0;
donatien 8:0d1ec493842c 44 virtual uint16_t getMSDPid() = 0;
donatien 8:0d1ec493842c 45
donatien 8:0d1ec493842c 46 virtual uint16_t getSerialVid() = 0;
donatien 8:0d1ec493842c 47 virtual uint16_t getSerialPid() = 0;
donatien 8:0d1ec493842c 48
donatien 8:0d1ec493842c 49 virtual bool switchMode(USBDeviceConnected* pDev) = 0;
donatien 8:0d1ec493842c 50
donatien 9:c9e9817c398c 51 virtual USBEndpoint* getEp(USBDeviceConnected* pDev, int serialPortNumber, bool tx) = 0;
donatien 8:0d1ec493842c 52
donatien 8:0d1ec493842c 53 virtual int getSerialPortCount() = 0;
donatien 8:0d1ec493842c 54
donatien 8:0d1ec493842c 55 virtual void setVidPid(uint16_t vid, uint16_t pid) = 0;
donatien 8:0d1ec493842c 56
donatien 8:0d1ec493842c 57 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 58
donatien 8:0d1ec493842c 59 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 60
donatien 8:0d1ec493842c 61 virtual WAN_DONGLE_TYPE getType() = 0;
donatien 8:0d1ec493842c 62
donatien 8:0d1ec493842c 63 static WANDongleInitializer** getInitializers(USBHost* pHost);
donatien 8:0d1ec493842c 64 };
donatien 8:0d1ec493842c 65
donatien 8:0d1ec493842c 66 class VodafoneK3770Initializer : public WANDongleInitializer
donatien 8:0d1ec493842c 67 {
donatien 8:0d1ec493842c 68 public:
donatien 8:0d1ec493842c 69 VodafoneK3770Initializer(USBHost* pHost);
donatien 8:0d1ec493842c 70
donatien 8:0d1ec493842c 71 virtual uint16_t getMSDVid();
donatien 8:0d1ec493842c 72 virtual uint16_t getMSDPid();
donatien 8:0d1ec493842c 73
donatien 8:0d1ec493842c 74 virtual uint16_t getSerialVid();
donatien 8:0d1ec493842c 75 virtual uint16_t getSerialPid();
donatien 8:0d1ec493842c 76
donatien 8:0d1ec493842c 77 virtual bool switchMode(USBDeviceConnected* pDev);
donatien 8:0d1ec493842c 78
donatien 9:c9e9817c398c 79 virtual USBEndpoint* getEp(USBDeviceConnected* pDev, int serialPortNumber, bool tx);
donatien 8:0d1ec493842c 80
donatien 8:0d1ec493842c 81 virtual int getSerialPortCount();
donatien 8:0d1ec493842c 82
donatien 8:0d1ec493842c 83 virtual void setVidPid(uint16_t vid, uint16_t pid);
donatien 8:0d1ec493842c 84
donatien 8:0d1ec493842c 85 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 86
donatien 8:0d1ec493842c 87 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 88
donatien 8:0d1ec493842c 89 virtual WAN_DONGLE_TYPE getType();
donatien 8:0d1ec493842c 90
donatien 8:0d1ec493842c 91 private:
donatien 8:0d1ec493842c 92
donatien 8:0d1ec493842c 93 bool m_hasSwitched;
donatien 8:0d1ec493842c 94 int m_currentSerialIntf;
donatien 8:0d1ec493842c 95 int m_endpointsToFetch;
donatien 8:0d1ec493842c 96 };
donatien 8:0d1ec493842c 97
donatien 8:0d1ec493842c 98 class VodafoneK3772ZInitializer : public WANDongleInitializer
donatien 8:0d1ec493842c 99 {
donatien 8:0d1ec493842c 100 public:
donatien 8:0d1ec493842c 101 VodafoneK3772ZInitializer(USBHost* pHost);
donatien 8:0d1ec493842c 102
donatien 8:0d1ec493842c 103 virtual uint16_t getMSDVid();
donatien 8:0d1ec493842c 104 virtual uint16_t getMSDPid();
donatien 8:0d1ec493842c 105
donatien 8:0d1ec493842c 106 virtual uint16_t getSerialVid();
donatien 8:0d1ec493842c 107 virtual uint16_t getSerialPid();
donatien 8:0d1ec493842c 108
donatien 8:0d1ec493842c 109 virtual bool switchMode(USBDeviceConnected* pDev);
donatien 8:0d1ec493842c 110
donatien 9:c9e9817c398c 111 virtual USBEndpoint* getEp(USBDeviceConnected* pDev, int serialPortNumber, bool tx);
donatien 8:0d1ec493842c 112
donatien 8:0d1ec493842c 113 virtual int getSerialPortCount();
donatien 8:0d1ec493842c 114
donatien 8:0d1ec493842c 115 virtual void setVidPid(uint16_t vid, uint16_t pid);
donatien 8:0d1ec493842c 116
donatien 8:0d1ec493842c 117 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 118
donatien 8:0d1ec493842c 119 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 120
donatien 8:0d1ec493842c 121 virtual WAN_DONGLE_TYPE getType();
donatien 8:0d1ec493842c 122
donatien 8:0d1ec493842c 123 private:
donatien 8:0d1ec493842c 124
donatien 8:0d1ec493842c 125 bool m_hasSwitched;
donatien 8:0d1ec493842c 126 int m_currentSerialIntf;
donatien 8:0d1ec493842c 127 int m_endpointsToFetch;
donatien 8:0d1ec493842c 128 };
donatien 8:0d1ec493842c 129
donatien 8:0d1ec493842c 130 #endif