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

[TC-IDM-4.3] Report Data Messages post Subscription Activation (python) #33477

Draft
wants to merge 38 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
640286b
Initial commit
raul-marquez-csa May 15, 2024
68f3b6a
progress
raul-marquez-csa May 16, 2024
f67b271
Merge branch 'project-chip:master' into tc-idm-4.3-(python)
raul-marquez-csa May 21, 2024
8356a27
Updates steps to step array
raul-marquez-csa May 21, 2024
34b7667
Fix restyle
raul-marquez-csa May 21, 2024
078ed6b
Merge branch 'master' into tc-idm-4.3-(python)
raul-marquez-csa May 21, 2024
87ce2a4
progress
raul-marquez-csa May 21, 2024
17f9d2b
Step 2 progress
raul-marquez-csa May 22, 2024
cba575c
Lint
raul-marquez-csa May 22, 2024
ab37069
Merge branch 'master' into tc-idm-4.3-(python)
raul-marquez-csa May 22, 2024
0201dd7
Fix restyle
raul-marquez-csa May 22, 2024
2ba8359
Merge branch 'tc-idm-4.3-(python)' of github.com:raul-marquez-csa/con…
raul-marquez-csa May 22, 2024
985e53a
Merge branch 'project-chip:master' into tc-idm-4.3-(python)
raul-marquez-csa May 23, 2024
3900053
Adds handleNotifySubscriptionStillActive to AsyncReadTransaction, tem…
raul-marquez-csa May 23, 2024
759dd8c
Merge branch 'master' into tc-idm-4.3-(python)
raul-marquez-csa May 23, 2024
3eee95e
Merge branch 'master' into tc-idm-4.3-(python)
raul-marquez-csa May 24, 2024
56742f8
Adds SetNotifySubscriptionStillActiveCallback
raul-marquez-csa May 24, 2024
7674e43
Merge branch 'tc-idm-4.3-(python)' of github.com:raul-marquez-csa/con…
raul-marquez-csa May 24, 2024
e566592
Measuring time
raul-marquez-csa May 25, 2024
ce9f2a0
Merge branch 'master' into tc-idm-4.3-(python)
raul-marquez-csa May 29, 2024
5a5b92a
progress
raul-marquez-csa Jun 10, 2024
dd487fd
Merge branch 'tc-idm-4.3-(python)' of github.com:raul-marquez-csa/con…
raul-marquez-csa Jun 10, 2024
400c38f
Merge branch 'master' into tc-idm-4.3-(python)
raul-marquez-csa Jul 2, 2024
f68d2e8
Merge branch 'project-chip:master' into tc-idm-4.3-(python)
raul-marquez-csa Aug 1, 2024
b04d1a9
Removes duplicate AttributeChangeCallback class
raul-marquez-csa Aug 2, 2024
06dd24e
progress
raul-marquez-csa Aug 12, 2024
e635865
Merge branch 'project-chip:master' into tc-idm-4.3-(python)
raul-marquez-csa Aug 13, 2024
892d585
Step 1
raul-marquez-csa Aug 17, 2024
38fba93
Merge branch 'project-chip:master' into tc-idm-4.3-(python)
raul-marquez-csa Aug 17, 2024
74c170c
Merge branch 'project-chip:master' into tc-idm-4.3-(python)
raul-marquez-csa Aug 19, 2024
0251902
Step2 progress
raul-marquez-csa Aug 20, 2024
9f262a3
Step2 progress
raul-marquez-csa Aug 20, 2024
69928d8
Merge remote-tracking branch 'origin/master' into tc-idm-4.3-(python)
raul-marquez-csa Nov 19, 2024
78d4db1
Merge branch 'master' into tc-idm-4.3-(python)
raul-marquez-csa Nov 21, 2024
42a7bfe
Update to latest master merge and refactors
raul-marquez-csa Nov 21, 2024
c42d462
Fix restyle
raul-marquez-csa Nov 21, 2024
cccf2d7
Fix restyle
raul-marquez-csa Nov 21, 2024
01352e1
Merge branch 'master' into tc-idm-4.3-(python)
raul-marquez-csa Nov 26, 2024
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
4 changes: 4 additions & 0 deletions src/app/BufferedReadCallback.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ class BufferedReadCallback : public ReadClient::Callback
//
void OnReportBegin() override;
void OnReportEnd() override;
void NotifySubscriptionStillActive(const ReadClient & apReadClient) override
{
mCallback.NotifySubscriptionStillActive(apReadClient);
}
void OnAttributeData(const ConcreteDataAttributePath & aPath, TLV::TLVReader * apData, const StatusIB & aStatus) override;
void OnError(CHIP_ERROR aError) override
{
Expand Down
36 changes: 32 additions & 4 deletions src/controller/python/chip/clusters/Attribute.py
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,15 @@ def SetErrorCallback(self, callback: Callable[[int, SubscriptionTransaction], No
if callback is not None:
self._onErrorCb = callback

def SetNotifySubscriptionStillActiveCallback(self, callback: Callable):
'''
Sets the callback function that gets invoked when a report data message is sent. The callback
is expected to have the following signature:
def Callback()
'''
if callback is not None:
self._readTransaction.register_notify_subscription_still_active_callback(callback)

@property
def OnAttributeChangeCb(self) -> Callable[[TypedAttributePath, SubscriptionTransaction], None]:
return self._onAttributeChangeCb
Expand Down Expand Up @@ -817,12 +826,23 @@ def handleDone(self):
self._event_loop.call_soon_threadsafe(self._handleDone)

def handleReportBegin(self):
pass
self._handleReportBegin()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggest removing - this doesn't do anything.


def handleReportEnd(self):
# self._event_loop.call_soon_threadsafe(self._handleReportEnd)
self._handleReportEnd()

# def _handleNotifySubscriptionStillActive(self):
# if self._notify_subscription_still_active_callback:
# self._notify_subscription_still_active_callback()

def handleNotifySubscriptionStillActive(self):
# self._handleNotifySubscriptionStillActive()
if self._notify_subscription_still_active_callback:
self._notify_subscription_still_active_callback()

def register_notify_subscription_still_active_callback(self, callback):
self._notify_subscription_still_active_callback = callback


class AsyncWriteTransaction:
def __init__(self, future: Future, eventLoop):
Expand Down Expand Up @@ -885,6 +905,8 @@ def handleDone(self):
None, py_object)
_OnReportEndCallbackFunct = CFUNCTYPE(
None, py_object)
_OnNotifySubscriptionStillActiveCallbackFunct = CFUNCTYPE(
None, py_object)


@_OnReadAttributeDataCallbackFunct
Expand Down Expand Up @@ -934,6 +956,11 @@ def _OnReportEndCallback(closure):
closure.handleReportEnd()


@_OnNotifySubscriptionStillActiveCallbackFunct
def _OnNotifySubscriptionStillActiveCallback(closure):
closure.handleNotifySubscriptionStillActive()


@_OnReadDoneCallbackFunct
def _OnReadDoneCallback(closure):
closure.handleDone()
Expand Down Expand Up @@ -1199,14 +1226,15 @@ def Init():
_OnReadAttributeDataCallbackFunct, _OnReadEventDataCallbackFunct,
_OnSubscriptionEstablishedCallbackFunct, _OnResubscriptionAttemptedCallbackFunct,
_OnReadErrorCallbackFunct, _OnReadDoneCallbackFunct,
_OnReportBeginCallbackFunct, _OnReportEndCallbackFunct])
_OnReportBeginCallbackFunct, _OnReportEndCallbackFunct,
_OnNotifySubscriptionStillActiveCallbackFunct])

handle.pychip_WriteClient_InitCallbacks(
_OnWriteResponseCallback, _OnWriteErrorCallback, _OnWriteDoneCallback)
handle.pychip_ReadClient_InitCallbacks(
_OnReadAttributeDataCallback, _OnReadEventDataCallback,
_OnSubscriptionEstablishedCallback, _OnResubscriptionAttemptedCallback, _OnReadErrorCallback, _OnReadDoneCallback,
_OnReportBeginCallback, _OnReportEndCallback)
_OnReportBeginCallback, _OnReportEndCallback, _OnNotifySubscriptionStillActiveCallback)

_BuildAttributeIndex()
_BuildClusterIndex()
Expand Down
27 changes: 18 additions & 9 deletions src/controller/python/chip/clusters/attribute.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ using OnReadErrorCallback = void (*)(PyObject * appContext, PyChip
using OnReadDoneCallback = void (*)(PyObject * appContext);
using OnReportBeginCallback = void (*)(PyObject * appContext);
using OnReportEndCallback = void (*)(PyObject * appContext);
using OnNotifySubscriptionStillActiveCallback = void (*)(PyObject * appContext);

OnReadAttributeDataCallback gOnReadAttributeDataCallback = nullptr;
OnReadEventDataCallback gOnReadEventDataCallback = nullptr;
Expand All @@ -92,6 +93,7 @@ OnReadErrorCallback gOnReadErrorCallback = nullptr;
OnReadDoneCallback gOnReadDoneCallback = nullptr;
OnReportBeginCallback gOnReportBeginCallback = nullptr;
OnReportBeginCallback gOnReportEndCallback = nullptr;
OnNotifySubscriptionStillActiveCallback gOnNotifySubscriptionStillActiveCallback = nullptr;

void PythonResubscribePolicy(uint32_t aNumCumulativeRetries, uint32_t & aNextSubscriptionIntervalMsec, bool & aShouldResubscribe)
{
Expand Down Expand Up @@ -227,6 +229,11 @@ class ReadClientCallback : public ReadClient::Callback

void OnReportEnd() override { gOnReportEndCallback(mAppContext); }

void NotifySubscriptionStillActive(const ReadClient & apReadClient) override
{
gOnNotifySubscriptionStillActiveCallback(mAppContext);
}

void OnDone(ReadClient *) override
{
gOnReadDoneCallback(mAppContext);
Expand Down Expand Up @@ -329,16 +336,18 @@ void pychip_ReadClient_InitCallbacks(OnReadAttributeDataCallback onReadAttribute
OnSubscriptionEstablishedCallback onSubscriptionEstablishedCallback,
OnResubscriptionAttemptedCallback onResubscriptionAttemptedCallback,
OnReadErrorCallback onReadErrorCallback, OnReadDoneCallback onReadDoneCallback,
OnReportBeginCallback onReportBeginCallback, OnReportEndCallback onReportEndCallback)
OnReportBeginCallback onReportBeginCallback, OnReportEndCallback onReportEndCallback,
OnNotifySubscriptionStillActiveCallback onNotifySubscriptionStillActiveCallback)
{
gOnReadAttributeDataCallback = onReadAttributeDataCallback;
gOnReadEventDataCallback = onReadEventDataCallback;
gOnSubscriptionEstablishedCallback = onSubscriptionEstablishedCallback;
gOnResubscriptionAttemptedCallback = onResubscriptionAttemptedCallback;
gOnReadErrorCallback = onReadErrorCallback;
gOnReadDoneCallback = onReadDoneCallback;
gOnReportBeginCallback = onReportBeginCallback;
gOnReportEndCallback = onReportEndCallback;
gOnReadAttributeDataCallback = onReadAttributeDataCallback;
gOnReadEventDataCallback = onReadEventDataCallback;
gOnSubscriptionEstablishedCallback = onSubscriptionEstablishedCallback;
gOnResubscriptionAttemptedCallback = onResubscriptionAttemptedCallback;
gOnReadErrorCallback = onReadErrorCallback;
gOnReadDoneCallback = onReadDoneCallback;
gOnReportBeginCallback = onReportBeginCallback;
gOnReportEndCallback = onReportEndCallback;
gOnNotifySubscriptionStillActiveCallback = onNotifySubscriptionStillActiveCallback;
}

PyChipError pychip_WriteClient_WriteAttributes(void * appContext, DeviceProxy * device, size_t timedWriteTimeoutMsSizeT,
Expand Down
Loading
Loading