Vodafone K3770/K3772-Z modems driver & networking library

Dependencies:   Socket

This library is deprecated. Please use the newest production branch of the library from https://mbed.org/users/mbed_official/code/VodafoneUSBModem/

Committer:
donatien
Date:
Fri Aug 17 15:21:55 2012 +0000
Revision:
0:bd5343539e38
Child:
2:50930edb6eb3
Initial public commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
donatien 0:bd5343539e38 1 /* VodafoneUSBModem.h */
donatien 0:bd5343539e38 2 /* Copyright (C) 2012 mbed.org, MIT License
donatien 0:bd5343539e38 3 *
donatien 0:bd5343539e38 4 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
donatien 0:bd5343539e38 5 * and associated documentation files (the "Software"), to deal in the Software without restriction,
donatien 0:bd5343539e38 6 * including without limitation the rights to use, copy, modify, merge, publish, distribute,
donatien 0:bd5343539e38 7 * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
donatien 0:bd5343539e38 8 * furnished to do so, subject to the following conditions:
donatien 0:bd5343539e38 9 *
donatien 0:bd5343539e38 10 * The above copyright notice and this permission notice shall be included in all copies or
donatien 0:bd5343539e38 11 * substantial portions of the Software.
donatien 0:bd5343539e38 12 *
donatien 0:bd5343539e38 13 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
donatien 0:bd5343539e38 14 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
donatien 0:bd5343539e38 15 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
donatien 0:bd5343539e38 16 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
donatien 0:bd5343539e38 17 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
donatien 0:bd5343539e38 18 */
donatien 0:bd5343539e38 19
donatien 0:bd5343539e38 20 #ifndef VODAFONEUSBMODEM_H_
donatien 0:bd5343539e38 21 #define VODAFONEUSBMODEM_H_
donatien 0:bd5343539e38 22
donatien 0:bd5343539e38 23 #include "core/fwk.h"
donatien 0:bd5343539e38 24
donatien 0:bd5343539e38 25 #include "WANDongle.h"
donatien 0:bd5343539e38 26 #include "at/ATCommandsInterface.h"
donatien 0:bd5343539e38 27 #include "serial/usb/USBSerialStream.h"
donatien 0:bd5343539e38 28 #include "ip/PPPIPInterface.h"
donatien 0:bd5343539e38 29 #include "sms/SMSInterface.h"
donatien 0:bd5343539e38 30 #include "ussd/USSDInterface.h"
donatien 0:bd5343539e38 31 #include "link/LinkMonitor.h"
donatien 0:bd5343539e38 32
donatien 0:bd5343539e38 33 /** Vodafone USB Modem (K3770/K3772-Z) dongle
donatien 0:bd5343539e38 34 */
donatien 0:bd5343539e38 35 class VodafoneUSBModem
donatien 0:bd5343539e38 36 {
donatien 0:bd5343539e38 37 public:
donatien 0:bd5343539e38 38 /** Create Vodafone USB Modem (K3770/K3772-Z) dongle API instance
donatien 0:bd5343539e38 39
donatien 0:bd5343539e38 40 */
donatien 0:bd5343539e38 41 VodafoneUSBModem();
donatien 0:bd5343539e38 42
donatien 0:bd5343539e38 43 //Internet-related functions
donatien 0:bd5343539e38 44
donatien 0:bd5343539e38 45 /** Open a 3G internet connection
donatien 0:bd5343539e38 46 @return 0 on success, error code on failure
donatien 0:bd5343539e38 47 */
donatien 0:bd5343539e38 48 int connect(const char* apn = NULL, const char* user = NULL, const char* password = NULL);
donatien 0:bd5343539e38 49
donatien 0:bd5343539e38 50 /** Close the internet connection
donatien 0:bd5343539e38 51 @return 0 on success, error code on failure
donatien 0:bd5343539e38 52 */
donatien 0:bd5343539e38 53 int disconnect();
donatien 0:bd5343539e38 54
donatien 0:bd5343539e38 55
donatien 0:bd5343539e38 56 /** Send a SM
donatien 0:bd5343539e38 57 @param number The receiver's phone number
donatien 0:bd5343539e38 58 @param message The message to send
donatien 0:bd5343539e38 59 @return 0 on success, error code on failure
donatien 0:bd5343539e38 60 */
donatien 0:bd5343539e38 61 int sendSM(const char* number, const char* message);
donatien 0:bd5343539e38 62
donatien 0:bd5343539e38 63
donatien 0:bd5343539e38 64 /** Receive a SM
donatien 0:bd5343539e38 65 @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)
donatien 0:bd5343539e38 66 @param message Pointer to a buffer to store the the incoming message
donatien 0:bd5343539e38 67 @param maxLength Maximum message length that can be stored in buffer (including null-terminating character)
donatien 0:bd5343539e38 68 @return 0 on success, error code on failure
donatien 0:bd5343539e38 69 */
donatien 0:bd5343539e38 70 int getSM(char* number, char* message, size_t maxLength);
donatien 0:bd5343539e38 71
donatien 0:bd5343539e38 72 /** Get the number of SMs in the incoming box
donatien 0:bd5343539e38 73 @param pCount pointer to store the number of unprocessed SMs on
donatien 0:bd5343539e38 74 @return 0 on success, error code on failure
donatien 0:bd5343539e38 75 */
donatien 0:bd5343539e38 76 int getSMCount(size_t* pCount);
donatien 0:bd5343539e38 77
donatien 0:bd5343539e38 78 /** Send a USSD command & wait for its result
donatien 0:bd5343539e38 79 @param command The command to send
donatien 0:bd5343539e38 80 @param result Buffer in which to store the result
donatien 0:bd5343539e38 81 @param maxLength Maximum result length that can be stored in buffer (including null-terminating character)
donatien 0:bd5343539e38 82 @return 0 on success, error code on failure
donatien 0:bd5343539e38 83 */
donatien 0:bd5343539e38 84 int sendUSSD(const char* command, char* result, size_t maxLength);
donatien 0:bd5343539e38 85
donatien 0:bd5343539e38 86 /** Get link state
donatien 0:bd5343539e38 87 @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
donatien 0:bd5343539e38 88 @param pRegistrationState pointer to store the current registration state
donatien 0:bd5343539e38 89 @param pBearer pointer to store the current bearer
donatien 0:bd5343539e38 90 @return 0 on success, error code on failure
donatien 0:bd5343539e38 91 */
donatien 0:bd5343539e38 92 int getLinkState(int* pRssi, LinkMonitor::REGISTRATION_STATE* pRegistrationState, LinkMonitor::BEARER* pBearer);
donatien 0:bd5343539e38 93
donatien 0:bd5343539e38 94 /** Get the ATCommandsInterface instance
donatien 0:bd5343539e38 95 @return Pointer to the ATCommandsInterface instance
donatien 0:bd5343539e38 96 */
donatien 0:bd5343539e38 97 ATCommandsInterface* getATCommandsInterface();
donatien 0:bd5343539e38 98
donatien 0:bd5343539e38 99 protected:
donatien 0:bd5343539e38 100 int init();
donatien 0:bd5343539e38 101
donatien 0:bd5343539e38 102 private:
donatien 0:bd5343539e38 103 WANDongle m_dongle;
donatien 0:bd5343539e38 104
donatien 0:bd5343539e38 105 USBSerialStream m_atStream;
donatien 0:bd5343539e38 106 USBSerialStream m_pppStream;
donatien 0:bd5343539e38 107
donatien 0:bd5343539e38 108 ATCommandsInterface m_at;
donatien 0:bd5343539e38 109
donatien 0:bd5343539e38 110 SMSInterface m_sms;
donatien 0:bd5343539e38 111 USSDInterface m_ussd;
donatien 0:bd5343539e38 112 LinkMonitor m_linkMonitor;
donatien 0:bd5343539e38 113
donatien 0:bd5343539e38 114 PPPIPInterface m_ppp;
donatien 0:bd5343539e38 115
donatien 0:bd5343539e38 116 bool m_dongleConnected;
donatien 0:bd5343539e38 117 bool m_ipInit;
donatien 0:bd5343539e38 118 bool m_smsInit;
donatien 0:bd5343539e38 119 bool m_ussdInit;
donatien 0:bd5343539e38 120 bool m_linkMonitorInit;
donatien 0:bd5343539e38 121 bool m_atOpen;
donatien 0:bd5343539e38 122 };
donatien 0:bd5343539e38 123
donatien 0:bd5343539e38 124
donatien 0:bd5343539e38 125 #endif /* VODAFONEUSBMODEM_H_ */