|
27 | 27 | from ctypes import CFUNCTYPE, c_size_t, c_uint8, c_uint16, c_uint32, c_uint64, c_void_p, py_object
|
28 | 28 | from dataclasses import dataclass, field
|
29 | 29 | from enum import Enum, unique
|
30 |
| -from typing import Any, Callable, Dict, List, Optional, Union |
| 30 | +from typing import Any, Callable, Dict, List, Optional, Tuple, Union |
31 | 31 |
|
32 | 32 | import chip.exceptions
|
33 | 33 | import chip.interaction_model
|
@@ -503,6 +503,26 @@ def OverrideLivenessTimeoutMs(self, timeoutMs: int):
|
503 | 503 | lambda: handle.pychip_ReadClient_OverrideLivenessTimeout(self._readTransaction._pReadClient, timeoutMs)
|
504 | 504 | )
|
505 | 505 |
|
| 506 | + def GetReportingIntervalsSeconds(self) -> Tuple[int, int]: |
| 507 | + ''' |
| 508 | + Retrieve the reporting intervals associated with an active subscription. |
| 509 | + This should only be called if we're of subscription interaction type and after a subscription has been established. |
| 510 | + ''' |
| 511 | + handle = chip.native.GetLibraryHandle() |
| 512 | + handle.pychip_ReadClient_GetReportingIntervals.argtypes = [ |
| 513 | + ctypes.c_void_p, ctypes.POINTER(ctypes.c_uint16), ctypes.POINTER(ctypes.c_uint16)] |
| 514 | + handle.pychip_ReadClient_GetReportingIntervals.restype = PyChipError |
| 515 | + |
| 516 | + minIntervalSec = ctypes.c_uint16(0) |
| 517 | + maxIntervalSec = ctypes.c_uint16(0) |
| 518 | + |
| 519 | + builtins.chipStack.Call( |
| 520 | + lambda: handle.pychip_ReadClient_GetReportingIntervals( |
| 521 | + self._readTransaction._pReadClient, ctypes.pointer(minIntervalSec), ctypes.pointer(maxIntervalSec)) |
| 522 | + ).raise_on_error() |
| 523 | + |
| 524 | + return minIntervalSec.value, maxIntervalSec.value |
| 525 | + |
506 | 526 | def SetResubscriptionAttemptedCallback(self, callback: Callable[[SubscriptionTransaction, int, int], None], isAsync=False):
|
507 | 527 | '''
|
508 | 528 | Sets the callback function that gets invoked anytime a re-subscription is attempted. The callback is expected
|
@@ -557,6 +577,10 @@ def OnEventChangeCb(self) -> Callable[[EventReadResult, SubscriptionTransaction]
|
557 | 577 | def OnErrorCb(self) -> Callable[[int, SubscriptionTransaction], None]:
|
558 | 578 | return self._onErrorCb
|
559 | 579 |
|
| 580 | + @property |
| 581 | + def subscriptionId(self) -> int: |
| 582 | + return self._subscriptionId |
| 583 | + |
560 | 584 | def Shutdown(self):
|
561 | 585 | if (self._isDone):
|
562 | 586 | print("Subscription was already terminated previously!")
|
|
0 commit comments