微波EDA网,见证研发工程师的成长!
首页 > 研发问答 > 无线和射频 > 射频无线通信设计 > zigbee定位问题

zigbee定位问题

时间:10-02 整理:3721RD 点击:
zigbee定位,让网关在一定时间内收不到数据包,就驱动网关的蜂鸣器响。

下面是网关主要程序:
//系统上电后,执行ZMain.c的int main()函数实现硬件的初始化,包括osal_int_disable( INTS_ALL );初始化板上硬件设置。。。当完成上述初始化时,执行osal_start_system()开始运行OSAL系统。(如下)

ZSEG int main( void )
{
// Turn off interrupts
osal_int_disable( INTS_ALL );

// Initialize HAL
HAL_BOARD_INIT();

// Make sure supply voltage is high enough to run
zmain_vdd_check();

// Initialize stack memory
zmain_ram_init();

// Initialize board I/O
InitBoard( OB_COLD );

// Initialze HAL drivers
HalDriverInit();

// Initialize NV System
osal_nv_init( NULL );

// Determine the extended address
zmain_ext_addr();

// Initialize basic NV items
zgInit();

// Initialize the MAC
ZMacInit();

#ifndef NONWK
// Since the AF isn't a task, call it's initialization routine
afInit();
#endif

#ifdef LCD_SUPPORTED
HalLcdInit();
#endif
// Initialize the operating system
osal_init_system();

// Allow interrupts
osal_int_enable( INTS_ALL );

// Final board initialization
InitBoard( OB_READY );
//HalLcdInit();
// Display information about this device
zmain_dev_info();
/* Display the device info on the LCD */
#ifdef LCD_SUPPORTED
zmain_lcd_init();
#endif

osal_start_system(); // No Return from here
} // main()

//osal_start_system()一旦执行,就不再返回上面的main()函数。

//之后就进入下面的uint SampleApp_ProcessEvent(uint8 task_id,uint16 events),判断收到的数据包,是什么事件,该函数如下:

uint16 SampleApp_ProcessEvent( uint8 task_id, uint16 events )
{
if ( events & SYS_EVENT_MSG )
{
afIncomingMSGPacket_t *MSGpkt = (afIncomingMSGPacket_t *)osal_msg_receive(
SampleApp_TaskID );

while ( MSGpkt != NULL )
{
switch ( MSGpkt->hdr.event )
{
case KEY_CHANGE:
handleKeys( ((keyChange_t *)MSGpkt)->state, ((keyChange_t *)MSGpkt)->keys );
break;

case AF_DATA_CONFIRM_CMD:
#if !defined( RTR_NWK )
{
// This message is received as a confirmation of a data packet sent.
// The status is of ZStatus_t type [defined in ZComDef.h]
afDataConfirm_t *afDataConfirm = (afDataConfirm_t *)MSGpkt;

/* No ACK from the MAC layer implies that mobile device is out of
* range of most recent parent. Therefore, begin an orphan scan
* to try to find a former parent.
* NOTE: To get the fastest action in the process of finding a new
* parent, set the MAX_JOIN_ATTEMPTS in ZDApp.c to 1.
*/
if ( afDataConfirm->hdr.status == ZMacNoACK )
{
SampleApp_NoACK();
}
// Some other error -- Do something.
else
{
}
}
#endif
break;

case AF_INCOMING_MSG_CMD:
processMSGCmd( MSGpkt );
break;

case ZDO_STATE_CHANGE:
#if defined( POWER_SAVING )
if ( rejoinPending )
{
rejoinPending = FALSE;

// Ok to resume power saving ops.
SampleApp_Sleep( TRUE );
}
#endif
break;

default:
break;
}

osal_msg_deallocate( (uint8 *)MSGpkt );
MSGpkt = (afIncomingMSGPacket_t *)osal_msg_receive( SampleApp_TaskID );
}

// Return unprocessed events.
return ( events ^ SYS_EVENT_MSG );
}

return 0; // Discard unknown eve
}

现在就是加上逻辑功能没实现,帮帮忙。

设置一个心跳包就行

ZigBee不是通过信号强度定位吗

是的,就是移动节点根据参考节点的位置信息和RSSI计算出自己的位置,然后发给网关

该怎么设置,请多帮忙哦

该怎么设置,请多帮忙哦!

刚开始入门,帮顶!

设置一个定时器,搞个几分钟上报一次数据或者半个小时都行,而且你这个不能算作定位,希望你以后描述问题清晰些

恩,可以加你QQ吗?

我基本不QQ聊天,而且在论坛讨论,遇到相同问题的人也可以看到

请问楼主用的是哪家公司的芯片呢?

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top