zclGeneral_SendOnOff_CmdOnDuration这个函数无法使用,因为 error #20: identifier "COMMAND_ON_DURATION" is undefined
而且在 On/Off Cluster Commands 的定义中也是没有 COMMAND_ON_DURATION这个的定义
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
zclGeneral_SendOnOff_CmdOnDuration这个函数无法使用,因为 error #20: identifier "COMMAND_ON_DURATION" is undefined
而且在 On/Off Cluster Commands 的定义中也是没有 COMMAND_ON_DURATION这个的定义
你是在哪里使用的?看一下下面的定义,没有找到COMMAND_ON_DURATION的定义的位置
/*! * Send an On Off Command - COMMAND_ONOFF_ONDURATION * Use like: * ZStatus_t zclGeneral_SendOnOff_CmdOnDuration( uint16_t srcEP, afAddrType_t *dstAddr, uint16_t onDuration, uint8_t disableDefaultRsp, uint8_t seqNum ); */ #define zclGeneral_SendOnOff_CmdOnDuration(a,b,c,d,e) zcl_SendCommand( (a), (b), ZCL_CLUSTER_ID_GENERAL_ON_OFF, COMMAND_ON_DURATION, TRUE, ZCL_FRAME_CLIENT_SERVER_DIR, (d), 0, (e), 2, (c) )
我在zclSampleSw_CmdCallbacks里面使用,你说的COMMAND_ON_DURATION自己添加是什么意思?
添加在下面这里吗??
/*******************************/ /*** On/Off Cluster Commands ***/ /*******************************/ /// On receipt of this command, a device SHALL enter its 'Off' state. #define COMMAND_ON_OFF_OFF 0x00 /// On receipt of this command, a device SHALL enter its 'On' state. #define COMMAND_ON_OFF_ON 0x01 /// On receipt of this command, if a device is in its 'Off' state it SHALL ///enter its 'On' state. Otherwise, if it is in its 'On' state it SHALL /// enter its 'Off' state. #define COMMAND_ON_OFF_TOGGLE 0x02 /// The Effect Identifier field is 8-bits in length and specifies the fading /// effect to use when switching the device off. #define COMMAND_ON_OFF_OFF_WITH_EFFECT 0x40 /// The On With Recall Global Scene command allows the recall of the settings /// when the device was turned off. #define COMMAND_ON_OFF_ON_WITH_RECALL_GLOBAL_SCENE 0x41 /// The On With Timed Off command allows devices to be turned on for a specific /// duration with a guarded off duration so that SHOULD the device be /// subsequently switched off, further On With Timed Off commands. #define COMMAND_ON_OFF_ON_WITH_TIMED_OFF 0x42
zcl_general.h里面已经定义了COMMAND_ON_DURATION 0x42
/*******************************/
/*** On/Off Cluster Commands ***/
/*******************************/
/// On receipt of this command, a device SHALL enter its 'Off' state.
#define COMMAND_ON_OFF_OFF 0x00
/// On receipt of this command, a device SHALL enter its 'On' state.
#define COMMAND_ON_OFF_ON 0x01
/// On receipt of this command, if a device is in its 'Off' state it SHALL
///enter its 'On' state. Otherwise, if it is in its 'On' state it SHALL
/// enter its 'Off' state.
#define COMMAND_ON_OFF_TOGGLE 0x02
/// The Effect Identifier field is 8-bits in length and specifies the fading
/// effect to use when switching the device off.
#define COMMAND_ON_OFF_OFF_WITH_EFFECT 0x40
/// The On With Recall Global Scene command allows the recall of the settings
/// when the device was turned off.
#define COMMAND_ON_OFF_ON_WITH_RECALL_GLOBAL_SCENE 0x41
/// The On With Timed Off command allows devices to be turned on for a specific
/// duration with a guarded off duration so that SHOULD the device be
/// subsequently switched off, further On With Timed Off commands.
#define COMMAND_ON_OFF_ON_WITH_TIMED_OFF 0x42
我这边终端的设置
1.zclSampleSw_Attrs,其中
zclSampleSw_OnOff = 0;
const uint16_t zclSampleSw_onoff_clusterRevision = 0x0001;
const uint8_t zclSampleSw_onofftime[5] = {0x00, 0x00,0x01,0x00,0x01};
// *** On / Off Cluster *** //
{
ZCL_CLUSTER_ID_GENERAL_ON_OFF,
{ // Attribute record
ATTRID_ON_OFF_ON_OFF,
ZCL_DATATYPE_BOOLEAN,
ACCESS_CONTROL_READ | ACCESS_REPORTABLE,
(void*)&zclSampleSw_OnOff
}
},
{
ZCL_CLUSTER_ID_GENERAL_ON_OFF,
{ // Attribute record
ATTRID_CLUSTER_REVISION,
ZCL_DATATYPE_UINT16,
ACCESS_CONTROL_READ | ACCESS_CLIENT,
(void *)&zclSampleSw_onoff_clusterRevision
}
},
{
ZCL_CLUSTER_ID_GENERAL_ON_OFF,
{ // Attribute record
ATTRID_ON_OFF_OFF_WAIT_TIME,
ZCL_DATATYPE_UINT40,
ACCESS_CONTROL_READ | ACCESS_CLIENT,
(void *)&zclSampleSw_onofftime
}
}
2.zclSampleSw_CmdCallbacks 里面:
static void zclonDurationCB(zclOnWithTimedOff_t *pCmd ){
printf("zclonDurationCB\n");
}
static zclGeneral_AppCallbacks_t zclSampleSw_CmdCallbacks =
{
zclSampleSw_BasicResetCB, // Basic Cluster Reset command
NULL, // Identfiy cmd
NULL, // Identify Query command
NULL, // Identify Query Response command
NULL, // Identify Trigger Effect command
#ifdef ZCL_ON_OFF
zclonoffCB, // On/Off cluster commands
NULL, // On/Off cluster enhanced command Off with Effect
NULL, // On/Off cluster enhanced command On with Recall Global Scene
zclonDurationCB, // On/Off cluster enhanced command On with Timed Off
#endif
#ifdef ZCL_LEVEL_CTRL
NULL, // Level Control Move to Level command
NULL, // Level Control Move command
NULL, // Level Control Step command
NULL, // Level Control Stop command
NULL, // Level Control Move to Closest Frequency command
#endif
#ifdef ZCL_GROUPS
NULL, // Group Response commands
#endif
#ifdef ZCL_SCENES
NULL, // Scene Store Request command
NULL, // Scene Recall Request command
NULL, // Scene Response command
#endif
#ifdef ZCL_ALARMS
NULL, // Alarm (Response) commands
#endif
#ifdef SE_UK_EXT
NULL, // Get Event Log command
NULL, // Publish Event Log command
#endif
NULL, // RSSI Location command
NULL // RSSI Location Response command
};
协调器的设置:
#define zclGeneral_SendOnOff_CmdOnDuration(a,b,c,d,e) zcl_SendCommand( (a), (b), ZCL_CLUSTER_ID_GENERAL_ON_OFF, COMMAND_ON_OFF_ON_WITH_TIMED_OFF, TRUE, ZCL_FRAME_CLIENT_SERVER_DIR, (d), 0, (e), 2, (c) )
void zclSampleSw_actionToggleLight(const int32_t _itemEntry)
{
zstack_getZCLFrameCounterRsp_t Rsp;
Zstackapi_getZCLFrameCounterReq(appServiceTaskId, &Rsp);
zclSampleSw_DstAddr.addrMode = afAddr16Bit;
zclSampleSw_DstAddr.addr.shortAddr = 0xe0c1;
zclSampleSw_DstAddr.endPoint = 8;
zclSampleSw_DstAddr.panId = 0xd02a;
zclGeneral_SendOnOff_CmdOnDuration( SAMPLESW_ENDPOINT, &zclSampleSw_DstAddr, 0, TRUE, Rsp.zclFrameCounter);
}
实验现象:
1.发送的数据,终端能触发zstackmsg_CmdIDs_AF_INCOMING_MSG_IND,说明有数据过来
2.但是 zclonDurationCB 这个callback没有执行,不知道什么原因
static ZStatus_t zclGeneral_ProcessInOnOff( zclIncoming_t *pInMsg,
zclGeneral_AppCallbacks_t *pCBs )
{
ZStatus_t stat = ZSuccess;
if ( zcl_ServerCmd( pInMsg->hdr.fc.direction ) )
{
switch ( pInMsg->hdr.commandID )
{
case COMMAND_ON_OFF_OFF:
case COMMAND_ON_OFF_ON:
case COMMAND_ON_OFF_TOGGLE:
if ( pCBs->pfnOnOff )
{
pCBs->pfnOnOff( pInMsg->hdr.commandID );
}
break;
#ifdef ZCL_LIGHT_LINK_ENHANCE
case COMMAND_ON_OFF_OFF_WITH_EFFECT:
if ( pCBs->pfnOnOff_OffWithEffect )
{
zclOffWithEffect_t cmd;
cmd.srcAddr = &(pInMsg->msg->srcAddr);
cmd.effectId = pInMsg->pData[0];
cmd.effectVariant = pInMsg->pData[1];
pCBs->pfnOnOff_OffWithEffect( &cmd );
}
break;
case COMMAND_ON_OFF_ON_WITH_RECALL_GLOBAL_SCENE:
if ( pCBs->pfnOnOff_OnWithRecallGlobalScene )
{
pCBs->pfnOnOff_OnWithRecallGlobalScene();
}
break;
case COMMAND_ON_OFF_ON_WITH_TIMED_OFF:
if ( pCBs->pfnOnOff_OnWithTimedOff )
{
zclOnWithTimedOff_t cmd;
cmd.onOffCtrl.byte = pInMsg->pData[0];
cmd.onTime = BUILD_UINT16( pInMsg->pData[1], pInMsg->pData[2] );
cmd.offWaitTime = BUILD_UINT16( pInMsg->pData[3], pInMsg->pData[4] );
pCBs->pfnOnOff_OnWithTimedOff( &cmd );
}
break;
#endif // ZCL_LIGHT_LINK_ENHANCE
default:
stat = ZFailure;
break;
}
}
// no Client command
return ( stat );
}
问题找到了,由于ZCL_LIGHT_LINK_ENHANCE这个没有定义 ,所以导致case COMMAND_ON_OFF_ON_WITH_TIMED_OFF:一直没有被触发。
ZCL_LIGHT_LINK_ENHANCE这个定义是什么意思?我如果define这个定义会有什么影响吗??
多谢