zigbee按键扫描
2017-06-15 18:25
330 查看
/*********************************************************************
* @fn SerialApp_ProcessEvent
*
* @brief Generic Application Task event processor.
*
* @param task_id - The OSAL assigned task ID.
* @param events - Bit map of events to process.
*
* @return Event flags of all unprocessed events.
*/
UINT16 SerialApp_ProcessEvent( uint8 task_id, UINT16 events )
{
(void)task_id; // Intentionally unreferenced parameter
if ( events & SYS_EVENT_MSG )
{
afIncomingMSGPacket_t *MSGpkt;
while ( (MSGpkt = (afIncomingMSGPacket_t *)osal_msg_receive( SerialApp_TaskID )) )
{
switch ( MSGpkt->hdr.event )
{
case KEY_CHANGE:
SampleApp_HandleKeys( ((keyChange_t *)MSGpkt)->state, ((keyChange_t *)MSGpkt)->keys );
break;
case AF_INCOMING_MSG_CMD:
SerialApp_ProcessMSGCmd( MSGpkt );
break;
case ZDO_STATE_CHANGE:
SampleApp_NwkState = (devStates_t)(MSGpkt->hdr.status);
if ( (SampleApp_NwkState == DEV_ZB_COORD)
|| (SampleApp_NwkState == DEV_ROUTER)
|| (SampleApp_NwkState == DEV_END_DEVICE) )
{
// Start sending the periodic message in a regular interval.
HalLedSet(HAL_LED_1, HAL_LED_MODE_ON);
if(SampleApp_NwkState != DEV_ZB_COORD)
SerialApp_DeviceConnect();
}
else
{
// Device is no longer in the network
}
break;
default:
break;
}
osal_msg_deallocate( (uint8 *)MSGpkt );
}
return ( events ^ SYS_EVENT_MSG );
}
if ( events & SERIALAPP_SEND_EVT )
{
SerialApp_Send();
return ( events ^ SERIALAPP_SEND_EVT );
}
if ( events & SERIALAPP_RESP_EVT )
{
SerialApp_Resp();
return ( events ^ SERIALAPP_RESP_EVT );
}
return ( 0 ); // Discard unknown events.
}
void SampleApp_HandleKeys( uint8 shift, uint8 keys )
{
(void)shift; // Intentionally unreferenced parameter
if ( keys & HAL_KEY_SW_6 )
{
//#if defined(ZDO_COORDINATOR) //协调器只接收数据
//SampleApp_SendPeriodicMessage(); //以组播方式发数据
//#else //路由器和终端才发送数据
//#endif
HalLcdWriteString( "1111: ", HAL_LCD_LINE_1 );
}
if ( keys & HAL_KEY_SW_1 )
{
HalLcdWriteString( "2222: ", HAL_LCD_LINE_1 );
/* The Flashr Command is sent to Group 1.
* This key toggles this device in and out of group 1.
* If this device doesn't belong to group 1, this application
* will not receive the Flash command sent to group 1.
*/
//aps_Group_t *grp;
//grp = aps_FindGroup( SAMPLEAPP_ENDPOINT, SAMPLEAPP_FLASH_GROUP );
//if ( grp )
//{
// Remove from the group
// aps_RemoveGroup( SAMPLEAPP_ENDPOINT, SAMPLEAPP_FLASH_GROUP );
//}
//else
//{
// Add to the flash group
// aps_AddGroup( SAMPLEAPP_ENDPOINT, &SampleApp_Group );
//}
}
}
* @fn SerialApp_ProcessEvent
*
* @brief Generic Application Task event processor.
*
* @param task_id - The OSAL assigned task ID.
* @param events - Bit map of events to process.
*
* @return Event flags of all unprocessed events.
*/
UINT16 SerialApp_ProcessEvent( uint8 task_id, UINT16 events )
{
(void)task_id; // Intentionally unreferenced parameter
if ( events & SYS_EVENT_MSG )
{
afIncomingMSGPacket_t *MSGpkt;
while ( (MSGpkt = (afIncomingMSGPacket_t *)osal_msg_receive( SerialApp_TaskID )) )
{
switch ( MSGpkt->hdr.event )
{
case KEY_CHANGE:
SampleApp_HandleKeys( ((keyChange_t *)MSGpkt)->state, ((keyChange_t *)MSGpkt)->keys );
break;
case AF_INCOMING_MSG_CMD:
SerialApp_ProcessMSGCmd( MSGpkt );
break;
case ZDO_STATE_CHANGE:
SampleApp_NwkState = (devStates_t)(MSGpkt->hdr.status);
if ( (SampleApp_NwkState == DEV_ZB_COORD)
|| (SampleApp_NwkState == DEV_ROUTER)
|| (SampleApp_NwkState == DEV_END_DEVICE) )
{
// Start sending the periodic message in a regular interval.
HalLedSet(HAL_LED_1, HAL_LED_MODE_ON);
if(SampleApp_NwkState != DEV_ZB_COORD)
SerialApp_DeviceConnect();
}
else
{
// Device is no longer in the network
}
break;
default:
break;
}
osal_msg_deallocate( (uint8 *)MSGpkt );
}
return ( events ^ SYS_EVENT_MSG );
}
if ( events & SERIALAPP_SEND_EVT )
{
SerialApp_Send();
return ( events ^ SERIALAPP_SEND_EVT );
}
if ( events & SERIALAPP_RESP_EVT )
{
SerialApp_Resp();
return ( events ^ SERIALAPP_RESP_EVT );
}
return ( 0 ); // Discard unknown events.
}
void SampleApp_HandleKeys( uint8 shift, uint8 keys )
{
(void)shift; // Intentionally unreferenced parameter
if ( keys & HAL_KEY_SW_6 )
{
//#if defined(ZDO_COORDINATOR) //协调器只接收数据
//SampleApp_SendPeriodicMessage(); //以组播方式发数据
//#else //路由器和终端才发送数据
//#endif
HalLcdWriteString( "1111: ", HAL_LCD_LINE_1 );
}
if ( keys & HAL_KEY_SW_1 )
{
HalLcdWriteString( "2222: ", HAL_LCD_LINE_1 );
/* The Flashr Command is sent to Group 1.
* This key toggles this device in and out of group 1.
* If this device doesn't belong to group 1, this application
* will not receive the Flash command sent to group 1.
*/
//aps_Group_t *grp;
//grp = aps_FindGroup( SAMPLEAPP_ENDPOINT, SAMPLEAPP_FLASH_GROUP );
//if ( grp )
//{
// Remove from the group
// aps_RemoveGroup( SAMPLEAPP_ENDPOINT, SAMPLEAPP_FLASH_GROUP );
//}
//else
//{
// Add to the flash group
// aps_AddGroup( SAMPLEAPP_ENDPOINT, &SampleApp_Group );
//}
}
}
相关文章推荐
- 新型的按键扫描程序
- 单片机开发——独立按键的扫描
- 正点原子标准例程-库函数版本——触摸按键扫描函数u8 TP_Scan(u8 tp)交流
- 基于VHDL的按键扫描程序
- zigbee按键
- zigbee学习:示例程序SampleApp中按键工作流程
- ZiGbee CC2530 OSAL系统 按键事件讲解
- 矩阵按键扫描
- platform设备驱动之按键扫描(cdev设备)
- 嵌入式成长轨迹35 【Zigbee项目】【单片机基础】【按键】
- 单片机按键扫描
- 经典按键扫描算法理解
- 新型按键扫描程序
- 按键扫描1
- 3个IO口扫描16个按键
- 仅三行代码的按键扫描程序,绝对够经典(秒杀郭天祥讲解的按键扫描)
- ZigBee TI ZStack CC2530 3.15 按键驱动02-中断模式
- 新型的按键扫描程序
- 新型的按键扫描程序,仅三行程序
- zigbee 是怎样注册,产生,处理 按键事件的?