2018.07.26

Dependencies:   FATFileSystem2 mbed-rtos

Fork of USBHost by mbed official

Committer:
sayzyas
Date:
Thu Jul 26 00:19:16 2018 +0000
Revision:
43:78f328f311dc
2018.07.26

Who changed what in which revision?

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