Developing with ZBOSS for Zigbee
ZCL On/Off cluster

Data Structures

struct  zb_zcl_on_off_off_with_effect_req_s
 Structured representation of Off with effect command payload. More...
 
struct  zb_zcl_on_off_on_with_timed_off_req_s
 Structured representation of On with timed off command payload. More...
 

On/Off cluster attributes

enum  zb_zcl_on_off_attr_e {
  ZB_ZCL_ATTR_ON_OFF_ON_OFF_ID = 0, ZB_ZCL_ATTR_ON_OFF_GLOBAL_SCENE_CONTROL = 0x4000, ZB_ZCL_ATTR_ON_OFF_ON_TIME = 0x4001, ZB_ZCL_ATTR_ON_OFF_OFF_WAIT_TIME = 0x4002,
  ZB_ZCL_ATTR_ON_OFF_START_UP_ON_OFF = 0x4003
}
 On/Off cluster attribute identifiers. More...
 
enum  zb_zcl_on_off_on_off_e { ZB_ZCL_ON_OFF_IS_OFF = 0, ZB_ZCL_ON_OFF_IS_ON = 1 }
 Permissible values for OnOff attribute. More...
 
enum  zb_zcl_on_off_start_up_on_off_e { ZB_ZCL_ON_OFF_START_UP_ON_OFF_IS_OFF = 0, ZB_ZCL_ON_OFF_START_UP_ON_OFF_IS_ON = 1, ZB_ZCL_ON_OFF_START_UP_ON_OFF_IS_TOGGLE = 2, ZB_ZCL_ON_OFF_START_UP_ON_OFF_IS_PREVIOUS = 0xFF }
 
#define ZB_ZCL_ON_OFF_ON_OFF_DEFAULT_VALUE   (ZB_ZCL_ON_OFF_IS_OFF)
 Default value for OnOff attribute.
 
#define ZB_ZCL_ON_OFF_GLOBAL_SCENE_CONTROL_DEFAULT_VALUE   ((zb_bool_t)0x01)
 Default value for GlobalSceneControl attribute.
 
#define ZB_ZCL_ON_OFF_ON_TIME_DEFAULT_VALUE   ((zb_uint16_t)0x0000)
 Default value for OnTime attribute.
 
#define ZB_ZCL_ON_OFF_OFF_WAIT_TIME_DEFAULT_VALUE   ((zb_uint16_t)0x0000)
 Default value for OffWaitTime attribute.
 
#define ZB_ZCL_DECLARE_ON_OFF_ATTRIB_LIST(attr_list, on_off)
 Declare attribute list for On/Off cluster. More...
 
#define ZB_ZCL_DECLARE_ON_OFF_ATTRIB_LIST_EXT( attr_list, on_off, global_scene_ctrl, on_time, off_wait_time)
 Declare attribute list for On/Off cluster (extended attribute set). More...
 

On/Off cluster commands

enum  zb_zcl_on_off_cmd_e {
  ZB_ZCL_CMD_ON_OFF_OFF_ID = 0x00, ZB_ZCL_CMD_ON_OFF_ON_ID = 0x01, ZB_ZCL_CMD_ON_OFF_TOGGLE_ID = 0x02, ZB_ZCL_CMD_ON_OFF_OFF_WITH_EFFECT_ID = 0x40,
  ZB_ZCL_CMD_ON_OFF_ON_WITH_RECALL_GLOBAL_SCENE_ID = 0x41, ZB_ZCL_CMD_ON_OFF_ON_WITH_TIMED_OFF_ID = 0x42
}
 On/Off cluster command identifiers. More...
 
enum  zb_zcl_on_off_effect_e { ZB_ZCL_ON_OFF_EFFECT_ID_DELAYED_ALL_OFF = 0x00, ZB_ZCL_ON_OFF_EFFECT_ID_DYING_LIGHT = 0x01 }
 
enum  zb_zcl_on_off_effect_variant_delayed_e { ZB_ZCL_ON_OFF_EFFECT_VARIANT_FADE = 0x00, ZB_ZCL_ON_OFF_EFFECT_VARIANT_NO_FADE = 0x01, ZB_ZCL_ON_OFF_EFFECT_VARIANT_50PART_FADE = 0x02 }
 
enum  zb_zcl_on_off_effect_variant_dying_e { ZB_ZCL_ON_OFF_EFFECT_VARIANT_20PART_FADE = 0x00 }
 
typedef struct zb_zcl_on_off_off_with_effect_req_s zb_zcl_on_off_off_with_effect_req_t
 Structured representation of Off with effect command payload.
 
typedef struct zb_zcl_on_off_on_with_timed_off_req_s zb_zcl_on_off_on_with_timed_off_req_t
 Structured representation of On with timed off command payload.
 
#define ZB_ZCL_ON_OFF_SEND_OFF_REQ( buffer, addr, dst_addr_mode, dst_ep, ep, prfl_id, dis_default_resp, cb)
 
#define ZB_ZCL_ON_OFF_SEND_ON_REQ( buffer, addr, dst_addr_mode, dst_ep, ep, prfl_id, dis_default_resp, cb)
 
#define ZB_ZCL_ON_OFF_SEND_TOGGLE_REQ( buffer, addr, dst_addr_mode, dst_ep, ep, prfl_id, dis_default_resp, cb)
 
#define ZB_ZCL_ON_OFF_SEND_OFF_WITH_EFFECT_REQ( buffer, addr, dst_addr_mode, dst_ep, ep, prof_id, dis_default_resp, effect_id, effect_var, cb)
 
#define ZB_ZCL_ON_OFF_SEND_ON_WITH_RECALL_GLOBAL_SCENE_REQ( buffer, addr, dst_addr_mode, dst_ep, ep, prof_id, dis_default_resp, cb)
 
#define ZB_ZCL_ON_OFF_SEND_ON_WITH_TIMED_OFF_REQ( buffer, addr, dst_addr_mode, dst_ep, ep, prof_id, dis_default_resp, on_off, on_time, off_wait_time, cb)
 
#define ZB_ZCL_ON_OFF_ACCEPT_ONLY_WHEN_ON   1
 
#define ZB_ZCL_ON_OFF_GET_OFF_WITH_EFFECT_REQ(data_ptr, buffer, status)
 Parses Off with Effect command. More...
 
#define ZB_ZCL_ON_OFF_GET_ON_WITH_TIMED_OFF_REQ(data_ptr, buffer, status)
 Parses On with timed off command. More...
 

Detailed Description

All commands in the cluster have only request form, and carry no payload.

Example
On command sending:
#define DST_ADDR g_dst_addr
#define DST_ADDR_MODE ZB_APS_ADDR_MODE_16_ENDP_PRESENT
#define ENDPOINT_C 5
#define ENDPOINT_ED 10
ZB_ZCL_ON_OFF_SEND_ON_REQ(buffer, DST_ADDR, DST_ADDR_MODE, ENDPOINT_C, ENDPOINT_ED, ZB_AF_HA_PROFILE_ID, ZB_ZCL_ENABLE_DEFAULT_RESPONSE, NULL);

Other two commands can be sent in the same way using appropriate macros.

For more information see 5.7.3_onoff_server sample

Macro Definition Documentation

◆ ZB_ZCL_DECLARE_ON_OFF_ATTRIB_LIST

#define ZB_ZCL_DECLARE_ON_OFF_ATTRIB_LIST (   attr_list,
  on_off 
)
Value:
ZB_ZCL_START_DECLARE_ATTRIB_LIST(attr_list) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_ON_OFF_ON_OFF_ID, (on_off)) \
ZB_ZCL_FINISH_DECLARE_ATTRIB_LIST

Declare attribute list for On/Off cluster.

Parameters
attr_list- attribute list name
on_off- pointer to variable to store On/Off attribute value

◆ ZB_ZCL_DECLARE_ON_OFF_ATTRIB_LIST_EXT

#define ZB_ZCL_DECLARE_ON_OFF_ATTRIB_LIST_EXT (   attr_list,
  on_off,
  global_scene_ctrl,
  on_time,
  off_wait_time 
)
Value:
ZB_ZCL_START_DECLARE_ATTRIB_LIST(attr_list) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_ON_OFF_ON_OFF_ID, (on_off)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_ON_OFF_GLOBAL_SCENE_CONTROL, (global_scene_ctrl)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_ON_OFF_ON_TIME, (on_time)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_ON_OFF_OFF_WAIT_TIME, (off_wait_time)) \
ZB_ZCL_FINISH_DECLARE_ATTRIB_LIST

Declare attribute list for On/Off cluster (extended attribute set).

Parameters
attr_list[IN] - attribute list name being declared by this macro.
on_off[IN] - pointer to a boolean variable storing on/off attribute value.
global_scene_ctrl[IN] - pointer to a boolean variable storing global scene control attribute value.
on_time[IN] - pointer to a unsigned 16-bit integer variable storing on time attribute value.
off_wait_time[IN] - pointer to a unsigned 16-bit integer variable storing off wait time attribute value.

◆ ZB_ZCL_ON_OFF_ACCEPT_ONLY_WHEN_ON

#define ZB_ZCL_ON_OFF_ACCEPT_ONLY_WHEN_ON   1

Accept only when on

See also
ZCL spec 3.8.2.3.6.1

◆ ZB_ZCL_ON_OFF_GET_OFF_WITH_EFFECT_REQ

#define ZB_ZCL_ON_OFF_GET_OFF_WITH_EFFECT_REQ (   data_ptr,
  buffer,
  status 
)
Value:
{ \
if (zb_buf_len((buffer)) != sizeof(zb_zcl_on_off_off_with_effect_req_t)) \
{ \
} \
else \
{ \
zb_zcl_on_off_off_with_effect_req_t *src_ptr = \
ZB_MEMCPY((data_ptr), src_ptr, sizeof(zb_zcl_on_off_off_with_effect_req_t)); \
} \
}

Parses Off with Effect command.

Attention
Assumes that ZCL header already cut.
Parameters
data_ptr- pointer to a variable of type zb_zcl_on_off_off_with_effect_req_s.
buffercontaining the packet (by pointer).
status- variable to put parse status to (see zb_zcl_parse_status_t).

◆ ZB_ZCL_ON_OFF_GET_ON_WITH_TIMED_OFF_REQ

#define ZB_ZCL_ON_OFF_GET_ON_WITH_TIMED_OFF_REQ (   data_ptr,
  buffer,
  status 
)
Value:
{ \
{ \
} \
else \
{ \
zb_zcl_on_off_on_with_timed_off_req_t *src_ptr = \
(data_ptr)->on_off = src_ptr->on_off; \
ZB_LETOH16(&((data_ptr)->on_time), &(src_ptr->on_time)); \
ZB_LETOH16(&((data_ptr)->off_wait_time), &(src_ptr->off_wait_time)); \
} \
}

Parses On with timed off command.

Attention
Assumes that ZCL header already cut.
Parameters
data_ptr- pointer to a variable of type zb_zcl_on_off_on_with_timed_off_req_s.
buffercontaining the packet (by pointer).
status- variable to put parse status to (see zb_zcl_parse_status_t).

◆ ZB_ZCL_ON_OFF_SEND_OFF_REQ

#define ZB_ZCL_ON_OFF_SEND_OFF_REQ (   buffer,
  addr,
  dst_addr_mode,
  dst_ep,
  ep,
  prfl_id,
  dis_default_resp,
  cb 
)
Value:
ZB_ZCL_ON_OFF_SEND_REQ( \
buffer, \
addr, \
dst_addr_mode, \
dst_ep, \
ep, \
prfl_id, \
dis_default_resp, \
cb)

Specific macro for sending Off command

◆ ZB_ZCL_ON_OFF_SEND_OFF_WITH_EFFECT_REQ

#define ZB_ZCL_ON_OFF_SEND_OFF_WITH_EFFECT_REQ (   buffer,
  addr,
  dst_addr_mode,
  dst_ep,
  ep,
  prof_id,
  dis_default_resp,
  effect_id,
  effect_var,
  cb 
)
Value:
{ \
zb_uint8_t* ptr = ZB_ZCL_START_PACKET_REQ(buffer) \
ZB_ZCL_CONSTRUCT_SPECIFIC_COMMAND_REQ_FRAME_CONTROL(ptr, dis_default_resp) \
ZB_ZCL_CONSTRUCT_COMMAND_HEADER_REQ(ptr, ZB_ZCL_GET_SEQ_NUM(), ZB_ZCL_CMD_ON_OFF_OFF_WITH_EFFECT_ID); \
ZB_ZCL_PACKET_PUT_DATA8(ptr, effect_id); \
ZB_ZCL_PACKET_PUT_DATA8(ptr, effect_var); \
ZB_ZCL_FINISH_PACKET(buffer, ptr) \
ZB_ZCL_SEND_COMMAND_SHORT(buffer, addr, dst_addr_mode, dst_ep, ep, prof_id, ZB_ZCL_CLUSTER_ID_ON_OFF, cb); \
}

Specific macro for sending Off with effect command

◆ ZB_ZCL_ON_OFF_SEND_ON_REQ

#define ZB_ZCL_ON_OFF_SEND_ON_REQ (   buffer,
  addr,
  dst_addr_mode,
  dst_ep,
  ep,
  prfl_id,
  dis_default_resp,
  cb 
)
Value:
ZB_ZCL_ON_OFF_SEND_REQ( \
buffer, \
addr, \
dst_addr_mode, \
dst_ep, \
ep, \
prfl_id, \
dis_default_resp, \
cb)

Specific macro for sending On command

◆ ZB_ZCL_ON_OFF_SEND_ON_WITH_RECALL_GLOBAL_SCENE_REQ

#define ZB_ZCL_ON_OFF_SEND_ON_WITH_RECALL_GLOBAL_SCENE_REQ (   buffer,
  addr,
  dst_addr_mode,
  dst_ep,
  ep,
  prof_id,
  dis_default_resp,
  cb 
)
Value:
ZB_ZCL_ON_OFF_SEND_REQ(buffer, addr, dst_addr_mode, dst_ep, ep, prof_id, dis_default_resp, \

Specific macro for sending On with recall global scene command

◆ ZB_ZCL_ON_OFF_SEND_ON_WITH_TIMED_OFF_REQ

#define ZB_ZCL_ON_OFF_SEND_ON_WITH_TIMED_OFF_REQ (   buffer,
  addr,
  dst_addr_mode,
  dst_ep,
  ep,
  prof_id,
  dis_default_resp,
  on_off,
  on_time,
  off_wait_time,
  cb 
)
Value:
{ \
zb_uint8_t* ptr = ZB_ZCL_START_PACKET_REQ(buffer) \
ZB_ZCL_CONSTRUCT_SPECIFIC_COMMAND_REQ_FRAME_CONTROL(ptr, dis_default_resp) \
ZB_ZCL_CONSTRUCT_COMMAND_HEADER_REQ(ptr, ZB_ZCL_GET_SEQ_NUM(), ZB_ZCL_CMD_ON_OFF_ON_WITH_TIMED_OFF_ID); \
ZB_ZCL_PACKET_PUT_DATA8(ptr, on_off); \
ZB_ZCL_PACKET_PUT_DATA16_VAL(ptr, on_time); \
ZB_ZCL_PACKET_PUT_DATA16_VAL(ptr, off_wait_time); \
ZB_ZCL_FINISH_PACKET(buffer, ptr) \
ZB_ZCL_SEND_COMMAND_SHORT(buffer, addr, dst_addr_mode, dst_ep, ep, prof_id, ZB_ZCL_CLUSTER_ID_ON_OFF, cb); \
}

Specific macro for sending On with timed off command

◆ ZB_ZCL_ON_OFF_SEND_TOGGLE_REQ

#define ZB_ZCL_ON_OFF_SEND_TOGGLE_REQ (   buffer,
  addr,
  dst_addr_mode,
  dst_ep,
  ep,
  prfl_id,
  dis_default_resp,
  cb 
)
Value:
ZB_ZCL_ON_OFF_SEND_REQ( \
buffer, \
addr, \
dst_addr_mode, \
dst_ep, \
ep, \
prfl_id, \
dis_default_resp, \
cb)

Specific macro for sending Toggle command

Enumeration Type Documentation

◆ zb_zcl_on_off_attr_e

On/Off cluster attribute identifiers.

See also
ZCL spec, subclause 3.8.2.2
Enumerator
ZB_ZCL_ATTR_ON_OFF_ON_OFF_ID 

OnOff attribute.

ZB_ZCL_ATTR_ON_OFF_GLOBAL_SCENE_CONTROL 

Global Scene Control attribute identifier.

ZB_ZCL_ATTR_ON_OFF_ON_TIME 

On Time attribute identifier.

ZB_ZCL_ATTR_ON_OFF_OFF_WAIT_TIME 

Off Wait Time attribute identifier.

ZB_ZCL_ATTR_ON_OFF_START_UP_ON_OFF 

The StartUpOnOff attribute SHALL define the desired startup behavior of a lamp device when it is supplied with power and this state SHALL be reflected in the OnOff attribute.

◆ zb_zcl_on_off_cmd_e

On/Off cluster command identifiers.

See also
ZCL spec, subclause 3.8.2.3
Enumerator
ZB_ZCL_CMD_ON_OFF_OFF_ID 

"Turn off" command.

ZB_ZCL_CMD_ON_OFF_ON_ID 

"Turn on" command.

ZB_ZCL_CMD_ON_OFF_TOGGLE_ID 

"Toggle state" command.

ZB_ZCL_CMD_ON_OFF_OFF_WITH_EFFECT_ID 

"Off with effect" command.

ZB_ZCL_CMD_ON_OFF_ON_WITH_RECALL_GLOBAL_SCENE_ID 

"On with recall global scene" command.

ZB_ZCL_CMD_ON_OFF_ON_WITH_TIMED_OFF_ID 

"On with timed off" command.

◆ zb_zcl_on_off_effect_e

Effect identifier enum

See also
ZCL spec 3.8.2.3.4.1
Enumerator
ZB_ZCL_ON_OFF_EFFECT_ID_DELAYED_ALL_OFF 

Effect identifier field value: Delayed all off Effect identifier field value: Dying light

◆ zb_zcl_on_off_effect_variant_delayed_e

Effect variant field for delayed enum

See also
ZCL spec 3.8.2.3.4.2
Enumerator
ZB_ZCL_ON_OFF_EFFECT_VARIANT_FADE 

Effect variant field value: Fade to off in 0.8 seconds Effect variant field value: No fade

ZB_ZCL_ON_OFF_EFFECT_VARIANT_NO_FADE 

Effect variant field value: 50% dim down in 0.8 seconds then fade to off in 12 seconds

◆ zb_zcl_on_off_effect_variant_dying_e

Effect variant field for delayed enum

See also
ZCL spec 3.8.2.3.4.2
Enumerator
ZB_ZCL_ON_OFF_EFFECT_VARIANT_20PART_FADE 

Effect variant field value: 20% dim up in 0.5s then fade to off in 1 second

◆ zb_zcl_on_off_on_off_e

Permissible values for OnOff attribute.

Enumerator
ZB_ZCL_ON_OFF_IS_OFF 

"Off" value

ZB_ZCL_ON_OFF_IS_ON 

"On" value

◆ zb_zcl_on_off_start_up_on_off_e

Enumerator
ZB_ZCL_ON_OFF_START_UP_ON_OFF_IS_OFF 

"Off" value

ZB_ZCL_ON_OFF_START_UP_ON_OFF_IS_ON 

"ON" value

ZB_ZCL_ON_OFF_START_UP_ON_OFF_IS_TOGGLE 

"Toggle" value

ZB_ZCL_ON_OFF_START_UP_ON_OFF_IS_PREVIOUS 

"Previous" value

ZB_ZCL_CMD_ON_OFF_ON_WITH_TIMED_OFF_ID
@ ZB_ZCL_CMD_ON_OFF_ON_WITH_TIMED_OFF_ID
Definition: zb_zcl_on_off.h:148
ZB_AF_HA_PROFILE_ID
#define ZB_AF_HA_PROFILE_ID
Definition: zboss_api_af.h:287
ZB_ZCL_ON_OFF_SEND_ON_REQ
#define ZB_ZCL_ON_OFF_SEND_ON_REQ( buffer, addr, dst_addr_mode, dst_ep, ep, prfl_id, dis_default_resp, cb)
Definition: zb_zcl_on_off.h:206
ZB_ZCL_CLUSTER_ID_ON_OFF
#define ZB_ZCL_CLUSTER_ID_ON_OFF
Definition: zb_zcl_common.h:207
ZB_ZCL_ATTR_ON_OFF_GLOBAL_SCENE_CONTROL
@ ZB_ZCL_ATTR_ON_OFF_GLOBAL_SCENE_CONTROL
Definition: zb_zcl_on_off.h:63
ZB_ZCL_ENABLE_DEFAULT_RESPONSE
#define ZB_ZCL_ENABLE_DEFAULT_RESPONSE
Definition: zb_zcl_common.h:932
ZB_ZCL_CMD_ON_OFF_TOGGLE_ID
@ ZB_ZCL_CMD_ON_OFF_TOGGLE_ID
Definition: zb_zcl_on_off.h:145
ZB_ZCL_CMD_ON_OFF_OFF_WITH_EFFECT_ID
@ ZB_ZCL_CMD_ON_OFF_OFF_WITH_EFFECT_ID
Definition: zb_zcl_on_off.h:146
ZB_ZCL_GET_SEQ_NUM
#define ZB_ZCL_GET_SEQ_NUM()
Return next sequence number for ZCL frame.
Definition: zb_zcl_common.h:1345
ZB_LETOH16
#define ZB_LETOH16
Definition: zb_types.h:786
zb_zcl_on_off_on_with_timed_off_req_s
Structured representation of On with timed off command payload.
Definition: zb_zcl_on_off.h:310
zb_zcl_on_off_off_with_effect_req_s
Structured representation of Off with effect command payload.
Definition: zb_zcl_on_off.h:301
zb_buf_begin
#define zb_buf_begin(buf)
Definition: zboss_api_buf.h:344
ZB_ZCL_CMD_ON_OFF_OFF_ID
@ ZB_ZCL_CMD_ON_OFF_OFF_ID
Definition: zb_zcl_on_off.h:143
ZB_ZCL_ATTR_ON_OFF_OFF_WAIT_TIME
@ ZB_ZCL_ATTR_ON_OFF_OFF_WAIT_TIME
Definition: zb_zcl_on_off.h:67
ZB_ZCL_PARSE_STATUS_SUCCESS
@ ZB_ZCL_PARSE_STATUS_SUCCESS
Definition: zb_zcl_common.h:324
ZB_ZCL_PARSE_STATUS_FAILURE
@ ZB_ZCL_PARSE_STATUS_FAILURE
Definition: zb_zcl_common.h:325
ZB_ZCL_ATTR_ON_OFF_ON_OFF_ID
@ ZB_ZCL_ATTR_ON_OFF_ON_OFF_ID
OnOff attribute.
Definition: zb_zcl_on_off.h:61
ZB_ZCL_CMD_ON_OFF_ON_WITH_RECALL_GLOBAL_SCENE_ID
@ ZB_ZCL_CMD_ON_OFF_ON_WITH_RECALL_GLOBAL_SCENE_ID
Definition: zb_zcl_on_off.h:147
ZB_ZCL_ATTR_ON_OFF_ON_TIME
@ ZB_ZCL_ATTR_ON_OFF_ON_TIME
Definition: zb_zcl_on_off.h:65
zb_buf_len
#define zb_buf_len(buf)
Definition: zboss_api_buf.h:362
ZB_ZCL_CMD_ON_OFF_ON_ID
@ ZB_ZCL_CMD_ON_OFF_ON_ID
Definition: zb_zcl_on_off.h:144