📄 gprs_cmd.c
字号:
#include <cdefBF533.h>
#include <ccblkfn.h>
#include <string.h>
#include "core_timer.h"
//#include "sms.h"
#include "dsp_uart.h"
#include "dsp_sys.h"
char null[] = "";
#define ATI 0
#define AT 1
int comm_cmd(char* cmd_buf, int type)
{
int wait, retry = 3;
char buf[100], *p;
int time, wait_time = 20;
int ret;
strcpy(buf, "at");
if(type == ATI)
strcat(buf, "+i");
else if(cmd_buf[0])
strcat(buf, "+");
strcat(buf, cmd_buf);
strcat(buf, "\r");
while(retry--)
{
memset(uart_recv_buffer, 0, RECEIVE_NUM);
uart_recved_cnt = 0;
//send the buffer through uart
uart_send((unsigned char*)buf, strlen(buf));
time = ctime;
while(ctime - time < wait_time)
{
wd();
if(p = strstr(uart_recv_buffer, "ERROR"))
{
if(strstr(p, "\r"))
break;
else
continue;
}
if(p = strstr(uart_recv_buffer, "OK"))
{
if(strstr(p, "\r"))
return 0;
else
continue;
}
}
}
return -1;//error
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -