USB Host Library for Sprint Dongles
Fork of USBHostWANDongleSprint by
USB3GModule/WANDongle.h@0:bfed5767d0a5, 2012-09-12 (annotated)
- Committer:
- donatien
- Date:
- Wed Sep 12 08:15:02 2012 +0000
- Revision:
- 0:bfed5767d0a5
Initial Commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
donatien | 0:bfed5767d0a5 | 1 | /* Copyright (c) 2010-2012 mbed.org, MIT License |
donatien | 0:bfed5767d0a5 | 2 | * |
donatien | 0:bfed5767d0a5 | 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software |
donatien | 0:bfed5767d0a5 | 4 | * and associated documentation files (the "Software"), to deal in the Software without |
donatien | 0:bfed5767d0a5 | 5 | * restriction, including without limitation the rights to use, copy, modify, merge, publish, |
donatien | 0:bfed5767d0a5 | 6 | * distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the |
donatien | 0:bfed5767d0a5 | 7 | * Software is furnished to do so, subject to the following conditions: |
donatien | 0:bfed5767d0a5 | 8 | * |
donatien | 0:bfed5767d0a5 | 9 | * The above copyright notice and this permission notice shall be included in all copies or |
donatien | 0:bfed5767d0a5 | 10 | * substantial portions of the Software. |
donatien | 0:bfed5767d0a5 | 11 | * |
donatien | 0:bfed5767d0a5 | 12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING |
donatien | 0:bfed5767d0a5 | 13 | * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
donatien | 0:bfed5767d0a5 | 14 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
donatien | 0:bfed5767d0a5 | 15 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
donatien | 0:bfed5767d0a5 | 16 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
donatien | 0:bfed5767d0a5 | 17 | */ |
donatien | 0:bfed5767d0a5 | 18 | |
donatien | 0:bfed5767d0a5 | 19 | #ifndef WANDONGLE_H |
donatien | 0:bfed5767d0a5 | 20 | #define WANDONGLE_H |
donatien | 0:bfed5767d0a5 | 21 | |
donatien | 0:bfed5767d0a5 | 22 | #include "USBHost.h" |
donatien | 0:bfed5767d0a5 | 23 | #include "IUSBHostSerial.h" |
donatien | 0:bfed5767d0a5 | 24 | |
donatien | 0:bfed5767d0a5 | 25 | #include "rtos.h" |
donatien | 0:bfed5767d0a5 | 26 | |
donatien | 0:bfed5767d0a5 | 27 | #include "WANDongleSerialPort.h" |
donatien | 0:bfed5767d0a5 | 28 | #include "WANDongleInitializer.h" |
donatien | 0:bfed5767d0a5 | 29 | #include "IUSBEnumerator.h" |
donatien | 0:bfed5767d0a5 | 30 | |
donatien | 0:bfed5767d0a5 | 31 | #define WANDONGLE_MAX_OUTEP_SIZE 64 |
donatien | 0:bfed5767d0a5 | 32 | #define WANDONGLE_MAX_INEP_SIZE 64 |
donatien | 0:bfed5767d0a5 | 33 | |
donatien | 0:bfed5767d0a5 | 34 | #define WANDONGLE_MAX_SERIAL_PORTS 2 |
donatien | 0:bfed5767d0a5 | 35 | |
donatien | 0:bfed5767d0a5 | 36 | /** A class to use a WAN (3G/LTE) access dongle |
donatien | 0:bfed5767d0a5 | 37 | * |
donatien | 0:bfed5767d0a5 | 38 | */ |
donatien | 0:bfed5767d0a5 | 39 | class WANDongle : public IUSBEnumerator { |
donatien | 0:bfed5767d0a5 | 40 | public: |
donatien | 0:bfed5767d0a5 | 41 | /* |
donatien | 0:bfed5767d0a5 | 42 | * Constructor |
donatien | 0:bfed5767d0a5 | 43 | * |
donatien | 0:bfed5767d0a5 | 44 | * @param rootdir mount name |
donatien | 0:bfed5767d0a5 | 45 | */ |
donatien | 0:bfed5767d0a5 | 46 | WANDongle(); |
donatien | 0:bfed5767d0a5 | 47 | |
donatien | 0:bfed5767d0a5 | 48 | /* |
donatien | 0:bfed5767d0a5 | 49 | * Check if a serial port device is connected |
donatien | 0:bfed5767d0a5 | 50 | * |
donatien | 0:bfed5767d0a5 | 51 | * @return true if a serial device is connected |
donatien | 0:bfed5767d0a5 | 52 | */ |
donatien | 0:bfed5767d0a5 | 53 | bool connected(); |
donatien | 0:bfed5767d0a5 | 54 | |
donatien | 0:bfed5767d0a5 | 55 | /* |
donatien | 0:bfed5767d0a5 | 56 | * Try to connect device |
donatien | 0:bfed5767d0a5 | 57 | * |
donatien | 0:bfed5767d0a5 | 58 | * * @return true if connection was successful |
donatien | 0:bfed5767d0a5 | 59 | */ |
donatien | 0:bfed5767d0a5 | 60 | bool tryConnect(); |
donatien | 0:bfed5767d0a5 | 61 | |
donatien | 0:bfed5767d0a5 | 62 | /* |
donatien | 0:bfed5767d0a5 | 63 | * Disconnect device |
donatien | 0:bfed5767d0a5 | 64 | * |
donatien | 0:bfed5767d0a5 | 65 | * * @return true if disconnection was successful |
donatien | 0:bfed5767d0a5 | 66 | */ |
donatien | 0:bfed5767d0a5 | 67 | bool disconnect(); |
donatien | 0:bfed5767d0a5 | 68 | |
donatien | 0:bfed5767d0a5 | 69 | WAN_DONGLE_TYPE getDongleType(); |
donatien | 0:bfed5767d0a5 | 70 | |
donatien | 0:bfed5767d0a5 | 71 | IUSBHostSerial& getSerial(int index); |
donatien | 0:bfed5767d0a5 | 72 | int getSerialCount(); |
donatien | 0:bfed5767d0a5 | 73 | |
donatien | 0:bfed5767d0a5 | 74 | //From IUSBEnumerator |
donatien | 0:bfed5767d0a5 | 75 | |
donatien | 0:bfed5767d0a5 | 76 | virtual void setVidPid(uint16_t vid, uint16_t pid); |
donatien | 0:bfed5767d0a5 | 77 | |
donatien | 0:bfed5767d0a5 | 78 | 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 | 0:bfed5767d0a5 | 79 | |
donatien | 0:bfed5767d0a5 | 80 | virtual bool useEndpoint(uint8_t intf_nb, ENDPOINT_TYPE type, ENDPOINT_DIRECTION dir); //Must return true if the endpoint will be used |
donatien | 0:bfed5767d0a5 | 81 | |
donatien | 0:bfed5767d0a5 | 82 | protected: |
donatien | 0:bfed5767d0a5 | 83 | USBHost * host; |
donatien | 0:bfed5767d0a5 | 84 | USBDeviceConnected * dev; |
donatien | 0:bfed5767d0a5 | 85 | bool dev_connected; |
donatien | 0:bfed5767d0a5 | 86 | |
donatien | 0:bfed5767d0a5 | 87 | WANDongleInitializer* m_pInitializer; |
donatien | 0:bfed5767d0a5 | 88 | |
donatien | 0:bfed5767d0a5 | 89 | void init(); |
donatien | 0:bfed5767d0a5 | 90 | |
donatien | 0:bfed5767d0a5 | 91 | WANDongleSerialPort m_serial[WANDONGLE_MAX_SERIAL_PORTS]; |
donatien | 0:bfed5767d0a5 | 92 | int m_serialCount; |
donatien | 0:bfed5767d0a5 | 93 | }; |
donatien | 0:bfed5767d0a5 | 94 | |
donatien | 0:bfed5767d0a5 | 95 | #endif |