u-blox USB modems (GSM and CDMA)
Dependencies: CellularUSBModem
Dependents: C027_CANInterfaceComm C027_ModemTransparentUSBCDC_revb UbloxModemHTTPClientTest C027_HTTPClientTest ... more
UbloxModem.h
00001 /* VodafoneUSBModem.h */ 00002 /* Copyright (C) 2012 mbed.org, MIT License 00003 * 00004 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 00005 * and associated documentation files (the "Software"), to deal in the Software without restriction, 00006 * including without limitation the rights to use, copy, modify, merge, publish, distribute, 00007 * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 00008 * furnished to do so, subject to the following conditions: 00009 * 00010 * The above copyright notice and this permission notice shall be included in all copies or 00011 * substantial portions of the Software. 00012 * 00013 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING 00014 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 00015 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 00016 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 00017 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 00018 */ 00019 00020 #ifndef UBLOXMODEM_H_ 00021 #define UBLOXMODEM_H_ 00022 00023 #include "core/fwk.h" 00024 00025 #include "at/ATCommandsInterface.h" 00026 #include "ip/PPPIPInterface.h" 00027 #include "sms/GSMSMSInterface.h" 00028 #include "sms/CDMASMSInterface.h" 00029 #include "ussd/USSDInterface.h" 00030 #include "link/LinkMonitor.h" 00031 #include "CellularModem.h" 00032 00033 class genericAtProcessor : public IATCommandsProcessor 00034 { 00035 public: 00036 genericAtProcessor(); 00037 const char* getResponse(void); 00038 private: 00039 virtual int onNewATResponseLine(ATCommandsInterface* pInst, const char* line); 00040 virtual int onNewEntryPrompt(ATCommandsInterface* pInst); 00041 protected: 00042 char str[256]; 00043 int i; 00044 }; 00045 00046 /** u-blox WCDMA modem (LISA-U200) 00047 */ 00048 class UbloxModem: public CellularModem 00049 { 00050 public: 00051 /** Create u-blox API instance 00052 @param powerGatingPin Optional pin commanding a power gating transistor on the modem's power line 00053 @param powerGatingOnWhenPinHigh true if the pin needs to be high to power the dongle, defaults to true 00054 */ 00055 UbloxModem(IOStream* atStream, IOStream* pppStream); 00056 00057 //Internet-related functions 00058 00059 /** Open a 3G internet connection 00060 @return 0 on success, error code on failure 00061 */ 00062 virtual int connect(const char* apn = NULL, const char* user = NULL, const char* password = NULL); 00063 00064 /** Close the internet connection 00065 @return 0 on success, error code on failure 00066 */ 00067 virtual int disconnect(); 00068 00069 00070 /** Send a SM 00071 @param number The receiver's phone number 00072 @param message The message to send 00073 @return 0 on success, error code on failure 00074 */ 00075 virtual int sendSM(const char* number, const char* message); 00076 00077 00078 /** Receive a SM 00079 @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) 00080 @param message Pointer to a buffer to store the the incoming message 00081 @param maxLength Maximum message length that can be stored in buffer (including null-terminating character) 00082 @return 0 on success, error code on failure 00083 */ 00084 virtual int getSM(char* number, char* message, size_t maxLength); 00085 00086 /** Get the number of SMs in the incoming box 00087 @param pCount pointer to store the number of unprocessed SMs on 00088 @return 0 on success, error code on failure 00089 */ 00090 virtual int getSMCount(size_t* pCount); 00091 00092 /** Send a USSD command & wait for its result 00093 @param command The command to send 00094 @param result Buffer in which to store the result 00095 @param maxLength Maximum result length that can be stored in buffer (including null-terminating character) 00096 @return 0 on success, error code on failure 00097 */ 00098 int sendUSSD(const char* command, char* result, size_t maxLength); 00099 00100 /** Get link state 00101 @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 00102 @param pRegistrationState pointer to store the current registration state 00103 @param pBearer pointer to store the current bearer 00104 @return 0 on success, error code on failure 00105 */ 00106 int getLinkState(int* pRssi, LinkMonitor::REGISTRATION_STATE* pRegistrationState, LinkMonitor::BEARER* pBearer); 00107 00108 int getPhoneNumber(char* phoneNumber); 00109 00110 /** Get the ATCommandsInterface instance 00111 @return Pointer to the ATCommandsInterface instance 00112 */ 00113 virtual ATCommandsInterface* getATCommandsInterface(); 00114 00115 protected: 00116 /** Initialise dongle. 00117 * The following actions are performed: 00118 * 1) Start AT interface thread 00119 * 2) Wait for network registration 00120 */ 00121 virtual int init(); 00122 00123 /** De-initialise dongle. 00124 * The following actions are performed: 00125 * 1) Tear down PPP session 00126 * 2) Set SMS,USSD, and LinkMonitor subsystems to un-initialised 00127 * 3) Close the AT commands interface 00128 */ 00129 virtual int cleanup(); 00130 00131 private: 00132 ATCommandsInterface m_at; //< Interface to AT commands processing 00133 00134 CDMASMSInterface m_CdmaSms; //< Interface to SMS manager (send/receive etc) 00135 GSMSMSInterface m_GsmSms; //< Interface to SMS manager (send/receive etc) 00136 USSDInterface m_ussd; //< Interface to USSD manager (send etc) 00137 LinkMonitor m_linkMonitor; //< Interface to link monitor (RSSI) 00138 00139 PPPIPInterface m_ppp; //< Interface to PPP conection manager (IP assignment etc) 00140 00141 bool m_ipInit; //< Has PPIPInterface object (m_ppp) been initialised? true/false 00142 bool m_smsInit; //< Has SMSInterface object (m_sms) been initialised? true/false 00143 bool m_ussdInit; //< Has USSDInterface object (m_ussd) been initialised? true/false 00144 bool m_linkMonitorInit; //< Has LinkMonitor object (m_linkMonitor) been initialised? true/false 00145 bool m_atOpen; //< Is the interface to the ATCommandsInterface open? true/false 00146 protected: 00147 bool m_onePort; 00148 enum { LISA_C200, LISA_U200, SARA_G350, UNKNOWN } m_type; 00149 }; 00150 00151 #include "WANDongle.h" 00152 #include "serial/usb/USBSerialStream.h" 00153 00154 class UbloxUSBModem: public UbloxModem 00155 { 00156 public: 00157 UbloxUSBModem(); 00158 virtual int init(); 00159 virtual int cleanup(); 00160 virtual int power(bool enable) { return 1; } 00161 00162 private: 00163 WANDongle m_dongle; //< Interface to USB connected WAN dongle 00164 00165 USBSerialStream m_atStream; //< Serial interface to AT channel on modem 00166 USBSerialStream m_pppStream; //< Serial interface to PPP channel on modem 00167 00168 bool m_dongleConnected; //< Is the dongle physically connected (does the USB stack respond)? true/false 00169 }; 00170 00171 #include "serial/io/IOSerialStream.h" 00172 00173 class UbloxSerModem: public UbloxModem 00174 { 00175 public: 00176 UbloxSerModem(); 00177 virtual int power(bool enable) { return 1; } 00178 private: 00179 RawSerial m_Serial; 00180 IOSerialStream m_atStream; //< Serial interface to AT channel on modem 00181 }; 00182 00183 #endif /* UBLOXMODEM_H_ */
Generated on Tue Jul 12 2022 19:17:01 by 1.7.2