modified u-blox modem driver

Dependencies:   CellularUSBModem

Fork of UbloxUSBModem by mbed official

Committer:
mbed_official
Date:
Tue Mar 04 10:01:06 2014 +0000
Revision:
10:45f5433cfa96
Parent:
5:60b48a013e86
Synchronized with git revision e4faeb42a7013bfc4d1dccf0a6d905d10aca5c00

Full URL: https://github.com/mbedmicro/mbed/commit/e4faeb42a7013bfc4d1dccf0a6d905d10aca5c00/

Update of cellular modem

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 10:45f5433cfa96 33 class genericAtProcessor : public IATCommandsProcessor
mbed_official 10:45f5433cfa96 34 {
mbed_official 10:45f5433cfa96 35 public:
mbed_official 10:45f5433cfa96 36 genericAtProcessor();
mbed_official 10:45f5433cfa96 37 const char* getResponse(void);
mbed_official 10:45f5433cfa96 38 private:
mbed_official 10:45f5433cfa96 39 virtual int onNewATResponseLine(ATCommandsInterface* pInst, const char* line);
mbed_official 10:45f5433cfa96 40 virtual int onNewEntryPrompt(ATCommandsInterface* pInst);
mbed_official 10:45f5433cfa96 41 protected:
mbed_official 10:45f5433cfa96 42 char str[256];
mbed_official 10:45f5433cfa96 43 int i;
mbed_official 10:45f5433cfa96 44 };
mbed_official 10:45f5433cfa96 45
mbed_official 5:60b48a013e86 46 /** u-blox WCDMA modem (LISA-U200)
mbed_official 5:60b48a013e86 47 */
mbed_official 5:60b48a013e86 48 class UbloxModem: public CellularModem
mbed_official 5:60b48a013e86 49 {
mbed_official 5:60b48a013e86 50 public:
mbed_official 5:60b48a013e86 51 /** Create u-blox API instance
mbed_official 5:60b48a013e86 52 @param powerGatingPin Optional pin commanding a power gating transistor on the modem's power line
mbed_official 5:60b48a013e86 53 @param powerGatingOnWhenPinHigh true if the pin needs to be high to power the dongle, defaults to true
mbed_official 5:60b48a013e86 54 */
mbed_official 5:60b48a013e86 55 UbloxModem(IOStream* atStream, IOStream* pppStream);
mbed_official 5:60b48a013e86 56
mbed_official 5:60b48a013e86 57 //Internet-related functions
mbed_official 5:60b48a013e86 58
mbed_official 5:60b48a013e86 59 /** Open a 3G internet connection
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 connect(const char* apn = NULL, const char* user = NULL, const char* password = NULL);
mbed_official 5:60b48a013e86 63
mbed_official 5:60b48a013e86 64 /** Close the internet connection
mbed_official 5:60b48a013e86 65 @return 0 on success, error code on failure
mbed_official 5:60b48a013e86 66 */
mbed_official 5:60b48a013e86 67 virtual int disconnect();
mbed_official 5:60b48a013e86 68
mbed_official 5:60b48a013e86 69
mbed_official 5:60b48a013e86 70 /** Send a SM
mbed_official 5:60b48a013e86 71 @param number The receiver's phone number
mbed_official 5:60b48a013e86 72 @param message The message to send
mbed_official 5:60b48a013e86 73 @return 0 on success, error code on failure
mbed_official 5:60b48a013e86 74 */
mbed_official 5:60b48a013e86 75 virtual int sendSM(const char* number, const char* message);
mbed_official 5:60b48a013e86 76
mbed_official 5:60b48a013e86 77
mbed_official 5:60b48a013e86 78 /** Receive a SM
mbed_official 5:60b48a013e86 79 @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 80 @param message Pointer to a buffer to store the the incoming message
mbed_official 5:60b48a013e86 81 @param maxLength Maximum message length that can be stored in buffer (including null-terminating character)
mbed_official 5:60b48a013e86 82 @return 0 on success, error code on failure
mbed_official 5:60b48a013e86 83 */
mbed_official 5:60b48a013e86 84 virtual int getSM(char* number, char* message, size_t maxLength);
mbed_official 5:60b48a013e86 85
mbed_official 5:60b48a013e86 86 /** Get the number of SMs in the incoming box
mbed_official 5:60b48a013e86 87 @param pCount pointer to store the number of unprocessed SMs on
mbed_official 5:60b48a013e86 88 @return 0 on success, error code on failure
mbed_official 5:60b48a013e86 89 */
mbed_official 5:60b48a013e86 90 virtual int getSMCount(size_t* pCount);
mbed_official 5:60b48a013e86 91
mbed_official 5:60b48a013e86 92 /** Send a USSD command & wait for its result
mbed_official 5:60b48a013e86 93 @param command The command to send
mbed_official 5:60b48a013e86 94 @param result Buffer in which to store the result
mbed_official 5:60b48a013e86 95 @param maxLength Maximum result length that can be stored in buffer (including null-terminating character)
mbed_official 5:60b48a013e86 96 @return 0 on success, error code on failure
mbed_official 5:60b48a013e86 97 */
mbed_official 5:60b48a013e86 98 int sendUSSD(const char* command, char* result, size_t maxLength);
mbed_official 5:60b48a013e86 99
mbed_official 5:60b48a013e86 100 /** Get link state
mbed_official 5:60b48a013e86 101 @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 102 @param pRegistrationState pointer to store the current registration state
mbed_official 5:60b48a013e86 103 @param pBearer pointer to store the current bearer
mbed_official 5:60b48a013e86 104 @return 0 on success, error code on failure
mbed_official 5:60b48a013e86 105 */
mbed_official 5:60b48a013e86 106 int getLinkState(int* pRssi, LinkMonitor::REGISTRATION_STATE* pRegistrationState, LinkMonitor::BEARER* pBearer);
mbed_official 5:60b48a013e86 107
mbed_official 10:45f5433cfa96 108 int getPhoneNumber(char* phoneNumber);
mbed_official 10:45f5433cfa96 109
mbed_official 5:60b48a013e86 110 /** Get the ATCommandsInterface instance
mbed_official 5:60b48a013e86 111 @return Pointer to the ATCommandsInterface instance
mbed_official 5:60b48a013e86 112 */
mbed_official 5:60b48a013e86 113 virtual ATCommandsInterface* getATCommandsInterface();
mbed_official 5:60b48a013e86 114
mbed_official 5:60b48a013e86 115 protected:
mbed_official 5:60b48a013e86 116 /** Initialise dongle.
mbed_official 5:60b48a013e86 117 * The following actions are performed:
mbed_official 5:60b48a013e86 118 * 1) Start AT interface thread
mbed_official 5:60b48a013e86 119 * 2) Wait for network registration
mbed_official 5:60b48a013e86 120 */
mbed_official 5:60b48a013e86 121 virtual int init();
mbed_official 5:60b48a013e86 122
mbed_official 5:60b48a013e86 123 /** De-initialise dongle.
mbed_official 5:60b48a013e86 124 * The following actions are performed:
mbed_official 5:60b48a013e86 125 * 1) Tear down PPP session
mbed_official 5:60b48a013e86 126 * 2) Set SMS,USSD, and LinkMonitor subsystems to un-initialised
mbed_official 5:60b48a013e86 127 * 3) Close the AT commands interface
mbed_official 5:60b48a013e86 128 */
mbed_official 5:60b48a013e86 129 virtual int cleanup();
mbed_official 5:60b48a013e86 130
mbed_official 5:60b48a013e86 131 private:
mbed_official 5:60b48a013e86 132 ATCommandsInterface m_at; //< Interface to AT commands processing
mbed_official 5:60b48a013e86 133
mbed_official 5:60b48a013e86 134 CDMASMSInterface m_CdmaSms; //< Interface to SMS manager (send/receive etc)
mbed_official 5:60b48a013e86 135 GSMSMSInterface m_GsmSms; //< Interface to SMS manager (send/receive etc)
mbed_official 5:60b48a013e86 136 USSDInterface m_ussd; //< Interface to USSD manager (send etc)
mbed_official 5:60b48a013e86 137 LinkMonitor m_linkMonitor; //< Interface to link monitor (RSSI)
mbed_official 5:60b48a013e86 138
mbed_official 5:60b48a013e86 139 PPPIPInterface m_ppp; //< Interface to PPP conection manager (IP assignment etc)
mbed_official 5:60b48a013e86 140
mbed_official 5:60b48a013e86 141 bool m_ipInit; //< Has PPIPInterface object (m_ppp) been initialised? true/false
mbed_official 5:60b48a013e86 142 bool m_smsInit; //< Has SMSInterface object (m_sms) been initialised? true/false
mbed_official 5:60b48a013e86 143 bool m_ussdInit; //< Has USSDInterface object (m_ussd) been initialised? true/false
mbed_official 5:60b48a013e86 144 bool m_linkMonitorInit; //< Has LinkMonitor object (m_linkMonitor) been initialised? true/false
mbed_official 5:60b48a013e86 145 bool m_atOpen; //< Is the interface to the ATCommandsInterface open? true/false
mbed_official 5:60b48a013e86 146 protected:
mbed_official 5:60b48a013e86 147 bool m_onePort;
mbed_official 10:45f5433cfa96 148 enum { LISA_C200, LISA_U200, SARA_G350, UNKNOWN } m_type;
mbed_official 5:60b48a013e86 149 };
mbed_official 5:60b48a013e86 150
mbed_official 5:60b48a013e86 151 #include "WANDongle.h"
mbed_official 5:60b48a013e86 152 #include "serial/usb/USBSerialStream.h"
mbed_official 5:60b48a013e86 153
mbed_official 5:60b48a013e86 154 class UbloxUSBModem: public UbloxModem
mbed_official 5:60b48a013e86 155 {
mbed_official 5:60b48a013e86 156 public:
mbed_official 5:60b48a013e86 157 UbloxUSBModem();
mbed_official 5:60b48a013e86 158 virtual int init();
mbed_official 5:60b48a013e86 159 virtual int cleanup();
mbed_official 5:60b48a013e86 160 virtual int power(bool enable) { return 1; }
mbed_official 5:60b48a013e86 161
mbed_official 5:60b48a013e86 162 private:
mbed_official 5:60b48a013e86 163 WANDongle m_dongle; //< Interface to USB connected WAN dongle
mbed_official 5:60b48a013e86 164
mbed_official 5:60b48a013e86 165 USBSerialStream m_atStream; //< Serial interface to AT channel on modem
mbed_official 5:60b48a013e86 166 USBSerialStream m_pppStream; //< Serial interface to PPP channel on modem
mbed_official 5:60b48a013e86 167
mbed_official 5:60b48a013e86 168 bool m_dongleConnected; //< Is the dongle physically connected (does the USB stack respond)? true/false
mbed_official 5:60b48a013e86 169 };
mbed_official 5:60b48a013e86 170
mbed_official 5:60b48a013e86 171 #include "serial/io/IOSerialStream.h"
mbed_official 5:60b48a013e86 172
mbed_official 5:60b48a013e86 173 class UbloxSerModem: public UbloxModem
mbed_official 5:60b48a013e86 174 {
mbed_official 5:60b48a013e86 175 public:
mbed_official 5:60b48a013e86 176 UbloxSerModem();
mbed_official 5:60b48a013e86 177 virtual int power(bool enable) { return 1; }
mbed_official 5:60b48a013e86 178 private:
mbed_official 5:60b48a013e86 179 RawSerial m_Serial;
mbed_official 5:60b48a013e86 180 IOSerialStream m_atStream; //< Serial interface to AT channel on modem
mbed_official 5:60b48a013e86 181 };
mbed_official 5:60b48a013e86 182
mbed_official 5:60b48a013e86 183 #endif /* UBLOXMODEM_H_ */