Joke Collection Website - Blessing messages - Android sends pdu-encoded SMS directly.
Android sends pdu-encoded SMS directly.
1> Initialization: ATZ\r
2> Set the text mode: at+cmgf = \ r (: PDU mode, 1: text mode)
3> Set PDU header:
typedef struct {
char SCA[16]; //short message service center number (SMSC address)
char TPA[16]; //target number or reply number (TP-DA or TP-RA)
char TP_PID; //user information protocol identifier (TP-PID)
char TP_DCS; //user information coding mode (TP-DCS)
char TP_SCTS[16]; //service timestamp string (TP_SCTS), which is used when receiving
char TP_UD[16]; //original user information
char index; //short message serial number, which is used when reading
}SM_PARAM;
// SMSC address information segment
memset(buf, , sizeof(buf));
nLength = strlen(pSrc-> SCA); //length of SMSC address string
buf [] = (char) ((nlength &; 1) == ? nLength : nLength + 1) / 2 + 1; // SMSC address information length
buf[1] = x91; //fixed: use the international format number
ndstlength = gsmbytes 2string (buf, pdst, 2); //convert 2 bytes to the target PDU string
ndstlength+= gsminvertnumbers (PSRC->; SCA, & pDst[nDstLength], nLength); //convert SMSC to
/
memset(buf, , sizeof(buf)) of basic parameters and target address of tpdu segment;
nLength = strlen(pSrc-> TPA); //length of TP-da address string
buf[] = x11; //is to send a short message (TP-MTI=1), and TP-VP uses a relative format (TP-VPF=1)
buf[1] = ; // TP-MR=
buf[2] = (char)nLength; //Number of destination address digits (real length of TP-DA address string)
buf[3] = x91; //fixed: use the international format number
ndstlength+= gsmbytes2string (buf,&; pDst[nDstLength], 4); //Convert 4 bytes to the target PDU string
ndstlength+= gsminvertnumbers (PSRC->; TPA, & pDst[nDstLength], nLength); //Convert TP-DA to target PDU string
// TPDU segment protocol identification, coding mode, user information, etc
/p>//nLength = strlen(pSrc->->; TP_UD); //the length of the user information string
memset(buf, , sizeof(buf));
buf[] = pSrc-> TP_PID; //protocol identifier (TP-PID)
buf[1] = pSrc-> TP_DCS; //user information coding mode (TP-DCS)
buf[2] = 1; //the validity period (TP-VP) is 5 minutes
buf [3] = str2hex (user _ PDU, PSRC-> TP_UD); //length of user information
ndstlength+= gsmbytes2string (buf,&; pDst[nDstLength], 4); //convert this segment of data to the target PDU string
strcat(pdu, "\x1a "); //end with CTRL-A
p>gsmString2Bytes(pdu, & nSmscLength, 2); //take the length of SMSC information in PDU string
4 >; Length of message sent: AT+CMGS= length. If the important length is wrong, it cannot be sent out.
5> Sending user information
1. at present, Text and PDU(Protocol Data Unit) modes are commonly used to send short messages.
1> Using Text mode to send and receive short messages is simple and easy to implement, but the biggest disadvantage is that it can't send and receive Chinese short messages.
2> Using PDU mode can not only support Chinese short messages, but also send English short messages.
2. Three codes can be used to send and receive short messages in PDU mode:
1> 7-bit (used to send ordinary ASCII characters, which encodes a string of 7-bit characters (the highest bit is ) into 8-bit data, and every 8 characters can be "compressed" into 7)
2> 8-bit (usually used to send data messages, such as pictures, ringtones, etc.)
3> UCS2 encoding (used to send Unicode characters)
- Previous article:How to delete something wrong in the WeChat group?
- Next article:Rushan Vehicle Violation Inquiry Website
- Related articles
- An aunt in Northeast China scolded epidemic prevention personnel for being inferior to dogs. How to treat her behavior from a psychological point of view?
- Does Huawei mobile phone have handwriting function?
- Missed text messages
- The page of Sinopharm General Hospital is different from before. How did it become the old one?
- Gourmet sentences-make sentences with delicious food
- How to set information floating window for Samsung n9500
- How to find deleted messages on my mobile phone?
- Fujian Mobile
- There is always a message sign flashing on the mobile phone interface, but there is no message in the inbox. What is the reason?
- Which electronic contract platform is the best? Has anyone used it? Please recommend!