SIM800C模块应用Arduino 51单片机 STM32
软件例程源码资料合集:
1、Arduino例程
2、51单片机测试源码
3、STM32测试源码
4、Linux
5、PC端
6、Windows
01.STM32 拨打电话
02.STM32 发送短信
03.STM32 短信远程控制开关
04.STM32 TCP通信
GSM GPRS模块和STM32的连接方式.txt
01.STC89C52+SIM800C拨打电话
02.STC89C52+SIM800C发送短信
03.STC89C52+SIM800C接收短信控制开关
04.STC89C52+SIM800C TCP通信
GSM GPRS模块和51单片机接线方式.txt
void main()
{
Uart_Init();
if (sendCommand("AT\r\n", "OK\r\n", 3000, 10) == Success);
else errorLog();
delay_ms(10);
if (sendCommand("AT+CPIN?\r\n", "READY", 1000, 10) == Success);
else errorLog();
delay_ms(10);
phone(phoneNumber); //´òµç»°
while(1)
{
}
}
void phone(char *number)
{
char send_buf[20] = {0};
memset(send_buf, 0, 20); //Çå¿Õ
strcpy(send_buf, "ATD");
strcat(send_buf, number);
strcat(send_buf, ";\r\n");
if (sendCommand(send_buf, "OK\r\n", 10000, 10) == Success);
else errorLog();
}
void errorLog()
{
while (1)
{
if (sendCommand("AT\r\n", "OK\r\n", 100, 10) == Success)
{
soft_reset();
}
delay_ms(200);
}
}
void soft_reset(void) //ÖÆÔìÖØÆôÃüÁî
{
((void (code *) (void)) 0x0000) ();
}
unsigned int sendCommand(char *Command, char *Response, unsigned long Timeout, unsigned char Retry)
{
unsigned char n;
CLR_Buf();
for (n = 0; n < Retry; n++)
{
SendString(Command); //·¢ËÍGPRSÖ¸Áî
Time_Cont = 0;
while (Time_Cont < Timeout)
{
delay_ms(100);
Time_Cont += 100;
if (strstr(Rec_Buf, Response) != NULL)
{
CLR_Buf();
return Success;
}
}
Time_Cont = 0;
}
CLR_Buf();
return Failure;
}
//****************************************************
//MSÑÓʱº¯Êý(12M¾§ÕñϲâÊÔ)
//****************************************************
void delay_ms(unsigned int n)
{
unsigned int i,j;
for(i=0;i