level 4
泽泽133
楼主
代码如下:
if ( events & SYS_EVENT_MSG )
{
MSGpkt = (afIncomingMSGPacket_t *)osal_msg_receive( GenericApp_TaskID );
while ( MSGpkt )
{
RLED = ~RLED;
switch ( MSGpkt->hdr.event )
{
case ZDO_CB_MSG:
GenericApp_ProcessZDOMsgs( (zdoIncomingMsg_t *)MSGpkt );
break;
case KEY_CHANGE:
// bangding();//允许绑定
service();//发送设备描述符
// GenericApp_HandleKeys( ((keyChange_t *)MSGpkt)->state, ((keyChange_t *)MSGpkt)->keys );
break;
// case CMD_SERIAL_MSG: //串口事件判断
// HalUARTWrite( HAL_UART_PORT_0,(MSGpkt->cmd).Data, (MSGpkt->cmd).DataLength);//将接收到的数打印到串口上
// break;
case MT_SYS_APP_MSG: // Z-Architect Messages 外部数据写到应用层
HalUARTWrite( HAL_UART_PORT_0,(MSGpkt->cmd).Data, (MSGpkt->cmd).DataLength);//将接收到的数打印到串口上
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
/*
这个消息被收到作为一个数据包发送的确认。
的目前状况ZStatus_t类型(定义在ZComDef.h]
消息字段AF.h中定义
*/
afDataConfirm = (afDataConfirm_t *)MSGpkt;
sentEP = afDataConfirm->endpoint;
sentStatus = afDataConfirm->hdr.status;
sentTransID = afDataConfirm->transID;
(void)sentEP;
(void)sentTransID;
// Action taken when confirmation is received.当确认收到采取行动。
if ( sentStatus != ZSuccess )
{
// The data wasn't delivered -- Do something
GLED=~GLED;
}
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) )
{
// Start sending "the" message in a regular interval.开始发送消息以一种固定的时间间隔。
osal_start_timerEx( GenericApp_TaskID,
GENERICAPP_SEND_MSG_EVT,
GENERICAPP_SEND_MSG_TIMEOUT );
}
break; default:
// RLED=~RLED;
break;
} // Release the memory
osal_msg_deallocate( (uint8 *)MSGpkt ); // Next
MSGpkt = (afIncomingMSGPacket_t *)osal_msg_receive( GenericApp_TaskID );
// GenericApp_SendTheMessage();
} // return unprocessed events
return (events ^ SYS_EVENT_MSG);
} // Send a message out - This event is generated by a timer
// (setup in GenericApp_Init()).
if( events & GENERICAPP_SEND_MSG_EVT )
2012年06月06日 00点06分
1
if ( events & SYS_EVENT_MSG )
{
MSGpkt = (afIncomingMSGPacket_t *)osal_msg_receive( GenericApp_TaskID );
while ( MSGpkt )
{
RLED = ~RLED;
switch ( MSGpkt->hdr.event )
{
case ZDO_CB_MSG:
GenericApp_ProcessZDOMsgs( (zdoIncomingMsg_t *)MSGpkt );
break;
case KEY_CHANGE:
// bangding();//允许绑定
service();//发送设备描述符
// GenericApp_HandleKeys( ((keyChange_t *)MSGpkt)->state, ((keyChange_t *)MSGpkt)->keys );
break;
// case CMD_SERIAL_MSG: //串口事件判断
// HalUARTWrite( HAL_UART_PORT_0,(MSGpkt->cmd).Data, (MSGpkt->cmd).DataLength);//将接收到的数打印到串口上
// break;
case MT_SYS_APP_MSG: // Z-Architect Messages 外部数据写到应用层
HalUARTWrite( HAL_UART_PORT_0,(MSGpkt->cmd).Data, (MSGpkt->cmd).DataLength);//将接收到的数打印到串口上
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
/*
这个消息被收到作为一个数据包发送的确认。
的目前状况ZStatus_t类型(定义在ZComDef.h]
消息字段AF.h中定义
*/
afDataConfirm = (afDataConfirm_t *)MSGpkt;
sentEP = afDataConfirm->endpoint;
sentStatus = afDataConfirm->hdr.status;
sentTransID = afDataConfirm->transID;
(void)sentEP;
(void)sentTransID;
// Action taken when confirmation is received.当确认收到采取行动。
if ( sentStatus != ZSuccess )
{
// The data wasn't delivered -- Do something
GLED=~GLED;
}
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) )
{
// Start sending "the" message in a regular interval.开始发送消息以一种固定的时间间隔。
osal_start_timerEx( GenericApp_TaskID,
GENERICAPP_SEND_MSG_EVT,
GENERICAPP_SEND_MSG_TIMEOUT );
}
break; default:
// RLED=~RLED;
break;
} // Release the memory
osal_msg_deallocate( (uint8 *)MSGpkt ); // Next
MSGpkt = (afIncomingMSGPacket_t *)osal_msg_receive( GenericApp_TaskID );
// GenericApp_SendTheMessage();
} // return unprocessed events
return (events ^ SYS_EVENT_MSG);
} // Send a message out - This event is generated by a timer
// (setup in GenericApp_Init()).
if( events & GENERICAPP_SEND_MSG_EVT )