Skip to content

Commit

Permalink
FIx #21324 (#21339)
Browse files Browse the repository at this point in the history
* [Python] Fix BLE init sequence in Python REPL

* Fix
  • Loading branch information
erjiaqing authored and pull[bot] committed Aug 24, 2023
1 parent 735f6d2 commit 6449205
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/controller/python/chip/FabricAdmin.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,16 @@ class FabricAdmin:
boot for a given fabric and ensuring it automatically picks up the right ICAC/RCAC details as well.
'''

_handle = chip.native.GetLibraryHandle()
_isActive = False
activeFabricIndexList = set()
activeFabricIdList = set()
activeAdmins = set()
vendorId = None

@classmethod
def _Handle(cls):
return chip.native.GetLibraryHandle()

def AllocateNextFabricIndex(self):
''' Allocate the next un-used fabric index.
'''
Expand Down Expand Up @@ -133,10 +136,10 @@ def __init__(self, vendorId: int, rcac: bytes = None, icac: bytes = None, fabric

print(
f"New FabricAdmin: FabricId: {self._fabricId}({self._fabricIndex}), VendorId = {hex(self.vendorId)}")
self._handle.pychip_OpCreds_InitializeDelegate.restype = c_void_p
self._Handle().pychip_OpCreds_InitializeDelegate.restype = c_void_p

self.closure = builtins.chipStack.Call(
lambda: self._handle.pychip_OpCreds_InitializeDelegate(
lambda: self._Handle().pychip_OpCreds_InitializeDelegate(
ctypes.py_object(self), ctypes.c_uint32(self._fabricIndex))
)

Expand Down Expand Up @@ -195,7 +198,7 @@ def Shutdown(self, deleteFromStorage: bool = True):
'''
if (self._isActive):
builtins.chipStack.Call(
lambda: self._handle.pychip_OpCreds_FreeDelegate(
lambda: self._Handle().pychip_OpCreds_FreeDelegate(
ctypes.c_void_p(self.closure))
)

Expand Down

0 comments on commit 6449205

Please sign in to comment.