UbloxCDMAModemInitializer.cpp 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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. #define __DEBUG__ 4
  19. #ifndef __MODULE__
  20. #define __MODULE__ "UbloxCDMAModemInitializer.cpp"
  21. #endif
  22. #include "core/dbg.h"
  23. #include <stdint.h>
  24. #include "UbloxCDMAModemInitializer.h"
  25. UbloxCDMAModemInitializer::UbloxCDMAModemInitializer(USBHost* pHost) : WANDongleInitializer(pHost)
  26. {
  27. }
  28. uint16_t UbloxCDMAModemInitializer::getMSDVid()
  29. {
  30. return 0x05C6;
  31. }
  32. uint16_t UbloxCDMAModemInitializer::getMSDPid()
  33. {
  34. return 0x0000; //No MSD mode (presumably)
  35. }
  36. uint16_t UbloxCDMAModemInitializer::getSerialVid()
  37. {
  38. return 0x05C6;
  39. }
  40. uint16_t UbloxCDMAModemInitializer::getSerialPid()
  41. {
  42. return 0x9004;
  43. }
  44. bool UbloxCDMAModemInitializer::switchMode(USBDeviceConnected* pDev)
  45. {
  46. return true;
  47. }
  48. int UbloxCDMAModemInitializer::getSerialPortCount()
  49. {
  50. return 2;
  51. }
  52. /*virtual*/ void UbloxCDMAModemInitializer::setVidPid(uint16_t vid, uint16_t pid)
  53. {
  54. m_currentSerialIntf = 0;
  55. m_currentEndpoint = 0;
  56. }
  57. /*virtual*/ bool UbloxCDMAModemInitializer::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
  58. {
  59. DBG("Interface #%d; Class:%02x; SubClass:%02x; Protocol:%02x", intf_nb, intf_class, intf_subclass, intf_protocol);
  60. if( intf_class == 0xFF ) {
  61. if( m_currentSerialIntf == 0 || m_currentSerialIntf == 1) {
  62. m_serialIntfMap[m_currentSerialIntf++] = intf_nb;
  63. return true;
  64. }
  65. m_currentSerialIntf++;
  66. }
  67. return false;
  68. }
  69. /*virtual*/ bool UbloxCDMAModemInitializer::useEndpoint(uint8_t intf_nb, ENDPOINT_TYPE type, ENDPOINT_DIRECTION dir) //Must return true if the endpoint will be used
  70. {
  71. DBG("USBEndpoint on Interface #%d; Type:%d; Direction:%d Current %d", intf_nb, type, dir, m_currentEndpoint);
  72. if(type == BULK_ENDPOINT) {
  73. if( intf_nb == 1 || intf_nb == 0) {
  74. m_currentEndpoint++;
  75. return true;
  76. } else {
  77. m_currentEndpoint++;
  78. }
  79. }
  80. /*
  81. if(type == INTERRUPT_ENDPOINT) {
  82. if( intf_nb == 1) {
  83. m_currentEndpoint++;
  84. return true;
  85. } else {
  86. m_currentEndpoint++;
  87. }
  88. }
  89. */
  90. return false;
  91. }
  92. /*virtual*/ int UbloxCDMAModemInitializer::getType()
  93. {
  94. return WAN_DONGLE_TYPE_UBLOX_LISAC200;
  95. }