我是土匪
发表于 2015-10-21 09:30
来与君 发表于 2015-10-20 22:59
100楼是我的……
不知不觉100楼了,感谢大家支持。
会继续更新。
下一篇章短信,酝酿之中。
cliffboy
发表于 2015-10-26 15:31
其实硬件层面需要考虑的东西也很多
shine_21
发表于 2015-10-29 17:45
楼主太强大了,赞一个。坐等楼主
s976228410
发表于 2015-10-29 17:54
顶楼主
我是土匪
发表于 2015-11-2 15:28
这几天赶项目,本周末会更新短信部分。感谢支持!
whyil
发表于 2015-11-2 21:53
顶楼主,好东西,没找到过这么详细的GPRS模块的用法过。
andy93762
发表于 2015-11-10 10:04
楼主继续更新啊
我是土匪
发表于 2015-11-11 15:41
andy93762 发表于 2015-11-10 10:04
楼主继续更新啊
抱歉,这几天在赶项目,明天就有时间了。
抱歉
icword91
发表于 2015-11-11 16:51
看得清楚不是很明白
jhycl
发表于 2015-11-17 14:11
MARK
我是土匪
发表于 2015-11-17 16:26
icword91 发表于 2015-11-11 16:51
看得清楚不是很明白
不清楚的地方可以交流。
交流才有提高。
zhangweiyun
发表于 2015-11-17 22:09
厉害啊 学习了
mei326
发表于 2015-11-20 15:26
好贴,持续关注@最近也在玩这块,看到SIM900A要停产了,好像是用SIM800C全面替换,想到既然是玩,就玩个高档点的模块,用了最新的主推的SIM7100C。不过都是英文资料,看着头大,还是参考SIM900A在进行调试,中文短信这块还没调好;期待楼主把短信这块详细讲解,如文本模式下英文、中文短信,PDU模式下短信等等,期待!
HTTP模式通信,是我主要需要调试的,期待
我是土匪
发表于 2015-11-24 14:15
icword91 发表于 2015-11-23 14:20
很多都在用合方圆GU900E在替代sim900A使用,功能更加全面速度更快,功耗更低,性能更加稳定。建议可以尝 ...
与其绞尽脑子在营销上设局,不如踏踏实实做好产品,好产品靠的是口碑相传。
我是土匪
发表于 2015-11-24 17:17
第五章短信
短信这里分几个部分:如何发送英文短信?如何发送中文短信?文本模式和PDU的区别?如何处理长短信?1\参照SIM900A_AT命令手册_V1.05(中文) P223,短信命令部分。AT+CMGF=1
OKAT+CSCS="GSM"
OKAT+CMGS="1358888××××"
> HELLO ,HERO!
> +CMGS: 158
OK
至此,英文短信搞定!
2\那么,中文短信如何处理?Baidu一下,很多**介绍都说,文本模式不能发送中文,果真吗?看下面:at+csmp=17,167,2,25
OKat+cscs="UCS2"
OKat+CMGS="0031003300350038003800380038003X003X003X003X"
> 4F604F1A6210529F
> +CMGS: 159
OK替换成自己要发的短信内容和号码。文本方式下,中文搞定!短信号码和发送的中文内容,经过“文本与unicode码转换小工具”转换,该软件很容易下载到。3\至此,中英文均可以采用文本方式发送,那么PDU和文本的最大区别在哪?什么时候使用PDU方式??土匪对短信没有深层次的研究,目的就是能利用模块,实现常见短信的应用,经过测试发现,在处理长短信的时候选择PDU方式。
我是土匪
发表于 2015-11-24 17:20
mei326 发表于 2015-11-20 15:26
好贴,持续关注@最近也在玩这块,看到SIM900A要停产了,好像是用SIM800C全面替换,想到既然是玩,就玩个高 ...
欢迎支持。
目前短信只做了长短信的解析,没有做发送,这部分这几天测试下。
我是土匪
发表于 2015-12-2 11:09
上传官方提供的二次开发部分关于短信的demo:
#define STR_CME_EER "+CME ERROR:"
#define STR_ERR "ERROR"
#define STR_OK "OK"
#define STR_INPUT ">"
#define SEND_OK "CMGS"
#define FL_END 100
#define MAX_AT_LEN 100
#define MAX_DATALEN 200
typedef enum ATCmdTypTag
{
AT_NULL=0,
AT_TEST,
AT_READ,
AT_WRITE,
AT_EXECUT,
AT_ELSE
}ATCmdTyp;
typedef enum ResTag
{
RES_OK, // AT command response is OK
RES_ERROR,
RES_ELSE
}t_res;
typedef struct CurcmdTag
{
ascii cmd_string;
u8 cmd_type;
} t_curcmd;
typedef s8(*fl_cmdhandle)(u8 *data,t_curcmd *curcmd);
typedef struct attab
{
u8* cmd;
fl_cmdhandle hd;
}t_attab;
voidclearcmd(t_curcmd *cmd);
static s8 updatecmd(u8 *cmddata, t_curcmd *cmd, ATCmdTyp cmdtype);
FlEventBuffer __align__ flEventBuffer;
FlEventBuffer __align__ flEventBufferM1;
FlEventBuffer __align__ flEventBufferM2;
FlEventBuffer __align__ flEventBufferM3;
FlEventBuffer __align__ flEventBufferM4;
FlEventBuffer __align__ flEventBufferM5;
extern void waitForSysInt(void);
extern void fl_MultiTaskPrio1(void);
extern void fl_MultiTaskPrio2(void);
extern void fl_MultiTaskPrio3(void);
extern void fl_MultiTaskPrio4(void);
extern void fl_MultiTaskPrio5(void);
/** Init function */
fl_task_entry fl_init = waitForSysInt;
/** Entry functions */
fl_task_entry fl_entries[] = { fl_MultiTaskPrio1, fl_MultiTaskPrio2, fl_MultiTaskPrio3, fl_MultiTaskPrio4, fl_MultiTaskPrio5, NULL };
/
我是土匪
发表于 2015-12-2 11:10
/*******************************************************************************
* Function:CHECK_OK
* Description: check the return value of AT command.
*******************************************************************************/
static s8 CHECK_OK(u8 *data, t_curcmd *curcmd)
{
s8 *p1=NULL;
s8 *p2=NULL;
p1 = (s8 *)strstr((const char *)data,STR_OK);
p2 = (s8 *)strstr((const char *)data,STR_ERR);
/*return OK*/
if(NULL != p1)
{
return RES_OK;
}
/*return ERROR*/
if(NULL != p2)
{
return RES_ERROR;
}
return RES_ELSE;
}
/*******************************************************************************
* Function:CHECK_CMGF
* Description: check the return value of AT+CMGF commandfrom modem, if the value is correct,
do the following tasks.
*******************************************************************************/
static s8 CHECK_CMGF(u8 *data, t_curcmd *curcmd)
{
s8 checkok=RES_ERROR;
checkok=CHECK_OK(data,curcmd);
switch (checkok)
{
case RES_OK:
{
updatecmd((u8*)"AT+CSCS\r", curcmd,AT_WRITE);
ebdat9_01SendToModem((u8*)"AT+CSCS=\"UCS2\"\r", sizeof("AT+CSCS=\"UCS2\"\r"));
return RES_OK;
}
case RES_ERROR:
return RES_ERROR;
case RES_ELSE:
return RES_ELSE;
}
return FL_ERROR;
}
/*******************************************************************************
* Function:CHECK_CSCS
* Description: check the return value of AT+CSCS commandfrom modem, if the value is correct,
do the following tasks.
*******************************************************************************/
static s8 CHECK_CSCS(u8 *data, t_curcmd *curcmd)
{
s8 checkok=RES_ERROR;
checkok=CHECK_OK(data,curcmd);
switch (checkok)
{
case RES_OK:
{
updatecmd((u8*)"AT+CSMP\r", curcmd,AT_WRITE);
ebdat9_01SendToModem((u8*)"AT+CSMP=17,167,0,25\r", sizeof("AT+CSMP=17,167,0,25\r"));
return RES_OK;
}
case RES_ERROR:
return RES_ERROR;
case RES_ELSE:
return RES_ELSE;
}
return FL_ERROR;
}
/*******************************************************************************
* Function:CHECK_CSMP
* Description: check the return value of AT+CSMP commandfrom modem, if the value is correct,
do the following tasks.
*******************************************************************************/
static s8 CHECK_CSMP(u8 *data, t_curcmd *curcmd)
{
s8 checkok=RES_ERROR;
checkok=CHECK_OK(data,curcmd);
switch (checkok)
{
case RES_OK:
{
updatecmd((u8*)"AT+CMGS\r",curcmd,AT_WRITE);
/*please input your own cell number!*/
ebdat9_01SendToModem((u8*)"AT+CMGS=\"00310035003800300030003800300036003100300030\"\r",\
sizeof("AT+CMGS=\"00310035003800300030003800300036003100300030\"\r"));
return RES_OK;
}
case RES_ERROR:
return RES_ERROR;
case RES_ELSE:
return RES_ELSE;
}
return FL_ERROR;
}
/*******************************************************************************
* Function:CHECK_CSGS
* Description: check the return value of sms send command, if the return value contains"CMGS",
it indicates that the msg is sent to the destination successfully.
*******************************************************************************/
static s8 CHECK_CMGS(u8 *data, t_curcmd *curcmd)
{
s8 *pKey=NULL;
pKey = (s8*)strstr((const char *)data,STR_INPUT);
if(NULL != pKey)
{
updatecmd((u8*)">\r",curcmd,AT_ELSE);
ebdat9_01SendToModem((u8*)"4F60597D\x1a\r", sizeof("4F60597D\x1a\r"));
return RES_OK;
}
pKey = (s8*)strstr((const char *)data,STR_ERR);
if(NULL != pKey)
{
return RES_ERROR;
}
return FL_ERROR;
}
/*******************************************************************************
* Function: CHECK_RESULT
* Description: check the return value of sms send command, if the return value contains"CMGS",
it indicates that the msg is sent to the destination successfully.
*******************************************************************************/
static s8 CHECK_RESULT(u8 *data, t_curcmd *curcmd)
{
s8 *pKey=NULL;
pKey = (s8*)strstr((const char *)data,SEND_OK);
if(NULL != pKey)
{
ebdat7_01DebugTrace("***SMS SEND OK!!!***");
return RES_OK;
}
pKey = (s8*)strstr((const char *)data,STR_OK);
if(NULL != pKey)
{
curcmd->cmd_string=0;
curcmd->cmd_type=AT_NULL;
ebdat7_01DebugTrace("***SMS SEND OVER!!!***");
return FL_END;
}
pKey = (s8*)strstr((const char *)data,STR_ERR);
if(NULL != pKey)
{
ebdat7_01DebugTrace("***SMS SEND ERROR!!!***");
return RES_ERROR;
}
return FL_ERROR;
}
/*init tab of AT command*/
t_attab attab[] = {
{(u8*)"AT+CMGF",CHECK_CMGF},
{(u8*)"AT+CSCS",CHECK_CSCS},
{(u8*)"AT+CSMP",CHECK_CSMP},
{(u8*)"AT+CMGS",CHECK_CMGS},
{(u8*)">",CHECK_RESULT},
};
/*******************************************************************************
* Function:clearcmd
* Description: clear the flcurcmd table.
*******************************************************************************/
voidclearcmd(t_curcmd *cmd)
{
/*set 0*/
memset(cmd->cmd_string,0,MAX_AT_LEN);
cmd->cmd_type=AT_NULL;
}
/*******************************************************************************
* Function:updatecmd
* Description: update the flcurcmd table, make sure it contains the latest command to be exauted.
*******************************************************************************/
static s8 updatecmd(u8 *cmddata, t_curcmd *cmd, ATCmdTyp cmdtype)
{
char *p1 = NULL;
char *p2 = NULL;
/*check the input parameter*/
if((NULL == cmd)||(NULL == cmddata))
{
return FL_ERROR;
}
clearcmd(cmd);
p1 = (char*)cmddata;
p2 = strchr((const char *)cmddata,0x0D);
memcpy(cmd->cmd_string,p1,p2-p1);
cmd->cmd_type=cmdtype;
return FL_OK;
}
/***************************************************************************
*Function: fl_entry
*Object: Customer application
*Variable Name |IN |OUT|GLB|Utilisation
*
****************************************************************************/
void fl_entry()
{
boolkeepGoing = TRUE;
u32 para1;
u16 i;
s8 result=-2;
t_curcmd *flcurcmd;
flcurcmd = ebdat4_01GetMemory(sizeof(t_curcmd ));
if( NULL== flcurcmd)
{
ebdat7_01DebugTrace("ALLOCATE MEMORY FAILED");
}
/*INIT currentcmd table*/
clearcmd(flcurcmd);
/* Echo mode off*/
ebdat9_01SendToModem((u8*)"ATE0\r",strlen("ATE0\r"));
ebdat7_00EnterDebugMode();
while (keepGoing == TRUE)
{
memset((u8*)&flEventBuffer,0x00,sizeof(flEventBuffer));
eat1_02GetEvent(&flEventBuffer);
switch(flEventBuffer.eventTyp)
{
case EVENT_MODEMDATA:
{
if( MODEM_CRWP == flEventBuffer.eventData.modemdata_evt.type )
{
flEventBuffer.eventData.modemdata_evt.data = 0;
/*get AT+CRWP parameters */
i = sscanf((const char *)flEventBuffer.eventData.modemdata_evt.data, "AT+CRWP=%d",¶1);
/*execute AT+CRWP=1to trigger sms sending function.*/
if( para1 == 1 )
{
/*note the first AT command*/
updatecmd((u8*)"AT+CMGF\r", flcurcmd,AT_WRITE);
/*sends the output data from core to embedded application*/
ebdat9_03SetModemdataToFL(TRUE);
ebdat9_01SendToModem((u8*)"AT+CMGF=1\r", sizeof("AT+CMGF=1\r"));
}
}
if( MODEM_CMD == flEventBuffer.eventData.modemdata_evt.type )
{
if(AT_NULL != flcurcmd->cmd_type)
{
/*find the AT COMMAND from mytab*/
for(i = 0;i< (sizeof(attab)/sizeof(t_attab));i++)
{
if(strcmp((const char*)flcurcmd->cmd_string,(const char*)attab.cmd) == 0)
{
/*compare the current command to attab*/
result = attab.hd((u8 *)flEventBuffer.eventData.modemdata_evt.data,flcurcmd); //核心部分
if( RES_OK == result )
{
ebdat7_01DebugTrace("OK\r\n");
}
if( FL_END == result )
{
ebdat9_03SetModemdataToFL(FALSE);
}
if( RES_ERROR == result )
{
ebdat7_01DebugTrace("%s command return ERROR!",flcurcmd->cmd_string);
/*clean the flcurcmd*/
clearcmd(flcurcmd);
ebdat9_03SetModemdataToFL(FALSE);
}
if( RES_ELSE == result )
{
ebdat7_01DebugTrace("UNKNOW RES ");
ebdat9_02SendToSerialPort((char * )flEventBuffer.eventData.modemdata_evt.data,\
flEventBuffer.eventData.modemdata_evt.length);
break;
}
/*ERROR occurs in the flow*/
if( FL_ERROR == result )
{
ebdat7_01DebugTrace("flow ERROR in %s",flcurcmd->cmd_string );
/*clean the flcurcmd*/
clearcmd(flcurcmd);
/*sends the output data from core to the port directly*/
ebdat9_03SetModemdataToFL(FALSE);
}
break;
}
}
}
else
{
/*sends string to serial port*/
ebdat9_02SendToSerialPort((char * )flEventBuffer.eventData.modemdata_evt.data,\
flEventBuffer.eventData.modemdata_evt.length);
}
}
else
{
;
}
}
break;
case EVENT_UARTDATA:
break;
case EVENT_INTR:
break;
case EVENT_SERAILSTATUS:
break;
case EVENT_TIMER:
break;
default:
break;
}
}
}
我是土匪
发表于 2015-12-2 11:34
简单描述一下:
通过外部串口AT+CRWP命令触发发送短信操作。
我是土匪
发表于 2015-12-2 11:42
提供一些标准接口函数:
bool gsm7BitConvertIRA(const u8 *gsmData, u16 gsmLen, u8 *iraData, u16 *iraLen, bool dropInconvertible)
{
bool result = TRUE;
u8 IraValue = 0;
u16 i = 0;
*iraLen = 0;
for (i = 0; i < gsmLen;i++)
{
if (IS_EXT_GSM(*gsmData))
{
/* 0x1B: GSM 03.38Extension character */
gsmData++;
i++;
IraValue = ext_gsm7_to_ira[*gsmData++];
}
else
{
IraValue = gsm7_to_ira[*gsmData++];
}
if(IraValue != INVALID_CHAR)
{
*iraData++ = IraValue;
}
else if (!dropInconvertible)
{
result = FALSE;
break;
}
else
{
*iraData++ = REPLACEMENT_CHAR;
}
(*iraLen)++;
}
*iraData = '\0';
return result;
}