TI中文支持网
TI专业的中文技术问题搜集分享网站

SampleLight工程里接收不到ZCL_SCENES的ZCL消息

大家好,我用Z-STACK 3.0.1里的SampleLight工程做灯泡开关和调光的实验。开关功能用ZCL_ONOFF的cluster,调节亮度使用ZCL_LEVEL_CTRL的cluster, 这两个都已经实现了。但是在用ZCL_SCENES作为调节颜色的cluster的时候发现灯泡对ZCL_SCENES的指令没有任何反应。为了测试我把处理ZCL_SCENES的代码做了如下修改:

static ZStatus_t zclGeneral_HdlInSpecificCommands( zclIncoming_t *pInMsg )
{ZStatus_t stat;zclGeneral_AppCallbacks_t *pCBs;// make sure endpoint existspCBs = zclGeneral_FindCallbacks( pInMsg->msg->endPoint );if ( pCBs == NULL )return ( ZFailure );switch ( pInMsg->msg->clusterId ){
#ifdef ZCL_BASICcase ZCL_CLUSTER_ID_GEN_BASIC:stat = zclGeneral_ProcessInBasic( pInMsg, pCBs );break;
#endif // ZCL_BASIC

#ifdef ZCL_IDENTIFYcase ZCL_CLUSTER_ID_GEN_IDENTIFY:stat = zclGeneral_ProcessInIdentity( pInMsg, pCBs );break;
#endif // ZCL_IDENTIFY

#ifdef ZCL_GROUPScase ZCL_CLUSTER_ID_GEN_GROUPS:if ( zcl_ServerCmd( pInMsg->hdr.fc.direction ) )stat = zclGeneral_ProcessInGroupsServer( pInMsg );elsestat = zclGeneral_ProcessInGroupsClient( pInMsg, pCBs );break;
#endif // ZCL_GROUPS

#ifdef ZCL_SCENEScase ZCL_CLUSTER_ID_GEN_SCENES:/*if ( zcl_ServerCmd( pInMsg->hdr.fc.direction ) )stat = zclGeneral_ProcessInScenesServer( pInMsg, pCBs );elsestat = zclGeneral_ProcessInScenesClient( pInMsg, pCBs );*///stat=zclGeneral_ProcessInScenesSimple(pInMsg, pCBs);//仅为实现功能的超级简化版处理方式//zclSampleLight_SceneSimpleCB();LedTurnOn(HAL_LED_2);break;
#endif // ZCL_SCENES

#ifdef ZCL_ON_OFFcase ZCL_CLUSTER_ID_GEN_ON_OFF:stat = zclGeneral_ProcessInOnOff( pInMsg, pCBs );break;
#endif // ZCL_ON_OFF

#ifdef ZCL_LEVEL_CTRLcase ZCL_CLUSTER_ID_GEN_LEVEL_CONTROL:stat = zclGeneral_ProcessInLevelControl( pInMsg, pCBs );break;
#endif // ZCL_LEVEL_CTRL

#ifdef ZCL_ALARMScase ZCL_CLUSTER_ID_GEN_ALARMS:if ( zcl_ServerCmd( pInMsg->hdr.fc.direction ) )stat = zclGeneral_ProcessInAlarmsServer( pInMsg, pCBs );elsestat = zclGeneral_ProcessInAlarmsClient( pInMsg, pCBs );break;
#endif // ZCL_ALARMS

#ifdef ZCL_LOCATIONcase ZCL_CLUSTER_ID_GEN_LOCATION:if ( zcl_ServerCmd( pInMsg->hdr.fc.direction ) )stat = zclGeneral_ProcessInLocationServer( pInMsg, pCBs );elsestat = zclGeneral_ProcessInLocationClient( pInMsg, pCBs );break;
#endif // ZCL_LOCATIONcase ZCL_CLUSTER_ID_GEN_POWER_CFG:case ZCL_CLUSTER_ID_GEN_DEVICE_TEMP_CONFIG:case ZCL_CLUSTER_ID_GEN_ON_OFF_SWITCH_CONFIG:case ZCL_CLUSTER_ID_GEN_TIME:default:stat = ZFailure;break;}return ( stat );
}

灯泡打开代码LedTurnOn(HAL_LED_2)直接写到这里了,结果还是没有反应。

要接受ZCL_SCENES还要做什么设置呢?

Alvin Chen:

你的抓包文件上传一下,你有绑定ZCL_SCENES?以及在Options里面添加ZCL_SCENES?

YiKai Chen:

你應該是要實做zclGeneral_AppCallbacks_t裡面Scene Store Request command/Scene Recall Request command這兩個回呼函數

Alvin Chen:

回复 Alvin Chen:

 * ZCL General Profile Callback table*/
static zclGeneral_AppCallbacks_t zclGenericApp_CmdCallbacks =
{zclGenericApp_BasicResetCB,// Basic Cluster Reset commandNULL,// Identify Trigger Effect commandNULL,// On/Off cluster commandsNULL,// On/Off cluster enhanced command Off with EffectNULL,// On/Off cluster enhanced command On with Recall Global SceneNULL,// On/Off cluster enhanced command On with Timed Off
#ifdef ZCL_LEVEL_CTRLNULL,// Level Control Move to Level commandNULL,// Level Control Move commandNULL,// Level Control Step commandNULL,// Level Control Stop command
#endif
#ifdef ZCL_GROUPSNULL,// Group Response commands
#endif
#ifdef ZCL_SCENESNULL,// Scene Store Request commandNULL,// Scene Recall Request commandNULL,// Scene Response command
#endif
#ifdef ZCL_ALARMSNULL,// Alarm (Response) commands
#endif
#ifdef SE_UK_EXTNULL,// Get Event Log commandNULL,// Publish Event Log command
#endifNULL,// RSSI Location commandNULL// RSSI Location Response command
};

user5242421:

回复 Alvin Chen:

我修改了zclGeneral_AppCallbacks_t的定义,增加了一项

zclGCB_SceneSimple_t              pfnSceneSimple;               // Simple Scene test process function

typedef struct
{zclGCB_BasicReset_tpfnBasicReset;// Basic Cluster Reset commandzclGCB_IdentifyTriggerEffect_tpfnIdentifyTriggerEffect;// Identify Trigger Effect commandzclGCB_OnOff_tpfnOnOff;// On/Off cluster commandszclGCB_OnOff_OffWithEffect_tpfnOnOff_OffWithEffect;// On/Off cluster enhanced command Off with EffectzclGCB_OnOff_OnWithRecallGlobalScene_tpfnOnOff_OnWithRecallGlobalScene;// On/Off cluster enhanced command On with Recall Global ScenezclGCB_OnOff_OnWithTimedOff_tpfnOnOff_OnWithTimedOff;// On/Off cluster enhanced command On with Timed Off
#ifdef ZCL_LEVEL_CTRLzclGCB_LevelControlMoveToLevel_tpfnLevelControlMoveToLevel;// Level Control Move to Level commandzclGCB_LevelControlMove_tpfnLevelControlMove;// Level Control Move commandzclGCB_LevelControlStep_tpfnLevelControlStep;// Level Control Step commandzclGCB_LevelControlStop_tpfnLevelControlStop;// Level Control Stop command
#endif
#ifdef ZCL_GROUPSzclGCB_GroupRsp_tpfnGroupRsp;// Group Response commands
#endif
#ifdef ZCL_SCENESzclGCB_SceneStoreReq_tpfnSceneStoreReq;// Scene Store Request commandzclGCB_SceneRecallReq_tpfnSceneRecallReq;// Scene Recall Request commandzclGCB_SceneRsp_tpfnSceneRsp;// Scene Response commandzclGCB_SceneSimple_tpfnSceneSimple;// Simple Scene test process function
#endif
#ifdef ZCL_ALARMSzclGCB_Alarm_tpfnAlarm;// Alarm (Response) commands
#endif
#ifdef SE_UK_EXTzclGCB_GetEventLog_tpfnGetEventLog;// Get Event Log commandzclGCB_PublishEventLog_tpfnPublishEventLog;// Publish Event Log command
#endifzclGCB_Location_tpfnLocation;// RSSI Location commandzclGCB_LocationRsp_tpfnLocationRsp;// RSSI Location Response command
} zclGeneral_AppCallbacks_t;

然后在主程序的回调函数注册里修改为:

static zclGeneral_AppCallbacks_t zclSampleLight_CmdCallbacks =
{zclSampleLight_BasicResetCB,// Basic Cluster Reset commandNULL,// Identify Trigger Effect commandzclSampleLight_OnOffCB,// On/Off cluster commandsNULL,// On/Off cluster enhanced command Off with EffectNULL,// On/Off cluster enhanced command On with Recall Global SceneNULL,// On/Off cluster enhanced command On with Timed Off
#ifdef ZCL_LEVEL_CTRLzclSampleLight_LevelControlMoveToLevelCB, // Level Control Move to Level commandzclSampleLight_LevelControlMoveCB,// Level Control Move commandzclSampleLight_LevelControlStepCB,// Level Control Step commandzclSampleLight_LevelControlStopCB,// Level Control Stop command
#endif
#ifdef ZCL_GROUPSNULL,// Group Response commands
#endif
#ifdef ZCL_SCENESNULL,// Scene Store Request commandNULL,// Scene Recall Request commandNULL,// Scene Response commandzclSampleLight_SceneSimpleCB,// Scene simple test
#endif
#ifdef ZCL_ALARMSNULL,// Alarm (Response) commands
#endif
#ifdef SE_UK_EXTNULL,// Get Event Log commandNULL,// Publish Event Log command
#endifNULL,// RSSI Location commandNULL// RSSI Location Response command
};

但是其实这些都不重要不是嘛? 因为这些回调函数是在接收到消息之后,在一系列的函数调用里被使用到的。但是我直接把开灯部分的代码写到最初的消息处理里了,按说应该是一旦接收cluster_id为ZCL_SCENES的指令,不管指令的具体内容都会立刻点亮灯泡的

user5242421:

回复 Alvin Chen:

ZCL_SCENES.rar

Alvin Chen:

回复 user5242421:

你的抓包文件了?
e2echina.ti.com/…/155357

YiKai Chen:

回复 user5242421:

建議先抓包看看你的ZCL_SCENES的指令有沒有真的送出來

user5242421:

回复 Alvin Chen:

抓包文件上传怎么还要审核,还没发出来,我在传一次

user5242421:

回复 user5242421:

5557.ZCL_SCENES.rar

这个抓包文件测试了ZCL_ONOFF_TONGLE, ZCL_LEVEL_CTRL和ZCL_SCENES三个操作,只有最后一个没有任何反应

Alvin Chen:

回复 user5242421:

看上去是你回调函数的问题,举个例子:

如果添加ATTRID_SCENES_COUNT – SceneCount支持,
则需要在zclGeneral_AppCallbacks_t中实现Scene Store Request命令的回调,

你这个zclSampleLight_SceneSimpleCB,// Scene simple test的attribute?
建议你去测试一下ATTRID_SCENES_COUNT这个attribute然后在zclGeneral_AppCallbacks_t中注册Scene Store Request。

赞(0)
未经允许不得转载:TI中文支持网 » SampleLight工程里接收不到ZCL_SCENES的ZCL消息
分享到: 更多 (0)