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.

On/Off Cluster Operation State Machine

Other Parts Discussed in Thread: Z-STACK

上图的On/Off Cluster Operation State Machine状态机的几个问题:

1.这个On/Off Cluster Operation State Machine的状态机什么时候启动??

2.协调器那边传过来ontime和offwaittime之后,从"Off" ----> "Timed On", 然后当OnTime减少到0之后,就恢复到"Off"状态??

3.时间的减少自动0.1秒减少1??比如:100就是10秒

  • 1. 應該在收到On/Off 相關command时启动
    2. 對
    3. onTime attribute的單位刻度是100ms,所以100就是10秒沒錯
  • 协调器发送的OnTime, offWaitTime,是被保存在这里吗?


    { ZCL_CLUSTER_ID_GENERAL_ON_OFF, { // Attribute record ATTRID_ON_OFF_OFF_WAIT_TIME, ZCL_DATATYPE_UINT40, ACCESS_CONTROL_READ | ACCESS_CLIENT, (void *)&zclPixie_onoff_time } }

    ACCESS_CONTROL_READ | ACCESS_CLIENT  这个是不是要加上ACCESS_CONTROL_WRITE类型?

    zclPixie_onoff_time这个不能设置成const?
  • 1. onTime是存在ATTRID_ON_OFF_ON_TIME,offWaitTime是存在ATTRID_ON_OFF_OFF_WAIT_TIME,這兩個attributes都是可以read/write/report所以應該用 ACCESS_CONTROL_READ | ACCESS_CONTROL_WRITE  | ACCESS_REPORTABLE

    2. zclPixie_onoff_time这个不能设置成const

    建議你讀一下ZCL SPEC

  • 收到的on/offf 命令在zclGeneral_ProcessInCmdOnOff中处理

  • 协调器发送onTime,offWaitTime的值,终端接收到这个值之后,是不会自动保存好的吧

    协调器发送函数:

    ZStatus_t zclGeneral_SendOnOff_CmdOnWithTimedOff ( uint8_t srcEP, afAddrType_t *dstAddr,
                                                       zclOnOffCtrl_t onOffCtrl, uint16_t onTime, uint16_t offWaitTime,
                                                       uint8_t disableDefaultRsp, uint8_t seqNum )
    {
      uint8_t buf[5];
    
      buf[0] = onOffCtrl.byte;
      buf[1] = LO_UINT16( onTime );
      buf[2] = HI_UINT16( onTime );
      buf[3] = LO_UINT16( offWaitTime );
      buf[4] = HI_UINT16( offWaitTime );
    
      return zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_GENERAL_ON_OFF,
                              COMMAND_ON_OFF_ON_WITH_TIMED_OFF, TRUE, ZCL_FRAME_CLIENT_SERVER_DIR,
                              disableDefaultRsp, 0, seqNum, 5, buf );
    }

    终端接收函数:

    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;

  • 據我所知目前的Z-Stack 不会自动保存
  • /*********************************/
    /*** On/Off Cluster Attributes ***/
    /*********************************/
    /// Represents the On/Off device state
    #define ATTRID_ON_OFF_ON_OFF                                     0x0000
    /// In order to support the use case where the user gets back the last setting
    /// of the devices
    #define ATTRID_ON_OFF_GLOBAL_SCENE_CONTROL                0x4000
    /// The OnTime attribute specifies the length of time (in 1/10ths second) that
    /// the "on" state SHALL be maintained before automatically transitioning to the
    /// "off" state when using the On with timed off command.
    #define ATTRID_ON_OFF_ON_TIME                             0x4001
    /// The OffWaitTime attribute specifies the length of time (in 1/10ths second)
    /// that the "off" state SHALL be guarded to prevent an on command turning the
    /// device back to its "on" state (e.g., when leaving a room, the lights are
    /// turned off but an occupancy sensor detects the leaving person and attempts
    /// to turn the lights back on).
    #define ATTRID_ON_OFF_OFF_WAIT_TIME                       0x4002
    // Start Up On/Off Attribute
    #define ATTRID_ON_OFF_START_UP_ON_OFF                     0x4003

    TI的ON/OFF cluster 比zigbee联盟定义的要多一个0x4003.

    这个怎么使用?

  • 如果你看最新的ZCL spec就會有看到ATTRID_ON_OFF_START_UP_ON_OFF 這個新的attribute, ID就是0x4003
  • 有新版ZCL的链接吗,我google出来的都是ZCL6的
  • 新版的ZCL spec你要加入Zibgee Alliance才能下載
  • 我感觉我的On/Off Cluster Operation State Machine状态机并没有启动,协调器发送
    ZStatus_t zclGeneral_SendOnOff_CmdOnWithTimedOff 之后,终端这边虽然接收到了数据,但是我把ONOFF的属性值打印出来还是0,一直没变。
    有什么方法来确定状态机正常启动了
  • 建議你調適一下on/off callback
x 出现错误。请重试或与管理员联系。