]> git.gir.st - tmk_keyboard.git/blob - tmk_core/tool/mbed/mbed-sdk/libraries/net/cellular/UbloxUSBModem/UbloxUSBCDMAModem.h
Merge commit 'f6d56675f9f981c5464f0ca7a1fbb0162154e8c5'
[tmk_keyboard.git] / tmk_core / tool / mbed / mbed-sdk / libraries / net / cellular / UbloxUSBModem / UbloxUSBCDMAModem.h
1 /* UbloxUSBCDMAModem.h */
2 /* Copyright (C) 2012 mbed.org, MIT License
3 *
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:
9 *
10 * The above copyright notice and this permission notice shall be included in all copies or
11 * substantial portions of the Software.
12 *
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.
18 */
19
20 #ifndef UBLOXUSBCDMAMODEM_H_
21 #define UBLOXUSBCDMAMODEM_H_
22
23 #include "core/fwk.h"
24
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"
31
32 /** u-blox LISA-C200 modem
33 */
34 class UbloxUSBCDMAModem: public CellularModem
35 {
36 public:
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
40 */
41 UbloxUSBCDMAModem(PinName powerGatingPin = NC, bool powerGatingOnWhenPinHigh = true, int serial = 0);
42
43 //Internet-related functions
44
45 /** Open a 3G internet connection
46 @return 0 on success, error code on failure
47 */
48 virtual int connect(const char* apn = NULL, const char* user = NULL, const char* password = NULL);
49
50 /** Close the internet connection
51 @return 0 on success, error code on failure
52 */
53 virtual int disconnect();
54
55
56 /** Send a SM
57 @param number The receiver's phone number
58 @param message The message to send
59 @return 0 on success, error code on failure
60 */
61 virtual int sendSM(const char* number, const char* message);
62
63
64 /** Receive a SM
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
69 */
70 virtual int getSM(char* number, char* message, size_t maxLength);
71
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
75 */
76 virtual int getSMCount(size_t* pCount);
77
78 /** Get the ATCommandsInterface instance
79 @return Pointer to the ATCommandsInterface instance
80 */
81 virtual ATCommandsInterface* getATCommandsInterface();
82
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
87 */
88 virtual int power(bool enable);
89
90 protected:
91 bool power();
92
93 int init();
94 int cleanup();
95
96 private:
97 WANDongle m_dongle;
98
99 USBSerialStream m_stream;
100
101 ATCommandsInterface m_at;
102
103 CDMASMSInterface m_sms;
104
105 PPPIPInterface m_ppp;
106
107 bool m_dongleConnected;
108 bool m_ipInit;
109 bool m_smsInit;
110 bool m_atOpen;
111
112 PinName m_powerGatingPin;
113 bool m_powerGatingOnWhenPinHigh;
114 };
115
116
117 #endif /* UBLOXUSBCDMAMODEM_H_ */
118
Imprint / Impressum