AT sends variable SMS in stm32

Publisher:zhaodawei617Latest update time:2016-10-05 Source: eefocusKeywords:stm32 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
/******************** (C) COPYRIGHT 2015 **************************
 * 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************/
 
Keywords:stm32 Reference address:AT sends variable SMS in stm32

Previous article:stm32 i2C hardware driver ht16c22
Next article:RTC operation of stm32

Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号