Simple detection for LE910-NA1 modules

Fork of MTS-Cellular by MultiTech

Committer:
Vanger
Date:
Mon Aug 11 16:27:27 2014 +0000
Revision:
53:1aee5fe47adb
Parent:
52:2cb58398a4f9
Child:
56:43205bd2752a
Updated example code under Cellular.h

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 bind(unsigned int port);
Mike Fiore 1:f155d94d6f3a 81 virtual bool open(const std::string& address, unsigned int port, Mode mode);
Mike Fiore 1:f155d94d6f3a 82 virtual bool isOpen();
Mike Fiore 1:f155d94d6f3a 83 virtual bool close();
Mike Fiore 1:f155d94d6f3a 84 virtual int read(char* data, int max, int timeout = -1);
Mike Fiore 1:f155d94d6f3a 85 virtual int write(const char* data, int length, int timeout = -1);
Mike Fiore 1:f155d94d6f3a 86 virtual unsigned int readable();
Mike Fiore 1:f155d94d6f3a 87 virtual unsigned int writeable();
Mike Fiore 1:f155d94d6f3a 88 virtual bool ping(const std::string& address = "8.8.8.8");
Mike Fiore 1:f155d94d6f3a 89 virtual std::string getDeviceIP();
Mike Fiore 1:f155d94d6f3a 90 virtual bool setDeviceIP(std::string address = "DHCP");
Vanger 26:2b769ed8de4f 91
Vanger 34:7d412c989964 92 /** A method for setting the APN
Vanger 34:7d412c989964 93 *
Vanger 34:7d412c989964 94 * @param apn APN to be passed as a c-string
Vanger 34:7d412c989964 95 * @returns the standard AT Code enumeration
Vanger 34:7d412c989964 96 */
Vanger 26:2b769ed8de4f 97 virtual Code setApn(const std::string& apn);
Mike Fiore 1:f155d94d6f3a 98
Mike Fiore 1:f155d94d6f3a 99 /** A method for configuring command ehco capability on the radio. This command
Mike Fiore 1:f155d94d6f3a 100 * sets whether sent characters are echoed back from the radio, in which case you
Mike Fiore 1:f155d94d6f3a 101 * will receive back every command you send.
Mike Fiore 1:f155d94d6f3a 102 *
Mike Fiore 1:f155d94d6f3a 103 * @param state if true echo will be turned off, otherwise it will be turned on.
Mike Fiore 1:f155d94d6f3a 104 * @returns the standard AT Code enumeration.
Mike Fiore 1:f155d94d6f3a 105 */
Vanger 27:ec44d5a9544f 106 virtual Code echo(bool state);
Mike Fiore 1:f155d94d6f3a 107
Mike Fiore 1:f155d94d6f3a 108 /** This method can be used to trade socket functionality for performance.
Mike Fiore 1:f155d94d6f3a 109 * In order to enable a socket connection to be closed by the client side programtically,
Mike Fiore 1:f155d94d6f3a 110 * this class must process all read and write data on the socket to guard the special
Mike Fiore 1:f155d94d6f3a 111 * escape character used to close an open socket connection. It is recommened that you
Mike Fiore 1:f155d94d6f3a 112 * use the default of true unless the overhead of these operations is too significant.
Vanger 34:7d412c989964 113 * If set to false, socket must be closed using physical pin signals rather than through
Vanger 34:7d412c989964 114 * the use of the ETX data character
Mike Fiore 1:f155d94d6f3a 115 *
Mike Fiore 1:f155d94d6f3a 116 * @param enabled set to true if you want the socket closeable, otherwise false. The default
Mike Fiore 1:f155d94d6f3a 117 * is true.
Mike Fiore 1:f155d94d6f3a 118 * @returns the standard AT Code enumeration.
Mike Fiore 1:f155d94d6f3a 119 */
Vanger 31:529db15abda7 120 virtual Code setSocketCloseable(bool enabled = true); //ETX closes socket (ETX and DLE in payload are escaped with DLE)
Mike Fiore 1:f155d94d6f3a 121 };
Mike Fiore 1:f155d94d6f3a 122
Mike Fiore 1:f155d94d6f3a 123 }
Mike Fiore 1:f155d94d6f3a 124
Mike Fiore 1:f155d94d6f3a 125 #endif