u-blox USB modems (GSM and CDMA)

Dependencies:   CellularUSBModem

Dependents:   C027_CANInterfaceComm C027_ModemTransparentUSBCDC_revb UbloxModemHTTPClientTest C027_HTTPClientTest ... more

Legacy Networking Libray

This is an mbed 2 networking library. For an mbed OS 5 compatible library, please see:

Import libraryC027Interface

Socket interface for C027Interface. Implements the NetworkSocketAPI

Committer:
mbed_official
Date:
Mon Dec 16 09:00:36 2013 +0000
Revision:
5:60b48a013e86
Child:
8:45f5433cfa96
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?

UserRevisionLine numberNew contents of line
mbed_official 5:60b48a013e86 1 /* VodafoneUSBModem.h */
mbed_official 5:60b48a013e86 2 /* Copyright (C) 2012 mbed.org, MIT License
mbed_official 5:60b48a013e86 3 *
mbed_official 5:60b48a013e86 4 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
mbed_official 5:60b48a013e86 5 * and associated documentation files (the "Software"), to deal in the Software without restriction,
mbed_official 5:60b48a013e86 6 * including without limitation the rights to use, copy, modify, merge, publish, distribute,
mbed_official 5:60b48a013e86 7 * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
mbed_official 5:60b48a013e86 8 * furnished to do so, subject to the following conditions:
mbed_official 5:60b48a013e86 9 *
mbed_official 5:60b48a013e86 10 * The above copyright notice and this permission notice shall be included in all copies or
mbed_official 5:60b48a013e86 11 * substantial portions of the Software.
mbed_official 5:60b48a013e86 12 *
mbed_official 5:60b48a013e86 13 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
mbed_official 5:60b48a013e86 14 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
mbed_official 5:60b48a013e86 15 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
mbed_official 5:60b48a013e86 16 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
mbed_official 5:60b48a013e86 17 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
mbed_official 5:60b48a013e86 18 */
mbed_official 5:60b48a013e86 19
mbed_official 5:60b48a013e86 20 #ifndef UBLOXMODEM_H_
mbed_official 5:60b48a013e86 21 #define UBLOXMODEM_H_
mbed_official 5:60b48a013e86 22
mbed_official 5:60b48a013e86 23 #include "core/fwk.h"
mbed_official 5:60b48a013e86 24
mbed_official 5:60b48a013e86 25 #include "at/ATCommandsInterface.h"
mbed_official 5:60b48a013e86 26 #include "ip/PPPIPInterface.h"
mbed_official 5:60b48a013e86 27 #include "sms/GSMSMSInterface.h"
mbed_official 5:60b48a013e86 28 #include "sms/CDMASMSInterface.h"
mbed_official 5:60b48a013e86 29 #include "ussd/USSDInterface.h"
mbed_official 5:60b48a013e86 30 #include "link/LinkMonitor.h"
mbed_official 5:60b48a013e86 31 #include "CellularModem.h"
mbed_official 5:60b48a013e86 32
mbed_official 5:60b48a013e86 33 /** u-blox WCDMA modem (LISA-U200)
mbed_official 5:60b48a013e86 34 */
mbed_official 5:60b48a013e86 35 class UbloxModem: public CellularModem
mbed_official 5:60b48a013e86 36 {
mbed_official 5:60b48a013e86 37 public:
mbed_official 5:60b48a013e86 38 /** Create u-blox API instance
mbed_official 5:60b48a013e86 39 @param powerGatingPin Optional pin commanding a power gating transistor on the modem's power line
mbed_official 5:60b48a013e86 40 @param powerGatingOnWhenPinHigh true if the pin needs to be high to power the dongle, defaults to true
mbed_official 5:60b48a013e86 41 */
mbed_official 5:60b48a013e86 42 UbloxModem(IOStream* atStream, IOStream* pppStream);
mbed_official 5:60b48a013e86 43
mbed_official 5:60b48a013e86 44 //Internet-related functions
mbed_official 5:60b48a013e86 45
mbed_official 5:60b48a013e86 46 /** Open a 3G internet connection
mbed_official 5:60b48a013e86 47 @return 0 on success, error code on failure
mbed_official 5:60b48a013e86 48 */
mbed_official 5:60b48a013e86 49 virtual int connect(const char* apn = NULL, const char* user = NULL, const char* password = NULL);
mbed_official 5:60b48a013e86 50
mbed_official 5:60b48a013e86 51 /** Close the internet connection
mbed_official 5:60b48a013e86 52 @return 0 on success, error code on failure
mbed_official 5:60b48a013e86 53 */
mbed_official 5:60b48a013e86 54 virtual int disconnect();
mbed_official 5:60b48a013e86 55
mbed_official 5:60b48a013e86 56
mbed_official 5:60b48a013e86 57 /** Send a SM
mbed_official 5:60b48a013e86 58 @param number The receiver's phone number
mbed_official 5:60b48a013e86 59 @param message The message to send
mbed_official 5:60b48a013e86 60 @return 0 on success, error code on failure
mbed_official 5:60b48a013e86 61 */
mbed_official 5:60b48a013e86 62 virtual int sendSM(const char* number, const char* message);
mbed_official 5:60b48a013e86 63
mbed_official 5:60b48a013e86 64
mbed_official 5:60b48a013e86 65 /** Receive a SM
mbed_official 5:60b48a013e86 66 @param number Pointer to a buffer to store the sender's phone number (must be at least 17 characters-long, including the sapce for the null-terminating char)
mbed_official 5:60b48a013e86 67 @param message Pointer to a buffer to store the the incoming message
mbed_official 5:60b48a013e86 68 @param maxLength Maximum message length that can be stored in buffer (including null-terminating character)
mbed_official 5:60b48a013e86 69 @return 0 on success, error code on failure
mbed_official 5:60b48a013e86 70 */
mbed_official 5:60b48a013e86 71 virtual int getSM(char* number, char* message, size_t maxLength);
mbed_official 5:60b48a013e86 72
mbed_official 5:60b48a013e86 73 /** Get the number of SMs in the incoming box
mbed_official 5:60b48a013e86 74 @param pCount pointer to store the number of unprocessed SMs on
mbed_official 5:60b48a013e86 75 @return 0 on success, error code on failure
mbed_official 5:60b48a013e86 76 */
mbed_official 5:60b48a013e86 77 virtual int getSMCount(size_t* pCount);
mbed_official 5:60b48a013e86 78
mbed_official 5:60b48a013e86 79 /** Send a USSD command & wait for its result
mbed_official 5:60b48a013e86 80 @param command The command to send
mbed_official 5:60b48a013e86 81 @param result Buffer in which to store the result
mbed_official 5:60b48a013e86 82 @param maxLength Maximum result length that can be stored in buffer (including null-terminating character)
mbed_official 5:60b48a013e86 83 @return 0 on success, error code on failure
mbed_official 5:60b48a013e86 84 */
mbed_official 5:60b48a013e86 85 int sendUSSD(const char* command, char* result, size_t maxLength);
mbed_official 5:60b48a013e86 86
mbed_official 5:60b48a013e86 87 /** Get link state
mbed_official 5:60b48a013e86 88 @param pRssi pointer to store the current RSSI in dBm, between -51 dBm and -113 dBm if known; -51 dBm means -51 dBm or more; -113 dBm means -113 dBm or less; 0 if unknown
mbed_official 5:60b48a013e86 89 @param pRegistrationState pointer to store the current registration state
mbed_official 5:60b48a013e86 90 @param pBearer pointer to store the current bearer
mbed_official 5:60b48a013e86 91 @return 0 on success, error code on failure
mbed_official 5:60b48a013e86 92 */
mbed_official 5:60b48a013e86 93 int getLinkState(int* pRssi, LinkMonitor::REGISTRATION_STATE* pRegistrationState, LinkMonitor::BEARER* pBearer);
mbed_official 5:60b48a013e86 94
mbed_official 5:60b48a013e86 95 /** Get the ATCommandsInterface instance
mbed_official 5:60b48a013e86 96 @return Pointer to the ATCommandsInterface instance
mbed_official 5:60b48a013e86 97 */
mbed_official 5:60b48a013e86 98 virtual ATCommandsInterface* getATCommandsInterface();
mbed_official 5:60b48a013e86 99
mbed_official 5:60b48a013e86 100 protected:
mbed_official 5:60b48a013e86 101 /** Initialise dongle.
mbed_official 5:60b48a013e86 102 * The following actions are performed:
mbed_official 5:60b48a013e86 103 * 1) Start AT interface thread
mbed_official 5:60b48a013e86 104 * 2) Wait for network registration
mbed_official 5:60b48a013e86 105 */
mbed_official 5:60b48a013e86 106 virtual int init();
mbed_official 5:60b48a013e86 107
mbed_official 5:60b48a013e86 108 /** De-initialise dongle.
mbed_official 5:60b48a013e86 109 * The following actions are performed:
mbed_official 5:60b48a013e86 110 * 1) Tear down PPP session
mbed_official 5:60b48a013e86 111 * 2) Set SMS,USSD, and LinkMonitor subsystems to un-initialised
mbed_official 5:60b48a013e86 112 * 3) Close the AT commands interface
mbed_official 5:60b48a013e86 113 */
mbed_official 5:60b48a013e86 114 virtual int cleanup();
mbed_official 5:60b48a013e86 115
mbed_official 5:60b48a013e86 116 private:
mbed_official 5:60b48a013e86 117 ATCommandsInterface m_at; //< Interface to AT commands processing
mbed_official 5:60b48a013e86 118
mbed_official 5:60b48a013e86 119 CDMASMSInterface m_CdmaSms; //< Interface to SMS manager (send/receive etc)
mbed_official 5:60b48a013e86 120 GSMSMSInterface m_GsmSms; //< Interface to SMS manager (send/receive etc)
mbed_official 5:60b48a013e86 121 USSDInterface m_ussd; //< Interface to USSD manager (send etc)
mbed_official 5:60b48a013e86 122 LinkMonitor m_linkMonitor; //< Interface to link monitor (RSSI)
mbed_official 5:60b48a013e86 123
mbed_official 5:60b48a013e86 124 PPPIPInterface m_ppp; //< Interface to PPP conection manager (IP assignment etc)
mbed_official 5:60b48a013e86 125
mbed_official 5:60b48a013e86 126 bool m_ipInit; //< Has PPIPInterface object (m_ppp) been initialised? true/false
mbed_official 5:60b48a013e86 127 bool m_smsInit; //< Has SMSInterface object (m_sms) been initialised? true/false
mbed_official 5:60b48a013e86 128 bool m_ussdInit; //< Has USSDInterface object (m_ussd) been initialised? true/false
mbed_official 5:60b48a013e86 129 bool m_linkMonitorInit; //< Has LinkMonitor object (m_linkMonitor) been initialised? true/false
mbed_official 5:60b48a013e86 130 bool m_atOpen; //< Is the interface to the ATCommandsInterface open? true/false
mbed_official 5:60b48a013e86 131 protected:
mbed_official 5:60b48a013e86 132 bool m_onePort;
mbed_official 5:60b48a013e86 133 bool m_gsm;
mbed_official 5:60b48a013e86 134 };
mbed_official 5:60b48a013e86 135
mbed_official 5:60b48a013e86 136 #include "WANDongle.h"
mbed_official 5:60b48a013e86 137 #include "serial/usb/USBSerialStream.h"
mbed_official 5:60b48a013e86 138
mbed_official 5:60b48a013e86 139 class UbloxUSBModem: public UbloxModem
mbed_official 5:60b48a013e86 140 {
mbed_official 5:60b48a013e86 141 public:
mbed_official 5:60b48a013e86 142 UbloxUSBModem();
mbed_official 5:60b48a013e86 143 virtual int init();
mbed_official 5:60b48a013e86 144 virtual int cleanup();
mbed_official 5:60b48a013e86 145 virtual int power(bool enable) { return 1; }
mbed_official 5:60b48a013e86 146
mbed_official 5:60b48a013e86 147 private:
mbed_official 5:60b48a013e86 148 WANDongle m_dongle; //< Interface to USB connected WAN dongle
mbed_official 5:60b48a013e86 149
mbed_official 5:60b48a013e86 150 USBSerialStream m_atStream; //< Serial interface to AT channel on modem
mbed_official 5:60b48a013e86 151 USBSerialStream m_pppStream; //< Serial interface to PPP channel on modem
mbed_official 5:60b48a013e86 152
mbed_official 5:60b48a013e86 153 bool m_dongleConnected; //< Is the dongle physically connected (does the USB stack respond)? true/false
mbed_official 5:60b48a013e86 154 };
mbed_official 5:60b48a013e86 155
mbed_official 5:60b48a013e86 156 #include "serial/io/IOSerialStream.h"
mbed_official 5:60b48a013e86 157
mbed_official 5:60b48a013e86 158 class UbloxSerModem: public UbloxModem
mbed_official 5:60b48a013e86 159 {
mbed_official 5:60b48a013e86 160 public:
mbed_official 5:60b48a013e86 161 UbloxSerModem();
mbed_official 5:60b48a013e86 162 virtual int power(bool enable) { return 1; }
mbed_official 5:60b48a013e86 163 private:
mbed_official 5:60b48a013e86 164 RawSerial m_Serial;
mbed_official 5:60b48a013e86 165 IOSerialStream m_atStream; //< Serial interface to AT channel on modem
mbed_official 5:60b48a013e86 166 };
mbed_official 5:60b48a013e86 167
mbed_official 5:60b48a013e86 168 #endif /* UBLOXMODEM_H_ */