Simple detection for LE910-NA1 modules
Fork of MTS-Cellular by
Cellular/EasyIP.h@26:2b769ed8de4f, 2014-06-26 (annotated)
- Committer:
- Vanger
- Date:
- Thu Jun 26 21:12:37 2014 +0000
- Revision:
- 26:2b769ed8de4f
- Parent:
- 3:04046eebaef5
- Child:
- 27:ec44d5a9544f
Made setApn() a pure virtual in Cellular.; Implemented setApn in both UIP and EasyIP; Implemented connect(), disconnect(), and ping() in EasyIP; Uncommented cell instantiation for EasyIP type models in CellularFactory
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Mike Fiore |
1:f155d94d6f3a | 1 | #ifndef SMC_H |
Mike Fiore |
1:f155d94d6f3a | 2 | #define SMC_H |
Mike Fiore |
1:f155d94d6f3a | 3 | |
Vanger | 26:2b769ed8de4f | 4 | #include <string> |
Vanger | 26:2b769ed8de4f | 5 | #include <vector> |
Vanger | 26:2b769ed8de4f | 6 | |
Vanger | 26:2b769ed8de4f | 7 | #include "MTSBufferedIO.h" |
Vanger | 26:2b769ed8de4f | 8 | #include "Cellular.h" |
Vanger | 26:2b769ed8de4f | 9 | |
Vanger | 26:2b769ed8de4f | 10 | namespace mts |
Vanger | 26:2b769ed8de4f | 11 | { |
Vanger | 26:2b769ed8de4f | 12 | /** This is a class for communicating without a Multi-Tech Systems SocketModem iCell. Instead, |
Vanger | 26:2b769ed8de4f | 13 | * it uses the hayes command set to implement the same commands and functions as the UIP class. |
Vanger | 26:2b769ed8de4f | 14 | * (See the UIP class and documentation, "UIP.h") |
Vanger | 26:2b769ed8de4f | 15 | * This class supports three main types of cellular radio interactions including: |
Vanger | 26:2b769ed8de4f | 16 | * configuration and status AT command processing, SMS processing, and TCP Socket |
Vanger | 26:2b769ed8de4f | 17 | * data connections. It should be noted that the radio can not process commands or |
Vanger | 26:2b769ed8de4f | 18 | * SMS messages while having an open data connection at the same time. The concurrent |
Vanger | 26:2b769ed8de4f | 19 | * capability may be added in a future release. This class also inherits from IPStack |
Vanger | 26:2b769ed8de4f | 20 | * providing a common set of commands for communication devices that have an onboard |
Vanger | 26:2b769ed8de4f | 21 | * IP Stack. It is also integrated with the standard mbed Sockets package and can therefore |
Vanger | 26:2b769ed8de4f | 22 | * be used seamlessly with clients and services built on top of this interface already within |
Vanger | 26:2b769ed8de4f | 23 | * the mbed library. |
Vanger | 26:2b769ed8de4f | 24 | * The default baud rate for the cellular radio is 115200 bps. |
Vanger | 26:2b769ed8de4f | 25 | */ |
Vanger | 26:2b769ed8de4f | 26 | class EasyIP : public Cellular //Inherits from Cellular. |
Vanger | 26:2b769ed8de4f | 27 | { |
Vanger | 26:2b769ed8de4f | 28 | public: |
Vanger | 26:2b769ed8de4f | 29 | /** This static function is used to create or get a reference to a |
Vanger | 26:2b769ed8de4f | 30 | * Cellular object. Cellular uses the singleton pattern, which means |
Vanger | 26:2b769ed8de4f | 31 | * that you can only have one existing at a time. The first time you |
Vanger | 26:2b769ed8de4f | 32 | * call getInstance this method creates a new uninitialized Cellular |
Vanger | 26:2b769ed8de4f | 33 | * object and returns it. All future calls to this method will return |
Vanger | 26:2b769ed8de4f | 34 | * a reference to the instance created during the first call. Note that |
Vanger | 26:2b769ed8de4f | 35 | * you must call init on the returned instance before mnaking any other |
Vanger | 26:2b769ed8de4f | 36 | * calls. If using this class's bindings to any of the Socket package |
Vanger | 26:2b769ed8de4f | 37 | * classes like TCPSocketConnection, you must call this method and the |
Vanger | 26:2b769ed8de4f | 38 | * init method on the returned object first, before even creating the |
Vanger | 26:2b769ed8de4f | 39 | * other objects. |
Vanger | 26:2b769ed8de4f | 40 | * |
Vanger | 26:2b769ed8de4f | 41 | * @returns a reference to the single Cellular obect that has been created. |
Vanger | 26:2b769ed8de4f | 42 | */ |
Vanger | 26:2b769ed8de4f | 43 | EasyIP(Radio type); |
Vanger | 26:2b769ed8de4f | 44 | |
Vanger | 26:2b769ed8de4f | 45 | /** Destructs a Cellular object and frees all related resources. |
Vanger | 26:2b769ed8de4f | 46 | */ |
Vanger | 26:2b769ed8de4f | 47 | ~EasyIP(); |
Vanger | 26:2b769ed8de4f | 48 | |
Vanger | 26:2b769ed8de4f | 49 | virtual bool init(MTSBufferedIO* io); |
Vanger | 26:2b769ed8de4f | 50 | |
Vanger | 26:2b769ed8de4f | 51 | // Wifi connection based commands derived from CommInterface.h |
Vanger | 26:2b769ed8de4f | 52 | virtual bool connect(); |
Vanger | 26:2b769ed8de4f | 53 | virtual void disconnect(); |
Vanger | 26:2b769ed8de4f | 54 | virtual bool isConnected(); |
Vanger | 26:2b769ed8de4f | 55 | virtual void reset(); |
Vanger | 26:2b769ed8de4f | 56 | |
Vanger | 26:2b769ed8de4f | 57 | // TCP and UDP Socket related commands |
Vanger | 26:2b769ed8de4f | 58 | // For behavior of the following methods refer to IPStack.h documentation |
Vanger | 26:2b769ed8de4f | 59 | virtual bool bind(unsigned int port); |
Vanger | 26:2b769ed8de4f | 60 | virtual bool open(const std::string& address, unsigned int port, Mode mode); |
Vanger | 26:2b769ed8de4f | 61 | virtual bool isOpen(); |
Vanger | 26:2b769ed8de4f | 62 | virtual bool close(); |
Vanger | 26:2b769ed8de4f | 63 | virtual int read(char* data, int max, int timeout = -1); //-1 times for no timeout? |
Vanger | 26:2b769ed8de4f | 64 | virtual int write(const char* data, int length, int timeout = -1); |
Vanger | 26:2b769ed8de4f | 65 | virtual unsigned int readable(); |
Vanger | 26:2b769ed8de4f | 66 | virtual unsigned int writeable(); |
Vanger | 26:2b769ed8de4f | 67 | virtual bool ping(const std::string& address = "8.8.8.8"); //Can this default address be different? |
Vanger | 26:2b769ed8de4f | 68 | virtual std::string getDeviceIP(); |
Vanger | 26:2b769ed8de4f | 69 | virtual bool setDeviceIP(std::string address = "DHCP");//What does this do? Run DHCP to configure the IP? |
Vanger | 26:2b769ed8de4f | 70 | |
Vanger | 26:2b769ed8de4f | 71 | //Sets the APN, also sets mode to IP, might need to change |
Vanger | 26:2b769ed8de4f | 72 | virtual Code setApn(const std::string& apn); |
Vanger | 26:2b769ed8de4f | 73 | /** A method for configuring command ehco capability on the radio. This command |
Vanger | 26:2b769ed8de4f | 74 | * sets whether sent characters are echoed back from the radio, in which case you |
Vanger | 26:2b769ed8de4f | 75 | * will receive back every command you send. |
Vanger | 26:2b769ed8de4f | 76 | * |
Vanger | 26:2b769ed8de4f | 77 | * @param state if true echo will be turned off, otherwise it will be turned on. |
Vanger | 26:2b769ed8de4f | 78 | * @returns the standard AT Code enumeration. |
Vanger | 26:2b769ed8de4f | 79 | */ |
Vanger | 26:2b769ed8de4f | 80 | Code echo(bool state); |
Vanger | 26:2b769ed8de4f | 81 | |
Vanger | 26:2b769ed8de4f | 82 | /** This method can be used to trade socket functionality for performance. |
Vanger | 26:2b769ed8de4f | 83 | * In order to enable a socket connection to be closed by the client side programtically, |
Vanger | 26:2b769ed8de4f | 84 | * this class must process all read and write data on the socket to guard the special |
Vanger | 26:2b769ed8de4f | 85 | * escape character used to close an open socket connection. It is recommened that you |
Vanger | 26:2b769ed8de4f | 86 | * use the default of true unless the overhead of these operations is too significant. |
Vanger | 26:2b769ed8de4f | 87 | * |
Vanger | 26:2b769ed8de4f | 88 | * @param enabled set to true if you want the socket closeable, otherwise false. The default |
Vanger | 26:2b769ed8de4f | 89 | * is true. |
Vanger | 26:2b769ed8de4f | 90 | * @returns the standard AT Code enumeration. |
Vanger | 26:2b769ed8de4f | 91 | */ |
Vanger | 26:2b769ed8de4f | 92 | Code setSocketCloseable(bool enabled = true); //ETX closes socket (ETX and DLE in payload are escaped with DLE) |
Vanger | 26:2b769ed8de4f | 93 | }; |
Vanger | 26:2b769ed8de4f | 94 | |
Vanger | 26:2b769ed8de4f | 95 | } |
Vanger | 26:2b769ed8de4f | 96 | |
Mike Fiore |
1:f155d94d6f3a | 97 | #endif |