WANDongle.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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. #ifndef WANDONGLE_H
  19. #define WANDONGLE_H
  20. #include "USBHostConf.h"
  21. #ifdef USBHOST_3GMODULE
  22. #include "USBHost.h"
  23. #include "IUSBHostSerial.h"
  24. #include "rtos.h"
  25. #include "WANDongleSerialPort.h"
  26. #include "WANDongleInitializer.h"
  27. #include "IUSBEnumerator.h"
  28. #define WANDONGLE_MAX_OUTEP_SIZE 64
  29. #define WANDONGLE_MAX_INEP_SIZE 64
  30. /** A class to use a WAN (3G/LTE) access dongle
  31. *
  32. */
  33. class WANDongle : public IUSBEnumerator {
  34. public:
  35. /*
  36. * Constructor
  37. *
  38. * @param rootdir mount name
  39. */
  40. WANDongle();
  41. /*
  42. * Destructor
  43. */
  44. virtual ~WANDongle();
  45. /*
  46. * Check if a serial port device is connected
  47. *
  48. * @return true if a serial device is connected
  49. */
  50. bool connected();
  51. /*
  52. * Try to connect device
  53. *
  54. * * @return true if connection was successful
  55. */
  56. bool tryConnect();
  57. /*
  58. * Disconnect device
  59. *
  60. * * @return true if disconnection was successful
  61. */
  62. bool disconnect();
  63. int getDongleType();
  64. IUSBHostSerial& getSerial(int index);
  65. int getSerialCount();
  66. bool addInitializer(WANDongleInitializer* pInitializer);
  67. //From IUSBEnumerator
  68. virtual void setVidPid(uint16_t vid, uint16_t pid);
  69. 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
  70. virtual bool useEndpoint(uint8_t intf_nb, ENDPOINT_TYPE type, ENDPOINT_DIRECTION dir); //Must return true if the endpoint will be used
  71. protected:
  72. USBHost * host;
  73. USBDeviceConnected * dev;
  74. bool dev_connected;
  75. WANDongleInitializer* m_pInitializer;
  76. void init();
  77. WANDongleSerialPort m_serial[WANDONGLE_MAX_SERIAL_PORTS];
  78. int m_serialCount;
  79. int m_totalInitializers;
  80. WANDongleInitializer* m_Initializers[WANDONGLE_MAX_INITIALIZERS];
  81. };
  82. #endif /* USBHOST_3GMODULE */
  83. #endif