Skip to content

Commit

Permalink
- fixed error event priority level (#26872)
Browse files Browse the repository at this point in the history
- fixed the EventHeader could not be generated when unsuccessful
- fixed memory leak
  • Loading branch information
yzm157 authored and pull[bot] committed Oct 2, 2023
1 parent 816c050 commit 1080764
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions src/controller/python/chip/clusters/Attribute.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ class EventTimestampType(Enum):

@unique
class EventPriority(Enum):
DEBUG = 1
INFO = 2
CRITICAL = 3
DEBUG = 0
INFO = 1
CRITICAL = 2


@dataclass
Expand Down Expand Up @@ -535,7 +535,7 @@ def Callback(transaction: SubscriptionTransaction, errorEncountered: int, nextRe
self._onResubscriptionAttemptedCb = callback
self._onResubscriptionAttemptedCb_isAsync = isAsync

def SetResubscriptionSucceededCallback(self, callback: Callback[[SubscriptionTransaction], None], isAsync=False):
def SetResubscriptionSucceededCallback(self, callback: Callable[[SubscriptionTransaction], None], isAsync=False):
'''
Sets the callback function that gets invoked when a re-subscription attempt succeeds. The callback
is expected to have the following signature:
Expand Down Expand Up @@ -886,8 +886,13 @@ def _OnReadAttributeDataCallback(closure, dataVersion: int, endpoint: int, clust
def _OnReadEventDataCallback(closure, endpoint: int, cluster: int, event: c_uint64, number: int, priority: int, timestamp: int, timestampType: int, data, len, status):
dataBytes = ctypes.string_at(data, len)
path = EventPath(ClusterId=cluster, EventId=event)
closure.handleEventData(EventHeader(
EndpointId=endpoint, ClusterId=cluster, EventId=event, EventNumber=number, Priority=EventPriority(priority), Timestamp=timestamp, TimestampType=EventTimestampType(timestampType)), path, dataBytes[:], status)

# EventHeader is valid only when successful
eventHeader = None
if status == chip.interaction_model.Status.Success.value:
eventHeader = EventHeader(
EndpointId=endpoint, ClusterId=cluster, EventId=event, EventNumber=number, Priority=EventPriority(priority), Timestamp=timestamp, TimestampType=EventTimestampType(timestampType))
closure.handleEventData(eventHeader, path, dataBytes[:], status)


@_OnSubscriptionEstablishedCallbackFunct
Expand Down Expand Up @@ -1079,10 +1084,6 @@ def Read(future: Future, eventLoop, device, devCtrl, attributes: List[AttributeP
path = chip.interaction_model.EventPathIBstruct.build(path)
readargs.append(ctypes.c_char_p(path))

ctypes.pythonapi.Py_IncRef(ctypes.py_object(transaction))
minInterval = 0
maxInterval = 0

readClientObj = ctypes.POINTER(c_void_p)()
readCallbackObj = ctypes.POINTER(c_void_p)()

Expand Down

0 comments on commit 1080764

Please sign in to comment.