A library for talking to Multi-Tech's Cellular SocketModem Devices.

Dependents:   M2X_dev axeda_wrapper_dev MTS_M2x_Example1 MTS_Cellular_Connect_Example ... more

Committer:
sgodinez
Date:
Fri Dec 13 20:18:47 2013 +0000
Revision:
11:134435d8a2d5
Parent:
5:93e889a5abc6
Child:
13:0af863114629
IPStack.h interface definition

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jengbrecht 0:563b70517320 1 #ifndef CELLULAR_H
jengbrecht 0:563b70517320 2 #define CELLULAR_H
jengbrecht 0:563b70517320 3
sgodinez 11:134435d8a2d5 4 #include "IPStack.h"
sgodinez 11:134435d8a2d5 5 #include "MTSBufferedIO.h"
jengbrecht 0:563b70517320 6 #include "mbed.h"
jengbrecht 0:563b70517320 7 #include <string>
sgodinez 4:6561c9128c6f 8 #include <vector>
jengbrecht 0:563b70517320 9
sgodinez 11:134435d8a2d5 10 class Cellular : virtual IPStack
jengbrecht 0:563b70517320 11 {
jengbrecht 0:563b70517320 12 public:
jengbrecht 0:563b70517320 13 enum Code {
jengbrecht 0:563b70517320 14 OK, ERROR, NO_RESPONSE, FAILURE
jengbrecht 0:563b70517320 15 };
jengbrecht 0:563b70517320 16
jengbrecht 0:563b70517320 17 enum ESC_CHAR {
jengbrecht 0:563b70517320 18 CR, CTRL_Z
jengbrecht 0:563b70517320 19 };
jengbrecht 0:563b70517320 20
jengbrecht 0:563b70517320 21 enum Registration {
jengbrecht 0:563b70517320 22 NOT_REGISTERED, REGISTERED, SEARCHING, DENIED, UNKNOWN, ROAMING
jengbrecht 0:563b70517320 23 };
jengbrecht 0:563b70517320 24
sgodinez 4:6561c9128c6f 25 struct Sms {
sgodinez 4:6561c9128c6f 26 std::string phoneNumber;
sgodinez 4:6561c9128c6f 27 std::string message;
sgodinez 4:6561c9128c6f 28 std::string timestamp;
sgodinez 4:6561c9128c6f 29 };
sgodinez 4:6561c9128c6f 30
sgodinez 4:6561c9128c6f 31
sgodinez 4:6561c9128c6f 32 Cellular(MTSBufferedIO& io);
jengbrecht 0:563b70517320 33 ~Cellular();
jengbrecht 0:563b70517320 34
sgodinez 11:134435d8a2d5 35 virtual bool connect(); // Parameters for this function will vary between devices!!!
sgodinez 11:134435d8a2d5 36 virtual void disconnect();
sgodinez 11:134435d8a2d5 37 virtual bool isConnected();
jengbrecht 0:563b70517320 38
sgodinez 11:134435d8a2d5 39 // Used for TCPSocketConnection & UDPSocketConnection
sgodinez 11:134435d8a2d5 40 virtual bool bind(unsigned int port);
sgodinez 11:134435d8a2d5 41 virtual bool open(const std::string& address, unsigned int port, Mode mode);
sgodinez 11:134435d8a2d5 42 virtual bool isOpen();
sgodinez 11:134435d8a2d5 43 virtual void close();
sgodinez 11:134435d8a2d5 44 virtual int read(char* data, int max, int timeout = -1);
sgodinez 11:134435d8a2d5 45 virtual int write(char* data, int length, int timeout = -1);
sgodinez 11:134435d8a2d5 46 virtual unsigned int readable();
sgodinez 11:134435d8a2d5 47 virtual unsigned int writeable();
sgodinez 11:134435d8a2d5 48
sgodinez 11:134435d8a2d5 49 //Other
sgodinez 11:134435d8a2d5 50 virtual void reset();
sgodinez 11:134435d8a2d5 51
sgodinez 11:134435d8a2d5 52 //Cellular Radio Specific
sgodinez 11:134435d8a2d5 53 std::string sendCommand(std::string command, int timeoutMillis, ESC_CHAR esc = CR);
sgodinez 11:134435d8a2d5 54 Code sendBasicCommand(std::string command, int timeoutMillis, ESC_CHAR esc = CR);
sgodinez 11:134435d8a2d5 55
sgodinez 11:134435d8a2d5 56 Code test();
jengbrecht 0:563b70517320 57 Code echoOff(bool state);
jengbrecht 0:563b70517320 58 int getSignalStrength();
sgodinez 5:93e889a5abc6 59 std::string getPhoneNumber();
sgodinez 5:93e889a5abc6 60 Registration getRegistration();
sgodinez 11:134435d8a2d5 61 Code setApn(const std::string& apn);
sgodinez 11:134435d8a2d5 62 Code setDns(const std::string& apn);
sgodinez 4:6561c9128c6f 63
sgodinez 4:6561c9128c6f 64 //SMS
sgodinez 4:6561c9128c6f 65 Code sendSMS(const std::string& phoneNumber, const std::string& message);
sgodinez 4:6561c9128c6f 66 Code sendSMS(const Sms& sms);
sgodinez 4:6561c9128c6f 67 std::vector<Cellular::Sms> getReceivedSms();
sgodinez 4:6561c9128c6f 68 Code deleteAllReceivedSms();
sgodinez 4:6561c9128c6f 69 Code deleteOnlyReceivedReadSms();
sgodinez 4:6561c9128c6f 70
sgodinez 11:134435d8a2d5 71 Code getCode();
jengbrecht 0:563b70517320 72
jengbrecht 0:563b70517320 73 private:
sgodinez 4:6561c9128c6f 74 MTSBufferedIO& io;
sgodinez 11:134435d8a2d5 75 Code code;
sgodinez 11:134435d8a2d5 76
sgodinez 11:134435d8a2d5 77 bool pppConnected;
sgodinez 11:134435d8a2d5 78 std::string apn;
sgodinez 11:134435d8a2d5 79
sgodinez 11:134435d8a2d5 80 Mode mode;
sgodinez 11:134435d8a2d5 81 bool socketOpened;
sgodinez 11:134435d8a2d5 82 unsigned int local_port;
sgodinez 11:134435d8a2d5 83 unsigned int host_port;
sgodinez 11:134435d8a2d5 84 std::string host_address;
sgodinez 11:134435d8a2d5 85
sgodinez 11:134435d8a2d5 86
sgodinez 11:134435d8a2d5 87
jengbrecht 0:563b70517320 88 };
jengbrecht 0:563b70517320 89
jengbrecht 0:563b70517320 90 #endif /* CELLULAR_H */