本帖最后由 1353740943 于 2013-3-10 16:37 编辑
我要在一个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
",11); //串口
HalLcdWriteString( "Get People", HAL_LCD_LINE_3 ); //LCD
}
else
{
data[4]=0;//无人
HalUARTWrite(0,"No People
",10); //串口
}
if(SMOKE==1)
{
data[5]=1;//没烟雾
HalUARTWrite(0,"No bad Air
",11); //串口
}
else
{
data[5]=0;//有烟雾
HalUARTWrite(0,"Get bad Air
",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 flash
time;
switch ( pkt->clusterId )
{
case SAMPLEAPP_POINT_TO_POINT_CLUSTERID:
/***********温度打印***************/
HalUARTWrite(0,"Temp is:",8); //提示接收到数据
HalUARTWrite(0,&pkt->cmd.Data[0],2); //温 度
HalUARTWrite(0,"
",1); // 回车换行
/***************湿度打印****************/
HalUARTWrite(0,"Humidity is:",12); //提示接收到数据
HalUARTWrite(0,&pkt->cmd.Data[2],2); //湿度
HalUARTWrite(0,"
",1);
if(&pkt->cmd.Data[4])
HalUARTWrite(0,"Get People
",11);
else
HalUARTWrite(0,"No People
",10);
if(&pkt->cmd.Data[5])
HalUARTWrite(0,"Get bad air
",12);
else
HalUARTWrite(0,"No bad air
",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”,说明两个数据发送的过程中出现了问题,弄了好久也解决不了,诚心求大神帮忙,小弟感激不尽
亲 我最近搞这块 能不能把你调好的代码发给我看看啊 这个问题困了我好长时间了呢 谢谢你了哦
一周热门 更多>