pdulib
Public Member Functions | List of all members
PDU Class Reference

PDU class, provides methods to decode a PDU message or encode a new one. More...

#include <pdulib.h>

Public Member Functions

int encodePDU (const char *recipient, const char *message)
 Encode a PDU block for sending to an GSM modem. More...
 
const char * getSMS ()
 Get the address of the PDU message created by encodePDU More...
 
void setSCAnumber (const char *number)
 Before encoding a PDU, you must supply the SCA phone number. Typically this can be retrieved from a GSM modem with the AT+CSCA? command. More...
 
bool decodePDU (const char *pdu)
 Decode a PDU, typically received from a GSM modem when in PDU mode. After a successful decoding you can retrieve the components parts, desctibed below. More...
 
char * getSCAnumber ()
 Get the SCA number from a decoded PDU. More...
 
const char * getSender ()
 Get the senders phone number from a decoded PDU. More...
 
const char * getTimeStamp ()
 Get the Timestamp from a decoded PDU. More...
 
const unsigned char * getText ()
 Get the text froma a decoded PDU. More...
 

Detailed Description

PDU class, provides methods to decode a PDU message or encode a new one.

Parameters
NoneThere are no parameters for the constructor

Member Function Documentation

◆ decodePDU()

bool PDU::decodePDU ( const char *  pdu)

Decode a PDU, typically received from a GSM modem when in PDU mode. After a successful decoding you can retrieve the components parts, desctibed below.

Parameters
pduA pointer to the PDU
Returns
true If the decoding succeeded.
false If the decoding did not succeed.

◆ encodePDU()

int PDU::encodePDU ( const char *  recipient,
const char *  message 
)

Encode a PDU block for sending to an GSM modem.

Parameters
recipientPhone number, must be numeric, no whitespace. International numbers prefixed by '+'
messageThe message in UTF-8 format
Returns
int The length of the message, need for the GSM command AT+CSMG=nn

◆ getSCAnumber()

char * PDU::getSCAnumber ( )

Get the SCA number from a decoded PDU.

Returns
char* Pointer to the number

◆ getSender()

const char * PDU::getSender ( )

Get the senders phone number from a decoded PDU.

Returns
const char* Pointer to the number

◆ getSMS()

const char * PDU::getSMS ( )

Get the address of the PDU message created by encodePDU

Returns
const char* The pointer to the message. It already contained the CTRL/Z delimiter byte.

◆ getText()

const unsigned char * PDU::getText ( )

Get the text froma a decoded PDU.

Returns
const unsigned char* The message in UTF-8 format.

◆ getTimeStamp()

const char * PDU::getTimeStamp ( )

Get the Timestamp from a decoded PDU.

Returns
const char* The tomestamp formatted as YYYMMDDHHMMSS

◆ setSCAnumber()

void PDU::setSCAnumber ( const char *  number)

Before encoding a PDU, you must supply the SCA phone number. Typically this can be retrieved from a GSM modem with the AT+CSCA? command.

Parameters
numberThe number as retrieved from the AT+CSCA? command

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