u-blox USB modems (GSM and CDMA)

Dependencies:   CellularUSBModem

Dependents:   C027_CANInterfaceComm C027_ModemTransparentUSBCDC_revb UbloxModemHTTPClientTest C027_HTTPClientTest ... more

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers UbloxCDMAModemInitializer.cpp Source File

UbloxCDMAModemInitializer.cpp

00001 /* Copyright (c) 2010-2012 mbed.org, MIT License
00002 *
00003 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
00004 * and associated documentation files (the "Software"), to deal in the Software without
00005 * restriction, including without limitation the rights to use, copy, modify, merge, publish,
00006 * distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
00007 * Software is furnished to do so, subject to the following conditions:
00008 *
00009 * The above copyright notice and this permission notice shall be included in all copies or
00010 * substantial portions of the Software.
00011 *
00012 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
00013 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00014 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
00015 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
00016 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00017 */
00018 
00019 #define __DEBUG__ 4
00020 #ifndef __MODULE__
00021 #define __MODULE__ "UbloxCDMAModemInitializer.cpp"
00022 #endif
00023 
00024 #include "core/dbg.h"
00025 
00026 #include <stdint.h>
00027 
00028 #include "UbloxCDMAModemInitializer.h"
00029 
00030 UbloxCDMAModemInitializer::UbloxCDMAModemInitializer(USBHost* pHost) : WANDongleInitializer(pHost)
00031 {
00032 }
00033 
00034 uint16_t UbloxCDMAModemInitializer::getMSDVid()
00035 {
00036     return 0x05C6;
00037 }
00038 uint16_t UbloxCDMAModemInitializer::getMSDPid()
00039 {
00040     return 0x0000;    //No MSD mode (presumably)
00041 }
00042 
00043 uint16_t UbloxCDMAModemInitializer::getSerialVid()
00044 {
00045     return 0x05C6;
00046 }
00047 uint16_t UbloxCDMAModemInitializer::getSerialPid()
00048 {
00049     return 0x9004;
00050 }
00051 
00052 bool UbloxCDMAModemInitializer::switchMode(USBDeviceConnected* pDev)
00053 {
00054     return true;
00055 }
00056 
00057 int UbloxCDMAModemInitializer::getSerialPortCount()
00058 {
00059     return 2;
00060 }
00061 
00062 /*virtual*/ void UbloxCDMAModemInitializer::setVidPid(uint16_t vid, uint16_t pid)
00063 {
00064     m_currentSerialIntf = 0;
00065     m_currentEndpoint = 0;
00066 }
00067 
00068 /*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
00069 {
00070     DBG("Interface #%d; Class:%02x; SubClass:%02x; Protocol:%02x", intf_nb, intf_class, intf_subclass, intf_protocol);
00071 
00072     if( intf_class == 0xFF ) {
00073         if( m_currentSerialIntf == 0 || m_currentSerialIntf == 1) {
00074             m_serialIntfMap[m_currentSerialIntf++] = intf_nb;
00075             return true;
00076         }
00077         m_currentSerialIntf++;
00078     }
00079 
00080     return false;
00081 }
00082 
00083 /*virtual*/ bool UbloxCDMAModemInitializer::useEndpoint(uint8_t intf_nb, ENDPOINT_TYPE type, ENDPOINT_DIRECTION dir) //Must return true if the endpoint will be used
00084 {
00085     DBG("USBEndpoint on Interface #%d; Type:%d; Direction:%d Current %d", intf_nb, type, dir, m_currentEndpoint);
00086     if(type == BULK_ENDPOINT) {
00087         if( intf_nb == 1 || intf_nb == 0) {
00088             m_currentEndpoint++;
00089             return true;
00090         } else {
00091             m_currentEndpoint++;
00092         }
00093     }
00094 
00095         /*
00096     if(type == INTERRUPT_ENDPOINT) {
00097         if( intf_nb == 1) {
00098             m_currentEndpoint++;
00099             return true;
00100         } else {
00101             m_currentEndpoint++;
00102         }
00103     }
00104         */
00105         
00106     return false;
00107 }
00108 
00109 
00110 /*virtual*/ int UbloxCDMAModemInitializer::getType()
00111 {
00112     return WAN_DONGLE_TYPE_UBLOX_LISAC200;
00113 }
00114