/******************** (C) COPYRIGHT 2015 **************************
Keywords:stm32
Reference address:AT sends variable SMS in stm32
* File name: main.c
* Description: Usage: p is the content of the SMS to be sent
* center is the SMS center of the mobile phone card
* tel is the mobile phone number to be sent
* The serial port will print the contents of AT operation
**********************************************************************************/
#include "stm32f10x.h"
#include "usart1.h"
#include "wchar.h"
#include
/*
* Function name: main
* Description: Main function
* Input: None
* Output: None
*/
//0891683110101605F011000D91687100275510F0000800
//pdu mode data:0891683108200205F031000D91683157121468F00008AA 04 4F60597D
//0891
//683108200205F0
//31----------TPDU header
//00
//0D
//91
//683157121468F0
//00----------Protocol identifier
//08----------Coding scheme 08 is Chinese code 00 is English or number
//AA----------Validity period
//04----------User data length Divide the user data length by 2 and format it into a 2-digit hexadecimal number.
//4F60597D
u8 messageContent[500];
u16 ATCMGSLen = 0;
//SMS content length:
u16 MessageLen = 0;
u16 ContentLen = 0;
int main(void)
{
int i = 0;
//This can be flexibly configured
wchar_t p[] = L"Alarm: Abnormal temperature and humidity of vehicle-mounted equipment 00002: Current time: 14:59:00, October 16, 2014, temperature: +23.3℃, humidity: 73.2%RH.";
//The SMS center needs to obtain it from the mobile phone card
u8 center[] = "3110101605F0";
//Mobile phone number needs to be set
u8 tel[] = "7100275510F0";
//Basic configuration of serial port IO
USART1_Config();
ATCMGSLen += strlen("11000D91");
ATCMGSLen += 14;
ATCMGSLen += strlen("000800");
ATCMGSLen += 2;
MessageLen = (sizeof(p)/sizeof(wchar_t) - 1) * 4;
strncpy(&messageContent[0],"0891683110101605F0",strlen("0891683110101605F0"));
strncpy(&messageContent[0],"089168",strlen("089168"));
strncpy(&messageContent[0 + strlen("089168")],center,strlen(center));
strncpy(&messageContent[0 + strlen("0891683110101605F0")],"11000D9168",strlen("11000D9168"));
strncpy(&messageContent[0 + strlen("0891683110101605F0") + strlen("11000D9168")],tel,strlen(tel));
strncpy(&messageContent[0 + strlen("0891683110101605F0") + strlen("11000D9168") + strlen("7100275510F0")],
"000800",strlen("000800"));
ATCMGSLen += MessageLen;
ATCMGSLen = ATCMGSLen/2;
ContentLen = MessageLen / 2;
sprintf(&messageContent[0 + strlen("0891683110101605F0") + strlen("11000D9168") + strlen("7100275510F0") + strlen("000800")],
"%02x",ContentLen);
{
int len = strlen("0891683110101605F0") + strlen("11000D9168") + strlen("7100275510F0") + strlen("000800") + 2;
for(i = 0; i < sizeof(p)/sizeof(wchar_t) - 1 ; i ++)
sprintf(&messageContent[len + i * 4],"%04x",p[i]);
}
printf(" AT+CMGS=%d\r\n",ATCMGSLen);
printf("%s\r\n",messageContent);
for(;;)
{
}
}
/******************* (C) COPYRIGHT 2015 *****END OF FILE************/
Previous article:stm32 i2C hardware driver ht16c22
Next article:RTC operation of stm32
- Popular Resources
- Popular amplifiers
Recommended Content
Latest Microcontroller Articles
He Limin Column
Microcontroller and Embedded Systems Bible
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
MoreSelected Circuit Diagrams
MorePopular Articles
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
MoreDaily News
- Huawei's Strategic Department Director Gai Gang: The cumulative installed base of open source Euler operating system exceeds 10 million sets
- Download from the Internet--ARM Getting Started Notes
- Learn ARM development(22)
- Learn ARM development(21)
- Learn ARM development(20)
- Learn ARM development(19)
- Learn ARM development(14)
- Learn ARM development(15)
- Analysis of the application of several common contact parts in high-voltage connectors of new energy vehicles
- Wiring harness durability test and contact voltage drop test method
Guess you like
- A novice asks for advice on the MSP430 interrupt flag PxIFG
- ST MEMS sensor official Chinese technical documentation summary (continuously updated)
- What is 5G Super Uplink?
- Outsourcing of small brushless sensor driver
- Single-ended forward converter
- Bootloader issue of CH579
- SPI to USB CDC
- Battery Pack SOC
- Strange phenomenon of screen display and USB!
- 【Portable programmable instrument】Begin preparation for debugging