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