标签:返回 bsp 网络状态 cmd 系统 event end 操作系统 ems
//任务处理函数
UINT16 GenericApp_ProcessEvent( byte task_id, UINT16 events )
{
//定义应用层数据包
afIncomingMSGPacket_t *MSGpkt;
//如果系统消息到来
if ( events & SYS_EVENT_MSG )
{
//接收数据包
MSGpkt = (afIncomingMSGPacket_t *)osal_msg_receive( GenericApp_TaskID );
//如果数据包不为空
while ( MSGpkt )
{
//判断消息类型
switch ( MSGpkt->hdr.event )
{
//处理在初始化中注册的消息
case ZDO_CB_MSG:
SAPI_ProcessZDOMsgs( (zdoIncomingMsg_t *)pMsg );
break;
//按键消息
case KEY_CHANGE:
//调用按键处理函数
GenericApp_HandleKeys( ((keyChange_t *)MSGpkt)->state, ((keyChange_t *)MSGpkt)->keys );
break;
//数据发送后返回信息处理函数
case AF_DATA_CONFIRM_CMD:
// This message is received as a confirmation of a data packet sent.
// The status is of ZStatus_t type [defined in ZComDef.h]
// The message fields are defined in AF.h
pDataConfirm = (afDataConfirm_t *) pMsg;
SAPI_SendDataConfirm( pDataConfirm->transID, pDataConfirm->hdr.status );
break;
//接收数据事件
case AF_INCOMING_MSG_CMD:
//调接收数据的处理函数
GenericApp_MessageMSGCB( MSGpkt );
break;
//网络状态发生变化事件
case ZDO_STATE_CHANGE:
//获取网络状态
GenericApp_NwkState = (devStates_t)(MSGpkt->hdr.status);
//判断网络类型
if ( (GenericApp_NwkState == DEV_ZB_COORD)
|| (GenericApp_NwkState == DEV_ROUTER)
|| (GenericApp_NwkState == DEV_END_DEVICE) )
{
}
break;
default:
break;
}
//释放存储区
osal_msg_deallocate( (uint8 *)MSGpkt );
//判断操作系统层是否有未处理的数据包,继续处理缓冲区中的包
MSGpkt = (afIncomingMSGPacket_t *)osal_msg_receive( GenericApp_TaskID );
}
// 返回未处理的任务
return (events ^ SYS_EVENT_MSG);
}
// Discard unknown events
return 0;
}
标签:返回 bsp 网络状态 cmd 系统 event end 操作系统 ems
原文地址:http://www.cnblogs.com/liushao/p/6351506.html