2018.07.26

Dependencies:   FATFileSystem3 mbed-rtos

Fork of USBHost by mbed official

Committer:
sayzyas
Date:
Thu Jul 26 00:20:32 2018 +0000
Revision:
43:1675750cca08
2018.07.26

Who changed what in which revision?

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