Donatien Garnier / VodafoneUSBModem

Dependencies:   Socket

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers VodafoneUSBModem.h Source File

VodafoneUSBModem.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 VODAFONEUSBMODEM_H_
00021 #define VODAFONEUSBMODEM_H_
00022 
00023 #error 'This library is deprecated. Please use the newest production branch of the library from https://mbed.org/users/mbed_official/code/VodafoneUSBModem/'
00024 
00025 #include "core/fwk.h"
00026 
00027 #include "WANDongle.h"
00028 #include "at/ATCommandsInterface.h"
00029 #include "serial/usb/USBSerialStream.h"
00030 #include "ip/PPPIPInterface.h"
00031 #include "sms/SMSInterface.h"
00032 #include "ussd/USSDInterface.h"
00033 #include "link/LinkMonitor.h"
00034 
00035 /** Vodafone USB Modem (K3770/K3772-Z) dongle
00036  */
00037 class VodafoneUSBModem
00038 {
00039 public:
00040   /** Create Vodafone USB Modem (K3770/K3772-Z) dongle API instance
00041 
00042    */
00043   VodafoneUSBModem();
00044 
00045   //Internet-related functions
00046 
00047   /** Open a 3G internet connection
00048       @return 0 on success, error code on failure
00049   */
00050   int connect(const char* apn = NULL, const char* user = NULL, const char* password = NULL);
00051 
00052   /** Close the internet connection
00053      @return 0 on success, error code on failure
00054   */
00055   int disconnect();
00056 
00057 
00058   /** Send a SM
00059      @param number The receiver's phone number
00060      @param message The message to send
00061      @return 0 on success, error code on failure
00062    */
00063   int sendSM(const char* number, const char* message);
00064 
00065 
00066   /** Receive a SM
00067      @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)
00068      @param message Pointer to a buffer to store the the incoming message
00069      @param maxLength Maximum message length that can be stored in buffer (including null-terminating character)
00070      @return 0 on success, error code on failure
00071    */
00072   int getSM(char* number, char* message, size_t maxLength);
00073 
00074   /** Get the number of SMs in the incoming box
00075      @param pCount pointer to store the number of unprocessed SMs on
00076      @return 0 on success, error code on failure
00077    */
00078   int getSMCount(size_t* pCount);
00079 
00080   /** Send a USSD command & wait for its result
00081     @param command The command to send
00082     @param result Buffer in which to store the result
00083     @param maxLength Maximum result length that can be stored in buffer (including null-terminating character)
00084     @return 0 on success, error code on failure
00085   */
00086   int sendUSSD(const char* command, char* result, size_t maxLength);
00087   
00088   /** Get link state
00089     @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
00090     @param pRegistrationState pointer to store the current registration state
00091     @param pBearer pointer to store the current bearer
00092     @return 0 on success, error code on failure
00093   */
00094   int getLinkState(int* pRssi, LinkMonitor::REGISTRATION_STATE* pRegistrationState, LinkMonitor::BEARER* pBearer);  
00095 
00096   /** Get the ATCommandsInterface instance
00097      @return Pointer to the ATCommandsInterface instance
00098    */
00099   ATCommandsInterface* getATCommandsInterface();
00100 
00101 protected:
00102   int init();
00103 
00104 private:
00105   WANDongle m_dongle;
00106   
00107   USBSerialStream m_atStream;
00108   USBSerialStream m_pppStream;
00109   
00110   ATCommandsInterface m_at;
00111   
00112   SMSInterface m_sms;
00113   USSDInterface m_ussd;
00114   LinkMonitor m_linkMonitor;
00115   
00116   PPPIPInterface m_ppp;
00117 
00118   bool m_dongleConnected;
00119   bool m_ipInit;
00120   bool m_smsInit;
00121   bool m_ussdInit;
00122   bool m_linkMonitorInit;
00123   bool m_atOpen;
00124 };
00125 
00126 
00127 #endif /* VODAFONEUSBMODEM_H_ */