Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use interval floor of 0 for ICD devices #892

Merged
merged 2 commits into from
Sep 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions matter_server/server/device_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@
DATA_KEY_LAST_NODE_ID = "last_node_id"

LOGGER = logging.getLogger(__name__)
NODE_SUBSCRIPTION_FLOOR = 1
NODE_SUBSCRIPTION_FLOOR_DEFAULT = 1
NODE_SUBSCRIPTION_FLOOR_ICD = 1
NODE_SUBSCRIPTION_CEILING_WIFI = 60
NODE_SUBSCRIPTION_CEILING_THREAD = 60
NODE_SUBSCRIPTION_CEILING_BATTERY_POWERED = 600
Expand Down Expand Up @@ -117,6 +118,9 @@
0, Clusters.BasicInformation.Attributes.SoftwareVersionString
)
)
ICD_ATTR_LIST_ATTRIBUTE_PATH = create_attribute_path_from_attribute(
0, Clusters.IcdManagement.Attributes.AttributeList
)


# pylint: disable=too-many-lines,too-many-instance-attributes,too-many-public-methods
Expand Down Expand Up @@ -1236,6 +1240,13 @@ def resubscription_succeeded(
interval_ceiling = NODE_SUBSCRIPTION_CEILING_BATTERY_POWERED
else:
interval_ceiling = NODE_SUBSCRIPTION_CEILING_THREAD
if node.attributes.get(ICD_ATTR_LIST_ATTRIBUTE_PATH) is not None:
# for ICD devices, the interval floor must be 0 according to the spec,
# to prevent additional battery drainage. See Matter core spec, chapter 8.5.2.2.
# TODO: revisit this after Matter 1.4 release (as that mighht change this again).
interval_floor = NODE_SUBSCRIPTION_FLOOR_ICD
else:
interval_floor = NODE_SUBSCRIPTION_FLOOR_DEFAULT
self._resubscription_attempt[node_id] = 0
# set-up the actual subscription
sub: Attribute.SubscriptionTransaction = (
Expand All @@ -1244,7 +1255,7 @@ def resubscription_succeeded(
[()],
events=[("*", 1)],
return_cluster_objects=False,
report_interval=(NODE_SUBSCRIPTION_FLOOR, interval_ceiling),
report_interval=(interval_floor, interval_ceiling),
auto_resubscribe=True,
)
)
Expand Down