2 /* Copyright (C) 2013 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 CELLULARMODEM_H_
21 #define CELLULARMODEM_H_
24 #include "at/ATCommandsInterface.h"
29 //Internet-related functions
31 /** Open a 3G internet connection
32 @return 0 on success, error code on failure
34 virtual int connect(const char* apn = NULL, const char* user = NULL, const char* password = NULL) = 0;
36 /** Close the internet connection
37 @return 0 on success, error code on failure
39 virtual int disconnect() = 0;
43 @param number The receiver's phone number
44 @param message The message to send
45 @return 0 on success, error code on failure
47 virtual int sendSM(const char* number, const char* message) = 0;
51 @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)
52 @param message Pointer to a buffer to store the the incoming message
53 @param maxLength Maximum message length that can be stored in buffer (including null-terminating character)
54 @return 0 on success, error code on failure
56 virtual int getSM(char* number, char* message, size_t maxLength) = 0;
58 /** Get the number of SMs in the incoming box
59 @param pCount pointer to store the number of unprocessed SMs on
60 @return 0 on success, error code on failure
62 virtual int getSMCount(size_t* pCount) = 0;
64 /** Get the ATCommandsInterface instance
65 @return Pointer to the ATCommandsInterface instance
67 virtual ATCommandsInterface* getATCommandsInterface() = 0;
69 /** Switch power on or off
70 In order to use this function, a pin name must have been entered in the constructor
71 @param enable true to switch the dongle on, false to switch it off
72 @return 0 on success, error code on failure
74 virtual int power(bool enable) = 0;
78 #endif /* CELLULARMODEM_H_ */