light入网问题
在一个100点左右的灯光网络,我的想法是,未入网的light在上电0-120s的随机时间内进行一次beacon request,如果这次request没入网成功,接下来每1分钟进行一次request,直到入网成功为止。
请问:
1、这120s的随机时间加在哪儿呢?是控制ZDApp_NetworkInit( extendedDelay )中的extendedDelay吗?我尝试修改它,似乎并不对。
2、每1分钟一次request怎么做?在ZDO_STATE_CHANGE_EVT事件中判断devState若不为DEV_ROUTER就开一个定时器每分钟调用 zllTarget_ClassicalCommissioningStart()吗?
1, uint8 ZDOInitDevice( uint16 startDelay )
2, 用 ZDApp_StartJoiningCycle( void )和ZDApp_StopJoiningCycle(
我在ZDApp_init()函数中修改ZDOInitDevice(uint16 startDelay) startDelay参数为30000,但是beacon request函数立即出现了。
void ZDApp_Init( uint8 task_id )
{
// Save the task ID
ZDAppTaskID = task_id;
// Initialize the ZDO global device short address storage
ZDAppNwkAddr.addrMode = Addr16Bit;
ZDAppNwkAddr.addr.shortAddr = INVALID_NODE_ADDR;
(void)NLME_GetExtAddr(); // Load the saveExtAddr pointer.
// Check for manual "Hold Auto Start"
ZDAppCheckForHoldKey(); //检查P20按键是否被按下,如果按下就hold start.
// Initialize ZDO items and setup the device - type of device to create.
ZDO_Init();
// Register the endpoint description with the AF
// This task doesn't have a Simple description, but we still need
// to register the endpoint.
afRegister( (endPointDesc_t *)&ZDApp_epDesc );
#if defined( ZDO_USERDESC_RESPONSE )
ZDApp_InitUserDesc();
#endif // ZDO_USERDESC_RESPONSE
// Start the device?
if ( devState != DEV_HOLD )
{
ZDOInitDevice( 0 );
}
else
{
ZDOInitDevice( ZDO_INIT_HOLD_NWK_START );
// Blink LED to indicate HOLD_START
HalLedBlink ( HAL_LED_4, 0, 50, 500 );
}
// Initialize the ZDO callback function pointers zdoCBFunc[]
ZDApp_InitZdoCBFunc();
ZDApp_RegisterCBs();
#if !defined ( ZDP_BIND_SKIP_VALIDATION )
#if defined ( REFLECTOR )
ZDApp_InitPendingBind();
#endif
#endif
} /* ZDApp_Init() */
在zllSampleLight_Init( byte task_id )中有一个函数 zllTarget_InitDevice(),感觉是这个函数中的zll_ClassicalCommissioningInit()启动了beacon request.
ZStatus_t zllTarget_InitDevice( void )
{
if ( !zll_IsFactoryNew() )
{
// Resume ZigBee functionality based on the info stored in NV
ZDOInitDevice( 0 );
}
else
{
uint8 x = TRUE;
// Enable our receiver
ZMacSetReq( ZMacRxOnIdle, &x );
// Determine unique PAN Id and Extended PAN Id
targetSelectNwkParams();
#ifndef HOLD_AUTO_START
zll_ClassicalCommissioningInit();
#endif
// Wait for a touchlink command
}
zllTarget_PermitJoin(0);
return ( ZSuccess );
}
周期调用ZDApp_StartJoiningCycle()函数似乎并不能启动beacon request,而周期调用zllTarget_ClassicalCommissioningStart()则可以。
对入网还不是太了解。
对比源码发现,ZDApp_StartJoiningCycle()最终调用的NLME_NetworkDiscoveryRequest( uint32 ScanChannels,uint8 scanDuration),而zllTarget_ClassicalCommissioningStart()最终调用的是NLME_NwkDiscReq2( NLME_ScanFields_t* fields ),不知道有多大的区别?without affecting the current nwk state?
/* This function requests the NWK layer to discover neighboring routers
*
* @MT SPI_CMD_NLME_NWK_DISC_REQ
*
*/
extern ZStatus_t NLME_NetworkDiscoveryRequest( uint32 ScanChannels,
uint8 scanDuration);
/* This function allows the NWK layer to discover neighboring routers
* without affecting the current nwk state
*/
extern ZStatus_t NLME_NwkDiscReq2( NLME_ScanFields_t* fields );
你可以按照下面的步骤去做,
1) 在编译选项里面,仍然把HOLD_AUTO_START加上去
2)在zllSampleLight_Init( byte task_id )函数最后加上下面代码
// find if we are already on a network from NV_RESTORE
uint8 state;
NLME_GetRequest( nwkNwkState, 0, &state );
if ( state < NWK_ROUTER )
{
osal_start_timerEx( zllSampleLight_TaskID, SAMPLELIGHT_START_EVT, 5000 );
}
在zllSampleLight_event_loop( uint8 task_id, uint16 events )去处理这个事件
if ( events & SAMPLELIGHT_START_EVT)
{
zllTarget_ClassicalCommissioningStart();
return (events ^ SAMPLELIGHT_START_EVT);
}
上面的5000时间,就是你可以自己添加的随机时间。
另外关于1分钟检测的,你可以开一个timer,检测节点的状态是否是NWK_ROUTER,然后在决定是否调用
zllTarget_ClassicalCommissioningStart();
如果已经在网络里面了,可以把这个timer event stop并且删除掉。
请问VV,CC3200+ZLL网关什么时候会在官网正式发布啊
你希望的网关是ZLL里面的brdige呢?还是home Automation里面的gateway。
两者的区别在于,前者是Router,只能添加ZLL的设备。
后者是Coordinator,除了ZLL的设备以外,还能添加HA的产品,像门磁,温湿度传感器,等等
VV,
我的系统里会是100个左右的灯,以后可能会有一些人体、光强度传感器,在商用场合的私有网络。我想zll里的bridge或HA里面的gateway可能都能够满足我们的要求。不知道哪一个会好一点?我现在手里有CC3200+ZNP的网关firmware,不知道ZNP是属于HA的gateway吗?之所以现在想用cc3200,也是因会对CC3200比较熟悉,用那个linux gateway不知道是不是需要花费很多的精力在那个cotex-a9上。不过现在这个CC3200+ZNP好像还没有完整的资料。
我们有一个参考设计,就是专门将ZNP跟其他Host 配合的参考代码。
http://www.ti.com/tool/TIDC-ZNP-HOST-SW3
http://www.ti.com/lit/ug/tidu757/tidu757.pdf
