MultiTech / MTS-Cellular

Dependents:   mtsas mtsas mtsas mtsas

Embed: (wiki syntax)

« Back to documentation index

EasyIP Class Reference

This class implements the same interface used for UIP version radios on an Easy IP radio using the Hayes AT command set. More...

#include <EasyIP.h>

Inherits mts::Cellular.

Public Types

enum  Radio
 

Enumeration for different cellular radio types.

More...
enum  Registration
 

An enumeration of radio registration states with a cell tower.

More...

Public Member Functions

 EasyIP (Radio type)
 This static function is used to create or get a reference to a Cellular object.
 ~EasyIP ()
 Destructs a Cellular object and frees all related resources.
virtual bool init (MTSBufferedIO *io)
 Initializes the MTS IO buffer.
virtual bool connect ()
 PPP connect command.
virtual void disconnect ()
 PPP disconnect command.
virtual bool isConnected ()
 Checks if the radio is connected to the cell network.
virtual void reset ()
 Resets the radio/modem.
virtual bool ping (const std::string &address="8.8.8.8")
 Pings specified DNS or IP address Google DNS server used as default ping address.
virtual Code setApn (const std::string &apn)
 Sets the APN.
virtual bool GPSenable ()
 Enables GPS.
virtual bool GPSdisable ()
 Disables GPS.
virtual bool GPSenabled ()
 Checks if GPS is enabled.
virtual Cellular::gpsData GPSgetPosition ()
 Get GPS position.
virtual bool GPSgotFix ()
 Check for GPS fix.
bool configureSignals (unsigned int DCD=NC, unsigned int DTR=NC, unsigned int RESET=NC)
 Sets up the physical connection pins (DTR,DCD, and RESET)
virtual Code test ()
 A method for testing command access to the radio.
virtual int getSignalStrength ()
 A method for getting the signal strength of the radio.
virtual Registration getRegistration ()
 This method is used to check the registration state of the radio with the cell tower.
virtual Code setDns (const std::string &primary, const std::string &secondary="0.0.0.0")
 This method is used to set the DNS which enables the use of URLs instead of IP addresses when making a socket connection.
virtual Code sendSMS (const std::string &phoneNumber, const std::string &message)
 This method is used to send an SMS message.
virtual Code sendSMS (const Sms &sms)
 This method is used to send an SMS message.
virtual std::vector
< Cellular::Sms
getReceivedSms ()
 This method retrieves all of the SMS messages currently available for this phone number.
virtual Code deleteAllReceivedSms ()
 This method can be used to remove/delete all received SMS messages even if they have never been retrieved or read.
virtual Code deleteOnlyReceivedReadSms ()
 This method can be used to remove/delete all received SMS messages that have been retrieved by the user through the getReceivedSms method.
virtual std::string sendCommand (const std::string &command, unsigned int timeoutMillis, char esc=CR)
 A method for sending a generic AT command to the radio.
virtual Code sendBasicCommand (const std::string &command, unsigned int timeoutMillis, char esc=CR)
 A method for sending a basic AT command to the radio.
virtual Code echo (bool state)
 A method for changing the echo commands from radio.
virtual Code setSocketCloseable (bool enabled)
 This method can be used to trade socket functionality for performance.
virtual bool bind (unsigned int port)
 Binds the socket to a specific port if able.
virtual bool isOpen ()
 Checks if a socket is open.
virtual unsigned int readable ()
 Checks if there is data available from the socket.
virtual unsigned int writeable ()
 Checks data to output on the socket.
virtual std::string getDeviceIP ()
 Gets the device IP.
virtual bool setDeviceIP (std::string address="DHCP")
 Sets the device IP (Not implemented, IP address values are assigned by DHCP)
std::string getEquipmentIdentifier ()
 Get the device IMEI or MEID (whichever is available)
int getRadioType ()
 Get radio type.
std::string getRadioTypeString ()
 Get string representation of radio type.

Static Public Member Functions

static std::string getRegistrationNames (Registration registration)
 A static method for getting a string representation for the Registration enumeration.
static std::string getRadioNames (Radio radio)
 A static method for getting a string representation for the Radio enumeration.

Detailed Description

This class implements the same interface used for UIP version radios on an Easy IP radio using the Hayes AT command set.

(See the UIP class and documentation, "UIP.h") This class supports four main types of cellular radio interactions including: configuration and status AT-command processing, SMS processing, TCP Socket data connections, and UDP data connections. It should be noted that the radio can not process commands or SMS messages while having an open data connection at the same time. The concurrent capability may be added in a future release. This class also inherits from IPStack providing a common set of commands for communication devices that have an onboard IP Stack. It is also integrated with the standard mbed Sockets package and can therefore be used seamlessly with clients and services built on top of this interface already within the mbed library. The default baud rate for the cellular radio is 115200 bps.

Example code is found under Cellular.h

Definition at line 28 of file EasyIP.h.


Member Enumeration Documentation

enum Radio [inherited]

Enumeration for different cellular radio types.

Definition at line 247 of file Cellular.h.

enum Registration [inherited]

An enumeration of radio registration states with a cell tower.

Definition at line 253 of file Cellular.h.


Constructor & Destructor Documentation

EasyIP ( Radio  type )

This static function is used to create or get a reference to a Cellular object.

Cellular uses the singleton pattern, which means that you can only have one existing at a time. The first time you call getInstance this method creates a new uninitialized Cellular object and returns it. All future calls to this method will return a reference to the instance created during the first call. Note that you must call init on the returned instance before mnaking any other calls. If using this class's bindings to any of the Socket package classes like TCPSocketConnection, you must call this method and the init method on the returned object first, before even creating the other objects.

Returns:
a reference to the single Cellular obect that has been created.

Definition at line 10 of file EasyIP.cpp.

~EasyIP (  )

Destructs a Cellular object and frees all related resources.

Definition at line 28 of file EasyIP.cpp.


Member Function Documentation

bool bind ( unsigned int  port ) [virtual, inherited]

Binds the socket to a specific port if able.

Parameters:
portinteger to bind the socket to.
Returns:
true if successfully bound port, false if bind failed.

Definition at line 523 of file Cellular.cpp.

bool configureSignals ( unsigned int  DCD = NC,
unsigned int  DTR = NC,
unsigned int  RESET = NC 
) [inherited]

Sets up the physical connection pins (DTR,DCD, and RESET)

Definition at line 18 of file Cellular.cpp.

bool connect (  ) [virtual]

PPP connect command.

Connects the radio to the cellular network.

Returns:
true if PPP connection to the network succeeded, false if the PPP connection failed.

Definition at line 62 of file EasyIP.cpp.

Code deleteAllReceivedSms (  ) [virtual, inherited]

This method can be used to remove/delete all received SMS messages even if they have never been retrieved or read.

Returns:
the standard AT Code enumeration.

Definition at line 409 of file Cellular.cpp.

Code deleteOnlyReceivedReadSms (  ) [virtual, inherited]

This method can be used to remove/delete all received SMS messages that have been retrieved by the user through the getReceivedSms method.

Messages that have not been retrieved yet will be unaffected.

Returns:
the standard AT Code enumeration.

Definition at line 404 of file Cellular.cpp.

void disconnect (  ) [virtual]

PPP disconnect command.

Disconnects from the PPP network, and will also close active socket connection if open.

Definition at line 144 of file EasyIP.cpp.

Code echo ( bool  state ) [virtual, inherited]

A method for changing the echo commands from radio.

Parameters:
stateEcho mode is off (an argument of 1 turns echos off, anything else turns echo on)
Returns:
standard Code enumeration

Definition at line 482 of file Cellular.cpp.

std::string getDeviceIP (  ) [virtual, inherited]

Gets the device IP.

Returns:
string containing the IP address

Definition at line 476 of file Cellular.cpp.

std::string getEquipmentIdentifier (  ) [inherited]

Get the device IMEI or MEID (whichever is available)

Returns:
string containing the IMEI for GSM, the MEID for CDMA, or an empty string if it failed to parse the number.

Definition at line 427 of file Cellular.cpp.

std::string getRadioNames ( Radio  radio ) [static, inherited]

A static method for getting a string representation for the Radio enumeration.

Parameters:
typea Radio enumeration.
Returns:
the enumeration name as a string.

Definition at line 58 of file Cellular.cpp.

int getRadioType (  ) [inherited]

Get radio type.

Returns:
the radio type (MTSMC-H5, etc)

Definition at line 442 of file Cellular.cpp.

std::string getRadioTypeString (  ) [inherited]

Get string representation of radio type.

Returns:
string containing the radio type (MTSMC-H5, etc)

Definition at line 447 of file Cellular.cpp.

std::vector< Cellular::Sms > getReceivedSms (  ) [virtual, inherited]

This method retrieves all of the SMS messages currently available for this phone number.

Returns:
a vector of existing SMS messages each as an Sms struct.

Definition at line 319 of file Cellular.cpp.

Cellular::Registration getRegistration (  ) [virtual, inherited]

This method is used to check the registration state of the radio with the cell tower.

If not appropriatley registered with the tower you cannot make a cellular connection.

Returns:
the registration state as an enumeration type.

Definition at line 121 of file Cellular.cpp.

std::string getRegistrationNames ( Registration  registration ) [static, inherited]

A static method for getting a string representation for the Registration enumeration.

Parameters:
codea Registration enumeration.
Returns:
the enumeration name as a string.

Definition at line 38 of file Cellular.cpp.

int getSignalStrength (  ) [virtual, inherited]

A method for getting the signal strength of the radio.

This method allows you to get a value that maps to signal strength in dBm. Here 0-1 is Poor, 2-9 is Marginal, 10-14 is Ok, 15-19 is Good, and 20+ is Excellent. If you get a result of 99 the signal strength is not known or not detectable.

Returns:
an integer representing the signal strength.

Definition at line 107 of file Cellular.cpp.

bool GPSdisable (  ) [virtual]

Disables GPS.

Returns:
true if GPS gets or is disabled, false if GPS failed to disable.

Reimplemented from Cellular.

Definition at line 727 of file EasyIP.cpp.

bool GPSenable (  ) [virtual]

Enables GPS.

Returns:
true if GPS gets or is enabled, false if GPS is not supported.

Reimplemented from Cellular.

Definition at line 696 of file EasyIP.cpp.

bool GPSenabled (  ) [virtual]

Checks if GPS is enabled.

Returns:
true if GPS is enabled, false if GPS is disabled.

Reimplemented from Cellular.

Definition at line 745 of file EasyIP.cpp.

Cellular::gpsData GPSgetPosition (  ) [virtual]

Get GPS position.

Returns:
a string containing the GPS position.

Reimplemented from Cellular.

Definition at line 756 of file EasyIP.cpp.

bool GPSgotFix (  ) [virtual]

Check for GPS fix.

Returns:
true if there is a fix and false otherwise.

Reimplemented from Cellular.

Definition at line 802 of file EasyIP.cpp.

bool init ( MTSBufferedIO *  io ) [virtual]

Initializes the MTS IO buffer.

Reimplemented from Cellular.

Definition at line 40 of file EasyIP.cpp.

bool isConnected (  ) [virtual]

Checks if the radio is connected to the cell network.

Checks antenna signal, cell tower registration, and context activation before finally pinging (4 pings, 32 bytes each) to confirm PPP connection to network. Will return true if there is an open socket connection as well.

Returns:
true if there is a PPP connection to the cell network, false if there is no PPP connection to the cell network.

Definition at line 187 of file EasyIP.cpp.

bool isOpen (  ) [virtual, inherited]

Checks if a socket is open.

Returns:
true if socket is open, false if socket is closed

Definition at line 513 of file Cellular.cpp.

bool ping ( const std::string &  address = "8.8.8.8" ) [virtual]

Pings specified DNS or IP address Google DNS server used as default ping address.

Returns:
true if ping received alive response else false

Definition at line 553 of file EasyIP.cpp.

unsigned int readable (  ) [virtual, inherited]

Checks if there is data available from the socket.

Returns:
number of bytes of data available to read.

Definition at line 414 of file Cellular.cpp.

void reset (  ) [virtual]

Resets the radio/modem.

Disconnects all active PPP and socket connections to do so.

Definition at line 276 of file EasyIP.cpp.

Code sendBasicCommand ( const std::string &  command,
unsigned int  timeoutMillis,
char  esc = CR 
) [virtual, inherited]

A method for sending a basic AT command to the radio.

A basic AT command is one that simply has a response of either OK or ERROR without any other information. Note that you cannot send commands and have a data connection at the same time.

Parameters:
commandthe command to send to the radio without the escape character.
timeoutMillisthe time in millis to wait for a response before returning.
escescape character to add at the end of the command, defaults to carriage return (CR).
Returns:
the standard Code enumeration.

Definition at line 162 of file Cellular.cpp.

string sendCommand ( const std::string &  command,
unsigned int  timeoutMillis,
char  esc = CR 
) [virtual, inherited]

A method for sending a generic AT command to the radio.

Note that you cannot send commands and have a data connection at the same time.

Parameters:
commandthe command to send to the radio without the escape character.
timeoutMillisthe time in millis to wait for a response before returning.
escescape character to add at the end of the command, defaults to carriage return (CR). Does not append any character if esc == 0.
Returns:
all data received from the radio after the command as a string.

Definition at line 181 of file Cellular.cpp.

Code sendSMS ( const std::string &  phoneNumber,
const std::string &  message 
) [virtual, inherited]

This method is used to send an SMS message.

Note that you cannot send an SMS message and have a data connection open at the same time.

Parameters:
phoneNumberthe phone number to send the message to as a string.
messagethe text message to be sent.
Returns:
the standard AT Code enumeration.

Definition at line 266 of file Cellular.cpp.

Code sendSMS ( const Sms sms ) [virtual, inherited]

This method is used to send an SMS message.

Note that you cannot send an SMS message and have a data connection open at the same time.

Parameters:
smsan Sms struct that contains all SMS transaction information.
Returns:
the standard AT Code enumeration.

Definition at line 157 of file Cellular.cpp.

Code setApn ( const std::string &  apn ) [virtual]

Sets the APN.

Parameters:
apnc-string of the APN to use
Returns:
MTS_SUCCESS if the APN was set, or is not needed, else it returns the result of the AT command sent to the radio to set the APN

Implements Cellular.

Definition at line 519 of file EasyIP.cpp.

bool setDeviceIP ( std::string  address = "DHCP" ) [virtual, inherited]

Sets the device IP (Not implemented, IP address values are assigned by DHCP)

Returns:
true if the IP was set, false if IP address assignment failed.

Definition at line 466 of file Cellular.cpp.

Code setDns ( const std::string &  primary,
const std::string &  secondary = "0.0.0.0" 
) [virtual, inherited]

This method is used to set the DNS which enables the use of URLs instead of IP addresses when making a socket connection.

Parameters:
theDNS server address as a string in form xxx.xxx.xxx.xxx.
Returns:
the standard AT Code enumeration.

Definition at line 152 of file Cellular.cpp.

Code setSocketCloseable ( bool  enabled ) [virtual, inherited]

This method can be used to trade socket functionality for performance.

Can disable checking socket closed messages from the data socket, and thus the socket will only be visibly closed to the local side if the radio is explicitly checked, or the socket is closed by the local side through the use of physical pin manipulation.

Uses the Hayes escape sequence (1 second pause, "+++", 1 second pause) to exit the socket connection to check if a received "NO CARRIER" string is from the radio indicating the socket has been closed, or is merely part of the data stream. Should not occur very often, however, if data carrying the string "NO CARRIER" is going to be transmitted frequently, then the socket should be set closeable and physical-socket-closing-means be used instead to reduce the large amount of overhead switching from checking the validity of the "NO CARRIER" message being and indication of the socket connection being closed.

Parameters:
enabledset to true if you want the socket closeable, otherwise false. The default is true.
Returns:
the standard AT Code enumeration.

Definition at line 497 of file Cellular.cpp.

Code test (  ) [virtual, inherited]

A method for testing command access to the radio.

This method sends the command "AT" to the radio, which is a standard radio test to see if you have command access to the radio. The function returns when it receives the expected response from the radio.

Returns:
the standard AT Code enumeration.

Definition at line 93 of file Cellular.cpp.

unsigned int writeable (  ) [virtual, inherited]

Checks data to output on the socket.

Returns:
number of bytes to be written to the socket.

Definition at line 452 of file Cellular.cpp.