Cellular library for MTS Socket Modem Arduino Shield devices from Multi-Tech Systems

Dependents:   mtsas mtsas mtsas mtsas

Committer:
Vanger
Date:
Tue Oct 21 17:26:05 2014 +0000
Revision:
66:8c55e2bf7270
Parent:
56:43205bd2752a
Child:
67:7c705fe2acec
Added a flag for close() calls to support closing the connection without clearing the buffer data.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Mike Fiore 3:04046eebaef5 1 #ifndef UIP_H
Mike Fiore 3:04046eebaef5 2 #define UIP_H
Mike Fiore 1:f155d94d6f3a 3
Mike Fiore 1:f155d94d6f3a 4 #include <string>
Mike Fiore 1:f155d94d6f3a 5 #include <vector>
Mike Fiore 1:f155d94d6f3a 6
Mike Fiore 1:f155d94d6f3a 7 #include "MTSBufferedIO.h"
Mike Fiore 1:f155d94d6f3a 8 #include "Cellular.h"
Mike Fiore 1:f155d94d6f3a 9
Mike Fiore 1:f155d94d6f3a 10 namespace mts
Mike Fiore 1:f155d94d6f3a 11 {
Mike Fiore 1:f155d94d6f3a 12
Mike Fiore 1:f155d94d6f3a 13 /** This is a class for communicating with a Multi-Tech Systems SocketModem iCell. The
Mike Fiore 1:f155d94d6f3a 14 * SocketModem iCell is a family of carrier certified embedded cellular radio modules with
Mike Fiore 1:f155d94d6f3a 15 * a common hardware footprint and AT command set for built in IP-stack functionality.
Mike Fiore 1:f155d94d6f3a 16 * This class supports three main types of cellular radio interactions including:
Mike Fiore 1:f155d94d6f3a 17 * configuration and status AT command processing, SMS processing, and TCP Socket
Mike Fiore 1:f155d94d6f3a 18 * data connections. It should be noted that the radio can not process commands or
Mike Fiore 1:f155d94d6f3a 19 * SMS messages while having an open data connection at the same time. The concurrent
Mike Fiore 1:f155d94d6f3a 20 * capability may be added in a future release. This class also inherits from IPStack
Mike Fiore 1:f155d94d6f3a 21 * providing a common set of commands for communication devices that have an onboard
Mike Fiore 1:f155d94d6f3a 22 * IP Stack. It is also integrated with the standard mbed Sockets package and can therefore
Mike Fiore 1:f155d94d6f3a 23 * be used seamlessly with clients and services built on top of this interface already within
Mike Fiore 1:f155d94d6f3a 24 * the mbed library.
Mike Fiore 1:f155d94d6f3a 25 *
Vanger 46:56ab41157957 26 * All of the following examples use the Pin Names for the STMicro Nucleo F401RE board coupled with
Mike Fiore 1:f155d94d6f3a 27 * the SocketModem Shield Arduino compatible board. Please chage Pin Names accordingly to
Mike Fiore 1:f155d94d6f3a 28 * match your hardware configuration. It also assumes the use of RTS/CTS hardware handshaking
Mike Fiore 1:f155d94d6f3a 29 * using GPIOs. To disable this you will need to change settings on the radio module and
Mike Fiore 1:f155d94d6f3a 30 * and use the MTSSerial class instead of MTSSerialFlowControl. The default baud rate for the
Mike Fiore 1:f155d94d6f3a 31 * cellular radio is 115200 bps.
Vanger 53:1aee5fe47adb 32 *
Vanger 53:1aee5fe47adb 33 * Example code is found under Cellular.h
Mike Fiore 1:f155d94d6f3a 34 */
Mike Fiore 1:f155d94d6f3a 35
Mike Fiore 3:04046eebaef5 36 class UIP : public Cellular
Mike Fiore 1:f155d94d6f3a 37 {
Mike Fiore 1:f155d94d6f3a 38 public:
Mike Fiore 1:f155d94d6f3a 39 /** This static function is used to create or get a reference to a
Mike Fiore 1:f155d94d6f3a 40 * Cellular object. Cellular uses the singleton pattern, which means
Mike Fiore 1:f155d94d6f3a 41 * that you can only have one existing at a time. The first time you
Mike Fiore 1:f155d94d6f3a 42 * call getInstance this method creates a new uninitialized Cellular
Mike Fiore 1:f155d94d6f3a 43 * object and returns it. All future calls to this method will return
Mike Fiore 1:f155d94d6f3a 44 * a reference to the instance created during the first call. Note that
Mike Fiore 1:f155d94d6f3a 45 * you must call init on the returned instance before mnaking any other
Mike Fiore 1:f155d94d6f3a 46 * calls. If using this class's bindings to any of the Socket package
Mike Fiore 1:f155d94d6f3a 47 * classes like TCPSocketConnection, you must call this method and the
Mike Fiore 1:f155d94d6f3a 48 * init method on the returned object first, before even creating the
Mike Fiore 1:f155d94d6f3a 49 * other objects.
Mike Fiore 1:f155d94d6f3a 50 *
Vanger 33:3b6f3904dde0 51 * @returns a reference to the single Cellular object that has been created.
Mike Fiore 1:f155d94d6f3a 52 */
Mike Fiore 11:4e428f689069 53 UIP(Radio type);
Mike Fiore 1:f155d94d6f3a 54
Mike Fiore 1:f155d94d6f3a 55 /** Destructs a Cellular object and frees all related resources.
Mike Fiore 1:f155d94d6f3a 56 */
Mike Fiore 3:04046eebaef5 57 ~UIP();
Mike Fiore 1:f155d94d6f3a 58
Mike Fiore 1:f155d94d6f3a 59 virtual bool init(MTSBufferedIO* io);
Mike Fiore 1:f155d94d6f3a 60
Vanger 34:7d412c989964 61 // Cell connection based commands derived from CommInterface.h
Vanger 34:7d412c989964 62 /** Initiates a PPP connection between the radio and the cell network */
Mike Fiore 1:f155d94d6f3a 63 virtual bool connect();
Vanger 34:7d412c989964 64
Vanger 34:7d412c989964 65 /** Disconnects the PPP connection between the radio and the cell network */
Mike Fiore 1:f155d94d6f3a 66 virtual void disconnect();
Vanger 34:7d412c989964 67
Vanger 34:7d412c989964 68 /** Checks if the radio has a PPP connection established with the cell network
Vanger 34:7d412c989964 69 * (Can reach the internet essentially)
Vanger 34:7d412c989964 70 */
Mike Fiore 1:f155d94d6f3a 71 virtual bool isConnected();
Vanger 34:7d412c989964 72
Vanger 34:7d412c989964 73 /** Resets the radio, must first close active socket and PPP connections
Vanger 34:7d412c989964 74 * to do so
Vanger 34:7d412c989964 75 */
Mike Fiore 1:f155d94d6f3a 76 virtual void reset();
Mike Fiore 1:f155d94d6f3a 77
Mike Fiore 1:f155d94d6f3a 78 // TCP and UDP Socket related commands
Mike Fiore 1:f155d94d6f3a 79 // For behavior of the following methods refer to IPStack.h documentation
Mike Fiore 1:f155d94d6f3a 80 virtual bool open(const std::string& address, unsigned int port, Mode mode);
Vanger 66:8c55e2bf7270 81 virtual bool close(bool clearBufffer);
Mike Fiore 1:f155d94d6f3a 82 virtual int read(char* data, int max, int timeout = -1);
Mike Fiore 1:f155d94d6f3a 83 virtual int write(const char* data, int length, int timeout = -1);
Mike Fiore 1:f155d94d6f3a 84 virtual bool ping(const std::string& address = "8.8.8.8");
Vanger 26:2b769ed8de4f 85
Vanger 34:7d412c989964 86 /** A method for setting the APN
Vanger 34:7d412c989964 87 *
Vanger 34:7d412c989964 88 * @param apn APN to be passed as a c-string
Vanger 34:7d412c989964 89 * @returns the standard AT Code enumeration
Vanger 34:7d412c989964 90 */
Vanger 26:2b769ed8de4f 91 virtual Code setApn(const std::string& apn);
Mike Fiore 1:f155d94d6f3a 92
Mike Fiore 1:f155d94d6f3a 93 };
Mike Fiore 1:f155d94d6f3a 94
Mike Fiore 1:f155d94d6f3a 95 }
Mike Fiore 1:f155d94d6f3a 96
Mike Fiore 1:f155d94d6f3a 97 #endif