博文EC200模块 设置新短信通知输出通道介绍了如何设置+CMTI指令。
使用sscanf和简化版的正则表达式,可以解析出存储位置(ME、SM)和所在的索引index。
#include <stdio.h>
#include <stdlib.h>
int main()
{
char ss[]="+CMTI: \"ME\",10";
char device[100];
int index=0;
sscanf(ss,"+CMTI: \"%[A-Z]\",%d",device,&index);
printf("%s\n",device);
printf("%d\n",index);
printf("Hello world!\n");
return 0;
}