data: sms text data
len: sms data length,
if dcs=7-bit or 8-bit, is the bytes length,
if dcs=UCS2,is the unicode length
dcs: refer oa_smsal_dcs_enum
RETURN:
OA_TRUE: the sms be handled by openat user, and will be be saved
OA_FALSE:the sms is not openat user cared
******************************************************************/
oa_bool oa_sms_rcv_ind_handler(oa_char * deliver_num, oa_char * timestamp, oa_uint8 * data, oa_uint16 len, oa_smsal_dcs_enum dcs)
{
OA_DEBUG_USER("SMS received:deliver_num=%s,timestamp=%d-%d-%d-%d:%d:%d,dcs=%d,len=%d,data=%s",\
deliver_num,*(timestamp+0),*(timestamp+1),*(timestamp+2),*(timestamp+3),*(timestamp+4),*(timestamp+5),dcs,len,data);
if(dcs == OA_SMSAL_DEFAULT_DCS)
{
/*handle ascii sms text. 7bit英文*/
}
else if(dcs == OA_SMSAL_UCS2_DCS)
{
/*handle unicode sms text. 中文*/
}
else
{
/*handle 8-bit sms text 16进制.*/
}
return OA_TRUE;/*delete current SMS from memory*/
//return OA_FALSE;/*do not delete this SMS, user can handle it*/
/*Warning: if user return OA_FALSE to save current sms in memory,
he should pay attention to the memory capacity.
Please use at+cpms to confirm current memory capacity and, when the memory is full,
user will receive AT command response "+OPENAT: SMS FULL" from PS port
and system will clean all the SMS in order to receive more SMS.*/
}
/************************/
GPRS 系统消息的处理
//Socket Notify Event indication handler framework
void oa_soc_notify_ind(void *inMsg)
{
oa_int32 ret = 0;
oa_app_soc_notify_ind_struct *soc_notify = (oa_app_soc_notify_ind_struct*) inMsg;
//if other application's socket id, ignore it.
if(soc_notify->socket_id != g_soc_context.socket_id)
{
GPRS_DEBUG("%s:sock_id=%d unknow, event_type=%d!",__func__,soc_notify->socket_id,soc_notify->event_type);
return;
}
switch (soc_notify->event_type)
{
case OA_SOC_WRITE:
{
/* Notify for send data*/
if (soc_notify->result == OA_TRUE)
{
g_soc_context.is_blocksend = OA_FALSE;
//resend the data ,else will lost data
GPRS_DEBUG("%s:sock_id=%d resend!",__func__,soc_notify->socket_id);
oa_soc_send_req( );
}
else
{
GPRS_DEBUG("%s:sock_id=%d send fail err=%d!",__func__,soc_notify->socket_id,soc_notify->error_cause);
oa_soc_close_req( );
}
break;
}
case OA_SOC_READ:
{
/* Notify for received data */
if (soc_notify->result == OA_TRUE)
{
do
{
oa_memset(gprs_rx_buffer, 0 , (OA_MAX_SOC_RCV_BUFLEN*sizeof(oa_uint8)));
//received gprs data, read data for protocol
ret = oa_soc_recv(soc_notify->socket_id , (oa_uint8*)gprs_rx_buffer, OA_MAX_SOC_RCV_BUFLEN, 0);
GPRS_DEBUG("%s:sock_id=%d read ok ret=%d!",__func__,soc_notify->socket_id,ret);
if(ret > 0)
{
// read data length=ret,
oa_soc_gprs_recv((oa_uint8*)gprs_rx_buffer, ret);
}
else
{
//read data error or block
}
}while(ret>0); //Make sure use do{...}while to read out all received data.
}
else
{
GPRS_DEBUG("%s:sock_id=%d read fail err=%d!",__func__,soc_notify->socket_id,soc_notify->error_cause);
oa_soc_close_req( );
}
break;
}
case OA_SOC_CONNECT:
{
if (soc_notify->result == OA_TRUE)
{
GPRS_DEBUG("%s:sock_id=%d connect ok!",__func__,soc_notify->socket_id);
//if connect OK, goto query gprs_tx data and send
oa_sleep(100); //just connected need delay 100ms then send gprs data, else may lost data