blob: d987196f2b1dbfba79ffb2ce97ef3e3799afb7d2 [file] [log] [blame]
{
"cells": [
{
"cell_type": "markdown",
"id": "7953092e-e313-4fb5-82ab-ce1d42f4c1a9",
"metadata": {
"tags": []
},
"source": [
"# Multi Fabric - Commissioning and Interactions\n",
"\n",
"<a href=\"http://35.236.121.59/hub/user-redirect/git-pull?repo=https%3A%2F%2Fgithub.com%2Fproject-chip%2Fconnectedhomeip&urlpath=lab%2Ftree%2Fconnectedhomeip%2Fdocs%2Fguides%2Frepl%2FMatter%2520-%2520Multi%2520Fabric%2520Commissioning.ipynb&branch=master\">\n",
"<img src=\"https://i.ibb.co/hR3yWsC/launch-playground.png\" alt=\"drawing\" width=\"130\"/>\n",
"</a>\n",
"<br></br>\n",
"\n",
"This walks through creating multiple controllers on multiple fabrics, using those controllers to commission a target onto those fabrics and finally, interacting with them using the interaction model."
]
},
{
"cell_type": "markdown",
"id": "c8aae2cc-41fa-4101-a744-c725be5f034c",
"metadata": {},
"source": [
"## FabricAdmins and Controllers\n",
"\n",
"The `FabricAdmin` class (present in the `chip.FabricAdmin` package) is responsible for adminstering a fabric. It houses the Fabric ID and Index, as well as an RCAC and ICAC that provides the certificate material grounding that fabric.\n",
"\n",
"The `FabricAdmin` can be used to vend `ChipDeviceController` objects that represent a controller instance with a specific identity grounded in the admin's fabric. This controller can then be used to commission and interact with devices."
]
},
{
"cell_type": "markdown",
"id": "7f2e9f8d-eb79-494f-adac-efefdba7165f",
"metadata": {},
"source": [
"## Clear Persisted Storage\n",
"\n",
"Let's clear out our persisted storage (if one exists) to start from a clean slate."
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "b351b723-9849-430d-ad4e-f699897416d1",
"metadata": {
"tags": []
},
"outputs": [
{
"data": {
"text/plain": [
"<subprocess.Popen at 0x109e2b160>"
]
},
"execution_count": 1,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import os, subprocess\n",
"\n",
"if os.path.isfile('/tmp/repl-storage.json'):\n",
" os.remove('/tmp/repl-storage.json')\n",
"\n",
"# So that the all-clusters-app won't boot with stale prior state. \n",
"os.system('rm -rf /tmp/chip_*')"
]
},
{
"cell_type": "markdown",
"id": "f50759eb-3511-4312-9cfd-7431dcb9366a",
"metadata": {
"tags": []
},
"source": [
"## Initialization\n",
"\n",
"Let's first begin by setting up by importing some key modules that are needed to make it easier for us to interact with the Matter stack.\n",
"\n",
"`ChipReplStartup.py` is run within the global namespace. This results in all of its imports being made available here.\n",
"\n",
"> **NOTE**: _This is not needed if you launch the REPL from the command-line._"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "72f25a72-0b7e-41d5-a9ef-18af8a54ec39",
"metadata": {
"tags": []
},
"outputs": [
{
"data": {
"text/html": [
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #00ff00; text-decoration-color: #00ff00\">──────────────────────────────────────── </span>Matter REPL<span style=\"color: #00ff00; text-decoration-color: #00ff00\"> ────────────────────────────────────────</span>\n",
"</pre>\n"
],
"text/plain": [
"\u001b[92m──────────────────────────────────────── \u001b[0mMatter REPL\u001b[92m ────────────────────────────────────────\u001b[0m\n"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">\n",
" \n",
"<span style=\"color: #000080; text-decoration-color: #000080; font-weight: bold\"> </span>\n",
"<span style=\"color: #000080; text-decoration-color: #000080; font-weight: bold\"> Welcome to the Matter Python REPL!</span>\n",
"<span style=\"color: #000080; text-decoration-color: #000080; font-weight: bold\"> </span>\n",
"<span style=\"color: #000080; text-decoration-color: #000080; font-weight: bold\"> For help, please type </span><span style=\"color: #008000; text-decoration-color: #008000; font-weight: bold\">matterhelp()</span>\n",
"<span style=\"color: #000080; text-decoration-color: #000080; font-weight: bold\"> </span>\n",
"<span style=\"color: #000080; text-decoration-color: #000080; font-weight: bold\"> To get more information on a particular object/class, you can pass</span>\n",
"<span style=\"color: #000080; text-decoration-color: #000080; font-weight: bold\"> that into </span><span style=\"color: #008000; text-decoration-color: #008000; font-weight: bold\">matterhelp()</span><span style=\"color: #000080; text-decoration-color: #000080; font-weight: bold\"> as well.</span>\n",
"<span style=\"color: #000080; text-decoration-color: #000080; font-weight: bold\"> </span>\n",
"<span style=\"color: #000080; text-decoration-color: #000080; font-weight: bold\"> </span>\n",
"</pre>\n"
],
"text/plain": [
"\n",
" \n",
"\u001b[1;34m \u001b[0m\n",
"\u001b[1;34m Welcome to the Matter Python REPL!\u001b[0m\n",
"\u001b[1;34m \u001b[0m\n",
"\u001b[1;34m For help, please type \u001b[0m\u001b[1;32mmatterhelp\u001b[0m\u001b[1;32m(\u001b[0m\u001b[1;32m)\u001b[0m\n",
"\u001b[1;34m \u001b[0m\n",
"\u001b[1;34m To get more information on a particular object/class, you can pass\u001b[0m\n",
"\u001b[1;34m that into \u001b[0m\u001b[1;32mmatterhelp\u001b[0m\u001b[1;32m(\u001b[0m\u001b[1;32m)\u001b[0m\u001b[1;34m as well.\u001b[0m\n",
"\u001b[1;34m \u001b[0m\n",
"\u001b[1;34m \u001b[0m\n"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #00ff00; text-decoration-color: #00ff00\">─────────────────────────────────────────────────────────────────────────────────────────────</span>\n",
"</pre>\n"
],
"text/plain": [
"\u001b[92m─────────────────────────────────────────────────────────────────────────────────────────────\u001b[0m\n"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"2022-01-25 16:58:57 johnsj-macbookpro1.roam.corp.google.com root[27921] ERROR [Errno 2] No such file or directory: '/tmp/repl-storage.json'\n",
"2022-01-25 16:58:57 johnsj-macbookpro1.roam.corp.google.com root[27921] WARNING Could not load configuration from /tmp/repl-storage.json - resetting configuration...\n"
]
},
{
"data": {
"text/html": [
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">\n",
"<span style=\"color: #af00ff; text-decoration-color: #af00ff\">No previous fabric admins discovered in persistent storage - creating a new one...</span>\n",
"</pre>\n"
],
"text/plain": [
"\n",
"\u001b[38;5;129mNo previous fabric admins discovered in persistent storage - creating a new one\u001b[0m\u001b[38;5;129m...\u001b[0m\n"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"New FabricAdmin: FabricId: 1(1)\n"
]
},
{
"data": {
"text/html": [
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">\n",
"\n",
"</pre>\n"
],
"text/plain": [
"\n",
"\n"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #af00ff; text-decoration-color: #af00ff\">Creating default device controller on fabric </span><span style=\"color: #af00ff; text-decoration-color: #af00ff; font-weight: bold\">1</span><span style=\"color: #af00ff; text-decoration-color: #af00ff\">...</span>\n",
"</pre>\n"
],
"text/plain": [
"\u001b[38;5;129mCreating default device controller on fabric \u001b[0m\u001b[1;38;5;129m1\u001b[0m\u001b[38;5;129m...\u001b[0m\n"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Allocating new controller with FabricId: 1(1), NodeId: 1\n"
]
},
{
"data": {
"text/html": [
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">\n",
"\n",
"<span style=\"color: #000080; text-decoration-color: #000080\">Default CHIP Device Controller has been initialized to manage </span><span style=\"color: #800000; text-decoration-color: #800000; font-weight: bold\">fabricAdmins[</span><span style=\"color: #800000; text-decoration-color: #800000; font-weight: bold\">0</span><span style=\"color: #800000; text-decoration-color: #800000; font-weight: bold\">]</span><span style=\"color: #000080; text-decoration-color: #000080; font-weight: bold\">, and is </span>\n",
"<span style=\"color: #000080; text-decoration-color: #000080; font-weight: bold\">available as </span><span style=\"color: #800000; text-decoration-color: #800000; font-weight: bold\">devCtrl</span>\n",
"</pre>\n"
],
"text/plain": [
"\n",
"\n",
"\u001b[34mDefault CHIP Device Controller has been initialized to manage \u001b[0m\u001b[1;31mfabricAdmins\u001b[0m\u001b[1;31m[\u001b[0m\u001b[1;31m0\u001b[0m\u001b[1;31m]\u001b[0m\u001b[1;34m, and is \u001b[0m\n",
"\u001b[1;34mavailable as \u001b[0m\u001b[1;31mdevCtrl\u001b[0m\n"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"import chip.native\n",
"import pkgutil\n",
"module = pkgutil.get_loader('chip.ChipReplStartup')\n",
"%run {module.path}"
]
},
{
"cell_type": "markdown",
"id": "d79775d7-2ebb-4d05-9f2f-c7859802dc98",
"metadata": {},
"source": [
"At startup, the REPL will attempt to find any previously configured fabrics stored in persisted storage. If it can't find any (as is the case here), it will construct a default `FabricAdmin` object on Fabric 1 (Index 1) as well as construct a device controller (`devCtrl`) on that fabric."
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "030ecc69-bad4-476f-95d5-cb593597cad6",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">\n",
"<span style=\"font-weight: bold\">[</span>\n",
"<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ </span><span style=\"font-weight: bold\">&lt;</span><span style=\"color: #ff00ff; text-decoration-color: #ff00ff; font-weight: bold\">chip.FabricAdmin.FabricAdmin</span><span style=\"color: #000000; text-decoration-color: #000000\"> object at </span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0x10a68dee0</span><span style=\"font-weight: bold\">&gt;</span>\n",
"<span style=\"font-weight: bold\">]</span>\n",
"</pre>\n"
],
"text/plain": [
"\n",
"\u001b[1m[\u001b[0m\n",
"\u001b[2;32m│ \u001b[0m\u001b[1m<\u001b[0m\u001b[1;95mchip.FabricAdmin.FabricAdmin\u001b[0m\u001b[39m object at \u001b[0m\u001b[1;36m0x10a68dee0\u001b[0m\u001b[1m>\u001b[0m\n",
"\u001b[1m]\u001b[0m\n"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"fabricAdmins"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "a5c5b564-2d16-4790-8659-a7f7f304df98",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"font-weight: bold\">&lt;</span><span style=\"color: #ff00ff; text-decoration-color: #ff00ff; font-weight: bold\">chip.ChipDeviceCtrl.ChipDeviceController</span><span style=\"color: #000000; text-decoration-color: #000000\"> object at </span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0x10a6c6040</span><span style=\"font-weight: bold\">&gt;</span>\n",
"</pre>\n"
],
"text/plain": [
"\u001b[1m<\u001b[0m\u001b[1;95mchip.ChipDeviceCtrl.ChipDeviceController\u001b[0m\u001b[39m object at \u001b[0m\u001b[1;36m0x10a6c6040\u001b[0m\u001b[1m>\u001b[0m\n"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"devCtrl"
]
},
{
"cell_type": "markdown",
"id": "b793def3-10ff-4f86-a84a-fce81b7a86a4",
"metadata": {},
"source": [
"### Commission onto Fabric 1"
]
},
{
"cell_type": "markdown",
"id": "a84a90a5-726f-4634-a148-3860ba3ba0fc",
"metadata": {},
"source": [
"#### Launch Server\n",
"\n",
"Let's launch an instance of the `chip-all-clusters-app`."
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "b8b08b57-61a7-4c3e-8acc-cf4d78a67f55",
"metadata": {},
"outputs": [],
"source": [
"import time, os\n",
"import subprocess\n",
"os.system('pkill -f chip-all-clusters-app')\n",
"time.sleep(1)\n",
"\n",
"# The location of the all-clusters-app in the cloud playground is one level higher - adjust for this by testing for file presence.\n",
"if (os.path.isfile('../../../out/debug/chip-all-clusters-app')):\n",
" appPath = '../../../out/debug/chip-all-clusters-app'\n",
"else:\n",
" appPath = '../../../../out/debug/chip-all-clusters-app'\n",
"\n",
"process = subprocess.Popen(appPath, stdout=subprocess.DEVNULL)\n",
"time.sleep(1)"
]
},
{
"cell_type": "markdown",
"id": "cdbc86a0-24ca-4d1b-85f6-1d812a190817",
"metadata": {},
"source": [
"#### Commission Target\n",
"\n",
"Commission the target onto Fabric 1 using the default device controller instance with a NodeId of 1."
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "cde97ce7-6478-45fd-b985-103b09d8dfa9",
"metadata": {
"tags": []
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"2022-01-25 16:59:00 johnsj-macbookpro1.roam.corp.google.com chip.CTL[27921] ERROR Unable to find country code, defaulting to WW\n",
"2022-01-25 16:59:00 johnsj-macbookpro1.roam.corp.google.com chip.SC[27921] ERROR The device does not support GetClock_RealTimeMS() API. This will eventually result in CASE session setup failures.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Node address has been updated\n",
"Commissioning complete\n"
]
},
{
"data": {
"text/html": [
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #00ff00; text-decoration-color: #00ff00; font-style: italic\">True</span>\n",
"</pre>\n"
],
"text/plain": [
"\u001b[3;92mTrue\u001b[0m\n"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"devCtrl.CommissionIP(b'127.0.0.1', 20202021, 2)"
]
},
{
"cell_type": "markdown",
"id": "c24fea58-d8a3-4352-a3b6-716340da74e5",
"metadata": {},
"source": [
"### Read OpCreds Cluster\n",
"\n",
"Read out the OpCreds cluster to confirm membership into Fabric 1."
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "830e3421-45a6-435f-9617-bbf34f7c3fe0",
"metadata": {
"tags": []
},
"outputs": [
{
"data": {
"text/html": [
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">\n",
"<span style=\"font-weight: bold\">{</span>\n",
"<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ </span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0</span>: <span style=\"font-weight: bold\">{</span>\n",
"<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ │ </span><span style=\"font-weight: bold\">&lt;</span><span style=\"color: #ff00ff; text-decoration-color: #ff00ff; font-weight: bold\">class</span><span style=\"color: #000000; text-decoration-color: #000000\"> </span><span style=\"color: #008000; text-decoration-color: #008000\">'chip.clusters.Objects.OperationalCredentials'</span><span style=\"font-weight: bold\">&gt;</span>: <span style=\"font-weight: bold\">{</span>\n",
"<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ │ │ </span><span style=\"font-weight: bold\">&lt;</span><span style=\"color: #ff00ff; text-decoration-color: #ff00ff; font-weight: bold\">class</span><span style=\"color: #000000; text-decoration-color: #000000\"> </span><span style=\"color: #008000; text-decoration-color: #008000\">'chip.clusters.Objects.OperationalCredentials.Attributes.FabricsList'</span><span style=\"font-weight: bold\">&gt;</span>: <span style=\"font-weight: bold\">[</span>\n",
"<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ │ │ │ </span><span style=\"color: #800080; text-decoration-color: #800080; font-weight: bold\">FabricDescriptor</span><span style=\"font-weight: bold\">(</span>\n",
"<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ │ │ │ │ </span><span style=\"color: #808000; text-decoration-color: #808000\">fabricIndex</span>=<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">1</span>,\n",
"<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ │ │ │ │ </span><span style=\"color: #808000; text-decoration-color: #808000\">rootPublicKey</span>=<span style=\"color: #008000; text-decoration-color: #008000\">b'\\x04\\xa2\\x88}\\xbd\\xdb\\xd4\\xbc^U\\xa3\\xcef\\xf7\\x92\\xbe\\xa7X;E\\xb8-Y\\x12^$\\xe0\\x1bS\\xf9\\x9a\\x8f\\xacvj\\xfa!&amp;m6\\x00\\xe3\\xd1\\x85o\\x1b\\x9eH\\xabC?\\xd8\\xec\\x08lH\\xb5X\\x1f:u\\xb0\\xfbj\\x98'</span>,\n",
"<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ │ │ │ │ </span><span style=\"color: #808000; text-decoration-color: #808000\">vendorId</span>=<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">27168</span>,\n",
"<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ │ │ │ │ </span><span style=\"color: #808000; text-decoration-color: #808000\">fabricId</span>=<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">1</span>,\n",
"<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ │ │ │ │ </span><span style=\"color: #808000; text-decoration-color: #808000\">nodeId</span>=<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">2</span>,\n",
"<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ │ │ │ │ </span><span style=\"color: #808000; text-decoration-color: #808000\">label</span>=<span style=\"color: #008000; text-decoration-color: #008000\">''</span>\n",
"<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ │ │ │ </span><span style=\"font-weight: bold\">)</span>\n",
"<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ │ │ </span><span style=\"font-weight: bold\">]</span>\n",
"<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ │ </span><span style=\"font-weight: bold\">}</span>\n",
"<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ </span><span style=\"font-weight: bold\">}</span>\n",
"<span style=\"font-weight: bold\">}</span>\n",
"</pre>\n"
],
"text/plain": [
"\n",
"\u001b[1m{\u001b[0m\n",
"\u001b[2;32m│ \u001b[0m\u001b[1;36m0\u001b[0m: \u001b[1m{\u001b[0m\n",
"\u001b[2;32m│ │ \u001b[0m\u001b[1m<\u001b[0m\u001b[1;95mclass\u001b[0m\u001b[39m \u001b[0m\u001b[32m'chip.clusters.Objects.OperationalCredentials'\u001b[0m\u001b[1m>\u001b[0m: \u001b[1m{\u001b[0m\n",
"\u001b[2;32m│ │ │ \u001b[0m\u001b[1m<\u001b[0m\u001b[1;95mclass\u001b[0m\u001b[39m \u001b[0m\u001b[32m'chip.clusters.Objects.OperationalCredentials.Attributes.FabricsList'\u001b[0m\u001b[1m>\u001b[0m: \u001b[1m[\u001b[0m\n",
"\u001b[2;32m│ │ │ │ \u001b[0m\u001b[1;35mFabricDescriptor\u001b[0m\u001b[1m(\u001b[0m\n",
"\u001b[2;32m│ │ │ │ │ \u001b[0m\u001b[33mfabricIndex\u001b[0m=\u001b[1;36m1\u001b[0m,\n",
"\u001b[2;32m│ │ │ │ │ \u001b[0m\u001b[33mrootPublicKey\u001b[0m=\u001b[32mb\u001b[0m\u001b[32m'\\x04\\xa2\\x88\u001b[0m\u001b[32m}\u001b[0m\u001b[32m\\xbd\\xdb\\xd4\\xbc^U\\xa3\\xcef\\xf7\\x92\\xbe\\xa7X;E\\xb8-Y\\x12^$\\xe0\\x1bS\\xf9\\x9a\\x8f\\xacvj\\xfa!&m6\\x00\\xe3\\xd1\\x85o\\x1b\\x9eH\\xabC?\\xd8\\xec\\x08lH\\xb5X\\x1f:u\\xb0\\xfbj\\x98'\u001b[0m,\n",
"\u001b[2;32m│ │ │ │ │ \u001b[0m\u001b[33mvendorId\u001b[0m=\u001b[1;36m27168\u001b[0m,\n",
"\u001b[2;32m│ │ │ │ │ \u001b[0m\u001b[33mfabricId\u001b[0m=\u001b[1;36m1\u001b[0m,\n",
"\u001b[2;32m│ │ │ │ │ \u001b[0m\u001b[33mnodeId\u001b[0m=\u001b[1;36m2\u001b[0m,\n",
"\u001b[2;32m│ │ │ │ │ \u001b[0m\u001b[33mlabel\u001b[0m=\u001b[32m''\u001b[0m\n",
"\u001b[2;32m│ │ │ │ \u001b[0m\u001b[1m)\u001b[0m\n",
"\u001b[2;32m│ │ │ \u001b[0m\u001b[1m]\u001b[0m\n",
"\u001b[2;32m│ │ \u001b[0m\u001b[1m}\u001b[0m\n",
"\u001b[2;32m│ \u001b[0m\u001b[1m}\u001b[0m\n",
"\u001b[1m}\u001b[0m\n"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"await devCtrl.ReadAttribute(2, [(Clusters.OperationalCredentials.Attributes.FabricsList)], fabricFiltered=False)"
]
},
{
"cell_type": "markdown",
"id": "77c0c2a1-3014-4dc5-8d42-5a3459ed311a",
"metadata": {},
"source": [
"### Commission onto Fabric 2"
]
},
{
"cell_type": "markdown",
"id": "965a5fbf-5762-4432-93f9-47782c5ee050",
"metadata": {},
"source": [
"#### Create new FabricAdmin"
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "9f7d6810-6d8e-47c9-8795-b4bc8777e963",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"New FabricAdmin: FabricId: 2(2)\n"
]
}
],
"source": [
"import chip.FabricAdmin as FabricAdmin\n",
"fabric2 = FabricAdmin.FabricAdmin(fabricId = 2, fabricIndex = 2)"
]
},
{
"cell_type": "markdown",
"id": "73477a0d-f80f-4973-b34b-fe31b55cb5e1",
"metadata": {},
"source": [
"Here's a brief peek at the JSON data that is in the persisted storage file."
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "f211c5be-665b-4630-9570-a44a6f17f358",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">\n",
"<span style=\"font-weight: bold\">{</span>\n",
"<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ </span><span style=\"color: #008000; text-decoration-color: #008000\">'repl-config'</span>: <span style=\"font-weight: bold\">{</span>\n",
"<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ │ </span><span style=\"color: #008000; text-decoration-color: #008000\">'fabricAdmins'</span>: <span style=\"font-weight: bold\">{</span>\n",
"<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ │ │ </span><span style=\"color: #008000; text-decoration-color: #008000\">'1'</span>: <span style=\"font-weight: bold\">{</span>\n",
"<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ │ │ │ </span><span style=\"color: #008000; text-decoration-color: #008000\">'fabricId'</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">1</span>\n",
"<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ │ │ </span><span style=\"font-weight: bold\">}</span>,\n",
"<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ │ │ </span><span style=\"color: #008000; text-decoration-color: #008000\">'2'</span>: <span style=\"font-weight: bold\">{</span>\n",
"<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ │ │ │ </span><span style=\"color: #008000; text-decoration-color: #008000\">'fabricId'</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">2</span>\n",
"<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ │ │ </span><span style=\"font-weight: bold\">}</span>\n",
"<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ │ </span><span style=\"font-weight: bold\">}</span>\n",
"<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ </span><span style=\"font-weight: bold\">}</span>,\n",
"<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ </span><span style=\"color: #008000; text-decoration-color: #008000\">'sdk-config'</span>: <span style=\"font-weight: bold\">{</span>\n",
"<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ │ </span><span style=\"color: #008000; text-decoration-color: #008000\">'ExampleOpCredsCAKey1'</span>: <span style=\"color: #008000; text-decoration-color: #008000\">'BKKIfb3b1LxeVaPOZveSvqdYO0W4LVkSXiTgG1P5mo+sdmr6ISZtNgDj0YVvG55Iq0M/2OwIbEi1WB86dbD7apgpj13h8fueMKMfErM65jMAsAPBcPEhnVc3JJ6m7K4Qq0ORAwBgAABhAAAAAAAAAA=='</span>,\n",
"<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ │ </span><span style=\"color: #008000; text-decoration-color: #008000\">'ExampleOpCredsICAKey1'</span>: <span style=\"color: #008000; text-decoration-color: #008000\">'BCwMgmSo2C1vhjBR642H5nieC/jJManFAW54QhdovJhdySYZn96XJoBNyouhoGf9rn0SipgIhmvHPcPqDrDwcAXiQyB87caIuz5DJ3v7KHHLquGmdv5pNpZ4IhqDomt/2kORAwBgAABhAAAAAAAAAA=='</span>,\n",
"<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ │ </span><span style=\"color: #008000; text-decoration-color: #008000\">'ExampleCAIntermediateCert1'</span>: <span style=\"color: #008000; text-decoration-color: #008000\">'MIIB2TCCAYCgAwIBAgIBADAKBggqhkjOPQQDAjBEMSAwHgYKKwYBBAGConwBBAwQMDAwMDAwMDAwMDAwMDAwMDEgMB4GCisGAQQBgqJ8AQUMEDAwMDAwMDAwMDAwMDAwMDEwHhcNMjEwMTAxMDAwMDAwWhcNMzAxMjMwMDAwMDAwWjBEMSAwHgYKKwYBBAGConwBAwwQMDAwMDAwMDAwMDAwMDAwMTEgMB4GCisGAQQBgqJ8AQUMEDAwMDAwMDAwMDAwMDAwMDEwWTATBgcqhkjOPQIBBggqhkjOPQMBBwNCAAQsDIJkqNgtb4YwUeuNh+Z4ngv4yTGpxQFueEIXaLyYXckmGZ/elyaATcqLoaBn/a59EoqYCIZrxz3D6g6w8HAFo2MwYTAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQUcPz5CkZJujm2U0jL0G1lZwoJXD0wHwYDVR0jBBgwFoAUfvAKJyeJwjao2nq+Q3ayf27KXrUwCgYIKoZIzj0EAwIDRwAwRAIgEaX5gBqc5b8eswqDDlc2IQ+wLKfbsONC3FzsuwLCBNkCIAyn32oaFV0YCN9GeiUpYvqbypnMWQGnffF85v7wKhBX'</span>,\n",
"<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ │ </span><span style=\"color: #008000; text-decoration-color: #008000\">'ExampleCARootCert1'</span>: <span style=\"color: #008000; text-decoration-color: #008000\">'MIIB2jCCAYCgAwIBAgIBADAKBggqhkjOPQQDAjBEMSAwHgYKKwYBBAGConwBBAwQMDAwMDAwMDAwMDAwMDAwMDEgMB4GCisGAQQBgqJ8AQUMEDAwMDAwMDAwMDAwMDAwMDEwHhcNMjEwMTAxMDAwMDAwWhcNMzAxMjMwMDAwMDAwWjBEMSAwHgYKKwYBBAGConwBBAwQMDAwMDAwMDAwMDAwMDAwMDEgMB4GCisGAQQBgqJ8AQUMEDAwMDAwMDAwMDAwMDAwMDEwWTATBgcqhkjOPQIBBggqhkjOPQMBBwNCAASiiH2929S8XlWjzmb3kr6nWDtFuC1ZEl4k4BtT+ZqPrHZq+iEmbTYA49GFbxueSKtDP9jsCGxItVgfOnWw+2qYo2MwYTAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQUfvAKJyeJwjao2nq+Q3ayf27KXrUwHwYDVR0jBBgwFoAUfvAKJyeJwjao2nq+Q3ayf27KXrUwCgYIKoZIzj0EAwIDSAAwRQIgMzvVbqCxT+xJOpxN9HUSYZYdExmkRLN2Jl9vLijLc+sCIQDAxLgwwuxGNPtWJ/dY4kGqpWwNNbq9pEkmQ//t2KhfBg=='</span>,\n",
"<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ │ </span><span style=\"color: #008000; text-decoration-color: #008000\">'ExampleOpCredsCAKey2'</span>: <span style=\"color: #008000; text-decoration-color: #008000\">'BJ1gkAlp0ZrmBkQiko2ces/p86N1qCB30y+tdT5HrWEBqgPh6SVNnZfe5ZMjzJZFp/J1K+7MSDF7QeAgKrQYwcAcV1G9fnqw9anHoj+EW2k9xqw0b4bWXE9f2xKfWWb/ykCSAwBgAABhAAAAAAAAAA=='</span>,\n",
"<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ │ </span><span style=\"color: #008000; text-decoration-color: #008000\">'ExampleOpCredsICAKey2'</span>: <span style=\"color: #008000; text-decoration-color: #008000\">'BMktytxSOcWsbMcZ6WrjsODvTRKcLWZjo8bt8CDUqfhoHLFqrmahTQnH4rY8gjRpKRBw/Yw2YpEodcaLyC1V+cC2VvZrLqLVW8uRNPkVxcojVHAXYAGCRp6CW4kQ+zBtNUCSAwBgAABhAAAAAAAAAA=='</span>\n",
"<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ </span><span style=\"font-weight: bold\">}</span>\n",
"<span style=\"font-weight: bold\">}</span>\n",
"</pre>\n"
],
"text/plain": [
"\n",
"\u001b[1m{\u001b[0m\n",
"\u001b[2;32m│ \u001b[0m\u001b[32m'repl-config'\u001b[0m: \u001b[1m{\u001b[0m\n",
"\u001b[2;32m│ │ \u001b[0m\u001b[32m'fabricAdmins'\u001b[0m: \u001b[1m{\u001b[0m\n",
"\u001b[2;32m│ │ │ \u001b[0m\u001b[32m'1'\u001b[0m: \u001b[1m{\u001b[0m\n",
"\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'fabricId'\u001b[0m: \u001b[1;36m1\u001b[0m\n",
"\u001b[2;32m│ │ │ \u001b[0m\u001b[1m}\u001b[0m,\n",
"\u001b[2;32m│ │ │ \u001b[0m\u001b[32m'2'\u001b[0m: \u001b[1m{\u001b[0m\n",
"\u001b[2;32m│ │ │ │ \u001b[0m\u001b[32m'fabricId'\u001b[0m: \u001b[1;36m2\u001b[0m\n",
"\u001b[2;32m│ │ │ \u001b[0m\u001b[1m}\u001b[0m\n",
"\u001b[2;32m│ │ \u001b[0m\u001b[1m}\u001b[0m\n",
"\u001b[2;32m│ \u001b[0m\u001b[1m}\u001b[0m,\n",
"\u001b[2;32m│ \u001b[0m\u001b[32m'sdk-config'\u001b[0m: \u001b[1m{\u001b[0m\n",
"\u001b[2;32m│ │ \u001b[0m\u001b[32m'ExampleOpCredsCAKey1'\u001b[0m: \u001b[32m'BKKIfb3b1LxeVaPOZveSvqdYO0W4LVkSXiTgG1P5mo+sdmr6ISZtNgDj0YVvG55Iq0M/2OwIbEi1WB86dbD7apgpj13h8fueMKMf\u001b[0m\u001b[32mErM65jMAsAPBcPEhnVc3JJ6m7K4Qq0ORAwBgAABhAAAAAAAAAA\u001b[0m\u001b[32m=='\u001b[0m,\n",
"\u001b[2;32m│ │ \u001b[0m\u001b[32m'ExampleOpCredsICAKey1'\u001b[0m: \u001b[32m'BCwMgmSo2C1vhjBR642H5nieC/jJManFAW54QhdovJhdySYZn96XJoBNyouhoGf9rn0SipgIhmvHPcPqDrDwcAXiQyB87caIuz5DJ3v7KHHLquGmdv5pNpZ4IhqDomt/\u001b[0m\u001b[32m2kORAwBgAABhAAAAAAAAAA\u001b[0m\u001b[32m=='\u001b[0m,\n",
"\u001b[2;32m│ │ \u001b[0m\u001b[32m'ExampleCAIntermediateCert1'\u001b[0m: \u001b[32m'MIIB2TCCAYCgAwIBAgIBADAKBggqhkjOPQQDAjBEMSAwHgYKKwYBBAGConwBBAwQMDAwMDAwMDAwMDAwMDAwMDEgMB4GCisGAQQBgqJ8AQUMEDAwMDAwMDAwMDAwMDAwMDEwHhcNMjEwMTAxMDAwMDAwWhcNMzAxMjMwMDAwMDAwWjBEMSAwHgYKKwYBBAGConwBAwwQMDAwMDAwMDAwMDAwMDAwMTEgMB4GCisGAQQBgqJ8AQUMEDAwMDAwMDAwMDAwMDAwMDEwWTATBgcqhkjOPQIBBggqhkjOPQMBBwNCAAQsDIJkqNgtb4YwUeuNh+Z4ngv4yTGpxQFueEIXaLyYXckmGZ/elyaATcqLoaBn/a59EoqYCIZrxz3D6g6w8HAFo2MwYTAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQUcPz5CkZJujm2U0jL0G1lZwoJXD0wHwYDVR0jBBgwFoAUfvAKJyeJwjao2nq+Q3ayf27KXrUwCgYIKoZIzj0EAwIDRwAwRAIgEaX5gBqc5b8eswqDDlc2IQ+wLKfbsONC3FzsuwLCBNkCIAyn32oaFV0YCN9GeiUpYvqbypnMWQGnffF85v7wKhBX'\u001b[0m,\n",
"\u001b[2;32m│ │ \u001b[0m\u001b[32m'ExampleCARootCert1'\u001b[0m: \u001b[32m'MIIB2jCCAYCgAwIBAgIBADAKBggqhkjOPQQDAjBEMSAwHgYKKwYBBAGConwBBAwQMDAwMDAwMDAwMDAwMDAwMDEgMB4GCisGAQQBgqJ8AQUMEDAwMDAwMDAwMDAwMDAwMDEwHhcNMjEwMTAxMDAwMDAwWhcNMzAxMjMwMDAwMDAwWjBEMSAwHgYKKwYBBAGConwBBAwQMDAwMDAwMDAwMDAwMDAwMDEgMB4GCisGAQQBgqJ8AQUMEDAwMDAwMDAwMDAwMDAwMDEwWTATBgcqhkjOPQIBBggqhkjOPQMBBwNCAASiiH2929S8XlWjzmb3kr6nWDtFuC1ZEl4k4BtT+ZqPrHZq+iEmbTYA49GFbxueSKtDP9jsCGxItVgfOnWw+2qYo2MwYTAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQUfvAKJyeJwjao2nq+Q3ayf27KXrUwHwYDVR0jBBgwFoAUfvAKJyeJwjao2nq+Q3ayf27KXrUwCgYIKoZIzj0EAwIDSAAwRQIgMzvVbqCxT+xJOpxN9HUSYZYdExmkRLN2Jl9vLijLc+sCIQDAxLgwwuxGNPtWJ/dY4kGqpWwNNbq9pEkmQ//\u001b[0m\u001b[32mt2KhfBg\u001b[0m\u001b[32m=='\u001b[0m,\n",
"\u001b[2;32m│ │ \u001b[0m\u001b[32m'ExampleOpCredsCAKey2'\u001b[0m: \u001b[32m'BJ1gkAlp0ZrmBkQiko2ces/p86N1qCB30y+tdT5HrWEBqgPh6SVNnZfe5ZMjzJZFp/J1K+7MSDF7QeAgKrQYwcAcV1G9fnqw9anHoj+EW2k9xqw0b4bWXE9f2xKfWWb/\u001b[0m\u001b[32mykCSAwBgAABhAAAAAAAAAA\u001b[0m\u001b[32m=='\u001b[0m,\n",
"\u001b[2;32m│ │ \u001b[0m\u001b[32m'ExampleOpCredsICAKey2'\u001b[0m: \u001b[32m'BMktytxSOcWsbMcZ6WrjsODvTRKcLWZjo8bt8CDUqfhoHLFqrmahTQnH4rY8gjRpKRBw/Yw2YpEodcaLyC1V+cC2VvZrLqLVW8uRNPkVxcojVHAXYAGCRp6CW4kQ+\u001b[0m\u001b[32mzBtNUCSAwBgAABhAAAAAAAAAA\u001b[0m\u001b[32m=='\u001b[0m\n",
"\u001b[2;32m│ \u001b[0m\u001b[1m}\u001b[0m\n",
"\u001b[1m}\u001b[0m\n"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"builtins.chipStack.GetStorageManager().jsonData"
]
},
{
"cell_type": "code",
"execution_count": 10,
"id": "15bb2c3e-9051-421c-8769-4a59e4b2fc73",
"metadata": {
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Allocating new controller with FabricId: 2(2), NodeId: 1\n"
]
}
],
"source": [
"devCtrl2 = fabric2.NewController()"
]
},
{
"cell_type": "markdown",
"id": "9da4943c-ffff-42e1-a369-f36f89423ed6",
"metadata": {},
"source": [
"#### Open Commissioning Window"
]
},
{
"cell_type": "code",
"execution_count": 11,
"id": "7902ab28-3c74-4717-8522-f6c4a17c5efe",
"metadata": {},
"outputs": [],
"source": [
"await devCtrl.SendCommand(2, 0, Clusters.AdministratorCommissioning.Commands.OpenBasicCommissioningWindow(180))"
]
},
{
"cell_type": "code",
"execution_count": 12,
"id": "1c57c8ff-5ae9-4fdd-9fb8-4eda0e297db2",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"2022-01-25 16:59:00 johnsj-macbookpro1.roam.corp.google.com chip.CTL[27921] ERROR Unable to find country code, defaulting to WW\n",
"2022-01-25 16:59:00 johnsj-macbookpro1.roam.corp.google.com chip.SC[27921] ERROR The device does not support GetClock_RealTimeMS() API. This will eventually result in CASE session setup failures.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Node address has been updated\n",
"Commissioning complete\n"
]
},
{
"data": {
"text/html": [
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #00ff00; text-decoration-color: #00ff00; font-style: italic\">True</span>\n",
"</pre>\n"
],
"text/plain": [
"\u001b[3;92mTrue\u001b[0m\n"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"devCtrl2.CommissionIP(b'127.0.0.1', 20202021, 2)"
]
},
{
"cell_type": "markdown",
"id": "d55534a4-a926-42da-8b80-a9b3408324dc",
"metadata": {},
"source": [
"### Read OpCreds Cluster\n",
"\n",
"Read out the OpCreds cluster to confirm membership into Fabric 2."
]
},
{
"cell_type": "code",
"execution_count": 13,
"id": "0c087a70-d852-4329-958d-d91a1bdbffaf",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">\n",
"<span style=\"font-weight: bold\">{</span>\n",
"<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ </span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0</span>: <span style=\"font-weight: bold\">{</span>\n",
"<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ │ </span><span style=\"font-weight: bold\">&lt;</span><span style=\"color: #ff00ff; text-decoration-color: #ff00ff; font-weight: bold\">class</span><span style=\"color: #000000; text-decoration-color: #000000\"> </span><span style=\"color: #008000; text-decoration-color: #008000\">'chip.clusters.Objects.OperationalCredentials'</span><span style=\"font-weight: bold\">&gt;</span>: <span style=\"font-weight: bold\">{</span>\n",
"<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ │ │ </span><span style=\"font-weight: bold\">&lt;</span><span style=\"color: #ff00ff; text-decoration-color: #ff00ff; font-weight: bold\">class</span><span style=\"color: #000000; text-decoration-color: #000000\"> </span><span style=\"color: #008000; text-decoration-color: #008000\">'chip.clusters.Objects.OperationalCredentials.Attributes.FabricsList'</span><span style=\"font-weight: bold\">&gt;</span>: <span style=\"font-weight: bold\">[</span>\n",
"<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ │ │ │ </span><span style=\"color: #800080; text-decoration-color: #800080; font-weight: bold\">FabricDescriptor</span><span style=\"font-weight: bold\">(</span>\n",
"<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ │ │ │ │ </span><span style=\"color: #808000; text-decoration-color: #808000\">fabricIndex</span>=<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">1</span>,\n",
"<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ │ │ │ │ </span><span style=\"color: #808000; text-decoration-color: #808000\">rootPublicKey</span>=<span style=\"color: #008000; text-decoration-color: #008000\">b'\\x04\\xa2\\x88}\\xbd\\xdb\\xd4\\xbc^U\\xa3\\xcef\\xf7\\x92\\xbe\\xa7X;E\\xb8-Y\\x12^$\\xe0\\x1bS\\xf9\\x9a\\x8f\\xacvj\\xfa!&amp;m6\\x00\\xe3\\xd1\\x85o\\x1b\\x9eH\\xabC?\\xd8\\xec\\x08lH\\xb5X\\x1f:u\\xb0\\xfbj\\x98'</span>,\n",
"<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ │ │ │ │ </span><span style=\"color: #808000; text-decoration-color: #808000\">vendorId</span>=<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">27168</span>,\n",
"<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ │ │ │ │ </span><span style=\"color: #808000; text-decoration-color: #808000\">fabricId</span>=<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">1</span>,\n",
"<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ │ │ │ │ </span><span style=\"color: #808000; text-decoration-color: #808000\">nodeId</span>=<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">2</span>,\n",
"<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ │ │ │ │ </span><span style=\"color: #808000; text-decoration-color: #808000\">label</span>=<span style=\"color: #008000; text-decoration-color: #008000\">''</span>\n",
"<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ │ │ │ </span><span style=\"font-weight: bold\">)</span>,\n",
"<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ │ │ │ </span><span style=\"color: #800080; text-decoration-color: #800080; font-weight: bold\">FabricDescriptor</span><span style=\"font-weight: bold\">(</span>\n",
"<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ │ │ │ │ </span><span style=\"color: #808000; text-decoration-color: #808000\">fabricIndex</span>=<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">2</span>,\n",
"<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ │ │ │ │ </span><span style=\"color: #808000; text-decoration-color: #808000\">rootPublicKey</span>=<span style=\"color: #008000; text-decoration-color: #008000\">b'\\x04\\x9d`\\x90\\ti\\xd1\\x9a\\xe6\\x06D\"\\x92\\x8d\\x9cz\\xcf\\xe9\\xf3\\xa3u\\xa8 w\\xd3/\\xadu&gt;G\\xada\\x01\\xaa\\x03\\xe1\\xe9%M\\x9d\\x97\\xde\\xe5\\x93#\\xcc\\x96E\\xa7\\xf2u+\\xee\\xccH1{A\\xe0 *\\xb4\\x18\\xc1\\xc0'</span>,\n",
"<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ │ │ │ │ </span><span style=\"color: #808000; text-decoration-color: #808000\">vendorId</span>=<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">28544</span>,\n",
"<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ │ │ │ │ </span><span style=\"color: #808000; text-decoration-color: #808000\">fabricId</span>=<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">2</span>,\n",
"<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ │ │ │ │ </span><span style=\"color: #808000; text-decoration-color: #808000\">nodeId</span>=<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">2</span>,\n",
"<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ │ │ │ │ </span><span style=\"color: #808000; text-decoration-color: #808000\">label</span>=<span style=\"color: #008000; text-decoration-color: #008000\">''</span>\n",
"<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ │ │ │ </span><span style=\"font-weight: bold\">)</span>\n",
"<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ │ │ </span><span style=\"font-weight: bold\">]</span>\n",
"<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ │ </span><span style=\"font-weight: bold\">}</span>\n",
"<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ </span><span style=\"font-weight: bold\">}</span>\n",
"<span style=\"font-weight: bold\">}</span>\n",
"</pre>\n"
],
"text/plain": [
"\n",
"\u001b[1m{\u001b[0m\n",
"\u001b[2;32m│ \u001b[0m\u001b[1;36m0\u001b[0m: \u001b[1m{\u001b[0m\n",
"\u001b[2;32m│ │ \u001b[0m\u001b[1m<\u001b[0m\u001b[1;95mclass\u001b[0m\u001b[39m \u001b[0m\u001b[32m'chip.clusters.Objects.OperationalCredentials'\u001b[0m\u001b[1m>\u001b[0m: \u001b[1m{\u001b[0m\n",
"\u001b[2;32m│ │ │ \u001b[0m\u001b[1m<\u001b[0m\u001b[1;95mclass\u001b[0m\u001b[39m \u001b[0m\u001b[32m'chip.clusters.Objects.OperationalCredentials.Attributes.FabricsList'\u001b[0m\u001b[1m>\u001b[0m: \u001b[1m[\u001b[0m\n",
"\u001b[2;32m│ │ │ │ \u001b[0m\u001b[1;35mFabricDescriptor\u001b[0m\u001b[1m(\u001b[0m\n",
"\u001b[2;32m│ │ │ │ │ \u001b[0m\u001b[33mfabricIndex\u001b[0m=\u001b[1;36m1\u001b[0m,\n",
"\u001b[2;32m│ │ │ │ │ \u001b[0m\u001b[33mrootPublicKey\u001b[0m=\u001b[32mb\u001b[0m\u001b[32m'\\x04\\xa2\\x88\u001b[0m\u001b[32m}\u001b[0m\u001b[32m\\xbd\\xdb\\xd4\\xbc^U\\xa3\\xcef\\xf7\\x92\\xbe\\xa7X;E\\xb8-Y\\x12^$\\xe0\\x1bS\\xf9\\x9a\\x8f\\xacvj\\xfa!&m6\\x00\\xe3\\xd1\\x85o\\x1b\\x9eH\\xabC?\\xd8\\xec\\x08lH\\xb5X\\x1f:u\\xb0\\xfbj\\x98'\u001b[0m,\n",
"\u001b[2;32m│ │ │ │ │ \u001b[0m\u001b[33mvendorId\u001b[0m=\u001b[1;36m27168\u001b[0m,\n",
"\u001b[2;32m│ │ │ │ │ \u001b[0m\u001b[33mfabricId\u001b[0m=\u001b[1;36m1\u001b[0m,\n",
"\u001b[2;32m│ │ │ │ │ \u001b[0m\u001b[33mnodeId\u001b[0m=\u001b[1;36m2\u001b[0m,\n",
"\u001b[2;32m│ │ │ │ │ \u001b[0m\u001b[33mlabel\u001b[0m=\u001b[32m''\u001b[0m\n",
"\u001b[2;32m│ │ │ │ \u001b[0m\u001b[1m)\u001b[0m,\n",
"\u001b[2;32m│ │ │ │ \u001b[0m\u001b[1;35mFabricDescriptor\u001b[0m\u001b[1m(\u001b[0m\n",
"\u001b[2;32m│ │ │ │ │ \u001b[0m\u001b[33mfabricIndex\u001b[0m=\u001b[1;36m2\u001b[0m,\n",
"\u001b[2;32m│ │ │ │ │ \u001b[0m\u001b[33mrootPublicKey\u001b[0m=\u001b[32mb\u001b[0m\u001b[32m'\\x04\\x9d`\\x90\\ti\\xd1\\x9a\\xe6\\x06D\"\\x92\\x8d\\x9cz\\xcf\\xe9\\xf3\\xa3u\\xa8 w\\xd3/\\xadu>G\\xada\\x01\\xaa\\x03\\xe1\\xe9%M\\x9d\\x97\\xde\\xe5\\x93#\\xcc\\x96E\\xa7\\xf2u+\\xee\\xccH1\u001b[0m\u001b[32m{\u001b[0m\u001b[32mA\\xe0 *\\xb4\\x18\\xc1\\xc0'\u001b[0m,\n",
"\u001b[2;32m│ │ │ │ │ \u001b[0m\u001b[33mvendorId\u001b[0m=\u001b[1;36m28544\u001b[0m,\n",
"\u001b[2;32m│ │ │ │ │ \u001b[0m\u001b[33mfabricId\u001b[0m=\u001b[1;36m2\u001b[0m,\n",
"\u001b[2;32m│ │ │ │ │ \u001b[0m\u001b[33mnodeId\u001b[0m=\u001b[1;36m2\u001b[0m,\n",
"\u001b[2;32m│ │ │ │ │ \u001b[0m\u001b[33mlabel\u001b[0m=\u001b[32m''\u001b[0m\n",
"\u001b[2;32m│ │ │ │ \u001b[0m\u001b[1m)\u001b[0m\n",
"\u001b[2;32m│ │ │ \u001b[0m\u001b[1m]\u001b[0m\n",
"\u001b[2;32m│ │ \u001b[0m\u001b[1m}\u001b[0m\n",
"\u001b[2;32m│ \u001b[0m\u001b[1m}\u001b[0m\n",
"\u001b[1m}\u001b[0m\n"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"await devCtrl2.ReadAttribute(2, [(Clusters.OperationalCredentials.Attributes.FabricsList)], fabricFiltered=False)"
]
},
{
"cell_type": "markdown",
"id": "b5cbbd20-1609-4fe1-a17e-8027b0ba1334",
"metadata": {
"tags": []
},
"source": [
"## Relaunch REPL\n",
"\n",
"Let's simulate re-launching the REPL to show-case the capabilities of the persistence storage and its mechanics."
]
},
{
"cell_type": "code",
"execution_count": 14,
"id": "d44f5ab8-c59f-4fdb-9a26-081f6799c512",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #00ff00; text-decoration-color: #00ff00\">──────────────────────────────────────── </span>Matter REPL<span style=\"color: #00ff00; text-decoration-color: #00ff00\"> ────────────────────────────────────────</span>\n",
"</pre>\n"
],
"text/plain": [
"\u001b[92m──────────────────────────────────────── \u001b[0mMatter REPL\u001b[92m ────────────────────────────────────────\u001b[0m\n"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">\n",
" \n",
"<span style=\"color: #000080; text-decoration-color: #000080; font-weight: bold\"> </span>\n",
"<span style=\"color: #000080; text-decoration-color: #000080; font-weight: bold\"> Welcome to the Matter Python REPL!</span>\n",
"<span style=\"color: #000080; text-decoration-color: #000080; font-weight: bold\"> </span>\n",
"<span style=\"color: #000080; text-decoration-color: #000080; font-weight: bold\"> For help, please type </span><span style=\"color: #008000; text-decoration-color: #008000; font-weight: bold\">matterhelp()</span>\n",
"<span style=\"color: #000080; text-decoration-color: #000080; font-weight: bold\"> </span>\n",
"<span style=\"color: #000080; text-decoration-color: #000080; font-weight: bold\"> To get more information on a particular object/class, you can pass</span>\n",
"<span style=\"color: #000080; text-decoration-color: #000080; font-weight: bold\"> that into </span><span style=\"color: #008000; text-decoration-color: #008000; font-weight: bold\">matterhelp()</span><span style=\"color: #000080; text-decoration-color: #000080; font-weight: bold\"> as well.</span>\n",
"<span style=\"color: #000080; text-decoration-color: #000080; font-weight: bold\"> </span>\n",
"<span style=\"color: #000080; text-decoration-color: #000080; font-weight: bold\"> </span>\n",
"</pre>\n"
],
"text/plain": [
"\n",
" \n",
"\u001b[1;34m \u001b[0m\n",
"\u001b[1;34m Welcome to the Matter Python REPL!\u001b[0m\n",
"\u001b[1;34m \u001b[0m\n",
"\u001b[1;34m For help, please type \u001b[0m\u001b[1;32mmatterhelp\u001b[0m\u001b[1;32m(\u001b[0m\u001b[1;32m)\u001b[0m\n",
"\u001b[1;34m \u001b[0m\n",
"\u001b[1;34m To get more information on a particular object/class, you can pass\u001b[0m\n",
"\u001b[1;34m that into \u001b[0m\u001b[1;32mmatterhelp\u001b[0m\u001b[1;32m(\u001b[0m\u001b[1;32m)\u001b[0m\u001b[1;34m as well.\u001b[0m\n",
"\u001b[1;34m \u001b[0m\n",
"\u001b[1;34m \u001b[0m\n"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #00ff00; text-decoration-color: #00ff00\">─────────────────────────────────────────────────────────────────────────────────────────────</span>\n",
"</pre>\n"
],
"text/plain": [
"\u001b[92m─────────────────────────────────────────────────────────────────────────────────────────────\u001b[0m\n"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">\n",
"\n",
"</pre>\n"
],
"text/plain": [
"\n",
"\n"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #af00ff; text-decoration-color: #af00ff\">Restoring FabricAdmin from storage to manage FabricId </span><span style=\"color: #af00ff; text-decoration-color: #af00ff; font-weight: bold\">1</span><span style=\"color: #af00ff; text-decoration-color: #af00ff\">, FabricIndex </span><span style=\"color: #af00ff; text-decoration-color: #af00ff; font-weight: bold\">1</span><span style=\"color: #af00ff; text-decoration-color: #af00ff\">...</span>\n",
"</pre>\n"
],
"text/plain": [
"\u001b[38;5;129mRestoring FabricAdmin from storage to manage FabricId \u001b[0m\u001b[1;38;5;129m1\u001b[0m\u001b[38;5;129m, FabricIndex \u001b[0m\u001b[1;38;5;129m1\u001b[0m\u001b[38;5;129m...\u001b[0m\n"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"New FabricAdmin: FabricId: 1(1)\n"
]
},
{
"data": {
"text/html": [
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #af00ff; text-decoration-color: #af00ff\">Restoring FabricAdmin from storage to manage FabricId </span><span style=\"color: #af00ff; text-decoration-color: #af00ff; font-weight: bold\">2</span><span style=\"color: #af00ff; text-decoration-color: #af00ff\">, FabricIndex </span><span style=\"color: #af00ff; text-decoration-color: #af00ff; font-weight: bold\">2</span><span style=\"color: #af00ff; text-decoration-color: #af00ff\">...</span>\n",
"</pre>\n"
],
"text/plain": [
"\u001b[38;5;129mRestoring FabricAdmin from storage to manage FabricId \u001b[0m\u001b[1;38;5;129m2\u001b[0m\u001b[38;5;129m, FabricIndex \u001b[0m\u001b[1;38;5;129m2\u001b[0m\u001b[38;5;129m...\u001b[0m\n"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"New FabricAdmin: FabricId: 2(2)\n"
]
},
{
"data": {
"text/html": [
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">\n",
"<span style=\"color: #000080; text-decoration-color: #000080\">Fabric Admins have been loaded and are available at </span><span style=\"color: #800000; text-decoration-color: #800000\">fabricAdmins</span>\n",
"</pre>\n"
],
"text/plain": [
"\n",
"\u001b[34mFabric Admins have been loaded and are available at \u001b[0m\u001b[31mfabricAdmins\u001b[0m\n"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">\n",
"\n",
"</pre>\n"
],
"text/plain": [
"\n",
"\n"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #af00ff; text-decoration-color: #af00ff\">Creating default device controller on fabric </span><span style=\"color: #af00ff; text-decoration-color: #af00ff; font-weight: bold\">1</span><span style=\"color: #af00ff; text-decoration-color: #af00ff\">...</span>\n",
"</pre>\n"
],
"text/plain": [
"\u001b[38;5;129mCreating default device controller on fabric \u001b[0m\u001b[1;38;5;129m1\u001b[0m\u001b[38;5;129m...\u001b[0m\n"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Allocating new controller with FabricId: 1(1), NodeId: 1\n"
]
},
{
"data": {
"text/html": [
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">\n",
"\n",
"<span style=\"color: #000080; text-decoration-color: #000080\">Default CHIP Device Controller has been initialized to manage </span><span style=\"color: #800000; text-decoration-color: #800000; font-weight: bold\">fabricAdmins[</span><span style=\"color: #800000; text-decoration-color: #800000; font-weight: bold\">0</span><span style=\"color: #800000; text-decoration-color: #800000; font-weight: bold\">]</span><span style=\"color: #000080; text-decoration-color: #000080; font-weight: bold\">, and is </span>\n",
"<span style=\"color: #000080; text-decoration-color: #000080; font-weight: bold\">available as </span><span style=\"color: #800000; text-decoration-color: #800000; font-weight: bold\">devCtrl</span>\n",
"</pre>\n"
],
"text/plain": [
"\n",
"\n",
"\u001b[34mDefault CHIP Device Controller has been initialized to manage \u001b[0m\u001b[1;31mfabricAdmins\u001b[0m\u001b[1;31m[\u001b[0m\u001b[1;31m0\u001b[0m\u001b[1;31m]\u001b[0m\u001b[1;34m, and is \u001b[0m\n",
"\u001b[1;34mavailable as \u001b[0m\u001b[1;31mdevCtrl\u001b[0m\n"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"import chip.native\n",
"import pkgutil\n",
"module = pkgutil.get_loader('chip.ChipReplStartup')\n",
"%run {module.path}"
]
},
{
"cell_type": "markdown",
"id": "2a619893-da3f-4651-bc9f-a2276906fc71",
"metadata": {},
"source": [
"The REPL has now loaded the two fabrics that were created in the previous session into the `fabricAdmins` variable. It has also created a default controller on the first fabric in that list (Fabric 1) as `devCtrl`."
]
},
{
"cell_type": "markdown",
"id": "1f97206d-2b2f-4ae2-8814-5c756b514ca1",
"metadata": {
"tags": []
},
"source": [
"### Establish CASE and Read OpCreds\n",
"\n",
"To prove that we do indeed have two distinct fabrics and controllers on each fabric, let's go ahead and update the label of each fabric. To do so, you'd need to succcessfully establish a CASE session through a controller on the respective fabric, and call the 'UpdateLabel' command.\n",
"\n",
"Underneath the covers, each device controller will do operational discovery of the NodeId being read and establish a CASE session before issuing the IM interaction."
]
},
{
"cell_type": "code",
"execution_count": 15,
"id": "45ee5838-b1e9-4ba8-b804-c3efc9d352d0",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"2022-01-25 16:59:00 johnsj-macbookpro1.roam.corp.google.com chip.SC[27921] ERROR The device does not support GetClock_RealTimeMS() API. This will eventually result in CASE session setup failures.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Node address has been updated\n",
"Established CASE with Device\n"
]
},
{
"data": {
"text/html": [
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">\n",
"<span style=\"font-weight: bold\">{</span>\n",
"<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ </span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0</span>: <span style=\"font-weight: bold\">{</span>\n",
"<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ │ </span><span style=\"font-weight: bold\">&lt;</span><span style=\"color: #ff00ff; text-decoration-color: #ff00ff; font-weight: bold\">class</span><span style=\"color: #000000; text-decoration-color: #000000\"> </span><span style=\"color: #008000; text-decoration-color: #008000\">'chip.clusters.Objects.OperationalCredentials'</span><span style=\"font-weight: bold\">&gt;</span>: <span style=\"font-weight: bold\">{</span>\n",
"<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ │ │ </span><span style=\"font-weight: bold\">&lt;</span><span style=\"color: #ff00ff; text-decoration-color: #ff00ff; font-weight: bold\">class</span><span style=\"color: #000000; text-decoration-color: #000000\"> </span><span style=\"color: #008000; text-decoration-color: #008000\">'chip.clusters.Objects.OperationalCredentials.Attributes.FabricsList'</span><span style=\"font-weight: bold\">&gt;</span>: <span style=\"font-weight: bold\">[</span>\n",
"<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ │ │ │ </span><span style=\"color: #800080; text-decoration-color: #800080; font-weight: bold\">FabricDescriptor</span><span style=\"font-weight: bold\">(</span>\n",
"<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ │ │ │ │ </span><span style=\"color: #808000; text-decoration-color: #808000\">fabricIndex</span>=<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">1</span>,\n",
"<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ │ │ │ │ </span><span style=\"color: #808000; text-decoration-color: #808000\">rootPublicKey</span>=<span style=\"color: #008000; text-decoration-color: #008000\">b'\\x04\\xa2\\x88}\\xbd\\xdb\\xd4\\xbc^U\\xa3\\xcef\\xf7\\x92\\xbe\\xa7X;E\\xb8-Y\\x12^$\\xe0\\x1bS\\xf9\\x9a\\x8f\\xacvj\\xfa!&amp;m6\\x00\\xe3\\xd1\\x85o\\x1b\\x9eH\\xabC?\\xd8\\xec\\x08lH\\xb5X\\x1f:u\\xb0\\xfbj\\x98'</span>,\n",
"<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ │ │ │ │ </span><span style=\"color: #808000; text-decoration-color: #808000\">vendorId</span>=<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">27168</span>,\n",
"<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ │ │ │ │ </span><span style=\"color: #808000; text-decoration-color: #808000\">fabricId</span>=<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">1</span>,\n",
"<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ │ │ │ │ </span><span style=\"color: #808000; text-decoration-color: #808000\">nodeId</span>=<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">2</span>,\n",
"<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ │ │ │ │ </span><span style=\"color: #808000; text-decoration-color: #808000\">label</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'Fabric1Label'</span>\n",
"<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ │ │ │ </span><span style=\"font-weight: bold\">)</span>,\n",
"<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ │ │ │ </span><span style=\"color: #800080; text-decoration-color: #800080; font-weight: bold\">FabricDescriptor</span><span style=\"font-weight: bold\">(</span>\n",
"<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ │ │ │ │ </span><span style=\"color: #808000; text-decoration-color: #808000\">fabricIndex</span>=<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">2</span>,\n",
"<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ │ │ │ │ </span><span style=\"color: #808000; text-decoration-color: #808000\">rootPublicKey</span>=<span style=\"color: #008000; text-decoration-color: #008000\">b'\\x04\\x9d`\\x90\\ti\\xd1\\x9a\\xe6\\x06D\"\\x92\\x8d\\x9cz\\xcf\\xe9\\xf3\\xa3u\\xa8 w\\xd3/\\xadu&gt;G\\xada\\x01\\xaa\\x03\\xe1\\xe9%M\\x9d\\x97\\xde\\xe5\\x93#\\xcc\\x96E\\xa7\\xf2u+\\xee\\xccH1{A\\xe0 *\\xb4\\x18\\xc1\\xc0'</span>,\n",
"<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ │ │ │ │ </span><span style=\"color: #808000; text-decoration-color: #808000\">vendorId</span>=<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">28544</span>,\n",
"<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ │ │ │ │ </span><span style=\"color: #808000; text-decoration-color: #808000\">fabricId</span>=<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">2</span>,\n",
"<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ │ │ │ │ </span><span style=\"color: #808000; text-decoration-color: #808000\">nodeId</span>=<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">2</span>,\n",
"<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ │ │ │ │ </span><span style=\"color: #808000; text-decoration-color: #808000\">label</span>=<span style=\"color: #008000; text-decoration-color: #008000\">''</span>\n",
"<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ │ │ │ </span><span style=\"font-weight: bold\">)</span>\n",
"<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ │ │ </span><span style=\"font-weight: bold\">]</span>\n",
"<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ │ </span><span style=\"font-weight: bold\">}</span>\n",
"<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ </span><span style=\"font-weight: bold\">}</span>\n",
"<span style=\"font-weight: bold\">}</span>\n",
"</pre>\n"
],
"text/plain": [
"\n",
"\u001b[1m{\u001b[0m\n",
"\u001b[2;32m│ \u001b[0m\u001b[1;36m0\u001b[0m: \u001b[1m{\u001b[0m\n",
"\u001b[2;32m│ │ \u001b[0m\u001b[1m<\u001b[0m\u001b[1;95mclass\u001b[0m\u001b[39m \u001b[0m\u001b[32m'chip.clusters.Objects.OperationalCredentials'\u001b[0m\u001b[1m>\u001b[0m: \u001b[1m{\u001b[0m\n",
"\u001b[2;32m│ │ │ \u001b[0m\u001b[1m<\u001b[0m\u001b[1;95mclass\u001b[0m\u001b[39m \u001b[0m\u001b[32m'chip.clusters.Objects.OperationalCredentials.Attributes.FabricsList'\u001b[0m\u001b[1m>\u001b[0m: \u001b[1m[\u001b[0m\n",
"\u001b[2;32m│ │ │ │ \u001b[0m\u001b[1;35mFabricDescriptor\u001b[0m\u001b[1m(\u001b[0m\n",
"\u001b[2;32m│ │ │ │ │ \u001b[0m\u001b[33mfabricIndex\u001b[0m=\u001b[1;36m1\u001b[0m,\n",
"\u001b[2;32m│ │ │ │ │ \u001b[0m\u001b[33mrootPublicKey\u001b[0m=\u001b[32mb\u001b[0m\u001b[32m'\\x04\\xa2\\x88\u001b[0m\u001b[32m}\u001b[0m\u001b[32m\\xbd\\xdb\\xd4\\xbc^U\\xa3\\xcef\\xf7\\x92\\xbe\\xa7X;E\\xb8-Y\\x12^$\\xe0\\x1bS\\xf9\\x9a\\x8f\\xacvj\\xfa!&m6\\x00\\xe3\\xd1\\x85o\\x1b\\x9eH\\xabC?\\xd8\\xec\\x08lH\\xb5X\\x1f:u\\xb0\\xfbj\\x98'\u001b[0m,\n",
"\u001b[2;32m│ │ │ │ │ \u001b[0m\u001b[33mvendorId\u001b[0m=\u001b[1;36m27168\u001b[0m,\n",
"\u001b[2;32m│ │ │ │ │ \u001b[0m\u001b[33mfabricId\u001b[0m=\u001b[1;36m1\u001b[0m,\n",
"\u001b[2;32m│ │ │ │ │ \u001b[0m\u001b[33mnodeId\u001b[0m=\u001b[1;36m2\u001b[0m,\n",
"\u001b[2;32m│ │ │ │ │ \u001b[0m\u001b[33mlabel\u001b[0m=\u001b[32m'Fabric1Label'\u001b[0m\n",
"\u001b[2;32m│ │ │ │ \u001b[0m\u001b[1m)\u001b[0m,\n",
"\u001b[2;32m│ │ │ │ \u001b[0m\u001b[1;35mFabricDescriptor\u001b[0m\u001b[1m(\u001b[0m\n",
"\u001b[2;32m│ │ │ │ │ \u001b[0m\u001b[33mfabricIndex\u001b[0m=\u001b[1;36m2\u001b[0m,\n",
"\u001b[2;32m│ │ │ │ │ \u001b[0m\u001b[33mrootPublicKey\u001b[0m=\u001b[32mb\u001b[0m\u001b[32m'\\x04\\x9d`\\x90\\ti\\xd1\\x9a\\xe6\\x06D\"\\x92\\x8d\\x9cz\\xcf\\xe9\\xf3\\xa3u\\xa8 w\\xd3/\\xadu>G\\xada\\x01\\xaa\\x03\\xe1\\xe9%M\\x9d\\x97\\xde\\xe5\\x93#\\xcc\\x96E\\xa7\\xf2u+\\xee\\xccH1\u001b[0m\u001b[32m{\u001b[0m\u001b[32mA\\xe0 *\\xb4\\x18\\xc1\\xc0'\u001b[0m,\n",
"\u001b[2;32m│ │ │ │ │ \u001b[0m\u001b[33mvendorId\u001b[0m=\u001b[1;36m28544\u001b[0m,\n",
"\u001b[2;32m│ │ │ │ │ \u001b[0m\u001b[33mfabricId\u001b[0m=\u001b[1;36m2\u001b[0m,\n",
"\u001b[2;32m│ │ │ │ │ \u001b[0m\u001b[33mnodeId\u001b[0m=\u001b[1;36m2\u001b[0m,\n",
"\u001b[2;32m│ │ │ │ │ \u001b[0m\u001b[33mlabel\u001b[0m=\u001b[32m''\u001b[0m\n",
"\u001b[2;32m│ │ │ │ \u001b[0m\u001b[1m)\u001b[0m\n",
"\u001b[2;32m│ │ │ \u001b[0m\u001b[1m]\u001b[0m\n",
"\u001b[2;32m│ │ \u001b[0m\u001b[1m}\u001b[0m\n",
"\u001b[2;32m│ \u001b[0m\u001b[1m}\u001b[0m\n",
"\u001b[1m}\u001b[0m\n"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"await devCtrl.SendCommand(2, 0, Clusters.OperationalCredentials.Commands.UpdateFabricLabel(\"Fabric1Label\"))\n",
"await devCtrl.ReadAttribute(2, [(Clusters.OperationalCredentials.Attributes.FabricsList)], fabricFiltered=False)"
]
},
{
"cell_type": "markdown",
"id": "ea5d9a2b-78b2-4bb9-843e-97d26b1c0f90",
"metadata": {
"tags": []
},
"source": [
"Instantiate a controller on fabric 2 and use it to read out the op creds from that fabric."
]
},
{
"cell_type": "code",
"execution_count": 16,
"id": "5d88cb17-bdda-418f-94ca-83d746c162b0",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"2022-01-25 16:59:00 johnsj-macbookpro1.roam.corp.google.com chip.SC[27921] ERROR The device does not support GetClock_RealTimeMS() API. This will eventually result in CASE session setup failures.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Allocating new controller with FabricId: 2(2), NodeId: 1\n",
"Node address has been updated\n",
"Established CASE with Device\n"
]
},
{
"data": {
"text/html": [
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">\n",
"<span style=\"font-weight: bold\">{</span>\n",
"<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ </span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0</span>: <span style=\"font-weight: bold\">{</span>\n",
"<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ │ </span><span style=\"font-weight: bold\">&lt;</span><span style=\"color: #ff00ff; text-decoration-color: #ff00ff; font-weight: bold\">class</span><span style=\"color: #000000; text-decoration-color: #000000\"> </span><span style=\"color: #008000; text-decoration-color: #008000\">'chip.clusters.Objects.OperationalCredentials'</span><span style=\"font-weight: bold\">&gt;</span>: <span style=\"font-weight: bold\">{</span>\n",
"<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ │ │ </span><span style=\"font-weight: bold\">&lt;</span><span style=\"color: #ff00ff; text-decoration-color: #ff00ff; font-weight: bold\">class</span><span style=\"color: #000000; text-decoration-color: #000000\"> </span><span style=\"color: #008000; text-decoration-color: #008000\">'chip.clusters.Objects.OperationalCredentials.Attributes.FabricsList'</span><span style=\"font-weight: bold\">&gt;</span>: <span style=\"font-weight: bold\">[</span>\n",
"<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ │ │ │ </span><span style=\"color: #800080; text-decoration-color: #800080; font-weight: bold\">FabricDescriptor</span><span style=\"font-weight: bold\">(</span>\n",
"<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ │ │ │ │ </span><span style=\"color: #808000; text-decoration-color: #808000\">fabricIndex</span>=<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">1</span>,\n",
"<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ │ │ │ │ </span><span style=\"color: #808000; text-decoration-color: #808000\">rootPublicKey</span>=<span style=\"color: #008000; text-decoration-color: #008000\">b'\\x04\\xa2\\x88}\\xbd\\xdb\\xd4\\xbc^U\\xa3\\xcef\\xf7\\x92\\xbe\\xa7X;E\\xb8-Y\\x12^$\\xe0\\x1bS\\xf9\\x9a\\x8f\\xacvj\\xfa!&amp;m6\\x00\\xe3\\xd1\\x85o\\x1b\\x9eH\\xabC?\\xd8\\xec\\x08lH\\xb5X\\x1f:u\\xb0\\xfbj\\x98'</span>,\n",
"<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ │ │ │ │ </span><span style=\"color: #808000; text-decoration-color: #808000\">vendorId</span>=<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">27168</span>,\n",
"<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ │ │ │ │ </span><span style=\"color: #808000; text-decoration-color: #808000\">fabricId</span>=<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">1</span>,\n",
"<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ │ │ │ │ </span><span style=\"color: #808000; text-decoration-color: #808000\">nodeId</span>=<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">2</span>,\n",
"<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ │ │ │ │ </span><span style=\"color: #808000; text-decoration-color: #808000\">label</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'Fabric1Label'</span>\n",
"<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ │ │ │ </span><span style=\"font-weight: bold\">)</span>,\n",
"<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ │ │ │ </span><span style=\"color: #800080; text-decoration-color: #800080; font-weight: bold\">FabricDescriptor</span><span style=\"font-weight: bold\">(</span>\n",
"<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ │ │ │ │ </span><span style=\"color: #808000; text-decoration-color: #808000\">fabricIndex</span>=<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">2</span>,\n",
"<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ │ │ │ │ </span><span style=\"color: #808000; text-decoration-color: #808000\">rootPublicKey</span>=<span style=\"color: #008000; text-decoration-color: #008000\">b'\\x04\\x9d`\\x90\\ti\\xd1\\x9a\\xe6\\x06D\"\\x92\\x8d\\x9cz\\xcf\\xe9\\xf3\\xa3u\\xa8 w\\xd3/\\xadu&gt;G\\xada\\x01\\xaa\\x03\\xe1\\xe9%M\\x9d\\x97\\xde\\xe5\\x93#\\xcc\\x96E\\xa7\\xf2u+\\xee\\xccH1{A\\xe0 *\\xb4\\x18\\xc1\\xc0'</span>,\n",
"<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ │ │ │ │ </span><span style=\"color: #808000; text-decoration-color: #808000\">vendorId</span>=<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">28544</span>,\n",
"<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ │ │ │ │ </span><span style=\"color: #808000; text-decoration-color: #808000\">fabricId</span>=<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">2</span>,\n",
"<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ │ │ │ │ </span><span style=\"color: #808000; text-decoration-color: #808000\">nodeId</span>=<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">2</span>,\n",
"<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ │ │ │ │ </span><span style=\"color: #808000; text-decoration-color: #808000\">label</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'Fabric2Label'</span>\n",
"<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ │ │ │ </span><span style=\"font-weight: bold\">)</span>\n",
"<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ │ │ </span><span style=\"font-weight: bold\">]</span>\n",
"<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ │ </span><span style=\"font-weight: bold\">}</span>\n",
"<span style=\"color: #7fbf7f; text-decoration-color: #7fbf7f\">│ </span><span style=\"font-weight: bold\">}</span>\n",
"<span style=\"font-weight: bold\">}</span>\n",
"</pre>\n"
],
"text/plain": [
"\n",
"\u001b[1m{\u001b[0m\n",
"\u001b[2;32m│ \u001b[0m\u001b[1;36m0\u001b[0m: \u001b[1m{\u001b[0m\n",
"\u001b[2;32m│ │ \u001b[0m\u001b[1m<\u001b[0m\u001b[1;95mclass\u001b[0m\u001b[39m \u001b[0m\u001b[32m'chip.clusters.Objects.OperationalCredentials'\u001b[0m\u001b[1m>\u001b[0m: \u001b[1m{\u001b[0m\n",
"\u001b[2;32m│ │ │ \u001b[0m\u001b[1m<\u001b[0m\u001b[1;95mclass\u001b[0m\u001b[39m \u001b[0m\u001b[32m'chip.clusters.Objects.OperationalCredentials.Attributes.FabricsList'\u001b[0m\u001b[1m>\u001b[0m: \u001b[1m[\u001b[0m\n",
"\u001b[2;32m│ │ │ │ \u001b[0m\u001b[1;35mFabricDescriptor\u001b[0m\u001b[1m(\u001b[0m\n",
"\u001b[2;32m│ │ │ │ │ \u001b[0m\u001b[33mfabricIndex\u001b[0m=\u001b[1;36m1\u001b[0m,\n",
"\u001b[2;32m│ │ │ │ │ \u001b[0m\u001b[33mrootPublicKey\u001b[0m=\u001b[32mb\u001b[0m\u001b[32m'\\x04\\xa2\\x88\u001b[0m\u001b[32m}\u001b[0m\u001b[32m\\xbd\\xdb\\xd4\\xbc^U\\xa3\\xcef\\xf7\\x92\\xbe\\xa7X;E\\xb8-Y\\x12^$\\xe0\\x1bS\\xf9\\x9a\\x8f\\xacvj\\xfa!&m6\\x00\\xe3\\xd1\\x85o\\x1b\\x9eH\\xabC?\\xd8\\xec\\x08lH\\xb5X\\x1f:u\\xb0\\xfbj\\x98'\u001b[0m,\n",
"\u001b[2;32m│ │ │ │ │ \u001b[0m\u001b[33mvendorId\u001b[0m=\u001b[1;36m27168\u001b[0m,\n",
"\u001b[2;32m│ │ │ │ │ \u001b[0m\u001b[33mfabricId\u001b[0m=\u001b[1;36m1\u001b[0m,\n",
"\u001b[2;32m│ │ │ │ │ \u001b[0m\u001b[33mnodeId\u001b[0m=\u001b[1;36m2\u001b[0m,\n",
"\u001b[2;32m│ │ │ │ │ \u001b[0m\u001b[33mlabel\u001b[0m=\u001b[32m'Fabric1Label'\u001b[0m\n",
"\u001b[2;32m│ │ │ │ \u001b[0m\u001b[1m)\u001b[0m,\n",
"\u001b[2;32m│ │ │ │ \u001b[0m\u001b[1;35mFabricDescriptor\u001b[0m\u001b[1m(\u001b[0m\n",
"\u001b[2;32m│ │ │ │ │ \u001b[0m\u001b[33mfabricIndex\u001b[0m=\u001b[1;36m2\u001b[0m,\n",
"\u001b[2;32m│ │ │ │ │ \u001b[0m\u001b[33mrootPublicKey\u001b[0m=\u001b[32mb\u001b[0m\u001b[32m'\\x04\\x9d`\\x90\\ti\\xd1\\x9a\\xe6\\x06D\"\\x92\\x8d\\x9cz\\xcf\\xe9\\xf3\\xa3u\\xa8 w\\xd3/\\xadu>G\\xada\\x01\\xaa\\x03\\xe1\\xe9%M\\x9d\\x97\\xde\\xe5\\x93#\\xcc\\x96E\\xa7\\xf2u+\\xee\\xccH1\u001b[0m\u001b[32m{\u001b[0m\u001b[32mA\\xe0 *\\xb4\\x18\\xc1\\xc0'\u001b[0m,\n",
"\u001b[2;32m│ │ │ │ │ \u001b[0m\u001b[33mvendorId\u001b[0m=\u001b[1;36m28544\u001b[0m,\n",
"\u001b[2;32m│ │ │ │ │ \u001b[0m\u001b[33mfabricId\u001b[0m=\u001b[1;36m2\u001b[0m,\n",
"\u001b[2;32m│ │ │ │ │ \u001b[0m\u001b[33mnodeId\u001b[0m=\u001b[1;36m2\u001b[0m,\n",
"\u001b[2;32m│ │ │ │ │ \u001b[0m\u001b[33mlabel\u001b[0m=\u001b[32m'Fabric2Label'\u001b[0m\n",
"\u001b[2;32m│ │ │ │ \u001b[0m\u001b[1m)\u001b[0m\n",
"\u001b[2;32m│ │ │ \u001b[0m\u001b[1m]\u001b[0m\n",
"\u001b[2;32m│ │ \u001b[0m\u001b[1m}\u001b[0m\n",
"\u001b[2;32m│ \u001b[0m\u001b[1m}\u001b[0m\n",
"\u001b[1m}\u001b[0m\n"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"devCtrl2 = fabricAdmins[1].NewController()\n",
"await devCtrl2.SendCommand(2, 0, Clusters.OperationalCredentials.Commands.UpdateFabricLabel(\"Fabric2Label\"))\n",
"await devCtrl2.ReadAttribute(2, [(Clusters.OperationalCredentials.Attributes.FabricsList)], fabricFiltered=False)"
]
},
{
"cell_type": "code",
"execution_count": 17,
"id": "4ecb4ab4-bb7a-4941-8080-34783028fce0",
"metadata": {},
"outputs": [],
"source": [
"devCtrl2.Shutdown()"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "matter-env",
"language": "python",
"name": "matter-env"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.2+chromium.10"
}
},
"nbformat": 4,
"nbformat_minor": 5
}