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