Simple test for USSD message.
Dependencies: CellularUSBModem
Fork of UbloxUSBModem by
UbloxGSMModemInitializer.cpp@5:60b48a013e86, 2013-12-16 (annotated)
- Committer:
- mbed_official
- Date:
- Mon Dec 16 09:00:36 2013 +0000
- Revision:
- 5:60b48a013e86
- Parent:
- 1:71286b99c1cb
Synchronized with git revision 170ac6562b7b2b5bb43f8ecf82b2af18b37eeb9c
Full URL: https://github.com/mbedmicro/mbed/commit/170ac6562b7b2b5bb43f8ecf82b2af18b37eeb9c/
improve USB host library and cellular modem stack
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
bogdanm | 1:71286b99c1cb | 1 | /* Copyright (c) 2010-2012 mbed.org, MIT License |
bogdanm | 1:71286b99c1cb | 2 | * |
bogdanm | 1:71286b99c1cb | 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software |
bogdanm | 1:71286b99c1cb | 4 | * and associated documentation files (the "Software"), to deal in the Software without |
bogdanm | 1:71286b99c1cb | 5 | * restriction, including without limitation the rights to use, copy, modify, merge, publish, |
bogdanm | 1:71286b99c1cb | 6 | * distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the |
bogdanm | 1:71286b99c1cb | 7 | * Software is furnished to do so, subject to the following conditions: |
bogdanm | 1:71286b99c1cb | 8 | * |
bogdanm | 1:71286b99c1cb | 9 | * The above copyright notice and this permission notice shall be included in all copies or |
bogdanm | 1:71286b99c1cb | 10 | * substantial portions of the Software. |
bogdanm | 1:71286b99c1cb | 11 | * |
bogdanm | 1:71286b99c1cb | 12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING |
bogdanm | 1:71286b99c1cb | 13 | * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
bogdanm | 1:71286b99c1cb | 14 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
bogdanm | 1:71286b99c1cb | 15 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
bogdanm | 1:71286b99c1cb | 16 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
bogdanm | 1:71286b99c1cb | 17 | */ |
bogdanm | 1:71286b99c1cb | 18 | |
bogdanm | 1:71286b99c1cb | 19 | #include "UbloxGSMModemInitializer.h" |
bogdanm | 1:71286b99c1cb | 20 | #include "core/dbg.h" |
bogdanm | 1:71286b99c1cb | 21 | |
bogdanm | 1:71286b99c1cb | 22 | #define __DEBUG__ 0 |
bogdanm | 1:71286b99c1cb | 23 | #ifndef __MODULE__ |
bogdanm | 1:71286b99c1cb | 24 | #define __MODULE__ "UbloxGSMModemInitializer.cpp" |
bogdanm | 1:71286b99c1cb | 25 | #endif |
bogdanm | 1:71286b99c1cb | 26 | |
bogdanm | 1:71286b99c1cb | 27 | //----------------------------------------------------------------------- |
bogdanm | 1:71286b99c1cb | 28 | // mamm, u-blox Modem |
bogdanm | 1:71286b99c1cb | 29 | //----------------------------------------------------------------------- |
bogdanm | 1:71286b99c1cb | 30 | |
bogdanm | 1:71286b99c1cb | 31 | UbloxGSMModemInitializer::UbloxGSMModemInitializer(USBHost* pHost) : WANDongleInitializer(pHost) |
bogdanm | 1:71286b99c1cb | 32 | { |
bogdanm | 1:71286b99c1cb | 33 | |
bogdanm | 1:71286b99c1cb | 34 | } |
bogdanm | 1:71286b99c1cb | 35 | |
bogdanm | 1:71286b99c1cb | 36 | uint16_t UbloxGSMModemInitializer::getMSDVid() { return 0x1546; } |
bogdanm | 1:71286b99c1cb | 37 | uint16_t UbloxGSMModemInitializer::getMSDPid() { return 0x0000; } |
bogdanm | 1:71286b99c1cb | 38 | |
bogdanm | 1:71286b99c1cb | 39 | uint16_t UbloxGSMModemInitializer::getSerialVid() { return 0x1546; } |
bogdanm | 1:71286b99c1cb | 40 | uint16_t UbloxGSMModemInitializer::getSerialPid() { return 0x1102; } |
bogdanm | 1:71286b99c1cb | 41 | |
bogdanm | 1:71286b99c1cb | 42 | bool UbloxGSMModemInitializer::switchMode(USBDeviceConnected* pDev) |
bogdanm | 1:71286b99c1cb | 43 | { |
bogdanm | 1:71286b99c1cb | 44 | for (int i = 0; i < pDev->getNbIntf(); i++) |
bogdanm | 1:71286b99c1cb | 45 | { |
bogdanm | 1:71286b99c1cb | 46 | if (pDev->getInterface(i)->intf_class == MSD_CLASS) |
bogdanm | 1:71286b99c1cb | 47 | { |
bogdanm | 1:71286b99c1cb | 48 | USBEndpoint* pEp = pDev->getEndpoint(i, BULK_ENDPOINT, OUT); |
bogdanm | 1:71286b99c1cb | 49 | if ( pEp != NULL ) |
bogdanm | 1:71286b99c1cb | 50 | { |
bogdanm | 1:71286b99c1cb | 51 | ERR("MSD descriptor found on device %p, intf %d", (void *)pDev, i); |
bogdanm | 1:71286b99c1cb | 52 | } |
bogdanm | 1:71286b99c1cb | 53 | } |
bogdanm | 1:71286b99c1cb | 54 | } |
bogdanm | 1:71286b99c1cb | 55 | return false; |
bogdanm | 1:71286b99c1cb | 56 | } |
bogdanm | 1:71286b99c1cb | 57 | |
bogdanm | 1:71286b99c1cb | 58 | #define UBX_SERIALCOUNT 7 |
bogdanm | 1:71286b99c1cb | 59 | |
bogdanm | 1:71286b99c1cb | 60 | int UbloxGSMModemInitializer::getSerialPortCount() |
bogdanm | 1:71286b99c1cb | 61 | { |
bogdanm | 1:71286b99c1cb | 62 | return UBX_SERIALCOUNT; |
bogdanm | 1:71286b99c1cb | 63 | } |
bogdanm | 1:71286b99c1cb | 64 | |
bogdanm | 1:71286b99c1cb | 65 | /*virtual*/ void UbloxGSMModemInitializer::setVidPid(uint16_t vid, uint16_t pid) |
bogdanm | 1:71286b99c1cb | 66 | { |
bogdanm | 1:71286b99c1cb | 67 | if( (vid == getSerialVid() ) && ( pid == getSerialPid() ) ) |
bogdanm | 1:71286b99c1cb | 68 | { |
bogdanm | 1:71286b99c1cb | 69 | m_hasSwitched = true; |
bogdanm | 1:71286b99c1cb | 70 | m_currentSerialIntf = 0; |
bogdanm | 1:71286b99c1cb | 71 | m_endpointsToFetch = UBX_SERIALCOUNT*2; |
bogdanm | 1:71286b99c1cb | 72 | } |
bogdanm | 1:71286b99c1cb | 73 | else |
bogdanm | 1:71286b99c1cb | 74 | { |
bogdanm | 1:71286b99c1cb | 75 | m_hasSwitched = false; |
bogdanm | 1:71286b99c1cb | 76 | m_endpointsToFetch = 1; |
bogdanm | 1:71286b99c1cb | 77 | } |
bogdanm | 1:71286b99c1cb | 78 | } |
bogdanm | 1:71286b99c1cb | 79 | |
bogdanm | 1:71286b99c1cb | 80 | /*virtual*/ bool UbloxGSMModemInitializer::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 |
bogdanm | 1:71286b99c1cb | 81 | { |
bogdanm | 1:71286b99c1cb | 82 | if( m_hasSwitched ) |
bogdanm | 1:71286b99c1cb | 83 | { |
bogdanm | 1:71286b99c1cb | 84 | DBG("Interface #%d; Class:%02x; SubClass:%02x; Protocol:%02x", intf_nb, intf_class, intf_subclass, intf_protocol); |
bogdanm | 1:71286b99c1cb | 85 | if( intf_class == 0x0A ) |
bogdanm | 1:71286b99c1cb | 86 | { |
bogdanm | 1:71286b99c1cb | 87 | if( (m_currentSerialIntf == 0) || (m_currentSerialIntf == 1) ) |
bogdanm | 1:71286b99c1cb | 88 | { |
bogdanm | 1:71286b99c1cb | 89 | m_serialIntfMap[m_currentSerialIntf++] = intf_nb; |
bogdanm | 1:71286b99c1cb | 90 | return true; |
bogdanm | 1:71286b99c1cb | 91 | } |
bogdanm | 1:71286b99c1cb | 92 | m_currentSerialIntf++; |
bogdanm | 1:71286b99c1cb | 93 | } |
bogdanm | 1:71286b99c1cb | 94 | } |
bogdanm | 1:71286b99c1cb | 95 | else |
bogdanm | 1:71286b99c1cb | 96 | { |
bogdanm | 1:71286b99c1cb | 97 | if( (intf_nb == 0) && (intf_class == MSD_CLASS) ) |
bogdanm | 1:71286b99c1cb | 98 | { |
bogdanm | 1:71286b99c1cb | 99 | return true; |
bogdanm | 1:71286b99c1cb | 100 | } |
bogdanm | 1:71286b99c1cb | 101 | } |
bogdanm | 1:71286b99c1cb | 102 | return false; |
bogdanm | 1:71286b99c1cb | 103 | } |
bogdanm | 1:71286b99c1cb | 104 | |
bogdanm | 1:71286b99c1cb | 105 | /*virtual*/ bool UbloxGSMModemInitializer::useEndpoint(uint8_t intf_nb, ENDPOINT_TYPE type, ENDPOINT_DIRECTION dir) //Must return true if the endpoint will be used |
bogdanm | 1:71286b99c1cb | 106 | { |
bogdanm | 1:71286b99c1cb | 107 | if( m_hasSwitched ) |
bogdanm | 1:71286b99c1cb | 108 | { |
bogdanm | 1:71286b99c1cb | 109 | DBG("USBEndpoint on Interface #%d; Type:%d; Direction:%d", intf_nb, type, dir); |
bogdanm | 1:71286b99c1cb | 110 | if( (type == BULK_ENDPOINT) && m_endpointsToFetch ) |
bogdanm | 1:71286b99c1cb | 111 | { |
bogdanm | 1:71286b99c1cb | 112 | m_endpointsToFetch--; |
bogdanm | 1:71286b99c1cb | 113 | return true; |
bogdanm | 1:71286b99c1cb | 114 | } |
bogdanm | 1:71286b99c1cb | 115 | } |
bogdanm | 1:71286b99c1cb | 116 | else |
bogdanm | 1:71286b99c1cb | 117 | { |
bogdanm | 1:71286b99c1cb | 118 | if( (type == BULK_ENDPOINT) && (dir == OUT) && m_endpointsToFetch ) |
bogdanm | 1:71286b99c1cb | 119 | { |
bogdanm | 1:71286b99c1cb | 120 | m_endpointsToFetch--; |
bogdanm | 1:71286b99c1cb | 121 | return true; |
bogdanm | 1:71286b99c1cb | 122 | } |
bogdanm | 1:71286b99c1cb | 123 | } |
bogdanm | 1:71286b99c1cb | 124 | return false; |
bogdanm | 1:71286b99c1cb | 125 | } |
bogdanm | 1:71286b99c1cb | 126 | |
bogdanm | 1:71286b99c1cb | 127 | /*virtual*/ int UbloxGSMModemInitializer::getType() |
bogdanm | 1:71286b99c1cb | 128 | { |
mbed_official | 5:60b48a013e86 | 129 | return WAN_DONGLE_TYPE_UBLOX_LISAU200; |
bogdanm | 1:71286b99c1cb | 130 | } |
bogdanm | 1:71286b99c1cb | 131 |