def GetCommissioner() -> Commissioner:
    """Gets a reference to the global commissioner singleton.

    Uses the configuration GetLocalNodeId().
    """

    global commissionerSingleton

    if commissionerSingleton is None:
        handle = GetLibraryHandle()
        _SetNativeCallSignatues(handle)

        native = handle.pychip_internal_Commissioner_New(GetLocalNodeId())
        if not native:
            raise Exception('Failed to create commissioner object.')

        handle.pychip_internal_PairingDelegate_SetNetworkCredentialsRequestedCallback(
            OnNetworkCredentialsRequested)
        handle.pychip_internal_PairingDelegate_SetOperationalCredentialsRequestedCallback(
            OnOperationalCredentialsRequested)
        handle.pychip_internal_PairingDelegate_SetPairingCompleteCallback(
            OnPairingComplete)

        commissionerSingleton = Commissioner(handle, native)

    return commissionerSingleton
Beispiel #2
0
    def __init__(self):
        self.chipLib = GetLibraryHandle()
        self.__InitNativeFunctions(self.chipLib)
        self.attributes = {}
        self.vendor_attributes = {}

        def AddAttribute(name, value):
            self.attributes[name.decode()] = value.decode()
        def AddVendorAttribute(tag, value):
            self.vendor_attributes[tag] = value.decode()

        self.attribute_visitor = SetupPayload.AttributeVisitor(AddAttribute)
        self.vendor_attribute_visitor = SetupPayload.VendorAttributeVisitor(AddVendorAttribute)