1 /* UbloxUSBCDMAModem.h */
2 /* Copyright (C) 2012 mbed.org, MIT License
4 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
5 * and associated documentation files (the "Software"), to deal in the Software without restriction,
6 * including without limitation the rights to use, copy, modify, merge, publish, distribute,
7 * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
8 * furnished to do so, subject to the following conditions:
10 * The above copyright notice and this permission notice shall be included in all copies or
11 * substantial portions of the Software.
13 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
14 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
15 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
16 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
17 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20 #ifndef UBLOXUSBCDMAMODEM_H_
21 #define UBLOXUSBCDMAMODEM_H_
25 #include "WANDongle.h"
26 #include "at/ATCommandsInterface.h"
27 #include "USBSerialStream.h"
28 #include "ip/PPPIPInterface.h"
29 #include "sms/CDMASMSInterface.h"
30 #include "CellularModem.h"
32 /** u-blox LISA-C200 modem
34 class UbloxUSBCDMAModem: public CellularModem
37 /** Create Sprint USB Modem (Sierra Wireless 598U) API instance
38 @param powerGatingPin Optional pin commanding a power gating transistor on the modem's power line
39 @param powerGatingOnWhenPinHigh true if the pin needs to be high to power the dongle, defaults to true
41 UbloxUSBCDMAModem(PinName powerGatingPin = NC, bool powerGatingOnWhenPinHigh = true, int serial = 0);
43 //Internet-related functions
45 /** Open a 3G internet connection
46 @return 0 on success, error code on failure
48 virtual int connect(const char* apn = NULL, const char* user = NULL, const char* password = NULL);
50 /** Close the internet connection
51 @return 0 on success, error code on failure
53 virtual int disconnect();
57 @param number The receiver's phone number
58 @param message The message to send
59 @return 0 on success, error code on failure
61 virtual int sendSM(const char* number, const char* message);
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)
66 @param message Pointer to a buffer to store the the incoming message
67 @param maxLength Maximum message length that can be stored in buffer (including null-terminating character)
68 @return 0 on success, error code on failure
70 virtual int getSM(char* number, char* message, size_t maxLength);
72 /** Get the number of SMs in the incoming box
73 @param pCount pointer to store the number of unprocessed SMs on
74 @return 0 on success, error code on failure
76 virtual int getSMCount(size_t* pCount);
78 /** Get the ATCommandsInterface instance
79 @return Pointer to the ATCommandsInterface instance
81 virtual ATCommandsInterface* getATCommandsInterface();
83 /** Switch power on or off
84 In order to use this function, a pin name must have been entered in the constructor
85 @param enable true to switch the dongle on, false to switch it off
86 @return 0 on success, error code on failure
88 virtual int power(bool enable);
99 USBSerialStream m_stream;
101 ATCommandsInterface m_at;
103 CDMASMSInterface m_sms;
105 PPPIPInterface m_ppp;
107 bool m_dongleConnected;
112 PinName m_powerGatingPin;
113 bool m_powerGatingOnWhenPinHigh;
117 #endif /* UBLOXUSBCDMAMODEM_H_ */