Dependents:   TimeZoneDemo EthernetJackTestCode MMEx_Challenge ntp_mem ... more

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers UMTSStick.h Source File

UMTSStick.h

Go to the documentation of this file.
00001 
00002 /*
00003 Copyright (c) 2010 Donatien Garnier (donatiengar [at] gmail [dot] com)
00004  
00005 Permission is hereby granted, free of charge, to any person obtaining a copy
00006 of this software and associated documentation files (the "Software"), to deal
00007 in the Software without restriction, including without limitation the rights
00008 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
00009 copies of the Software, and to permit persons to whom the Software is
00010 furnished to do so, subject to the following conditions:
00011  
00012 The above copyright notice and this permission notice shall be included in
00013 all copies or substantial portions of the Software.
00014  
00015 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00016 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00017 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
00018 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00019 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
00020 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
00021 THE SOFTWARE.
00022 */
00023 
00024 /** \file
00025 UMTS Stick driver header file
00026 */
00027 
00028 #ifndef UMTS_STICK_H
00029 #define UMTS_STICK_H
00030 
00031 #include "mbed.h"
00032 
00033 #include "drv/usb/UsbHostMgr.h"
00034 #include "drv/usb/UsbDevice.h"
00035 #include "drv/usb/UsbEndpoint.h"
00036 
00037 #include "drv/serial/usb/UsbSerial.h"
00038 
00039 #define UMTS_SWITCHING_COUNT 2
00040 
00041 typedef unsigned char byte;
00042 
00043 struct UMTSSwitchingInfo
00044 {
00045   uint16_t cdfsVid;
00046   uint16_t cdfsPid;
00047   uint16_t serialVid;
00048   uint16_t serialPidList[16];
00049   byte targetClass;
00050   bool huaweiPacket;
00051   byte cdfsPacket[31];
00052 };
00053 
00054 extern const UMTSSwitchingInfo UMTSwitchingTable[UMTS_SWITCHING_COUNT];
00055 
00056 ///UMTS Stick error codes
00057 enum UMTSStickErr
00058 {
00059   __UMTSERR_MIN = -0xFFFF,
00060   UMTSERR_NOTFOUND, ///<Stick was not found
00061   UMTSERR_NOTIMPLEMENTED, ///<This model is not implemented
00062   UMTSERR_USBERR, ///<USB Error
00063   UMTSERR_DISCONNECTED, ///<Stick disconnected
00064   UMTSERR_OK = 0 ///<Success
00065 };
00066 
00067 class UMTSStick
00068 {
00069 public:
00070   UMTSStick();
00071   ~UMTSStick();
00072   
00073   UMTSStickErr getSerial(UsbSerial** ppUsbSerial);
00074   
00075 private:
00076   UMTSStickErr waitForDevice();
00077   UMTSStickErr checkDeviceState(const UMTSSwitchingInfo* pInfo, bool* pCdfs);
00078 
00079   UMTSStickErr switchMode(const UMTSSwitchingInfo* pInfo);
00080   UMTSStickErr findSerial(UsbSerial** ppUsbSerial);
00081   
00082   
00083   UsbHostMgr m_host;
00084   UsbDevice* m_pDev;
00085 };
00086 
00087 #endif