USB Host WAN Dongle library

Fork of USBHostWANDongle_bleedingedge by Donatien Garnier

Committer:
donatien
Date:
Fri Jul 27 16:14:07 2012 +0000
Revision:
6:075e36a3463e
Parent:
3:4394986752db
Child:
8:0d1ec493842c
New enumeration model to only instantiate needed endpoints

Who changed what in which revision?

UserRevisionLine numberNew contents of line
donatien 2:a8b2d0cd9bbd 1 /* Copyright (c) 2010-2011 mbed.org, MIT License
donatien 2:a8b2d0cd9bbd 2 *
donatien 2:a8b2d0cd9bbd 3 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
donatien 2:a8b2d0cd9bbd 4 * and associated documentation files (the "Software"), to deal in the Software without
donatien 2:a8b2d0cd9bbd 5 * restriction, including without limitation the rights to use, copy, modify, merge, publish,
donatien 2:a8b2d0cd9bbd 6 * distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
donatien 2:a8b2d0cd9bbd 7 * Software is furnished to do so, subject to the following conditions:
donatien 2:a8b2d0cd9bbd 8 *
donatien 2:a8b2d0cd9bbd 9 * The above copyright notice and this permission notice shall be included in all copies or
donatien 2:a8b2d0cd9bbd 10 * substantial portions of the Software.
donatien 2:a8b2d0cd9bbd 11 *
donatien 2:a8b2d0cd9bbd 12 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
donatien 2:a8b2d0cd9bbd 13 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
donatien 2:a8b2d0cd9bbd 14 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
donatien 2:a8b2d0cd9bbd 15 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
donatien 2:a8b2d0cd9bbd 16 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
donatien 2:a8b2d0cd9bbd 17 */
donatien 2:a8b2d0cd9bbd 18
donatien 2:a8b2d0cd9bbd 19 #ifndef WANDONGLEINITIALIZER_H
donatien 2:a8b2d0cd9bbd 20 #define WANDONGLEINITIALIZER_H
donatien 2:a8b2d0cd9bbd 21
donatien 2:a8b2d0cd9bbd 22 #include <cstdint>
donatien 2:a8b2d0cd9bbd 23 using std::uint16_t;
donatien 2:a8b2d0cd9bbd 24 using std::uint32_t;
donatien 2:a8b2d0cd9bbd 25
donatien 2:a8b2d0cd9bbd 26 #include "USBHost.h"
donatien 6:075e36a3463e 27 #include "IUSBEnumerator.h"
donatien 2:a8b2d0cd9bbd 28
donatien 6:075e36a3463e 29 class WANDongleInitializer : public IUSBEnumerator
donatien 2:a8b2d0cd9bbd 30 {
donatien 2:a8b2d0cd9bbd 31 protected:
donatien 2:a8b2d0cd9bbd 32 WANDongleInitializer(USBHost* pHost);
donatien 2:a8b2d0cd9bbd 33 USBHost* m_pHost;
donatien 2:a8b2d0cd9bbd 34
donatien 2:a8b2d0cd9bbd 35 public:
donatien 2:a8b2d0cd9bbd 36 virtual uint16_t getMSDVid() = 0;
donatien 2:a8b2d0cd9bbd 37 virtual uint16_t getMSDPid() = 0;
donatien 2:a8b2d0cd9bbd 38
donatien 2:a8b2d0cd9bbd 39 virtual uint16_t getSerialVid() = 0;
donatien 2:a8b2d0cd9bbd 40 virtual uint16_t getSerialPid() = 0;
donatien 2:a8b2d0cd9bbd 41
donatien 2:a8b2d0cd9bbd 42 virtual bool switchMode(USBDeviceConnected* pDev) = 0;
donatien 2:a8b2d0cd9bbd 43
donatien 2:a8b2d0cd9bbd 44 virtual Endpoint* getEp(USBDeviceConnected* pDev, int serialPortNumber, bool tx) = 0;
donatien 2:a8b2d0cd9bbd 45
donatien 2:a8b2d0cd9bbd 46 virtual int getSerialPortCount() = 0;
donatien 2:a8b2d0cd9bbd 47
donatien 6:075e36a3463e 48 virtual void setVidPid(uint16_t vid, uint16_t pid) = 0;
donatien 6:075e36a3463e 49
donatien 6:075e36a3463e 50 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 6:075e36a3463e 51
donatien 6:075e36a3463e 52 virtual bool useEndpoint(uint8_t intf_nb, ENDPOINT_TYPE type, ENDPOINT_DIRECTION dir) = 0; //Must return true if the endpoint will be used
donatien 6:075e36a3463e 53
donatien 3:4394986752db 54 static WANDongleInitializer** getInitializers(USBHost* pHost);
donatien 2:a8b2d0cd9bbd 55 };
donatien 2:a8b2d0cd9bbd 56
donatien 2:a8b2d0cd9bbd 57 class VodafoneK3770Initializer : public WANDongleInitializer
donatien 2:a8b2d0cd9bbd 58 {
donatien 2:a8b2d0cd9bbd 59 public:
donatien 3:4394986752db 60 VodafoneK3770Initializer(USBHost* pHost);
donatien 2:a8b2d0cd9bbd 61
donatien 2:a8b2d0cd9bbd 62 virtual uint16_t getMSDVid();
donatien 2:a8b2d0cd9bbd 63 virtual uint16_t getMSDPid();
donatien 2:a8b2d0cd9bbd 64
donatien 2:a8b2d0cd9bbd 65 virtual uint16_t getSerialVid();
donatien 2:a8b2d0cd9bbd 66 virtual uint16_t getSerialPid();
donatien 2:a8b2d0cd9bbd 67
donatien 2:a8b2d0cd9bbd 68 virtual bool switchMode(USBDeviceConnected* pDev);
donatien 2:a8b2d0cd9bbd 69
donatien 2:a8b2d0cd9bbd 70 virtual Endpoint* getEp(USBDeviceConnected* pDev, int serialPortNumber, bool tx);
donatien 2:a8b2d0cd9bbd 71
donatien 3:4394986752db 72 virtual int getSerialPortCount();
donatien 6:075e36a3463e 73
donatien 6:075e36a3463e 74 virtual void setVidPid(uint16_t vid, uint16_t pid);
donatien 6:075e36a3463e 75
donatien 6:075e36a3463e 76 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 6:075e36a3463e 77
donatien 6:075e36a3463e 78 virtual bool useEndpoint(uint8_t intf_nb, ENDPOINT_TYPE type, ENDPOINT_DIRECTION dir); //Must return true if the endpoint will be used
donatien 6:075e36a3463e 79
donatien 6:075e36a3463e 80 private:
donatien 6:075e36a3463e 81
donatien 6:075e36a3463e 82 bool m_hasSwitched;
donatien 6:075e36a3463e 83 int m_currentSerialIntf;
donatien 6:075e36a3463e 84 int m_endpointsToFetch;
donatien 2:a8b2d0cd9bbd 85 };
donatien 2:a8b2d0cd9bbd 86
donatien 2:a8b2d0cd9bbd 87 #endif