Skip to content

Commit

Permalink
Restore interface and move to other PR
Browse files Browse the repository at this point in the history
  • Loading branch information
tianfeng-yang committed Feb 29, 2024
1 parent 012b4a3 commit 1205903
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 47 deletions.
16 changes: 0 additions & 16 deletions src/controller/python/chip/clusters/Attribute.py
Original file line number Diff line number Diff line change
Expand Up @@ -520,22 +520,6 @@ def GetReportingIntervalsSeconds(self) -> Tuple[int, int]:

return minIntervalSec.value, maxIntervalSec.value

def GetSubscriptionTimeoutMs(self) -> int:
'''
Returns the timeout(milliseconds) after which we consider the subscription to have
dropped, if we have received no messages within that amount of time.
Returns 0 milliseconds if a subscription has not yet been established (and
hence the MaxInterval is not yet known), or if the subscription session
is gone and hence the relevant MRP parameters can no longer be determined.
'''
timeoutMs = ctypes.c_uint32(0)
handle = chip.native.GetLibraryHandle()
builtins.chipStack.Call(
lambda: handle.pychip_ReadClient_GetSubscriptionTimeout(self._readTransaction._pReadClient, ctypes.pointer(timeoutMs))
)
return timeoutMs.value

def SetResubscriptionAttemptedCallback(self, callback: Callable[[SubscriptionTransaction, int, int], None], isAsync=False):
'''
Sets the callback function that gets invoked anytime a re-subscription is attempted. The callback is expected
Expand Down
35 changes: 4 additions & 31 deletions src/controller/python/chip/clusters/attribute.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -471,22 +471,6 @@ PyChipError pychip_ReadClient_GetReportingIntervals(ReadClient * pReadClient, ui
return ToPyChipError(err);
}

void pychip_ReadClient_GetSubscriptionTimeout(ReadClient * pReadClient, uint32_t * milliSec)
{
VerifyOrDie(pReadClient != nullptr);

Optional<System::Clock::Timeout> duration = pReadClient->GetSubscriptionTimeout();

// The return value of GetSubscriptionTimeout cannot be 0
// so milliSec=0 can be considered as the subscription has been abnormal.
*milliSec = 0;
if (duration.HasValue())
{
System::Clock::Milliseconds32 msec = std::chrono::duration_cast<System::Clock::Milliseconds32>(duration.Value());
*milliSec = msec.count();
}
}

PyChipError pychip_ReadClient_Read(void * appContext, ReadClient ** pReadClient, ReadClientCallback ** pCallback,
DeviceProxy * device, uint8_t * readParamsBuf, void ** attributePathsFromPython,
size_t numAttributePaths, void ** dataversionFiltersFromPython, size_t numDataversionFilters,
Expand Down Expand Up @@ -576,22 +560,11 @@ PyChipError pychip_ReadClient_Read(void * appContext, ReadClient ** pReadClient,
params.mKeepSubscriptions = pyParams.keepSubscriptions;
callback->SetAutoResubscribe(pyParams.autoResubscribe);

#if CONFIG_BUILD_FOR_HOST_UNIT_TEST
if (!pyParams.autoResubscribe)
{
// We want to allow certain kinds of spec-invalid subscriptions so we
// can test how the server reacts to them.
err = readClient->SendSubscribeRequestWithoutValidation(params);
}
else
#endif // CONFIG_BUILD_FOR_HOST_UNIT_TEST
{
dataVersionFilters.release();
attributePaths.release();
eventPaths.release();
dataVersionFilters.release();
attributePaths.release();
eventPaths.release();

err = readClient->SendAutoResubscribeRequest(std::move(params));
}
err = readClient->SendAutoResubscribeRequest(std::move(params));
SuccessOrExit(err);
}
else
Expand Down

0 comments on commit 1205903

Please sign in to comment.