Z-Stack Home 1.2.2 SampleDoorLock 问题请教
时间:10-02
整理:3721RD
点击:
描述:
1、CC2530 非开发套件,使用 SampleDoorLock 作为协调器、SampleDoorLockController作用终端
2、终端(SampleDoorLockController)开启一个定时器来检测按键(100ms),例如:P1_5 ==1时,来发起Becon reques 请求并且可以入网(入网抓包如下图)
3、例如:P1_6 ==1时,来发送解锁命令,但是数据发来出来,抢包没有抢出来。debug能正常进入定时器检测,例程其他地方没有改动,请问问题出在那里呢?谢谢,代码如下:
if ( events & SAMPLEDOORLOCK_wds ) { osal_start_timerEx( zclSampleDoorLockController_TaskID, SAMPLEDOORLOCK_wds, 100 ); // zcl_EZModeAction ( EZMODE_ACTION_TIMED_OUT, NULL ); // EZ-Mode timed out if(P1_6==1) { // increase PIN number if ( giDoorLockScreenMode == DOORLOCK_PINMODE ) { if ( giDoorLockPINColumnCount < 4 ) { if ( giDoorLockPINCount > 8 ) { giDoorLockPINCount = 0; } else { giDoorLockPINCount++; } } } // for all other modes, lock/unlock door else { zclDoorLock_t cmd; cmd.pPinRfidCode = aiDoorLockPIN; static bool locked = TRUE; giDoorLockScreenMode = DOORLOCK_MAINMODE; if ( locked ) { zclClosures_SendDoorLockUnlockDoor( SAMPLEDOORLOCKCONTROLLER_ENDPOINT, &zclSampleDoorLockController_DstAddr, &cmd, false, zclSampleDoorLockControllerSeqNum++ ); locked = FALSE; } else { zclClosures_SendDoorLockLockDoor( SAMPLEDOORLOCKCONTROLLER_ENDPOINT, &zclSampleDoorLockController_DstAddr, &cmd, false, zclSampleDoorLockControllerSeqNum++ ); locked = TRUE; } } } if(P1_5==1) { if ( ( giDoorLockScreenMode == DOORLOCK_MAINMODE ) || ( giDoorLockScreenMode == DOORLOCK_HELPMODE ) ) { giDoorLockScreenMode = DOORLOCK_MAINMODE; #ifdef ZCL_EZMODE { zclEZMode_InvokeData_t ezModeData; static uint16 clusterIDs[] = { ZCL_CLUSTER_ID_CLOSURES_DOOR_LOCK }; // only bind on the on/off cluster // Invoke EZ-Mode ezModeData.endpoint = SAMPLEDOORLOCKCONTROLLER_ENDPOINT; // endpoint on which to invoke EZ-Mode if ( ( zclSampleDoorLockController_NwkState == DEV_ZB_COORD ) || ( zclSampleDoorLockController_NwkState == DEV_ROUTER ) || ( zclSampleDoorLockController_NwkState == DEV_END_DEVICE ) ) { ezModeData.onNetwork = TRUE; // node is already on the network } else { ezModeData.onNetwork = FALSE; // node is not yet on the network } ezModeData.initiator = TRUE; // DoorLock Controller is an initiator ezModeData.numActiveInClusters = 0; ezModeData.pActiveInClusterIDs = NULL; ezModeData.numActiveOutClusters = 1; // active output cluster ezModeData.pActiveOutClusterIDs = clusterIDs; zcl_InvokeEZMode( &ezModeData ); #ifdef LCD_SUPPORTED HalLcdWriteString( "EZMode", HAL_LCD_LINE_2 ); #endif } // NOT ZCL_EZMODE, Use EndDeviceBind #else { zAddrType_t dstAddr; HalLedSet ( HAL_LED_4, HAL_LED_MODE_OFF ); // Initiate an End Device Bind Request, this bind request will // only use a cluster list that is important to binding. dstAddr.addrMode = afAddr16Bit; dstAddr.addr.shortAddr = 0; // Coordinator makes the match ZDP_EndDeviceBindReq( &dstAddr, NLME_GetShortAddr(), SAMPLEDOORLOCKCONTROLLER_ENDPOINT, ZCL_HA_PROFILE_ID, 0, NULL, // No incoming clusters to bind ZCLSAMPLEDOORLOCKCONTROLLER_BINDINGLIST, bindingOutClusters, TRUE ); } #endif // ZCL_EZMODE } } return ( events ^ SAMPLEDOORLOCK_wds ); }
如果定义了ZCL_EZMODE的话,首先需要进行两个设备在EZ_MODE下绑定的过程。
确保SampleDoorLock和SampleDoorLockController都处于EZ_MODE的状态下。
另外在一般应用中SampleDoorLock是实际的锁,是低功耗设备,所以是zigbee网络里的end device
SampleDoorLockController是控制端,一般可能是协调器等设备。