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