Overview
With the encapsulation capability of QuecPython, developers can quickly implement SMS sending and receiving functions without dealing with complex AT commands. In the REPL interactive environment, SMS sending can be completed with just one line of code, making IoT communication development more efficient!
Core Advantages
- Minimalist Call: Send SMS directly with sms.sendTextMsg("xxxxxxxxxxx", "HelloQuecPython!")
- Instant Send and Test: Real-time execution in the REPL environment for quick verification of SMS functions
- Full Support: Easily implement SMS sending, receiving, deletion and other operations
Function Introduction
Send SMS
TEXT Message
This method is used to send TEXT type messages (empty SMS is not supported).
sms.sendTextMsg(phoneNumber, msg, codeMode)
For API details, please refer to sms.sendTextMsg.
PDU Message
This method is used to send PDU type messages (empty SMS is not supported).
sms.sendPduMsg(phoneNumber, msg, codeMode)
For API details, please refer to sms.sendPduMsg.
Delete SMS
This method is used to delete the message at the specified index.
sms.deleteMsg(index [, delmode])
For API details, please refer to sms.deleteMsg.
Get SMS Quantity
This method is used to get the number of SMS messages.
sms.getMsgNums()
For API details, please refer to sms.getMsgNums.
Get SMS Content
TEXT Mode
This method is used to get SMS content in TEXT mode.
sms.searchTextMsg(index)
For API details, please refer to sms.searchTextMsg.
PDU Mode
This method is used to get SMS content in PDU mode.
sms.searchPduMsg(index)
For API details, please refer to sms.searchPduMsg.
SMS Decoding
Length Decoding
This method is used to get the length of the specified PDU SMS.
sms.getPduLength(pduMsg)
For API details, please refer to sms.getPduLength.
Content Decoding
This method is used for PDU decoding, which parses the PDU data read by the sms.searchPduMsg() interface.
sms.decodePdu(pduMsg, pduLen)
For API details, please refer to sms.decodePdu.
## Application Example
Use the SMS function of the QuecPython series development board to send and receive SMS with a mobile phone.
import sms
sms.deleteMsg(1,4) # Delete all SMS messages
Fill in the correct phone number
sms.sendTextMsg('xxxxxxxxxxx', 'Hello, world.', 'GSM') # Send SMS to the mobile phone
Get SMS content in TEXT mode
sms.searchTextMsg(0) # Receive SMS sent by the mobile phone
This article was originally published by DEV Community and written by QuecPython.
Read original article on DEV Community