USB BARCODE READER

Fork of USBHOST by ST

Committer:
shivanandgowdakr
Date:
Mon Jul 02 12:10:45 2018 +0000
Revision:
7:ccd0ac9ae1c9
Parent:
1:ab240722d7ef
USB BARCODE READER ;

Who changed what in which revision?

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