@@ -27,6 +27,7 @@ uint8_t powerSource = POWER_SOURCE_MAINS_1_PHASE; // 0x01 default
2727const uint16_t cluster_revision = 0x01 ;
2828DEF_STR (STRINGIFY_VALUE (VERSION_STR ), swBuildId );
2929extern network_indicator_t network_indicator ;
30+ extern zigbee_basic_cluster basic_cluster ;
3031
3132void basic_cluster_store_attrs_to_nv ();
3233void basic_cluster_load_attrs_from_nv ();
@@ -86,14 +87,18 @@ void basic_cluster_add_to_endpoint(zigbee_basic_cluster *cluster,
8687 ATTR_WRITABLE , device_config_str );
8788 SETUP_ATTR (12 , ZCL_ATTR_BASIC_MULTI_PRESS_RESET_COUNT , ZCL_DATA_TYPE_UINT8 ,
8889 ATTR_WRITABLE , g_multi_press_reset_count );
90+ SETUP_ATTR (13 , ZCL_ATTR_BASIC_INTERLOCK_MODE , ZCL_DATA_TYPE_BOOLEAN ,
91+ ATTR_WRITABLE , cluster -> interlock_mode );
92+ SETUP_ATTR (14 , ZCL_ATTR_BASIC_INTERLOCK_DELAY , ZCL_DATA_TYPE_UINT16 ,
93+ ATTR_WRITABLE , cluster -> interlock_delay_ms );
8994 if (network_indicator .has_dedicated_led ) {
90- SETUP_ATTR (13 , ZCL_ATTR_BASIC_STATUS_LED_STATE , ZCL_DATA_TYPE_BOOLEAN ,
95+ SETUP_ATTR (15 , ZCL_ATTR_BASIC_STATUS_LED_STATE , ZCL_DATA_TYPE_BOOLEAN ,
9196 ATTR_WRITABLE , network_indicator .manual_state_when_connected );
9297 }
9398
9499 endpoint -> clusters [endpoint -> cluster_count ].cluster_id = ZCL_CLUSTER_BASIC ;
95100 endpoint -> clusters [endpoint -> cluster_count ].attribute_count =
96- network_indicator .has_dedicated_led ? 14 : 13 ;
101+ network_indicator .has_dedicated_led ? 16 : 15 ;
97102 endpoint -> clusters [endpoint -> cluster_count ].attributes = cluster -> attr_infos ;
98103 endpoint -> clusters [endpoint -> cluster_count ].is_server = 1 ;
99104 endpoint -> cluster_count ++ ;
@@ -108,13 +113,17 @@ void basic_cluster_add_to_endpoint(zigbee_basic_cluster *cluster,
108113
109114typedef struct {
110115 uint8_t network_led_on ;
116+ uint8_t interlock_mode ;
117+ uint16_t interlock_delay_ms ;
111118} zigbee_basic_cluster_config ;
112119
113120static zigbee_basic_cluster_config nv_config_buffer ;
114121
115122void basic_cluster_store_attrs_to_nv () {
116123 nv_config_buffer .network_led_on =
117124 network_indicator .manual_state_when_connected ;
125+ nv_config_buffer .interlock_mode = basic_cluster .interlock_mode ;
126+ nv_config_buffer .interlock_delay_ms = basic_cluster .interlock_delay_ms ;
118127
119128 hal_nvm_write (NV_ITEM_BASIC_CLUSTER_DATA , sizeof (zigbee_basic_cluster_config ),
120129 (uint8_t * )& nv_config_buffer );
@@ -126,8 +135,18 @@ void basic_cluster_load_attrs_from_nv() {
126135 (uint8_t * )& nv_config_buffer );
127136
128137 if (st != HAL_NVM_SUCCESS ) {
138+ basic_cluster .interlock_mode = 0 ;
139+ basic_cluster .interlock_delay_ms = 100 ;
129140 return ;
130141 }
131142 network_indicator .manual_state_when_connected =
132143 nv_config_buffer .network_led_on ;
144+ basic_cluster .interlock_mode = nv_config_buffer .interlock_mode ;
145+ basic_cluster .interlock_delay_ms = nv_config_buffer .interlock_delay_ms ;
146+
147+ // In case NVM was blank (0xFF)
148+ if (basic_cluster .interlock_delay_ms == 0xFFFF ) {
149+ basic_cluster .interlock_mode = 0 ;
150+ basic_cluster .interlock_delay_ms = 100 ;
151+ }
133152}
0 commit comments