Phoenard
Public Member Functions | List of all members
PHN_Sim Class Reference

Simplistic library to make use of the SIM908 (phone) controller. More...

#include <PHNSim.h>

Public Member Functions

void init ()
 Ensures the SIM logic is initalized.
 
void begin ()
 Sets up the SIM for first use.
 
void end ()
 Shuts off the SIM.
 
void reset ()
 Resets all SIM AT parameters to the factory defaults.
 
void update ()
 Receives SIM status codes, call routinely to keep up to date.
 
bool isOn ()
 Checks if the SIM is currently turned on.
 
void togglePower ()
 Toggles power on or off - for async toggling.
 
int getRegStatus ()
 Reads the SIM network registration status.
 
bool isConnected ()
 Checks if the SIM has a connection with a network (is registered)
 
bool isSimCardInserted ()
 Checks whether a (valid) SIM card is inserted.
 
Date getDate ()
 Get the current date according to the SIM.
 
void setDate (Date newDate)
 Sets a new date stored and updated by the SIM.
 
bool readProvider (char *buffer, int bufferLength)
 Reads the SIM provider name.
 
float readBatteryLevel ()
 Reads the battery level ranging 0.0 (empty) to 1.0 (full)
 
int readSignalLevel ()
 Reads the signal level in dB, is 0 when there is no connection.
 
bool enterPin (const char *pin)
 Enters SIM Pin code.
 
bool enterPuk (const char *puk, const char *newPin)
 Enters SIM PUK and new Pin code.
 
int getPinStatus ()
 Gets the pin entering status.
 
void call (const char *address)
 Initiates a call.
 
void endCall ()
 Ends the current call, or cancels a call silently.
 
void rejectCall ()
 Rejects an incoming call by stating you are busy.
 
void acceptCall ()
 Accepts the call.
 
bool isCalled ()
 Checks whether the SIM is being called, used getCallStatus()
 
int getCallStatus ()
 Gets the calling status.
 
const char * getIncomingNumber ()
 Gets the number of the person calling this SIM.
 
void sendDTMF (char character)
 Sends a DTMF tone number, does nothing when character is NULL.
 
bool setVolume (int level)
 Sets the volume of the loudspeaker using a level 0 - 100.
 
int getMessageCount ()
 Gets the amount of messages stored in memory.
 
int getMessageLimit ()
 Gets the total limit amount of messages that can be stored in memory.
 
bool hasNewMessage ()
 Checks whether a new message is available.
 
SimMessage getNewMessage ()
 Reads the message received last.
 
SimMessage getMessage (int messageIndex)
 Reads a message from the message inbox.
 
void deleteMessage (int messageIndex)
 Deletes a message from the inbox.
 
bool sendMessage (const char *receiverAddress, const char *messageText)
 Sends a text message.
 
bool setContactBook (const char *bookName)
 Switches to a different phone book to access contacts of.
 
int getContactCount ()
 Gets how many valid contacts are stored in the current good book.
 
int getContactLimit () const
 Gets how many contacts can possibly be stored in the current book.
 
int getContactNumberLimit () const
 Gets the maximum length of a contact number field.
 
int getContactTextLimit () const
 Gets the maximum length of a contact text field.
 
SimContact getContact (int contactIndex)
 Reads the contact stored at the index in the current book.
 
bool addContact (SimContact contact)
 Adds new contact information to the current book.
 
bool setContact (int contactIndex, SimContact contact)
 Writes new contact information at the index in the current book.
 
bool deleteContact (int contactIndex)
 Deletes the contact information at the index in the current book.
 
bool sendATCommand (const char *command)
 Sends a command, returns whether it was successful.
 
bool sendATCommand (const char *command, char *respBuffer, uint16_t respBufferLength)
 Sends a command and receives the response, returns whether it was successful.
 
bool sendATCommand (const char *command, char *respBuffer, uint16_t respBufferLength, long timeout)
 Sends a command and receives the response, returns whether it was successful.
 
bool writeATCommand (const char *command)
 Writes the command, handling non-responsiveness and retries, not reading the full response.
 
unsigned char getSimTextArgs (char *text, char **args, unsigned char maxArgs)
 Reads the arguments sent in a sim text response message. More...
 
Date readDate (char *text)
 Reads a DATE argument from received response (note: alters text buffer)
 
void writeDate (char *buffer, Date date)
 Writes a DATE argument to an output buffer.
 

Detailed Description

Simplistic library to make use of the SIM908 (phone) controller.

Make or receive calls, send or receive text messages and generally operate the SIM908. Some of the basic AT-Commands are implemented with an easy API. You can make use of the AT-Command sending routines to extend the library. This function automatically parses the response into an array of arguments, with retries and basic text parsing taken care of.

Member Function Documentation

unsigned char PHN_Sim::getSimTextArgs ( char *  text,
char **  args,
unsigned char  maxArgs 
)

Reads the arguments sent in a sim text response message.

The command repeat in front has to be removed by the caller The args array has to be pre-allocated with the min. required elements Return value indicates the amount of arguments read Warning: alters the input text argument!


The documentation for this class was generated from the following files: