Skip to content

Commit

Permalink
Add option to disable server interaction (#871)
Browse files Browse the repository at this point in the history
  • Loading branch information
agners authored Sep 2, 2024
1 parent 18ba047 commit 5b0a173
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
6 changes: 6 additions & 0 deletions matter_server/server/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,11 @@
default=None,
help="Directory where OTA Provider stores software updates and configuration.",
)
parser.add_argument(
"--disable-server-interactions",
action="store_false",
help="Controls disabling server cluster interactions on a controller. This in turn disables advertisement of active controller operational identities.",
)

args = parser.parse_args()

Expand Down Expand Up @@ -223,6 +228,7 @@ def main() -> None:
args.enable_test_net_dcl,
args.bluetooth_adapter,
args.ota_provider_dir,
args.disable_server_interactions,
)

async def handle_stop(loop: asyncio.AbstractEventLoop) -> None:
Expand Down
7 changes: 4 additions & 3 deletions matter_server/server/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,12 @@ async def _handle_shutdown(app: web.Application) -> None:
class MatterServer:
"""Serve Matter stack over WebSockets."""

# pylint: disable=too-many-instance-attributes,too-many-arguments
# pylint: disable=too-many-instance-attributes

_runner: web.AppRunner | None = None
_http: MultiHostTCPSite | None = None

def __init__(
def __init__( # noqa: PLR0913, pylint: disable=too-many-arguments
self,
storage_path: str,
vendor_id: int,
Expand All @@ -112,6 +112,7 @@ def __init__(
enable_test_net_dcl: bool = False,
bluetooth_adapter_id: int | None = None,
ota_provider_dir: Path | None = None,
enable_server_interactions: bool = True,
) -> None:
"""Initialize the Matter Server."""
self.storage_path = storage_path
Expand All @@ -134,7 +135,7 @@ def __init__(
self.app = web.Application()
self.loop: asyncio.AbstractEventLoop | None = None
# Instantiate the Matter Stack using the SDK using the given storage path
self.stack = MatterStack(self, bluetooth_adapter_id)
self.stack = MatterStack(self, bluetooth_adapter_id, enable_server_interactions)
self.storage = StorageController(self)
self.vendor_info = VendorInfo(self)
# we dynamically register command handlers
Expand Down
5 changes: 4 additions & 1 deletion matter_server/server/stack.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ def __init__(
self,
server: "MatterServer",
bluetooth_adapter_id: int | None = None,
enable_server_interactions: bool = True,
) -> None:
"""Initialize Matter Stack."""
self.logger = logging.getLogger(__name__)
Expand All @@ -114,9 +115,11 @@ def __init__(
# Handle log level selection on SDK level
chip.logging.SetLogFilter(_category_num)

if not enable_server_interactions:
self.logger.warning("Initializing stack with server interactions disabled!")
self._chip_stack = ChipStack(
persistentStoragePath=storage_file,
enableServerInteractions=True,
enableServerInteractions=enable_server_interactions,
)

# Initialize Certificate Authority Manager
Expand Down

0 comments on commit 5b0a173

Please sign in to comment.