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