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

cellular/Cellular.h

Committer:
sgodinez
Date:
2013-12-11
Revision:
5:93e889a5abc6
Parent:
4:6561c9128c6f
Child:
11:134435d8a2d5

File content as of revision 5:93e889a5abc6:

#ifndef CELLULAR_H
#define CELLULAR_H

#include "mbed.h"
#include "MTSBufferedIO.h"
#include <string>
#include <vector>

class Cellular
{
public:
    enum Code {
        OK, ERROR, NO_RESPONSE, FAILURE
    };

    enum ESC_CHAR {
        CR, CTRL_Z
    };

    enum Registration {
        NOT_REGISTERED, REGISTERED, SEARCHING, DENIED, UNKNOWN, ROAMING
    };

    struct Sms {
            std::string phoneNumber;
            std::string message;
            std::string timestamp;
    };
    
    
    Cellular(MTSBufferedIO& io);
    ~Cellular();

    string sendCommand(string command, int timeoutMillis, ESC_CHAR esc = CR);
    Code sendBasicCommand(string command, int timeoutMillis, ESC_CHAR esc = CR);

    Code ATTest();
    Code echoOff(bool state);
    int getSignalStrength();
    std::string getPhoneNumber();
    Registration getRegistration();
    
    //SMS
    Code sendSMS(const std::string& phoneNumber, const std::string& message);
    Code sendSMS(const Sms& sms);
    std::vector<Cellular::Sms> getReceivedSms();
    Code deleteAllReceivedSms();
    Code deleteOnlyReceivedReadSms();
    
    int connect(string host, int port);    
    
private:
    MTSBufferedIO& io;
};

#endif /* CELLULAR_H */