Skip to content

Commit fb62642

Browse files
authored
Deprecating the matter stateful helpers (#989)
Github: ZAP#682
1 parent 4193917 commit fb62642

File tree

2 files changed

+80
-18
lines changed

2 files changed

+80
-18
lines changed

src-electron/generator/helper-session.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1489,6 +1489,30 @@ async function generated_attribute_min_max_index(
14891489
return dataPtr
14901490
}
14911491

1492+
/**
1493+
* If helper that checks if there are clusters enabled
1494+
* Available options:
1495+
* - side: side="client/server" can be used to check if there are client or
1496+
* server side clusters are available
1497+
* @param {*} options
1498+
* @returns Promise of content.
1499+
*
1500+
*/
1501+
async function if_enabled_clusters(options) {
1502+
let endpointTypes = await templateUtil.ensureEndpointTypeIds(this)
1503+
let clusters =
1504+
await queryEndpointType.selectAllClustersDetailsFromEndpointTypes(
1505+
this.global.db,
1506+
endpointTypes,
1507+
options
1508+
)
1509+
if (clusters.length > 0) {
1510+
return options.fn(this)
1511+
} else {
1512+
return options.inverse(this)
1513+
}
1514+
}
1515+
14921516
const dep = templateUtil.deprecatedHelper
14931517

14941518
// WARNING! WARNING! WARNING! WARNING! WARNING! WARNING!
@@ -1592,3 +1616,4 @@ exports.is_command_default_response_enabled =
15921616
is_command_default_response_enabled
15931617
exports.is_command_default_response_disabled =
15941618
is_command_default_response_disabled
1619+
exports.if_enabled_clusters = if_enabled_clusters

src-electron/generator/matter/app/zap-templates/templates/chip/helper.js

Lines changed: 55 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -750,44 +750,81 @@ const dep = templateUtil.deprecatedHelper;
750750
//
751751
// Module exports
752752
//
753-
exports.chip_clusters = chip_clusters;
754-
exports.chip_has_clusters = chip_has_clusters;
753+
exports.chip_clusters = dep(
754+
chip_clusters,
755+
'chip_clusters has been deprecated. Use all_user_clusters.'
756+
);
757+
exports.chip_has_clusters = dep(
758+
chip_has_clusters,
759+
'Use first/last block helper within all_user_clusters.'
760+
);
755761
exports.chip_client_clusters = dep(
756762
chip_client_clusters,
757763
'chip_client_clusters has been deprecated. Use all_user_clusters with the \
758-
side option as client'
764+
side option as client.'
765+
);
766+
exports.chip_has_client_clusters = dep(
767+
chip_has_client_clusters,
768+
'chip_has_client_clusters has been deprecated. Use if_enabled_clusters with side option as client.'
769+
);
770+
exports.chip_server_clusters = dep(
771+
chip_server_clusters,
772+
'chip_server_clusters has been deprecated. Use all_user_clusters with the side option as server.'
773+
);
774+
exports.chip_has_server_clusters = dep(
775+
chip_has_server_clusters,
776+
'chip_has_server_clusters has been deprecated. Use if_enabled_clusters with side option as server.'
759777
);
760-
exports.chip_has_client_clusters = chip_has_client_clusters;
761-
exports.chip_server_clusters = chip_server_clusters;
762-
exports.chip_has_server_clusters = chip_has_server_clusters;
763778
exports.chip_cluster_commands = dep(
764779
chip_cluster_commands,
765-
'chip_cluster_commands has been deprecated. Use zcl_commands with source attribute as client'
780+
'chip_cluster_commands has been deprecated. Use zcl_commands with source attribute as client.'
766781
);
767782
exports.chip_cluster_command_arguments = dep(chip_cluster_command_arguments, {
768783
to: 'zcl_command_arguments',
769784
});
770-
exports.chip_cluster_command_arguments_with_structs_expanded =
771-
chip_cluster_command_arguments_with_structs_expanded;
785+
exports.chip_cluster_command_arguments_with_structs_expanded = dep(
786+
chip_cluster_command_arguments_with_structs_expanded,
787+
'chip_cluster_command_arguments_with_structs_expanded has been deprecated. Use if_is_struct and zcl_struct_items_by_struct_name to expand the structs.'
788+
);
772789
exports.chip_server_global_responses = chip_server_global_responses;
773790
exports.chip_cluster_responses = dep(chip_cluster_responses, {
774791
to: 'zcl_command_responses',
775792
});
776-
exports.chip_cluster_response_arguments = chip_cluster_response_arguments;
793+
exports.chip_cluster_response_arguments = dep(
794+
chip_cluster_response_arguments,
795+
'chip_cluster_response_arguments has been deprecated. Use zcl_command_arguments.'
796+
);
777797
exports.chip_attribute_list_entryTypes = chip_attribute_list_entryTypes;
778798
exports.chip_server_cluster_attributes = dep(
779799
chip_server_cluster_attributes,
780800
'chip_server_cluster_attributes has been deprecated. Use \
781801
enabled_attributes_for_cluster_and_side and \
782-
zcl_attributes_server to get enabled and all server attributes respectively'
802+
zcl_attributes_server to get enabled and all server attributes respectively.'
803+
);
804+
exports.chip_server_cluster_events = dep(
805+
chip_server_cluster_events,
806+
'chip_server_cluster_events has been deprecated. Use zcl_events.'
807+
);
808+
exports.chip_server_has_list_attributes = dep(
809+
chip_server_has_list_attributes,
810+
'chip_server_has_list_attributes has been deprecated. Use isArray option to fiter array type attributes and use first/last blocks for one time checks.'
811+
);
812+
exports.chip_server_has_reportable_attributes = dep(
813+
chip_server_has_reportable_attributes,
814+
'chip_server_has_reportable_attributes has been deprecated. Use isReportableAttribute option to fiter reportable attributes and use first/last blocks for one time checks.'
815+
);
816+
exports.chip_available_cluster_commands = dep(
817+
chip_available_cluster_commands,
818+
'chip_available_cluster_commands has been deprecated. Use zcl_commands or all_user_cluster_generated_commands.'
819+
);
820+
exports.chip_endpoints = dep(
821+
chip_endpoints,
822+
'chip_endpoints has been deprecated. Use user_endpoints.'
823+
);
824+
exports.chip_endpoint_clusters = dep(
825+
chip_endpoint_clusters,
826+
'chip_endpoint_clusters has been deprecated. Use user_clusters or all_user_clusters.'
783827
);
784-
exports.chip_server_cluster_events = chip_server_cluster_events;
785-
exports.chip_server_has_list_attributes = chip_server_has_list_attributes;
786-
exports.chip_server_has_reportable_attributes =
787-
chip_server_has_reportable_attributes;
788-
exports.chip_available_cluster_commands = chip_available_cluster_commands;
789-
exports.chip_endpoints = chip_endpoints;
790-
exports.chip_endpoint_clusters = chip_endpoint_clusters;
791828
exports.if_chip_enum = if_chip_enum;
792829
exports.if_chip_complex = if_chip_complex;
793830
exports.if_basic_global_response = dep(if_basic_global_response, {

0 commit comments

Comments
 (0)