zigbee一个终端多个传感器的程序有问题,求大神指教
录入:edatop.com 阅读:
我要在一个zigbee终端节点上带多个传感器(DHT11+红外热释电+烟雾),可总是调不出来结果,下面为sampleAPP中的发送及数据处理函数,求大神指教!
数据点对点发送函数:
void SampleApp_SendPointToPointMessage( void )
{
uchar data[6];
data[0]=wendu_shi+48;
data[1]=wendu_ge%10+48;
data[2]=shidu_shi+48;
data[3]=shidu_ge%10+48;
if(PEOPLE==1)
{
data[4]=1;//有人
HalUARTWrite(0,"Get People\n",11); //串口
HalLcdWriteString( "Get People", HAL_LCD_LINE_3 ); //LCD
}
else
{
data[4]=0;//无人
HalUARTWrite(0,"No People\n",10); //串口
}
if(SMOKE==1)
{
data[5]=1;//没烟雾
HalUARTWrite(0,"No bad Air\n",11); //串口
}
else
{
data[5]=0;//有烟雾
HalUARTWrite(0,"Get bad Air\n",12); //串口
}
if ( AF_DataRequest( &Point_To_Point_DstAddr,
&SampleApp_epDesc,
SAMPLEAPP_POINT_TO_POINT_CLUSTERID,
6,
data,
&SampleApp_TransID,
AF_DISCV_ROUTE,
AF_DEFAULT_RADIUS ) == afStatus_SUCCESS )
{
}
else
{
// Error occurred in request to send.
}
}
数据处理函数:
void SampleApp_MessageMSGCB( afIncomingMSGPacket_t *pkt )
{
uint16 flashTime;
switch ( pkt->clusterId )
{
case SAMPLEAPP_POINT_TO_POINT_CLUSTERID:
/***********温度打印***************/
HalUARTWrite(0,"Temp is:",8); //提示接收到数据
HalUARTWrite(0,&pkt->cmd.Data[0],2); //温 度
HalUARTWrite(0,"\n",1); // 回车换行
/***************湿度打印****************/
HalUARTWrite(0,"Humidity is:",12); //提示接收到数据
HalUARTWrite(0,&pkt->cmd.Data[2],2); //湿度
HalUARTWrite(0,"\n",1);
if(&pkt->cmd.Data[4])
HalUARTWrite(0,"Get People\n",11);
else
HalUARTWrite(0,"No People\n",10);
if(&pkt->cmd.Data[5])
HalUARTWrite(0,"Get bad air\n",12);
else
HalUARTWrite(0,"No bad air\n",11);
break;
case SAMPLEAPP_FLASH_CLUSTERID:
flashTime = BUILD_UINT16(pkt->cmd.Data[1], pkt->cmd.Data[2] );
HalLedBlink( HAL_LED_4, 4, 50, (flashTime / 4) );
break;
}
}
下好程序后终端节点串口打印的温湿度正常,两个传感器状态随环境变化。协调节点的温湿度正常,而红外热释电及烟雾传感器的信息一直却显示为“Get People ,Get bad air”,说明两个数据发送的过程中出现了问题,弄了好久也解决不了,诚心求大神帮忙,小弟感激不尽
数据点对点发送函数:
void SampleApp_SendPointToPointMessage( void )
{
uchar data[6];
data[0]=wendu_shi+48;
data[1]=wendu_ge%10+48;
data[2]=shidu_shi+48;
data[3]=shidu_ge%10+48;
if(PEOPLE==1)
{
data[4]=1;//有人
HalUARTWrite(0,"Get People\n",11); //串口
HalLcdWriteString( "Get People", HAL_LCD_LINE_3 ); //LCD
}
else
{
data[4]=0;//无人
HalUARTWrite(0,"No People\n",10); //串口
}
if(SMOKE==1)
{
data[5]=1;//没烟雾
HalUARTWrite(0,"No bad Air\n",11); //串口
}
else
{
data[5]=0;//有烟雾
HalUARTWrite(0,"Get bad Air\n",12); //串口
}
if ( AF_DataRequest( &Point_To_Point_DstAddr,
&SampleApp_epDesc,
SAMPLEAPP_POINT_TO_POINT_CLUSTERID,
6,
data,
&SampleApp_TransID,
AF_DISCV_ROUTE,
AF_DEFAULT_RADIUS ) == afStatus_SUCCESS )
{
}
else
{
// Error occurred in request to send.
}
}
数据处理函数:
void SampleApp_MessageMSGCB( afIncomingMSGPacket_t *pkt )
{
uint16 flashTime;
switch ( pkt->clusterId )
{
case SAMPLEAPP_POINT_TO_POINT_CLUSTERID:
/***********温度打印***************/
HalUARTWrite(0,"Temp is:",8); //提示接收到数据
HalUARTWrite(0,&pkt->cmd.Data[0],2); //温 度
HalUARTWrite(0,"\n",1); // 回车换行
/***************湿度打印****************/
HalUARTWrite(0,"Humidity is:",12); //提示接收到数据
HalUARTWrite(0,&pkt->cmd.Data[2],2); //湿度
HalUARTWrite(0,"\n",1);
if(&pkt->cmd.Data[4])
HalUARTWrite(0,"Get People\n",11);
else
HalUARTWrite(0,"No People\n",10);
if(&pkt->cmd.Data[5])
HalUARTWrite(0,"Get bad air\n",12);
else
HalUARTWrite(0,"No bad air\n",11);
break;
case SAMPLEAPP_FLASH_CLUSTERID:
flashTime = BUILD_UINT16(pkt->cmd.Data[1], pkt->cmd.Data[2] );
HalLedBlink( HAL_LED_4, 4, 50, (flashTime / 4) );
break;
}
}
下好程序后终端节点串口打印的温湿度正常,两个传感器状态随环境变化。协调节点的温湿度正常,而红外热释电及烟雾传感器的信息一直却显示为“Get People ,Get bad air”,说明两个数据发送的过程中出现了问题,弄了好久也解决不了,诚心求大神帮忙,小弟感激不尽
我有温度 湿度 光敏 震动 红外的多传感器程序 ,需要的话可以私信给我
申明:网友回复良莠不齐,仅供参考。如需专业解答,请学习本站推出的微波射频专业培训课程。
上一篇:vga无线传输
下一篇:关于无线测试的好东西分享下