Go to the documentation of this file.
12 #ifdef PDU_LIB_INCLUDE
14 #define PDU_LIB_INCLUDE
15 #define BITMASK_7BITS 0x7F
18 #define DCS_COMPRESSED (5<<1)
19 #define DCS_CLASS_MEANING (4<<1)
20 #define DCS_ALPHABET_MASK (3<<2)
21 #define DCS_ALPHABET_OFFSET 2
22 #define DCS_7BIT_ALPHABET_MASK 0B0000 //(0<<2)
23 #define DCS_8BIT_ALPHABET_MASK 0B0100 //1<<2)
24 #define DCS_16BIT_ALPHABET_MASK 0B1000 //(2<<2)
25 #define DCS_CLASS_MASK 3
26 #define DCS_IMMEDIATE_DISPLAY 3
27 #define DCS_ME_SPECIFIC_MASK 1
28 #define DCS_SIM_SPECIFIC_MASK 2
29 #define DCS_TE_SPECIFIC_MASK 3
32 #define PDU_VALIDITY_MASK_OFFSET 3
33 #define PDU_VALIDITY_NOT_PRESENT 0
34 #define PDU_VALIDITY_PRESENT_RELATIVE 2
35 #define PDU_VALIDITY_PRESENT_ENHANCED 1
36 #define PDU_VALIDITY_PRESENT_ABSOLUTE 3
37 #define PSU_SMS_DELIVER 0
38 #define PSU_SMS_SUBMIT 1
41 #define INTERNATIONAL_NUMBER 0x91
42 #define NATIONAL_NUMBER 0xA1
44 #define EXT_MASK 0x80 // bit 7
45 #define TON_MASK 0x70 // bits 4-6
47 #define NPI_MASK 0x0f // bits 0-3
49 #define MAX_SMS_LENGTH_7BIT 160 // GSM 3.4
50 #define MAX_NUMBER_LENGTH 20 // gets packed into BCD or packed 7 bit
53 #define PDU_BINARY_MAX_LENGTH 170
59 enum eDCS { ALPHABET_7BIT, ALPHABET_8BIT, ALPHABET_16BIT };
60 enum eAddressType {INTERNATIONAL_NUMERIC,NATIONAL_NUMERIC,ALPHABETIC};
61 enum eLengthType {OCTETS,NIBBLES};
79 int encodePDU(
const char *recipient,
const char *message);
127 const unsigned char *
getText();
131 char scabuff[MAX_NUMBER_LENGTH];
133 char addressBuff[MAX_NUMBER_LENGTH];
135 unsigned char mesbuff[MAX_SMS_LENGTH_7BIT];
138 char scanumber[MAX_NUMBER_LENGTH];
142 char smsSubmit[PDU_BINARY_MAX_LENGTH*2];
146 void stringToBCD(
const char *number,
char *pdu);
147 void BCDtoString(
char *number,
const char *pdu,
int length);
148 void digitSwap(
const char *number,
char *pdu);
150 int ascii_to_pdu(
const char *ascii,
char *pdu);
151 int pdu_to_ascii(
const char *pdu,
int pdulength,
char *ascii);
153 int convert_ascii_to_7bit(
const char *ascii,
char *a7bit);
154 int convert_7bit_to_ascii(uint8_t *a7bit,
int length,
char *ascii);
156 uint8_t gethex(
const char *pc);
157 void putHex(
unsigned char b,
char *target);
159 int pdu_to_ucs2(
const char *pdu,
int length, uint16_t *ucs2);
161 int ucs2_to_utf8(
unsigned short ucs2,
unsigned char *utf8);
163 int utf8_to_ucs2_single(
const char *utf8,
short *ucs2);
164 int utf8_to_ucs2(
const char *utf8,
char *ucs2);
166 int utf8Length(
const char *);
167 bool decodeAddress(
const char *,
char *, eLengthType);
168 bool setAddress(
const char *,eAddressType,eLengthType);
190 int16_t lookup_ascii8to7[] = {
464 uint8_t lookup_ascii7to8[] = {
bool decodePDU(const char *pdu)
Decode a PDU, typically received from a GSM modem when in PDU mode. After a successful decoding you c...
Definition: pdulib.cpp:357
const char * getSender()
Get the senders phone number from a decoded PDU.
Definition: pdulib.cpp:544
int encodePDU(const char *recipient, const char *message)
Encode a PDU block for sending to an GSM modem.
Definition: pdulib.cpp:158
const char * getSMS()
Get the address of the PDU message created by encodePDU
Definition: pdulib.cpp:614
const char * getTimeStamp()
Get the Timestamp from a decoded PDU.
Definition: pdulib.cpp:547
PDU class, provides methods to decode a PDU message or encode a new one.
Definition: pdulib.h:67
const unsigned char * getText()
Get the text froma a decoded PDU.
Definition: pdulib.cpp:550
void setSCAnumber(const char *number)
Before encoding a PDU, you must supply the SCA phone number. Typically this can be retrieved from a G...
Definition: pdulib.cpp:618
char * getSCAnumber()
Get the SCA number from a decoded PDU.
Definition: pdulib.cpp:622