Skip to content

Commit

Permalink
[Python] Add TriggerResubscribeIfScheduled to SubscriptionTransaction
Browse files Browse the repository at this point in the history
Add TriggerResubscribeIfScheduled to SubscriptionTransaction. If the
ReadClient currently has a resubscription attempt scheduled, This
function allows to trigger that attempt immediately. This is useful
when the server side is up and communicating, and it's a good time to
try to resubscribe.
  • Loading branch information
agners committed Jun 5, 2024
1 parent d4d9054 commit bf71c58
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/controller/python/chip/clusters/Attribute.py
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,12 @@ def OverrideLivenessTimeoutMs(self, timeoutMs: int):
lambda: handle.pychip_ReadClient_OverrideLivenessTimeout(self._readTransaction._pReadClient, timeoutMs)
)

async def TriggerResubscribeIfScheduled(self, reason: str):
handle = chip.native.GetLibraryHandle()
await builtins.chipStack.CallAsync(
lambda: handle.pychip_ReadClient_TriggerResubscribeIfScheduled(self._readTransaction._pReadClient, reason.encode("utf-8"))
)

def GetReportingIntervalsSeconds(self) -> Tuple[int, int]:
'''
Retrieve the reporting intervals associated with an active subscription.
Expand Down
6 changes: 6 additions & 0 deletions src/controller/python/chip/clusters/attribute.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,12 @@ void pychip_ReadClient_OverrideLivenessTimeout(ReadClient * pReadClient, uint32_
pReadClient->OverrideLivenessTimeout(System::Clock::Milliseconds32(livenessTimeoutMs));
}

void pychip_ReadClient_TriggerResubscribeIfScheduled(ReadClient * pReadClient, const char * reason)
{
VerifyOrDie(pReadClient != nullptr);
pReadClient->TriggerResubscribeIfScheduled(reason);
}

PyChipError pychip_ReadClient_GetReportingIntervals(ReadClient * pReadClient, uint16_t * minIntervalSec, uint16_t * maxIntervalSec)
{
VerifyOrDie(pReadClient != nullptr);
Expand Down

0 comments on commit bf71c58

Please sign in to comment.