Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of MTS-Cellular by
UIP.h
00001 #ifndef UIP_H 00002 #define UIP_H 00003 00004 #include <string> 00005 #include <vector> 00006 00007 #include "MTSBufferedIO.h" 00008 #include "Cellular.h" 00009 00010 namespace mts 00011 { 00012 00013 /** This is a class for communicating with a Multi-Tech Systems SocketModem iCell. The 00014 * SocketModem iCell is a family of carrier certified embedded cellular radio modules with 00015 * a common hardware footprint and AT command set for built in IP-stack functionality. 00016 * This class supports three main types of cellular radio interactions including: 00017 * configuration and status AT command processing, SMS processing, and TCP Socket 00018 * data connections. It should be noted that the radio can not process commands or 00019 * SMS messages while having an open data connection at the same time. The concurrent 00020 * capability may be added in a future release. This class also inherits from IPStack 00021 * providing a common set of commands for communication devices that have an onboard 00022 * IP Stack. It is also integrated with the standard mbed Sockets package and can therefore 00023 * be used seamlessly with clients and services built on top of this interface already within 00024 * the mbed library. 00025 * 00026 * All of the following examples use the Pin Names for the STMicro Nucleo F401RE board coupled with 00027 * the SocketModem Shield Arduino compatible board. Please chage Pin Names accordingly to 00028 * match your hardware configuration. It also assumes the use of RTS/CTS hardware handshaking 00029 * using GPIOs. To disable this you will need to change settings on the radio module and 00030 * and use the MTSSerial class instead of MTSSerialFlowControl. The default baud rate for the 00031 * cellular radio is 115200 bps. 00032 * 00033 * Example code is found under Cellular.h 00034 */ 00035 00036 class UIP : public Cellular 00037 { 00038 public: 00039 /** This static function is used to create or get a reference to a 00040 * Cellular object. Cellular uses the singleton pattern, which means 00041 * that you can only have one existing at a time. The first time you 00042 * call getInstance this method creates a new uninitialized Cellular 00043 * object and returns it. All future calls to this method will return 00044 * a reference to the instance created during the first call. Note that 00045 * you must call init on the returned instance before mnaking any other 00046 * calls. If using this class's bindings to any of the Socket package 00047 * classes like TCPSocketConnection, you must call this method and the 00048 * init method on the returned object first, before even creating the 00049 * other objects. 00050 * 00051 * @returns a reference to the single Cellular object that has been created. 00052 */ 00053 UIP(Radio type); 00054 00055 /** Destructs a Cellular object and frees all related resources. 00056 */ 00057 ~UIP(); 00058 00059 virtual bool init(MTSBufferedIO* io); 00060 00061 // Cell connection based commands derived from CommInterface.h 00062 /** Initiates a PPP connection between the radio and the cell network */ 00063 virtual bool connect(); 00064 00065 /** Disconnects the PPP connection between the radio and the cell network */ 00066 virtual void disconnect(); 00067 00068 /** Checks if the radio has a PPP connection established with the cell network 00069 * (Can reach the internet essentially) 00070 */ 00071 virtual bool isConnected(); 00072 00073 /** Resets the radio, must first close active socket and PPP connections 00074 * to do so 00075 */ 00076 virtual void reset(); 00077 00078 // TCP and UDP Socket related commands 00079 // For behavior of the following methods refer to IPStack.h documentation 00080 virtual bool open(const std::string& address, unsigned int port, Mode mode); 00081 virtual bool close(bool shutdown); 00082 virtual int read(char* data, int max, int timeout = -1); 00083 virtual int write(const char* data, int length, int timeout = -1); 00084 virtual bool ping(const std::string& address = "8.8.8.8"); 00085 00086 /** A method for setting the APN 00087 * 00088 * @param apn APN to be passed as a c-string 00089 * @returns the standard AT Code enumeration 00090 */ 00091 virtual Code setApn(const std::string& apn); 00092 00093 }; 00094 00095 } 00096 00097 #endif
Generated on Wed Jul 13 2022 08:05:41 by
1.7.2
