ON Semiconductor / mbed-os

Dependents:   mbed-TFT-example-NCS36510 mbed-Accelerometer-example-NCS36510 mbed-Accelerometer-example-NCS36510

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers CellularModem.h Source File

CellularModem.h

00001 /* CellularModem.h */
00002 /* Copyright (C) 2013 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 CELLULARMODEM_H_
00021 #define CELLULARMODEM_H_
00022 
00023 #include "core/fwk.h"
00024 #include "at/ATCommandsInterface.h"
00025 
00026 class CellularModem
00027 {
00028 public:
00029   //Internet-related functions
00030 
00031   /** Open a 3G internet connection
00032       @return 0 on success, error code on failure
00033   */
00034   virtual int connect(const char* apn = NULL, const char* user = NULL, const char* password = NULL) = 0;
00035 
00036   /** Close the internet connection
00037      @return 0 on success, error code on failure
00038   */
00039   virtual int disconnect() = 0;
00040 
00041 
00042   /** Send a SM
00043      @param number The receiver's phone number
00044      @param message The message to send
00045      @return 0 on success, error code on failure
00046    */
00047   virtual int sendSM(const char* number, const char* message) = 0;
00048 
00049 
00050   /** Receive a SM
00051      @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)
00052      @param message Pointer to a buffer to store the the incoming message
00053      @param maxLength Maximum message length that can be stored in buffer (including null-terminating character)
00054      @return 0 on success, error code on failure
00055    */
00056   virtual int getSM(char* number, char* message, size_t maxLength) = 0;
00057 
00058   /** Get the number of SMs in the incoming box
00059      @param pCount pointer to store the number of unprocessed SMs on
00060      @return 0 on success, error code on failure
00061    */
00062   virtual int getSMCount(size_t* pCount) = 0;
00063 
00064   /** Get the ATCommandsInterface instance
00065     @return Pointer to the ATCommandsInterface instance
00066    */
00067   virtual ATCommandsInterface* getATCommandsInterface() = 0;
00068   
00069   /** Switch power on or off
00070     In order to use this function, a pin name must have been entered in the constructor
00071     @param enable true to switch the dongle on, false to switch it off
00072     @return 0 on success, error code on failure
00073   */
00074   virtual int power(bool enable) = 0;
00075 };
00076 
00077 
00078 #endif /* CELLULARMODEM_H_ */