Simple detection for LE910-NA1 modules
Fork of MTS-Cellular by
Cellular/UIP.h@11:4e428f689069, 2014-05-22 (annotated)
- Committer:
- Mike Fiore
- Date:
- Thu May 22 09:26:51 2014 -0500
- Revision:
- 11:4e428f689069
- Parent:
- 10:c188cc05aed5
- Child:
- 26:2b769ed8de4f
add CellularFactory to automatically detect and create right type of Cellular class
add static sendCommand function to CellUtils so we can talk to radio before instantiating Cellular
add Cellular::Radio param to UIP constructor
Who changed what in which revision?
User | Revision | Line number | New 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 | * |
Mike Fiore |
1:f155d94d6f3a | 26 | * All of the following examples use the Pin Names for the Freedom KL46Z 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. |
Mike Fiore |
1:f155d94d6f3a | 32 | */ |
Mike Fiore |
1:f155d94d6f3a | 33 | |
Mike Fiore |
3:04046eebaef5 | 34 | class UIP : public Cellular |
Mike Fiore |
1:f155d94d6f3a | 35 | { |
Mike Fiore |
1:f155d94d6f3a | 36 | public: |
Mike Fiore |
1:f155d94d6f3a | 37 | /** This static function is used to create or get a reference to a |
Mike Fiore |
1:f155d94d6f3a | 38 | * Cellular object. Cellular uses the singleton pattern, which means |
Mike Fiore |
1:f155d94d6f3a | 39 | * that you can only have one existing at a time. The first time you |
Mike Fiore |
1:f155d94d6f3a | 40 | * call getInstance this method creates a new uninitialized Cellular |
Mike Fiore |
1:f155d94d6f3a | 41 | * object and returns it. All future calls to this method will return |
Mike Fiore |
1:f155d94d6f3a | 42 | * a reference to the instance created during the first call. Note that |
Mike Fiore |
1:f155d94d6f3a | 43 | * you must call init on the returned instance before mnaking any other |
Mike Fiore |
1:f155d94d6f3a | 44 | * calls. If using this class's bindings to any of the Socket package |
Mike Fiore |
1:f155d94d6f3a | 45 | * classes like TCPSocketConnection, you must call this method and the |
Mike Fiore |
1:f155d94d6f3a | 46 | * init method on the returned object first, before even creating the |
Mike Fiore |
1:f155d94d6f3a | 47 | * other objects. |
Mike Fiore |
1:f155d94d6f3a | 48 | * |
Mike Fiore |
1:f155d94d6f3a | 49 | * @returns a reference to the single Cellular obect that has been created. |
Mike Fiore |
1:f155d94d6f3a | 50 | */ |
Mike Fiore |
11:4e428f689069 | 51 | UIP(Radio type); |
Mike Fiore |
1:f155d94d6f3a | 52 | |
Mike Fiore |
1:f155d94d6f3a | 53 | /** Destructs a Cellular object and frees all related resources. |
Mike Fiore |
1:f155d94d6f3a | 54 | */ |
Mike Fiore |
3:04046eebaef5 | 55 | ~UIP(); |
Mike Fiore |
1:f155d94d6f3a | 56 | |
Mike Fiore |
1:f155d94d6f3a | 57 | virtual bool init(MTSBufferedIO* io); |
Mike Fiore |
1:f155d94d6f3a | 58 | |
Mike Fiore |
1:f155d94d6f3a | 59 | // Wifi connection based commands derived from CommInterface.h |
Mike Fiore |
1:f155d94d6f3a | 60 | virtual bool connect(); |
Mike Fiore |
1:f155d94d6f3a | 61 | virtual void disconnect(); |
Mike Fiore |
1:f155d94d6f3a | 62 | virtual bool isConnected(); |
Mike Fiore |
1:f155d94d6f3a | 63 | virtual void reset(); |
Mike Fiore |
1:f155d94d6f3a | 64 | |
Mike Fiore |
1:f155d94d6f3a | 65 | // TCP and UDP Socket related commands |
Mike Fiore |
1:f155d94d6f3a | 66 | // For behavior of the following methods refer to IPStack.h documentation |
Mike Fiore |
1:f155d94d6f3a | 67 | virtual bool bind(unsigned int port); |
Mike Fiore |
1:f155d94d6f3a | 68 | virtual bool open(const std::string& address, unsigned int port, Mode mode); |
Mike Fiore |
1:f155d94d6f3a | 69 | virtual bool isOpen(); |
Mike Fiore |
1:f155d94d6f3a | 70 | virtual bool close(); |
Mike Fiore |
1:f155d94d6f3a | 71 | virtual int read(char* data, int max, int timeout = -1); |
Mike Fiore |
1:f155d94d6f3a | 72 | virtual int write(const char* data, int length, int timeout = -1); |
Mike Fiore |
1:f155d94d6f3a | 73 | virtual unsigned int readable(); |
Mike Fiore |
1:f155d94d6f3a | 74 | virtual unsigned int writeable(); |
Mike Fiore |
1:f155d94d6f3a | 75 | virtual bool ping(const std::string& address = "8.8.8.8"); |
Mike Fiore |
1:f155d94d6f3a | 76 | virtual std::string getDeviceIP(); |
Mike Fiore |
1:f155d94d6f3a | 77 | virtual bool setDeviceIP(std::string address = "DHCP"); |
Mike Fiore |
1:f155d94d6f3a | 78 | |
Mike Fiore |
1:f155d94d6f3a | 79 | /** A method for configuring command ehco capability on the radio. This command |
Mike Fiore |
1:f155d94d6f3a | 80 | * sets whether sent characters are echoed back from the radio, in which case you |
Mike Fiore |
1:f155d94d6f3a | 81 | * will receive back every command you send. |
Mike Fiore |
1:f155d94d6f3a | 82 | * |
Mike Fiore |
1:f155d94d6f3a | 83 | * @param state if true echo will be turned off, otherwise it will be turned on. |
Mike Fiore |
1:f155d94d6f3a | 84 | * @returns the standard AT Code enumeration. |
Mike Fiore |
1:f155d94d6f3a | 85 | */ |
Mike Fiore |
1:f155d94d6f3a | 86 | Code echo(bool state); |
Mike Fiore |
1:f155d94d6f3a | 87 | |
Mike Fiore |
1:f155d94d6f3a | 88 | /** This method can be used to trade socket functionality for performance. |
Mike Fiore |
1:f155d94d6f3a | 89 | * In order to enable a socket connection to be closed by the client side programtically, |
Mike Fiore |
1:f155d94d6f3a | 90 | * this class must process all read and write data on the socket to guard the special |
Mike Fiore |
1:f155d94d6f3a | 91 | * escape character used to close an open socket connection. It is recommened that you |
Mike Fiore |
1:f155d94d6f3a | 92 | * use the default of true unless the overhead of these operations is too significant. |
Mike Fiore |
1:f155d94d6f3a | 93 | * |
Mike Fiore |
1:f155d94d6f3a | 94 | * @param enabled set to true if you want the socket closeable, otherwise false. The default |
Mike Fiore |
1:f155d94d6f3a | 95 | * is true. |
Mike Fiore |
1:f155d94d6f3a | 96 | * @returns the standard AT Code enumeration. |
Mike Fiore |
1:f155d94d6f3a | 97 | */ |
Mike Fiore |
1:f155d94d6f3a | 98 | Code setSocketCloseable(bool enabled = true); //ETX closes socket (ETX and DLE in payload are escaped with DLE) |
Mike Fiore |
1:f155d94d6f3a | 99 | }; |
Mike Fiore |
1:f155d94d6f3a | 100 | |
Mike Fiore |
1:f155d94d6f3a | 101 | } |
Mike Fiore |
1:f155d94d6f3a | 102 | |
Mike Fiore |
1:f155d94d6f3a | 103 | #endif |