diff --git a/BUILD.gn b/BUILD.gn index 0992c61b0510c6..c67fc7a9c0136f 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -272,6 +272,9 @@ if (current_toolchain != "${dir_pw_toolchain}/default:default") { # Set this to true to enable bl602 builds by default. enable_bl602_builds = false + # Set this to true to enable qcc743 builds by default. + enable_qcc743_builds = false + # Set this to true to enable bl702 builds by default. enable_bl702_builds = false @@ -402,6 +405,9 @@ if (current_toolchain != "${dir_pw_toolchain}/default:default") { # Build the bl602 lighting app example. enable_bl602_lighting_app_build = enable_bl602_builds + # Build the qcc743 lighting app example. + enable_qcc743_lighting_app_build = enable_qcc743_builds + # Build the bl702 lighting app example. enable_bl702_lighting_app_build = enable_bl702_builds diff --git a/build_overrides/qcc74x_iot_sdk.gni b/build_overrides/qcc74x_iot_sdk.gni new file mode 100644 index 00000000000000..788d2a6a2714c3 --- /dev/null +++ b/build_overrides/qcc74x_iot_sdk.gni @@ -0,0 +1,19 @@ +# Copyright (c) 2021 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +declare_args() { + qcc74x_iot_sdk_build_root = "//third_party/qcc74x/" + + qcc74x_sdk_root = "/opt/qcc74x_sdk" +} diff --git a/config/qcc74x/args.gni b/config/qcc74x/args.gni new file mode 100644 index 00000000000000..ca2eca869106cc --- /dev/null +++ b/config/qcc74x/args.gni @@ -0,0 +1,19 @@ +# Copyright (c) 2022 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Options from standalone-chip.mk that differ from configure defaults. These +# options are used from examples/. + +custom_toolchain = + "//third_party/connectedhomeip/config/qcc74x/toolchain:riscv_gcc" diff --git a/config/qcc74x/common/lib/pw_rpc/BUILD.gn b/config/qcc74x/common/lib/pw_rpc/BUILD.gn new file mode 100644 index 00000000000000..897c5f4e402270 --- /dev/null +++ b/config/qcc74x/common/lib/pw_rpc/BUILD.gn @@ -0,0 +1,46 @@ +# Copyright (c) 2021 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build_overrides/chip.gni") +import("//build_overrides/pigweed.gni") +import("$dir_pw_build/target_types.gni") + +config("pw_string_config") { + defines = [ + "_GLIBCXX_USE_C99_MATH_TR1", + "_LDBL_EQ_DBL", + ] +} + +pw_source_set("pw_string_dep") { + public_configs = [ ":pw_string_config" ] +} + +static_library("pw_rpc") { + output_name = "libPwRpc" + + public_configs = [ "${dir_pigweed}/pw_hdlc:default_config" ] + + public_deps = [ + "$dir_pw_rpc:server", + "$dir_pw_rpc/nanopb:echo_service", + "${chip_root}/examples/platform/qcc74x/common/rpc/pw_sys_io:pw_sys_io", + dir_pw_assert, + dir_pw_checksum, + dir_pw_hdlc, + dir_pw_log, + ] + + output_dir = "${root_out_dir}/lib" +} diff --git a/config/qcc74x/common/lib/pw_rpc/pw_rpc.gni b/config/qcc74x/common/lib/pw_rpc/pw_rpc.gni new file mode 100644 index 00000000000000..ef3943d5097314 --- /dev/null +++ b/config/qcc74x/common/lib/pw_rpc/pw_rpc.gni @@ -0,0 +1,31 @@ +# Copyright (c) 2021 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build_overrides/chip.gni") +import("//build_overrides/pigweed.gni") + +pw_log_BACKEND = "$dir_pw_log_basic" +pw_assert_BACKEND = "$dir_pw_assert_log" +pw_sys_io_BACKEND = + "${chip_root}/examples/platform/qcc74x/common/rpc/pw_sys_io:pw_sys_io" + +pw_string_CONFIG = + "${chip_root}/config/qcc74x/common/lib/pw_rpc:pw_string_dep" + +pw_build_LINK_DEPS = [ + "$dir_pw_assert:impl", + "$dir_pw_log:impl", +] + +dir_pw_third_party_nanopb = "${chip_root}/third_party/nanopb/repo" diff --git a/config/qcc74x/toolchain/BUILD.gn b/config/qcc74x/toolchain/BUILD.gn new file mode 100644 index 00000000000000..b6eefabe6ed041 --- /dev/null +++ b/config/qcc74x/toolchain/BUILD.gn @@ -0,0 +1,20 @@ +# Copyright (c) 2021 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("riscv_toolchain.gni") + +riscv_toolchain("riscv_gcc") { + toolchain_args = { + } +} diff --git a/config/qcc74x/toolchain/riscv_toolchain.gni b/config/qcc74x/toolchain/riscv_toolchain.gni new file mode 100644 index 00000000000000..14eb800d8fa3f8 --- /dev/null +++ b/config/qcc74x/toolchain/riscv_toolchain.gni @@ -0,0 +1,48 @@ +# Copyright (c) 2021 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build_overrides/build.gni") +import("//build_overrides/chip.gni") + +import("//build_overrides/qcc74x_iot_sdk.gni") +import("${build_root}/toolchain/gcc_toolchain.gni") +import("${chip_root}/src/platform/device.gni") + +template("riscv_toolchain") { + gcc_toolchain(target_name) { + _tool_name_root = "" + + if ("linux" == host_os) { + if (chip_device_platform == "qcc743") { + _tool_name_root = "${qcc74x_sdk_root}/toolchain/t-head-riscv/gcc_t-head_v2.6.1/bin/riscv64-unknown-elf-" + } else { + _tool_name_root = "${qcc74x_sdk_root}/toolchain/riscv/Linux/bin/riscv64-unknown-elf-" + } + } else if ("mac" == host_os || "darwin" == host_os) { + _tool_name_root = "${qcc74x_sdk_root}/toolchain/riscv/Darwin/bin/riscv64-unknown-elf-" + } + + ar = _tool_name_root + "ar" + cc = _tool_name_root + "gcc" + cxx = _tool_name_root + "g++" + + toolchain_args = { + current_cpu = "riscv" + current_os = invoker.current_os + is_clang = false + + forward_variables_from(invoker.toolchain_args, "*") + } + } +} diff --git a/examples/build_overrides/qcc74x_sdk.gni b/examples/build_overrides/qcc74x_sdk.gni new file mode 100644 index 00000000000000..c8b9b483e4a5d2 --- /dev/null +++ b/examples/build_overrides/qcc74x_sdk.gni @@ -0,0 +1,20 @@ +# Copyright (c) 2021 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +declare_args() { + qcc74x_iot_sdk_build_root = + "//third_party/connectedhomeip/third_party/qcc74x" + + qcc74x_sdk_root = "/opt/qcc74x_sdk" +} diff --git a/examples/lighting-app/qcc74x/common/AppTask.cpp b/examples/lighting-app/qcc74x/common/AppTask.cpp new file mode 100644 index 00000000000000..9c6665bb78d826 --- /dev/null +++ b/examples/lighting-app/qcc74x/common/AppTask.cpp @@ -0,0 +1,530 @@ +/* + * + * Copyright (c) 2020 Project CHIP Authors + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#if HEAP_MONITORING +#include "MemMonitoring.h" +#endif + +#if CHIP_ENABLE_OPENTHREAD +#include +#include +#include +#include +#endif + +#if CONFIG_ENABLE_CHIP_SHELL +#include +#include +#endif + +#include +#include + +#if CHIP_DEVICE_LAYER_TARGET_QCC743 +#ifdef BOOT_PIN_RESET +#include +#endif +#else +extern "C" { +#include +#include +#include +} +#include +#endif + +#include "AppTask.h" +#include "mboard.h" + +using namespace ::chip; +using namespace ::chip::app; +using namespace ::chip::Credentials; +using namespace ::chip::DeviceLayer; + +#if CONFIG_ENABLE_CHIP_SHELL +using namespace chip::Shell; +#endif + +namespace { + +#if defined(BL706_NIGHT_LIGHT) || defined(BL602_NIGHT_LIGHT) +ColorLEDWidget sLightLED; +#else +DimmableLEDWidget sLightLED; +#endif + +Identify sIdentify = { + APP_LIGHT_ENDPOINT_ID, + AppTask::IdentifyStartHandler, + AppTask::IdentifyStopHandler, + Clusters::Identify::IdentifyTypeEnum::kLightOutput, +}; + +} // namespace + +AppTask AppTask::sAppTask; +StackType_t AppTask::appStack[APP_TASK_STACK_SIZE / sizeof(StackType_t)]; +StaticTask_t AppTask::appTaskStruct; + +void StartAppTask(void) +{ + GetAppTask().sAppTaskHandle = xTaskCreateStatic(GetAppTask().AppTaskMain, APP_TASK_NAME, ArraySize(GetAppTask().appStack), NULL, + APP_TASK_PRIORITY, GetAppTask().appStack, &GetAppTask().appTaskStruct); + if (GetAppTask().sAppTaskHandle == NULL) + { + ChipLogError(NotSpecified, "Failed to create app task"); + appError(APP_ERROR_EVENT_QUEUE_FAILED); + } +} + +#if CONFIG_ENABLE_CHIP_SHELL +#if CHIP_DEVICE_LAYER_TARGET_QCC743 +CHIP_ERROR AppTask::StartAppShellTask() +{ + Engine::Root().Init(); + + cmd_misc_init(); + + Engine::Root().RunMainLoop(); + + return CHIP_NO_ERROR; +} +#else +void AppTask::AppShellTask(void * args) +{ + Engine::Root().RunMainLoop(); +} + +CHIP_ERROR AppTask::StartAppShellTask() +{ + static TaskHandle_t shellTask; + + Engine::Root().Init(); + + cmd_misc_init(); + + xTaskCreate(AppTask::AppShellTask, "chip_shell", 1024 / sizeof(configSTACK_DEPTH_TYPE), NULL, APP_TASK_PRIORITY, &shellTask); + + return CHIP_NO_ERROR; +} +#endif +#endif + +void AppTask::PostEvent(app_event_t event) +{ + if (xPortIsInsideInterrupt()) + { + BaseType_t higherPrioTaskWoken = pdFALSE; + xTaskNotifyFromISR(sAppTaskHandle, event, eSetBits, &higherPrioTaskWoken); + } + else + { + xTaskNotify(sAppTaskHandle, event, eSetBits); + } +} + +void AppTask::AppTaskMain(void * pvParameter) +{ + app_event_t appEvent; + bool onoff = false; + uint64_t currentHeapFree = 0; + +#if !(CHIP_DEVICE_LAYER_TARGET_BL702 && CHIP_DEVICE_CONFIG_ENABLE_ETHERNET) + sLightLED.Init(); +#endif + +#ifdef BOOT_PIN_RESET + ButtonInit(); +#else + /** Without RESET PIN defined, factory reset will be executed if power cycle count(resetCnt) >= APP_REBOOT_RESET_COUNT */ + uint32_t resetCnt = 0; + size_t saved_value_len = 0; + ef_get_env_blob(APP_REBOOT_RESET_COUNT_KEY, &resetCnt, sizeof(resetCnt), &saved_value_len); + + if (resetCnt > APP_REBOOT_RESET_COUNT) + { + resetCnt = 0; + /** To share with RESET PIN logic, mButtonPressedTime is used to recorded resetCnt increased. + * +1 makes sure mButtonPressedTime is not zero; + * a power cycle during factory reset confirm time APP_BUTTON_PRESS_LONG will cancel factoryreset */ + GetAppTask().mButtonPressedTime = System::SystemClock().GetMonotonicMilliseconds64().count() + 1; + } + else + { + resetCnt++; + GetAppTask().mButtonPressedTime = 0; + } + ef_set_env_blob(APP_REBOOT_RESET_COUNT_KEY, &resetCnt, sizeof(resetCnt)); +#endif + + GetAppTask().sTimer = + xTimerCreate("lightTmr", pdMS_TO_TICKS(APP_TIMER_EVENT_DEFAULT_ITVL), false, NULL, AppTask::TimerCallback); + if (GetAppTask().sTimer == NULL) + { + ChipLogError(NotSpecified, "Failed to create timer task"); + appError(APP_ERROR_EVENT_QUEUE_FAILED); + } + + ChipLogProgress(NotSpecified, "Starting Platform Manager Event Loop"); + CHIP_ERROR ret = PlatformMgr().StartEventLoopTask(); + if (ret != CHIP_NO_ERROR) + { + ChipLogError(NotSpecified, "PlatformMgr().StartEventLoopTask() failed"); + appError(ret); + } + + GetAppTask().PostEvent(APP_EVENT_TIMER); + GetAppTask().PostEvent(APP_EVENT_LIGHTING_MASK); + + vTaskSuspend(NULL); + + DiagnosticDataProviderImpl::GetDefaultInstance().GetCurrentHeapFree(currentHeapFree); + ChipLogProgress(NotSpecified, "App Task started, with SRAM heap %lld left\r\n",currentHeapFree); + + while (true) + { + appEvent = APP_EVENT_NONE; + BaseType_t eventReceived = xTaskNotifyWait(0, APP_EVENT_ALL_MASK, (uint32_t *) &appEvent, portMAX_DELAY); + + if (eventReceived) + { + PlatformMgr().LockChipStack(); + + if (APP_EVENT_LIGHTING_MASK & appEvent) + { + LightingUpdate(appEvent); + } + + if (APP_EVENT_BTN_SHORT & appEvent) + { + if (Server::GetInstance().GetFabricTable().FabricCount()) + { + Clusters::OnOff::Attributes::OnOff::Get(GetAppTask().GetEndpointId(), &onoff); + onoff = !onoff; + Clusters::OnOff::Attributes::OnOff::Set(GetAppTask().GetEndpointId(), onoff); + } + else + { + sLightLED.Toggle(); + } + } + +#ifdef BOOT_PIN_RESET + if (APP_EVENT_BTN_LONG & appEvent) + { + /** Turn off light to indicate button long press for factory reset is confirmed */ + sLightLED.SetOnoff(false); + } +#endif + if (APP_EVENT_IDENTIFY_MASK & appEvent) + { + IdentifyHandleOp(appEvent); + } + + if (APP_EVENT_FACTORY_RESET & appEvent) + { + DeviceLayer::ConfigurationMgr().InitiateFactoryReset(); + } + + TimerEventHandler(appEvent); + + PlatformMgr().UnlockChipStack(); + } + } +} + +void AppTask::LightingUpdate(app_event_t status) +{ + uint8_t hue, sat; + bool onoff; + DataModel::Nullable v(0); + EndpointId endpoint = GetAppTask().GetEndpointId(); + + if (APP_EVENT_LIGHTING_MASK & status) + { + + if (Server::GetInstance().GetFabricTable().FabricCount()) + { + do + { + if (Protocols::InteractionModel::Status::Success != Clusters::OnOff::Attributes::OnOff::Get(endpoint, &onoff)) + { + break; + } + + if (Protocols::InteractionModel::Status::Success != + Clusters::LevelControl::Attributes::CurrentLevel::Get(endpoint, v)) + { + break; + } + + if (Protocols::InteractionModel::Status::Success != + Clusters::ColorControl::Attributes::CurrentHue::Get(endpoint, &hue)) + { + break; + } + + if (Protocols::InteractionModel::Status::Success != + Clusters::ColorControl::Attributes::CurrentSaturation::Get(endpoint, &sat)) + { + break; + } + + if (!onoff) + { + sLightLED.SetLevel(0); + } + else + { + if (v.IsNull()) + { + v.SetNonNull(254); + } +#if defined(BL706_NIGHT_LIGHT) || defined(BL602_NIGHT_LIGHT) + sLightLED.SetColor(v.Value(), hue, sat); +#else + sLightLED.SetLevel(v.Value()); +#endif + } + } while (0); + } + else + { +#if defined(BL706_NIGHT_LIGHT) || defined(BL602_NIGHT_LIGHT) + /** show yellow to indicate not-provision state for extended color light */ + sLightLED.SetColor(254, 35, 254); +#else + /** show 30% brightness to indicate not-provision state */ + sLightLED.SetLevel(25); +#endif + } + } +} + +bool AppTask::StartTimer(void) +{ + if (xTimerIsTimerActive(GetAppTask().sTimer)) + { + CancelTimer(); + } + + if (GetAppTask().mTimerIntvl == 0) + { + GetAppTask().mTimerIntvl = APP_TIMER_EVENT_DEFAULT_ITVL; + } + + if (xTimerChangePeriod(GetAppTask().sTimer, pdMS_TO_TICKS(GetAppTask().mTimerIntvl), pdMS_TO_TICKS(100)) != pdPASS) + { + ChipLogProgress(NotSpecified, "Failed to access timer with 100 ms delay."); + } + + return true; +} + +void AppTask::CancelTimer(void) +{ + xTimerStop(GetAppTask().sTimer, 0); +} + +void AppTask::TimerCallback(TimerHandle_t xTimer) +{ + GetAppTask().PostEvent(APP_EVENT_TIMER); +} + +void AppTask::TimerEventHandler(app_event_t event) +{ + uint32_t pressedTime = 0; + + if (GetAppTask().mButtonPressedTime) + { + pressedTime = System::SystemClock().GetMonotonicMilliseconds64().count() - GetAppTask().mButtonPressedTime; +#ifdef BOOT_PIN_RESET + if (ButtonPressed()) + { + if (pressedTime > APP_BUTTON_PRESS_LONG) + { + GetAppTask().PostEvent(APP_EVENT_BTN_LONG); + } + else if (pressedTime >= APP_BUTTON_PRESS_SHORT) + { +#if defined(BL602_NIGHT_LIGHT) || defined(BL706_NIGHT_LIGHT) + /** change color to indicate to wait factory reset confirm */ + sLightLED.SetColor(254, 0, 210); +#else + /** toggle led to indicate to wait factory reset confirm */ + sLightLED.Toggle(); +#endif + } + } + else + { + if (pressedTime >= APP_BUTTON_PRESS_LONG) + { + GetAppTask().PostEvent(APP_EVENT_FACTORY_RESET); + } + else if (APP_BUTTON_PRESS_SHORT >= pressedTime && pressedTime >= APP_BUTTON_PRESS_JITTER) + { + GetAppTask().PostEvent(APP_EVENT_BTN_SHORT); + } + else + { + GetAppTask().PostEvent(APP_EVENT_LIGHTING_MASK); + } + + GetAppTask().mTimerIntvl = APP_BUTTON_PRESSED_ITVL; + GetAppTask().mButtonPressedTime = 0; + } +#else + if (pressedTime > APP_BUTTON_PRESS_LONG) + { + /** factory reset confirm timeout */ + GetAppTask().mButtonPressedTime = 0; + GetAppTask().PostEvent(APP_EVENT_FACTORY_RESET); + } + else + { +#if defined(BL602_NIGHT_LIGHT) || defined(BL706_NIGHT_LIGHT) + /** change color to indicate to wait factory reset confirm */ + sLightLED.SetColor(254, 0, 210); +#else + /** toggle led to indicate to wait factory reset confirm */ + sLightLED.Toggle(); +#endif + } +#endif + } +#ifdef BOOT_PIN_RESET + else + { + if (ButtonPressed()) + { + GetAppTask().mTimerIntvl = APP_BUTTON_PRESSED_ITVL; + GetAppTask().mButtonPressedTime = System::SystemClock().GetMonotonicMilliseconds64().count(); + } + } +#endif + + StartTimer(); +} + +void AppTask::IdentifyStartHandler(Identify *) +{ + GetAppTask().PostEvent(APP_EVENT_IDENTIFY_START); +} + +void AppTask::IdentifyStopHandler(Identify *) +{ + GetAppTask().PostEvent(APP_EVENT_IDENTIFY_STOP); +} + +void AppTask::IdentifyHandleOp(app_event_t event) +{ + static uint32_t identifyState = 0; + + if (APP_EVENT_IDENTIFY_START & event) + { + identifyState = 1; + ChipLogProgress(NotSpecified, "identify start"); + } + + if ((APP_EVENT_IDENTIFY_IDENTIFY & event) && identifyState) + { + sLightLED.Toggle(); + ChipLogProgress(NotSpecified, "identify"); + } + + if (APP_EVENT_IDENTIFY_STOP & event) + { + identifyState = 0; + GetAppTask().PostEvent(APP_EVENT_LIGHTING_MASK); + ChipLogProgress(NotSpecified, "identify stop"); + } +} + +void AppTask::ButtonEventHandler(uint8_t btnIdx, uint8_t btnAction) +{ + GetAppTask().PostEvent(APP_EVENT_FACTORY_RESET); +} + +#ifdef BOOT_PIN_RESET +#if CHIP_DEVICE_LAYER_TARGET_QCC743 +static struct bflb_device_s * app_task_gpio_var = NULL; +static void app_task_gpio_isr(int irq, void *arg) +{ + bool intstatus = bflb_gpio_get_intstatus(app_task_gpio_var, BOOT_PIN_RESET); + if (intstatus) { + bflb_gpio_int_clear(app_task_gpio_var, BOOT_PIN_RESET); + } + + GetAppTask().ButtonEventHandler(arg); +} +#else +static hosal_gpio_dev_t gpio_key = { .port = BOOT_PIN_RESET, .config = INPUT_HIGH_IMPEDANCE, .priv = NULL }; +#endif + +void AppTask::ButtonInit(void) +{ + GetAppTask().mButtonPressedTime = 0; + +#if CHIP_DEVICE_LAYER_TARGET_QCC743 + app_task_gpio_var = bflb_device_get_by_name("gpio"); + + bflb_gpio_init(app_task_gpio_var, BOOT_PIN_RESET, GPIO_INPUT); + bflb_gpio_int_init(app_task_gpio_var, BOOT_PIN_RESET, GPIO_INT_TRIG_MODE_SYNC_FALLING_RISING_EDGE); + bflb_gpio_int_mask(app_task_gpio_var, BOOT_PIN_RESET, false); + + bflb_irq_attach(app_task_gpio_var->irq_num, app_task_gpio_isr, app_task_gpio_var); + bflb_irq_enable(app_task_gpio_var->irq_num); +#else + hosal_gpio_init(&gpio_key); + hosal_gpio_irq_set(&gpio_key, HOSAL_IRQ_TRIG_POS_PULSE, GetAppTask().ButtonEventHandler, NULL); +#endif +} + +bool AppTask::ButtonPressed(void) +{ +#if CHIP_DEVICE_LAYER_TARGET_QCC743 + return bflb_gpio_read(app_task_gpio_var, BOOT_PIN_RESET); +#else + uint8_t val = 1; + + hosal_gpio_input_get(&gpio_key, &val); + + return val == 1; +#endif +} + +void AppTask::ButtonEventHandler(void * arg) +{ + if (ButtonPressed()) + { + GetAppTask().PostEvent(APP_EVENT_BTN_ISR); + } +} +#endif diff --git a/examples/lighting-app/qcc74x/common/AppTask.h b/examples/lighting-app/qcc74x/common/AppTask.h new file mode 100644 index 00000000000000..bcc9dbaec7a4b5 --- /dev/null +++ b/examples/lighting-app/qcc74x/common/AppTask.h @@ -0,0 +1,143 @@ +/* + * + * Copyright (c) 2020 Project CHIP Authors + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include +#include + +#include "FreeRTOS.h" +#include "timers.h" + +#include + +using namespace ::chip; +using namespace ::chip::DeviceLayer; + +#define APP_BUTTON_PRESSED_ITVL 50 +#define APP_BUTTON_PRESS_JITTER 100 +#define APP_BUTTON_PRESS_SHORT 1000 +#define APP_BUTTON_PRESS_LONG 4000 +#define APP_TIMER_EVENT_DEFAULT_ITVL 1000 + +#define APP_LIGHT_ENDPOINT_ID 1 +#define APP_REBOOT_RESET_COUNT 3 +#define APP_REBOOT_RESET_COUNT_KEY "app_reset_cnt" + +// Application-defined error codes in the CHIP_ERROR space. +#define APP_ERROR_EVENT_QUEUE_FAILED CHIP_APPLICATION_ERROR(0x01) +#define APP_ERROR_CREATE_TASK_FAILED CHIP_APPLICATION_ERROR(0x02) +#define APP_ERROR_UNHANDLED_EVENT CHIP_APPLICATION_ERROR(0x03) +#define APP_ERROR_CREATE_TIMER_FAILED CHIP_APPLICATION_ERROR(0x04) +#define APP_ERROR_START_TIMER_FAILED CHIP_APPLICATION_ERROR(0x05) +#define APP_ERROR_STOP_TIMER_FAILED CHIP_APPLICATION_ERROR(0x06) + +struct Identify; + +class AppTask +{ +public: + friend AppTask & GetAppTask(void); + + enum app_event_t + { + APP_EVENT_NONE = 0x00000000, + + APP_EVENT_TIMER = 0x00000010, + APP_EVENT_BTN_SHORT = 0x00000020, + APP_EVENT_FACTORY_RESET = 0x00000040, + APP_EVENT_BTN_LONG = 0x00000080, + APP_EVENT_BTN_ISR = 0x00000100, + + APP_EVENT_LIGHTING_ONOFF = 0x00010000, + APP_EVENT_LIGHTING_LEVEL = 0x00020000, + APP_EVENT_LIGHTING_COLOR = 0x00040000, + APP_EVENT_LIGHTING_MASK = APP_EVENT_LIGHTING_ONOFF | APP_EVENT_LIGHTING_LEVEL | APP_EVENT_LIGHTING_COLOR, + + APP_EVENT_IDENTIFY_START = 0x01000000, + APP_EVENT_IDENTIFY_IDENTIFY = 0x02000000, + APP_EVENT_IDENTIFY_STOP = 0x04000000, + APP_EVENT_IDENTIFY_MASK = APP_EVENT_IDENTIFY_START | APP_EVENT_IDENTIFY_IDENTIFY | APP_EVENT_IDENTIFY_STOP, + + APP_EVENT_ALL_MASK = APP_EVENT_LIGHTING_MASK | APP_EVENT_TIMER | APP_EVENT_BTN_SHORT | APP_EVENT_BTN_LONG | + APP_EVENT_BTN_ISR | APP_EVENT_IDENTIFY_MASK, + }; + + void SetEndpointId(EndpointId endpointId) + { + if (mEndpointId != (EndpointId) -1) + mEndpointId = endpointId; + } + + EndpointId GetEndpointId(void) { return mEndpointId; } + void PostEvent(app_event_t event); + void ButtonEventHandler(uint8_t btnIdx, uint8_t btnAction); +#ifdef BOOT_PIN_RESET + static void ButtonEventHandler(void * arg); +#endif + + static void IdentifyStartHandler(Identify *); + static void IdentifyStopHandler(Identify *); + static void IdentifyHandleOp(app_event_t event); + +private: + friend void StartAppTask(void); + friend PlatformManagerImpl; + + static uint32_t AppRebootCheck(uint32_t time = 0); + + static void LightingSetBleAdv(void); + static void LightingSetProvisioned(void); + static void LightingSetFactoryReset(void); + + static void LightingUpdate(app_event_t event = APP_EVENT_NONE); + + static bool StartTimer(void); + static void CancelTimer(void); + static void TimerEventHandler(app_event_t event); + static void TimerCallback(TimerHandle_t xTimer); + +#ifdef BOOT_PIN_RESET + static void ButtonInit(void); + static bool ButtonPressed(void); +#endif + + static void ScheduleInit(intptr_t arg); + static void AppTaskMain(void * pvParameter); + + static CHIP_ERROR StartAppShellTask(); + static void AppShellTask(void * args); + + EndpointId mEndpointId = (EndpointId) 1; + TaskHandle_t sAppTaskHandle; + QueueHandle_t sAppEventQueue; + TimerHandle_t sTimer; + uint32_t mTimerIntvl; + uint64_t mButtonPressedTime; + + static StackType_t appStack[APP_TASK_STACK_SIZE / sizeof(StackType_t)]; + static StaticTask_t appTaskStruct; + static AppTask sAppTask; +}; + +inline AppTask & GetAppTask(void) +{ + return AppTask::sAppTask; +} + +void StartAppTask(); diff --git a/examples/lighting-app/qcc74x/common/ZclCallbacks.cpp b/examples/lighting-app/qcc74x/common/ZclCallbacks.cpp new file mode 100644 index 00000000000000..e987fcbd325112 --- /dev/null +++ b/examples/lighting-app/qcc74x/common/ZclCallbacks.cpp @@ -0,0 +1,96 @@ +/* + * + * Copyright (c) 2020 Project CHIP Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @file + * This file implements the handler for data model messages. + */ + +#include + +#include +#include +#include +#include +#include + +using namespace ::chip; +using namespace ::chip::app::Clusters; + +void MatterPostAttributeChangeCallback(const chip::app::ConcreteAttributePath & attributePath, uint8_t type, uint16_t size, + uint8_t * value) +{ + ClusterId clusterId = attributePath.mClusterId; + AttributeId attributeId = attributePath.mAttributeId; + ChipLogProgress(Zcl, "Cluster callback: " ChipLogFormatMEI, ChipLogValueMEI(clusterId)); + + if (clusterId == OnOff::Id && attributeId == OnOff::Attributes::OnOff::Id) + { + GetAppTask().PostEvent(AppTask::APP_EVENT_LIGHTING_ONOFF); + ChipLogProgress(Zcl, "OnOff attribute ID: " ChipLogFormatMEI " Type: %u Value: %u, length %u", ChipLogValueMEI(attributeId), + type, *value, size); + } + else if (clusterId == LevelControl::Id) + { + GetAppTask().PostEvent(AppTask::APP_EVENT_LIGHTING_LEVEL); + ChipLogProgress(Zcl, "Level Control attribute ID: " ChipLogFormatMEI " Type: %u Value: %u, length %u", + ChipLogValueMEI(attributeId), type, *value, size); + } + else if (clusterId == ColorControl::Id) + { + GetAppTask().PostEvent(AppTask::APP_EVENT_LIGHTING_COLOR); + ChipLogProgress(Zcl, "Color Control attribute ID: " ChipLogFormatMEI " Type: %u Value: %u, length %u", + ChipLogValueMEI(attributeId), type, *value, size); + } + else if (clusterId == OnOffSwitchConfiguration::Id) + { + GetAppTask().PostEvent(AppTask::APP_EVENT_LIGHTING_ONOFF); + ChipLogProgress(Zcl, "OnOff Switch Configuration attribute ID: " ChipLogFormatMEI " Type: %u Value: %u, length %u", + ChipLogValueMEI(attributeId), type, *value, size); + } + else if (clusterId == Identify::Id) + { + GetAppTask().PostEvent(AppTask::APP_EVENT_IDENTIFY_IDENTIFY); + ChipLogProgress(Zcl, "Identify attribute ID: " ChipLogFormatMEI " Type: %u Value: %u, length %u", + ChipLogValueMEI(attributeId), type, *value, size); + } +} + +/** @brief OnOff Cluster Init + * + * This function is called when a specific cluster is initialized. It gives the + * application an opportunity to take care of cluster initialization procedures. + * It is called exactly once for each endpoint where cluster is present. + * + * @param endpoint Ver.: always + * + * TODO Issue #3841 + * emberAfOnOffClusterInitCallback happens before the stack initialize the cluster + * attributes to the default value. + * The logic here expects something similar to the deprecated Plugins callback + * emberAfPluginOnOffClusterServerPostInitCallback. + * + */ +void emberAfOnOffClusterInitCallback(EndpointId endpoint) +{ + // TODO: implement any additional Cluster Server init actions +} + +void emberAfColorControlClusterInitCallback(EndpointId endpoint) +{ + GetAppTask().SetEndpointId(endpoint); +} diff --git a/examples/lighting-app/qcc74x/data_model/lighting-app-ethernet.matter b/examples/lighting-app/qcc74x/data_model/lighting-app-ethernet.matter new file mode 100644 index 00000000000000..626d1bce2be886 --- /dev/null +++ b/examples/lighting-app/qcc74x/data_model/lighting-app-ethernet.matter @@ -0,0 +1,2250 @@ +// This IDL was generated automatically by ZAP. +// It is for view/code review purposes only. + +/** Attributes and commands for putting a device into Identification mode (e.g. flashing a light). */ +cluster Identify = 3 { + revision 4; + + enum EffectIdentifierEnum : enum8 { + kBlink = 0; + kBreathe = 1; + kOkay = 2; + kChannelChange = 11; + kFinishEffect = 254; + kStopEffect = 255; + } + + enum EffectVariantEnum : enum8 { + kDefault = 0; + } + + enum IdentifyTypeEnum : enum8 { + kNone = 0; + kLightOutput = 1; + kVisibleIndicator = 2; + kAudibleBeep = 3; + kDisplay = 4; + kActuator = 5; + } + + attribute int16u identifyTime = 0; + readonly attribute IdentifyTypeEnum identifyType = 1; + readonly attribute command_id generatedCommandList[] = 65528; + readonly attribute command_id acceptedCommandList[] = 65529; + readonly attribute event_id eventList[] = 65530; + readonly attribute attrib_id attributeList[] = 65531; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; + + request struct IdentifyRequest { + int16u identifyTime = 0; + } + + request struct TriggerEffectRequest { + EffectIdentifierEnum effectIdentifier = 0; + EffectVariantEnum effectVariant = 1; + } + + /** Command description for Identify */ + command access(invoke: manage) Identify(IdentifyRequest): DefaultSuccess = 0; + /** Command description for TriggerEffect */ + command access(invoke: manage) TriggerEffect(TriggerEffectRequest): DefaultSuccess = 64; +} + +/** Attributes and commands for group configuration and manipulation. */ +cluster Groups = 4 { + revision 4; + + bitmap Feature : bitmap32 { + kGroupNames = 0x1; + } + + bitmap NameSupportBitmap : bitmap8 { + kGroupNames = 0x80; + } + + readonly attribute NameSupportBitmap nameSupport = 0; + readonly attribute command_id generatedCommandList[] = 65528; + readonly attribute command_id acceptedCommandList[] = 65529; + readonly attribute event_id eventList[] = 65530; + readonly attribute attrib_id attributeList[] = 65531; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; + + request struct AddGroupRequest { + group_id groupID = 0; + char_string<16> groupName = 1; + } + + response struct AddGroupResponse = 0 { + enum8 status = 0; + group_id groupID = 1; + } + + request struct ViewGroupRequest { + group_id groupID = 0; + } + + response struct ViewGroupResponse = 1 { + enum8 status = 0; + group_id groupID = 1; + char_string<16> groupName = 2; + } + + request struct GetGroupMembershipRequest { + group_id groupList[] = 0; + } + + response struct GetGroupMembershipResponse = 2 { + nullable int8u capacity = 0; + group_id groupList[] = 1; + } + + request struct RemoveGroupRequest { + group_id groupID = 0; + } + + response struct RemoveGroupResponse = 3 { + enum8 status = 0; + group_id groupID = 1; + } + + request struct AddGroupIfIdentifyingRequest { + group_id groupID = 0; + char_string<16> groupName = 1; + } + + /** Command description for AddGroup */ + fabric command access(invoke: manage) AddGroup(AddGroupRequest): AddGroupResponse = 0; + /** Command description for ViewGroup */ + fabric command ViewGroup(ViewGroupRequest): ViewGroupResponse = 1; + /** Command description for GetGroupMembership */ + fabric command GetGroupMembership(GetGroupMembershipRequest): GetGroupMembershipResponse = 2; + /** Command description for RemoveGroup */ + fabric command access(invoke: manage) RemoveGroup(RemoveGroupRequest): RemoveGroupResponse = 3; + /** Command description for RemoveAllGroups */ + fabric command access(invoke: manage) RemoveAllGroups(): DefaultSuccess = 4; + /** Command description for AddGroupIfIdentifying */ + fabric command access(invoke: manage) AddGroupIfIdentifying(AddGroupIfIdentifyingRequest): DefaultSuccess = 5; +} + +/** Attributes and commands for switching devices between 'On' and 'Off' states. */ +cluster OnOff = 6 { + revision 6; + + enum DelayedAllOffEffectVariantEnum : enum8 { + kDelayedOffFastFade = 0; + kNoFade = 1; + kDelayedOffSlowFade = 2; + } + + enum DyingLightEffectVariantEnum : enum8 { + kDyingLightFadeOff = 0; + } + + enum EffectIdentifierEnum : enum8 { + kDelayedAllOff = 0; + kDyingLight = 1; + } + + enum StartUpOnOffEnum : enum8 { + kOff = 0; + kOn = 1; + kToggle = 2; + } + + bitmap Feature : bitmap32 { + kLighting = 0x1; + kDeadFrontBehavior = 0x2; + kOffOnly = 0x4; + } + + bitmap OnOffControlBitmap : bitmap8 { + kAcceptOnlyWhenOn = 0x1; + } + + readonly attribute boolean onOff = 0; + readonly attribute optional boolean globalSceneControl = 16384; + attribute optional int16u onTime = 16385; + attribute optional int16u offWaitTime = 16386; + attribute access(write: manage) optional nullable StartUpOnOffEnum startUpOnOff = 16387; + readonly attribute command_id generatedCommandList[] = 65528; + readonly attribute command_id acceptedCommandList[] = 65529; + readonly attribute event_id eventList[] = 65530; + readonly attribute attrib_id attributeList[] = 65531; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; + + request struct OffWithEffectRequest { + EffectIdentifierEnum effectIdentifier = 0; + enum8 effectVariant = 1; + } + + request struct OnWithTimedOffRequest { + OnOffControlBitmap onOffControl = 0; + int16u onTime = 1; + int16u offWaitTime = 2; + } + + /** On receipt of this command, a device SHALL enter its ‘Off’ state. This state is device dependent, but it is recommended that it is used for power off or similar functions. On receipt of the Off command, the OnTime attribute SHALL be set to 0. */ + command Off(): DefaultSuccess = 0; + /** On receipt of this command, a device SHALL enter its ‘On’ state. This state is device dependent, but it is recommended that it is used for power on or similar functions. On receipt of the On command, if the value of the OnTime attribute is equal to 0, the device SHALL set the OffWaitTime attribute to 0. */ + command On(): DefaultSuccess = 1; + /** On receipt of this command, if a device is in its ‘Off’ state it SHALL enter its ‘On’ state. Otherwise, if it is in its ‘On’ state it SHALL enter its ‘Off’ state. On receipt of the Toggle command, if the value of the OnOff attribute is equal to FALSE and if the value of the OnTime attribute is equal to 0, the device SHALL set the OffWaitTime attribute to 0. If the value of the OnOff attribute is equal to TRUE, the OnTime attribute SHALL be set to 0. */ + command Toggle(): DefaultSuccess = 2; + /** The OffWithEffect command allows devices to be turned off using enhanced ways of fading. */ + command OffWithEffect(OffWithEffectRequest): DefaultSuccess = 64; + /** The OnWithRecallGlobalScene command allows the recall of the settings when the device was turned off. */ + command OnWithRecallGlobalScene(): DefaultSuccess = 65; + /** The OnWithTimedOff command allows devices to be turned on for a specific duration with a guarded off duration so that SHOULD the device be subsequently switched off, further OnWithTimedOff commands, received during this time, are prevented from turning the devices back on. */ + command OnWithTimedOff(OnWithTimedOffRequest): DefaultSuccess = 66; +} + +/** Attributes and commands for controlling devices that can be set to a level between fully 'On' and fully 'Off.' */ +cluster LevelControl = 8 { + revision 5; + + enum MoveModeEnum : enum8 { + kUp = 0; + kDown = 1; + } + + enum StepModeEnum : enum8 { + kUp = 0; + kDown = 1; + } + + bitmap Feature : bitmap32 { + kOnOff = 0x1; + kLighting = 0x2; + kFrequency = 0x4; + } + + bitmap OptionsBitmap : bitmap8 { + kExecuteIfOff = 0x1; + kCoupleColorTempToLevel = 0x2; + } + + readonly attribute nullable int8u currentLevel = 0; + readonly attribute optional int16u remainingTime = 1; + readonly attribute optional int8u minLevel = 2; + readonly attribute optional int8u maxLevel = 3; + readonly attribute optional int16u currentFrequency = 4; + readonly attribute optional int16u minFrequency = 5; + readonly attribute optional int16u maxFrequency = 6; + attribute OptionsBitmap options = 15; + attribute optional int16u onOffTransitionTime = 16; + attribute nullable int8u onLevel = 17; + attribute optional nullable int16u onTransitionTime = 18; + attribute optional nullable int16u offTransitionTime = 19; + attribute optional nullable int8u defaultMoveRate = 20; + attribute access(write: manage) optional nullable int8u startUpCurrentLevel = 16384; + readonly attribute command_id generatedCommandList[] = 65528; + readonly attribute command_id acceptedCommandList[] = 65529; + readonly attribute event_id eventList[] = 65530; + readonly attribute attrib_id attributeList[] = 65531; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; + + request struct MoveToLevelRequest { + int8u level = 0; + nullable int16u transitionTime = 1; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; + } + + request struct MoveRequest { + MoveModeEnum moveMode = 0; + nullable int8u rate = 1; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; + } + + request struct StepRequest { + StepModeEnum stepMode = 0; + int8u stepSize = 1; + nullable int16u transitionTime = 2; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; + } + + request struct StopRequest { + OptionsBitmap optionsMask = 0; + OptionsBitmap optionsOverride = 1; + } + + request struct MoveToLevelWithOnOffRequest { + int8u level = 0; + nullable int16u transitionTime = 1; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; + } + + request struct MoveWithOnOffRequest { + MoveModeEnum moveMode = 0; + nullable int8u rate = 1; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; + } + + request struct StepWithOnOffRequest { + StepModeEnum stepMode = 0; + int8u stepSize = 1; + nullable int16u transitionTime = 2; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; + } + + request struct StopWithOnOffRequest { + OptionsBitmap optionsMask = 0; + OptionsBitmap optionsOverride = 1; + } + + request struct MoveToClosestFrequencyRequest { + int16u frequency = 0; + } + + /** Command description for MoveToLevel */ + command MoveToLevel(MoveToLevelRequest): DefaultSuccess = 0; + /** Command description for Move */ + command Move(MoveRequest): DefaultSuccess = 1; + /** Command description for Step */ + command Step(StepRequest): DefaultSuccess = 2; + /** Command description for Stop */ + command Stop(StopRequest): DefaultSuccess = 3; + /** Command description for MoveToLevelWithOnOff */ + command MoveToLevelWithOnOff(MoveToLevelWithOnOffRequest): DefaultSuccess = 4; + /** Command description for MoveWithOnOff */ + command MoveWithOnOff(MoveWithOnOffRequest): DefaultSuccess = 5; + /** Command description for StepWithOnOff */ + command StepWithOnOff(StepWithOnOffRequest): DefaultSuccess = 6; + /** Command description for StopWithOnOff */ + command StopWithOnOff(StopWithOnOffRequest): DefaultSuccess = 7; + /** Change the currrent frequency to the provided one, or a close + approximation if the exact provided one is not possible. */ + command MoveToClosestFrequency(MoveToClosestFrequencyRequest): DefaultSuccess = 8; +} + +/** The Descriptor Cluster is meant to replace the support from the Zigbee Device Object (ZDO) for describing a node, its endpoints and clusters. */ +cluster Descriptor = 29 { + revision 2; + + bitmap Feature : bitmap32 { + kTagList = 0x1; + } + + struct DeviceTypeStruct { + devtype_id deviceType = 0; + int16u revision = 1; + } + + struct SemanticTagStruct { + nullable vendor_id mfgCode = 0; + enum8 namespaceID = 1; + enum8 tag = 2; + optional nullable char_string label = 3; + } + + readonly attribute DeviceTypeStruct deviceTypeList[] = 0; + readonly attribute cluster_id serverList[] = 1; + readonly attribute cluster_id clientList[] = 2; + readonly attribute endpoint_no partsList[] = 3; + readonly attribute optional SemanticTagStruct tagList[] = 4; + readonly attribute command_id generatedCommandList[] = 65528; + readonly attribute command_id acceptedCommandList[] = 65529; + readonly attribute event_id eventList[] = 65530; + readonly attribute attrib_id attributeList[] = 65531; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; +} + +/** The Access Control Cluster exposes a data model view of a + Node's Access Control List (ACL), which codifies the rules used to manage + and enforce Access Control for the Node's endpoints and their associated + cluster instances. */ +cluster AccessControl = 31 { + revision 1; // NOTE: Default/not specifically set + + enum AccessControlEntryAuthModeEnum : enum8 { + kPASE = 1; + kCASE = 2; + kGroup = 3; + } + + enum AccessControlEntryPrivilegeEnum : enum8 { + kView = 1; + kProxyView = 2; + kOperate = 3; + kManage = 4; + kAdminister = 5; + } + + enum ChangeTypeEnum : enum8 { + kChanged = 0; + kAdded = 1; + kRemoved = 2; + } + + struct AccessControlTargetStruct { + nullable cluster_id cluster = 0; + nullable endpoint_no endpoint = 1; + nullable devtype_id deviceType = 2; + } + + fabric_scoped struct AccessControlEntryStruct { + fabric_sensitive AccessControlEntryPrivilegeEnum privilege = 1; + fabric_sensitive AccessControlEntryAuthModeEnum authMode = 2; + nullable fabric_sensitive int64u subjects[] = 3; + nullable fabric_sensitive AccessControlTargetStruct targets[] = 4; + fabric_idx fabricIndex = 254; + } + + fabric_scoped struct AccessControlExtensionStruct { + fabric_sensitive octet_string<128> data = 1; + fabric_idx fabricIndex = 254; + } + + fabric_sensitive info event access(read: administer) AccessControlEntryChanged = 0 { + nullable node_id adminNodeID = 1; + nullable int16u adminPasscodeID = 2; + ChangeTypeEnum changeType = 3; + nullable AccessControlEntryStruct latestValue = 4; + fabric_idx fabricIndex = 254; + } + + fabric_sensitive info event access(read: administer) AccessControlExtensionChanged = 1 { + nullable node_id adminNodeID = 1; + nullable int16u adminPasscodeID = 2; + ChangeTypeEnum changeType = 3; + nullable AccessControlExtensionStruct latestValue = 4; + fabric_idx fabricIndex = 254; + } + + attribute access(read: administer, write: administer) AccessControlEntryStruct acl[] = 0; + attribute access(read: administer, write: administer) optional AccessControlExtensionStruct extension[] = 1; + readonly attribute int16u subjectsPerAccessControlEntry = 2; + readonly attribute int16u targetsPerAccessControlEntry = 3; + readonly attribute int16u accessControlEntriesPerFabric = 4; + readonly attribute command_id generatedCommandList[] = 65528; + readonly attribute command_id acceptedCommandList[] = 65529; + readonly attribute event_id eventList[] = 65530; + readonly attribute attrib_id attributeList[] = 65531; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; +} + +/** This cluster provides attributes and events for determining basic information about Nodes, which supports both + Commissioning and operational determination of Node characteristics, such as Vendor ID, Product ID and serial number, + which apply to the whole Node. Also allows setting user device information such as location. */ +cluster BasicInformation = 40 { + revision 3; + + enum ColorEnum : enum8 { + kBlack = 0; + kNavy = 1; + kGreen = 2; + kTeal = 3; + kMaroon = 4; + kPurple = 5; + kOlive = 6; + kGray = 7; + kBlue = 8; + kLime = 9; + kAqua = 10; + kRed = 11; + kFuchsia = 12; + kYellow = 13; + kWhite = 14; + kNickel = 15; + kChrome = 16; + kBrass = 17; + kCopper = 18; + kSilver = 19; + kGold = 20; + } + + enum ProductFinishEnum : enum8 { + kOther = 0; + kMatte = 1; + kSatin = 2; + kPolished = 3; + kRugged = 4; + kFabric = 5; + } + + struct CapabilityMinimaStruct { + int16u caseSessionsPerFabric = 0; + int16u subscriptionsPerFabric = 1; + } + + struct ProductAppearanceStruct { + ProductFinishEnum finish = 0; + nullable ColorEnum primaryColor = 1; + } + + critical event StartUp = 0 { + int32u softwareVersion = 0; + } + + critical event ShutDown = 1 { + } + + info event Leave = 2 { + fabric_idx fabricIndex = 0; + } + + info event ReachableChanged = 3 { + boolean reachableNewValue = 0; + } + + readonly attribute int16u dataModelRevision = 0; + readonly attribute char_string<32> vendorName = 1; + readonly attribute vendor_id vendorID = 2; + readonly attribute char_string<32> productName = 3; + readonly attribute int16u productID = 4; + attribute access(write: manage) char_string<32> nodeLabel = 5; + attribute access(write: administer) char_string<2> location = 6; + readonly attribute int16u hardwareVersion = 7; + readonly attribute char_string<64> hardwareVersionString = 8; + readonly attribute int32u softwareVersion = 9; + readonly attribute char_string<64> softwareVersionString = 10; + readonly attribute optional char_string<16> manufacturingDate = 11; + readonly attribute optional char_string<32> partNumber = 12; + readonly attribute optional long_char_string<256> productURL = 13; + readonly attribute optional char_string<64> productLabel = 14; + readonly attribute optional char_string<32> serialNumber = 15; + attribute access(write: manage) optional boolean localConfigDisabled = 16; + readonly attribute optional boolean reachable = 17; + readonly attribute optional char_string<32> uniqueID = 18; + readonly attribute CapabilityMinimaStruct capabilityMinima = 19; + readonly attribute optional ProductAppearanceStruct productAppearance = 20; + readonly attribute int32u specificationVersion = 21; + readonly attribute int16u maxPathsPerInvoke = 22; + readonly attribute command_id generatedCommandList[] = 65528; + readonly attribute command_id acceptedCommandList[] = 65529; + readonly attribute event_id eventList[] = 65530; + readonly attribute attrib_id attributeList[] = 65531; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; + + command MfgSpecificPing(): DefaultSuccess = 0; +} + +/** Provides an interface for providing OTA software updates */ +cluster OtaSoftwareUpdateProvider = 41 { + revision 1; // NOTE: Default/not specifically set + + enum ApplyUpdateActionEnum : enum8 { + kProceed = 0; + kAwaitNextAction = 1; + kDiscontinue = 2; + } + + enum DownloadProtocolEnum : enum8 { + kBDXSynchronous = 0; + kBDXAsynchronous = 1; + kHTTPS = 2; + kVendorSpecific = 3; + } + + enum StatusEnum : enum8 { + kUpdateAvailable = 0; + kBusy = 1; + kNotAvailable = 2; + kDownloadProtocolNotSupported = 3; + } + + readonly attribute command_id generatedCommandList[] = 65528; + readonly attribute command_id acceptedCommandList[] = 65529; + readonly attribute event_id eventList[] = 65530; + readonly attribute attrib_id attributeList[] = 65531; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; + + request struct QueryImageRequest { + vendor_id vendorID = 0; + int16u productID = 1; + int32u softwareVersion = 2; + DownloadProtocolEnum protocolsSupported[] = 3; + optional int16u hardwareVersion = 4; + optional char_string<2> location = 5; + optional boolean requestorCanConsent = 6; + optional octet_string<512> metadataForProvider = 7; + } + + response struct QueryImageResponse = 1 { + StatusEnum status = 0; + optional int32u delayedActionTime = 1; + optional char_string<256> imageURI = 2; + optional int32u softwareVersion = 3; + optional char_string<64> softwareVersionString = 4; + optional octet_string<32> updateToken = 5; + optional boolean userConsentNeeded = 6; + optional octet_string<512> metadataForRequestor = 7; + } + + request struct ApplyUpdateRequestRequest { + octet_string<32> updateToken = 0; + int32u newVersion = 1; + } + + response struct ApplyUpdateResponse = 3 { + ApplyUpdateActionEnum action = 0; + int32u delayedActionTime = 1; + } + + request struct NotifyUpdateAppliedRequest { + octet_string<32> updateToken = 0; + int32u softwareVersion = 1; + } + + /** Determine availability of a new Software Image */ + command QueryImage(QueryImageRequest): QueryImageResponse = 0; + /** Determine next action to take for a downloaded Software Image */ + command ApplyUpdateRequest(ApplyUpdateRequestRequest): ApplyUpdateResponse = 2; + /** Notify OTA Provider that an update was applied */ + command NotifyUpdateApplied(NotifyUpdateAppliedRequest): DefaultSuccess = 4; +} + +/** Provides an interface for downloading and applying OTA software updates */ +cluster OtaSoftwareUpdateRequestor = 42 { + revision 1; // NOTE: Default/not specifically set + + enum AnnouncementReasonEnum : enum8 { + kSimpleAnnouncement = 0; + kUpdateAvailable = 1; + kUrgentUpdateAvailable = 2; + } + + enum ChangeReasonEnum : enum8 { + kUnknown = 0; + kSuccess = 1; + kFailure = 2; + kTimeOut = 3; + kDelayByProvider = 4; + } + + enum UpdateStateEnum : enum8 { + kUnknown = 0; + kIdle = 1; + kQuerying = 2; + kDelayedOnQuery = 3; + kDownloading = 4; + kApplying = 5; + kDelayedOnApply = 6; + kRollingBack = 7; + kDelayedOnUserConsent = 8; + } + + fabric_scoped struct ProviderLocation { + node_id providerNodeID = 1; + endpoint_no endpoint = 2; + fabric_idx fabricIndex = 254; + } + + info event StateTransition = 0 { + UpdateStateEnum previousState = 0; + UpdateStateEnum newState = 1; + ChangeReasonEnum reason = 2; + nullable int32u targetSoftwareVersion = 3; + } + + critical event VersionApplied = 1 { + int32u softwareVersion = 0; + int16u productID = 1; + } + + info event DownloadError = 2 { + int32u softwareVersion = 0; + int64u bytesDownloaded = 1; + nullable int8u progressPercent = 2; + nullable int64s platformCode = 3; + } + + attribute access(write: administer) ProviderLocation defaultOTAProviders[] = 0; + readonly attribute boolean updatePossible = 1; + readonly attribute UpdateStateEnum updateState = 2; + readonly attribute nullable int8u updateStateProgress = 3; + readonly attribute command_id generatedCommandList[] = 65528; + readonly attribute command_id acceptedCommandList[] = 65529; + readonly attribute event_id eventList[] = 65530; + readonly attribute attrib_id attributeList[] = 65531; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; + + request struct AnnounceOTAProviderRequest { + node_id providerNodeID = 0; + vendor_id vendorID = 1; + AnnouncementReasonEnum announcementReason = 2; + optional octet_string<512> metadataForNode = 3; + endpoint_no endpoint = 4; + } + + /** Announce the presence of an OTA Provider */ + command AnnounceOTAProvider(AnnounceOTAProviderRequest): DefaultSuccess = 0; +} + +/** Nodes should be expected to be deployed to any and all regions of the world. These global regions + may have differing common languages, units of measurements, and numerical formatting + standards. As such, Nodes that visually or audibly convey information need a mechanism by which + they can be configured to use a user’s preferred language, units, etc */ +cluster LocalizationConfiguration = 43 { + revision 1; // NOTE: Default/not specifically set + + attribute access(write: manage) char_string<35> activeLocale = 0; + readonly attribute char_string supportedLocales[] = 1; + readonly attribute command_id generatedCommandList[] = 65528; + readonly attribute command_id acceptedCommandList[] = 65529; + readonly attribute event_id eventList[] = 65530; + readonly attribute attrib_id attributeList[] = 65531; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; +} + +/** Nodes should be expected to be deployed to any and all regions of the world. These global regions + may have differing preferences for how dates and times are conveyed. As such, Nodes that visually + or audibly convey time information need a mechanism by which they can be configured to use a + user’s preferred format. */ +cluster TimeFormatLocalization = 44 { + revision 1; // NOTE: Default/not specifically set + + enum CalendarTypeEnum : enum8 { + kBuddhist = 0; + kChinese = 1; + kCoptic = 2; + kEthiopian = 3; + kGregorian = 4; + kHebrew = 5; + kIndian = 6; + kIslamic = 7; + kJapanese = 8; + kKorean = 9; + kPersian = 10; + kTaiwanese = 11; + kUseActiveLocale = 255; + } + + enum HourFormatEnum : enum8 { + k12hr = 0; + k24hr = 1; + kUseActiveLocale = 255; + } + + bitmap Feature : bitmap32 { + kCalendarFormat = 0x1; + } + + attribute access(write: manage) HourFormatEnum hourFormat = 0; + attribute access(write: manage) optional CalendarTypeEnum activeCalendarType = 1; + readonly attribute optional CalendarTypeEnum supportedCalendarTypes[] = 2; + readonly attribute command_id generatedCommandList[] = 65528; + readonly attribute command_id acceptedCommandList[] = 65529; + readonly attribute event_id eventList[] = 65530; + readonly attribute attrib_id attributeList[] = 65531; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; +} + +/** This cluster is used to manage global aspects of the Commissioning flow. */ +cluster GeneralCommissioning = 48 { + revision 1; // NOTE: Default/not specifically set + + enum CommissioningErrorEnum : enum8 { + kOK = 0; + kValueOutsideRange = 1; + kInvalidAuthentication = 2; + kNoFailSafe = 3; + kBusyWithOtherAdmin = 4; + } + + enum RegulatoryLocationTypeEnum : enum8 { + kIndoor = 0; + kOutdoor = 1; + kIndoorOutdoor = 2; + } + + struct BasicCommissioningInfo { + int16u failSafeExpiryLengthSeconds = 0; + int16u maxCumulativeFailsafeSeconds = 1; + } + + attribute access(write: administer) int64u breadcrumb = 0; + readonly attribute BasicCommissioningInfo basicCommissioningInfo = 1; + readonly attribute RegulatoryLocationTypeEnum regulatoryConfig = 2; + readonly attribute RegulatoryLocationTypeEnum locationCapability = 3; + readonly attribute boolean supportsConcurrentConnection = 4; + readonly attribute command_id generatedCommandList[] = 65528; + readonly attribute command_id acceptedCommandList[] = 65529; + readonly attribute event_id eventList[] = 65530; + readonly attribute attrib_id attributeList[] = 65531; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; + + request struct ArmFailSafeRequest { + int16u expiryLengthSeconds = 0; + int64u breadcrumb = 1; + } + + response struct ArmFailSafeResponse = 1 { + CommissioningErrorEnum errorCode = 0; + char_string<128> debugText = 1; + } + + request struct SetRegulatoryConfigRequest { + RegulatoryLocationTypeEnum newRegulatoryConfig = 0; + char_string<2> countryCode = 1; + int64u breadcrumb = 2; + } + + response struct SetRegulatoryConfigResponse = 3 { + CommissioningErrorEnum errorCode = 0; + char_string debugText = 1; + } + + response struct CommissioningCompleteResponse = 5 { + CommissioningErrorEnum errorCode = 0; + char_string debugText = 1; + } + + /** Arm the persistent fail-safe timer with an expiry time of now + ExpiryLengthSeconds using device clock */ + command access(invoke: administer) ArmFailSafe(ArmFailSafeRequest): ArmFailSafeResponse = 0; + /** Set the regulatory configuration to be used during commissioning */ + command access(invoke: administer) SetRegulatoryConfig(SetRegulatoryConfigRequest): SetRegulatoryConfigResponse = 2; + /** Signals the Server that the Client has successfully completed all steps of Commissioning/Recofiguration needed during fail-safe period. */ + fabric command access(invoke: administer) CommissioningComplete(): CommissioningCompleteResponse = 4; +} + +/** Functionality to configure, enable, disable network credentials and access on a Matter device. */ +cluster NetworkCommissioning = 49 { + revision 1; // NOTE: Default/not specifically set + + enum NetworkCommissioningStatusEnum : enum8 { + kSuccess = 0; + kOutOfRange = 1; + kBoundsExceeded = 2; + kNetworkIDNotFound = 3; + kDuplicateNetworkID = 4; + kNetworkNotFound = 5; + kRegulatoryError = 6; + kAuthFailure = 7; + kUnsupportedSecurity = 8; + kOtherConnectionFailure = 9; + kIPV6Failed = 10; + kIPBindFailed = 11; + kUnknownError = 12; + } + + enum WiFiBandEnum : enum8 { + k2G4 = 0; + k3G65 = 1; + k5G = 2; + k6G = 3; + k60G = 4; + k1G = 5; + } + + bitmap Feature : bitmap32 { + kWiFiNetworkInterface = 0x1; + kThreadNetworkInterface = 0x2; + kEthernetNetworkInterface = 0x4; + kPerDeviceCredentials = 0x8; + } + + bitmap ThreadCapabilitiesBitmap : bitmap16 { + kIsBorderRouterCapable = 0x1; + kIsRouterCapable = 0x2; + kIsSleepyEndDeviceCapable = 0x4; + kIsFullThreadDevice = 0x8; + kIsSynchronizedSleepyEndDeviceCapable = 0x10; + } + + bitmap WiFiSecurityBitmap : bitmap8 { + kUnencrypted = 0x1; + kWEP = 0x2; + kWPAPersonal = 0x4; + kWPA2Personal = 0x8; + kWPA3Personal = 0x10; + kWPA3MatterPDC = 0x20; + } + + struct NetworkInfoStruct { + octet_string<32> networkID = 0; + boolean connected = 1; + optional nullable octet_string<20> networkIdentifier = 2; + optional nullable octet_string<20> clientIdentifier = 3; + } + + struct ThreadInterfaceScanResultStruct { + int16u panId = 0; + int64u extendedPanId = 1; + char_string<16> networkName = 2; + int16u channel = 3; + int8u version = 4; + octet_string<8> extendedAddress = 5; + int8s rssi = 6; + int8u lqi = 7; + } + + struct WiFiInterfaceScanResultStruct { + WiFiSecurityBitmap security = 0; + octet_string<32> ssid = 1; + octet_string<6> bssid = 2; + int16u channel = 3; + WiFiBandEnum wiFiBand = 4; + int8s rssi = 5; + } + + readonly attribute access(read: administer) int8u maxNetworks = 0; + readonly attribute access(read: administer) NetworkInfoStruct networks[] = 1; + readonly attribute optional int8u scanMaxTimeSeconds = 2; + readonly attribute optional int8u connectMaxTimeSeconds = 3; + attribute access(write: administer) boolean interfaceEnabled = 4; + readonly attribute access(read: administer) nullable NetworkCommissioningStatusEnum lastNetworkingStatus = 5; + readonly attribute access(read: administer) nullable octet_string<32> lastNetworkID = 6; + readonly attribute access(read: administer) nullable int32s lastConnectErrorValue = 7; + readonly attribute optional WiFiBandEnum supportedWiFiBands[] = 8; + readonly attribute optional ThreadCapabilitiesBitmap supportedThreadFeatures = 9; + readonly attribute optional int16u threadVersion = 10; + readonly attribute command_id generatedCommandList[] = 65528; + readonly attribute command_id acceptedCommandList[] = 65529; + readonly attribute event_id eventList[] = 65530; + readonly attribute attrib_id attributeList[] = 65531; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; + + request struct ScanNetworksRequest { + optional nullable octet_string<32> ssid = 0; + optional int64u breadcrumb = 1; + } + + response struct ScanNetworksResponse = 1 { + NetworkCommissioningStatusEnum networkingStatus = 0; + optional char_string debugText = 1; + optional WiFiInterfaceScanResultStruct wiFiScanResults[] = 2; + optional ThreadInterfaceScanResultStruct threadScanResults[] = 3; + } + + request struct AddOrUpdateWiFiNetworkRequest { + octet_string<32> ssid = 0; + octet_string<64> credentials = 1; + optional int64u breadcrumb = 2; + optional octet_string<140> networkIdentity = 3; + optional octet_string<20> clientIdentifier = 4; + optional octet_string<32> possessionNonce = 5; + } + + request struct AddOrUpdateThreadNetworkRequest { + octet_string<254> operationalDataset = 0; + optional int64u breadcrumb = 1; + } + + request struct RemoveNetworkRequest { + octet_string<32> networkID = 0; + optional int64u breadcrumb = 1; + } + + response struct NetworkConfigResponse = 5 { + NetworkCommissioningStatusEnum networkingStatus = 0; + optional char_string<512> debugText = 1; + optional int8u networkIndex = 2; + optional octet_string<140> clientIdentity = 3; + optional octet_string<64> possessionSignature = 4; + } + + request struct ConnectNetworkRequest { + octet_string<32> networkID = 0; + optional int64u breadcrumb = 1; + } + + response struct ConnectNetworkResponse = 7 { + NetworkCommissioningStatusEnum networkingStatus = 0; + optional char_string debugText = 1; + nullable int32s errorValue = 2; + } + + request struct ReorderNetworkRequest { + octet_string<32> networkID = 0; + int8u networkIndex = 1; + optional int64u breadcrumb = 2; + } + + request struct QueryIdentityRequest { + octet_string<20> keyIdentifier = 0; + optional octet_string<32> possessionNonce = 1; + } + + response struct QueryIdentityResponse = 10 { + octet_string<140> identity = 0; + optional octet_string<64> possessionSignature = 1; + } + + /** Detemine the set of networks the device sees as available. */ + command access(invoke: administer) ScanNetworks(ScanNetworksRequest): ScanNetworksResponse = 0; + /** Add or update the credentials for a given Wi-Fi network. */ + command access(invoke: administer) AddOrUpdateWiFiNetwork(AddOrUpdateWiFiNetworkRequest): NetworkConfigResponse = 2; + /** Add or update the credentials for a given Thread network. */ + command access(invoke: administer) AddOrUpdateThreadNetwork(AddOrUpdateThreadNetworkRequest): NetworkConfigResponse = 3; + /** Remove the definition of a given network (including its credentials). */ + command access(invoke: administer) RemoveNetwork(RemoveNetworkRequest): NetworkConfigResponse = 4; + /** Connect to the specified network, using previously-defined credentials. */ + command access(invoke: administer) ConnectNetwork(ConnectNetworkRequest): ConnectNetworkResponse = 6; + /** Modify the order in which networks will be presented in the Networks attribute. */ + command access(invoke: administer) ReorderNetwork(ReorderNetworkRequest): NetworkConfigResponse = 8; + /** Retrieve details about and optionally proof of possession of a network client identity. */ + command access(invoke: administer) QueryIdentity(QueryIdentityRequest): QueryIdentityResponse = 9; +} + +/** The cluster provides commands for retrieving unstructured diagnostic logs from a Node that may be used to aid in diagnostics. */ +cluster DiagnosticLogs = 50 { + revision 1; // NOTE: Default/not specifically set + + enum IntentEnum : enum8 { + kEndUserSupport = 0; + kNetworkDiag = 1; + kCrashLogs = 2; + } + + enum StatusEnum : enum8 { + kSuccess = 0; + kExhausted = 1; + kNoLogs = 2; + kBusy = 3; + kDenied = 4; + } + + enum TransferProtocolEnum : enum8 { + kResponsePayload = 0; + kBDX = 1; + } + + readonly attribute command_id generatedCommandList[] = 65528; + readonly attribute command_id acceptedCommandList[] = 65529; + readonly attribute event_id eventList[] = 65530; + readonly attribute attrib_id attributeList[] = 65531; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; + + request struct RetrieveLogsRequestRequest { + IntentEnum intent = 0; + TransferProtocolEnum requestedProtocol = 1; + optional char_string<32> transferFileDesignator = 2; + } + + response struct RetrieveLogsResponse = 1 { + StatusEnum status = 0; + long_octet_string logContent = 1; + optional epoch_us UTCTimeStamp = 2; + optional systime_us timeSinceBoot = 3; + } + + /** Retrieving diagnostic logs from a Node */ + command RetrieveLogsRequest(RetrieveLogsRequestRequest): RetrieveLogsResponse = 0; +} + +/** The General Diagnostics Cluster, along with other diagnostics clusters, provide a means to acquire standardized diagnostics metrics that MAY be used by a Node to assist a user or Administrative Node in diagnosing potential problems. */ +cluster GeneralDiagnostics = 51 { + revision 2; + + enum BootReasonEnum : enum8 { + kUnspecified = 0; + kPowerOnReboot = 1; + kBrownOutReset = 2; + kSoftwareWatchdogReset = 3; + kHardwareWatchdogReset = 4; + kSoftwareUpdateCompleted = 5; + kSoftwareReset = 6; + } + + enum HardwareFaultEnum : enum8 { + kUnspecified = 0; + kRadio = 1; + kSensor = 2; + kResettableOverTemp = 3; + kNonResettableOverTemp = 4; + kPowerSource = 5; + kVisualDisplayFault = 6; + kAudioOutputFault = 7; + kUserInterfaceFault = 8; + kNonVolatileMemoryError = 9; + kTamperDetected = 10; + } + + enum InterfaceTypeEnum : enum8 { + kUnspecified = 0; + kWiFi = 1; + kEthernet = 2; + kCellular = 3; + kThread = 4; + } + + enum NetworkFaultEnum : enum8 { + kUnspecified = 0; + kHardwareFailure = 1; + kNetworkJammed = 2; + kConnectionFailed = 3; + } + + enum RadioFaultEnum : enum8 { + kUnspecified = 0; + kWiFiFault = 1; + kCellularFault = 2; + kThreadFault = 3; + kNFCFault = 4; + kBLEFault = 5; + kEthernetFault = 6; + } + + bitmap Feature : bitmap32 { + kDataModelTest = 0x1; + } + + struct NetworkInterface { + char_string<32> name = 0; + boolean isOperational = 1; + nullable boolean offPremiseServicesReachableIPv4 = 2; + nullable boolean offPremiseServicesReachableIPv6 = 3; + octet_string<8> hardwareAddress = 4; + octet_string IPv4Addresses[] = 5; + octet_string IPv6Addresses[] = 6; + InterfaceTypeEnum type = 7; + } + + critical event HardwareFaultChange = 0 { + HardwareFaultEnum current[] = 0; + HardwareFaultEnum previous[] = 1; + } + + critical event RadioFaultChange = 1 { + RadioFaultEnum current[] = 0; + RadioFaultEnum previous[] = 1; + } + + critical event NetworkFaultChange = 2 { + NetworkFaultEnum current[] = 0; + NetworkFaultEnum previous[] = 1; + } + + critical event BootReason = 3 { + BootReasonEnum bootReason = 0; + } + + readonly attribute NetworkInterface networkInterfaces[] = 0; + readonly attribute int16u rebootCount = 1; + readonly attribute optional int64u upTime = 2; + readonly attribute optional int32u totalOperationalHours = 3; + readonly attribute optional BootReasonEnum bootReason = 4; + readonly attribute optional HardwareFaultEnum activeHardwareFaults[] = 5; + readonly attribute optional RadioFaultEnum activeRadioFaults[] = 6; + readonly attribute optional NetworkFaultEnum activeNetworkFaults[] = 7; + readonly attribute boolean testEventTriggersEnabled = 8; + readonly attribute command_id generatedCommandList[] = 65528; + readonly attribute command_id acceptedCommandList[] = 65529; + readonly attribute event_id eventList[] = 65530; + readonly attribute attrib_id attributeList[] = 65531; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; + + request struct TestEventTriggerRequest { + octet_string<16> enableKey = 0; + int64u eventTrigger = 1; + } + + response struct TimeSnapshotResponse = 2 { + systime_ms systemTimeMs = 0; + nullable posix_ms posixTimeMs = 1; + } + + request struct PayloadTestRequestRequest { + octet_string<16> enableKey = 0; + int8u value = 1; + int16u count = 2; + } + + response struct PayloadTestResponse = 4 { + octet_string payload = 0; + } + + /** Provide a means for certification tests to trigger some test-plan-specific events */ + command access(invoke: manage) TestEventTrigger(TestEventTriggerRequest): DefaultSuccess = 0; + /** Take a snapshot of system time and epoch time. */ + command TimeSnapshot(): TimeSnapshotResponse = 1; + /** Request a variable length payload response. */ + command PayloadTestRequest(PayloadTestRequestRequest): PayloadTestResponse = 3; +} + +/** The Software Diagnostics Cluster provides a means to acquire standardized diagnostics metrics that MAY be used by a Node to assist a user or Administrative Node in diagnosing potential problems. */ +cluster SoftwareDiagnostics = 52 { + revision 1; // NOTE: Default/not specifically set + + bitmap Feature : bitmap32 { + kWatermarks = 0x1; + } + + struct ThreadMetricsStruct { + int64u id = 0; + optional char_string<8> name = 1; + optional int32u stackFreeCurrent = 2; + optional int32u stackFreeMinimum = 3; + optional int32u stackSize = 4; + } + + info event SoftwareFault = 0 { + int64u id = 0; + optional char_string name = 1; + optional octet_string faultRecording = 2; + } + + readonly attribute optional ThreadMetricsStruct threadMetrics[] = 0; + readonly attribute optional int64u currentHeapFree = 1; + readonly attribute optional int64u currentHeapUsed = 2; + readonly attribute optional int64u currentHeapHighWatermark = 3; + readonly attribute command_id generatedCommandList[] = 65528; + readonly attribute command_id acceptedCommandList[] = 65529; + readonly attribute event_id eventList[] = 65530; + readonly attribute attrib_id attributeList[] = 65531; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; + + /** Reception of this command SHALL reset the values: The StackFreeMinimum field of the ThreadMetrics attribute, CurrentHeapHighWaterMark attribute. */ + command access(invoke: manage) ResetWatermarks(): DefaultSuccess = 0; +} + +/** The Ethernet Network Diagnostics Cluster provides a means to acquire standardized diagnostics metrics that MAY be used by a Node to assist a user or Administrative Node in diagnosing potential problems. */ +cluster EthernetNetworkDiagnostics = 55 { + revision 1; // NOTE: Default/not specifically set + + enum PHYRateEnum : enum8 { + kRate10M = 0; + kRate100M = 1; + kRate1G = 2; + kRate25G = 3; + kRate5G = 4; + kRate10G = 5; + kRate40G = 6; + kRate100G = 7; + kRate200G = 8; + kRate400G = 9; + } + + bitmap Feature : bitmap32 { + kPacketCounts = 0x1; + kErrorCounts = 0x2; + } + + readonly attribute optional nullable PHYRateEnum PHYRate = 0; + readonly attribute optional nullable boolean fullDuplex = 1; + readonly attribute optional int64u packetRxCount = 2; + readonly attribute optional int64u packetTxCount = 3; + readonly attribute optional int64u txErrCount = 4; + readonly attribute optional int64u collisionCount = 5; + readonly attribute optional int64u overrunCount = 6; + readonly attribute optional nullable boolean carrierDetect = 7; + readonly attribute optional int64u timeSinceReset = 8; + readonly attribute command_id generatedCommandList[] = 65528; + readonly attribute command_id acceptedCommandList[] = 65529; + readonly attribute event_id eventList[] = 65530; + readonly attribute attrib_id attributeList[] = 65531; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; + + /** Reception of this command SHALL reset the attributes: PacketRxCount, PacketTxCount, TxErrCount, CollisionCount, OverrunCount to 0 */ + command access(invoke: manage) ResetCounts(): DefaultSuccess = 0; +} + +/** Commands to trigger a Node to allow a new Administrator to commission it. */ +cluster AdministratorCommissioning = 60 { + revision 1; // NOTE: Default/not specifically set + + enum CommissioningWindowStatusEnum : enum8 { + kWindowNotOpen = 0; + kEnhancedWindowOpen = 1; + kBasicWindowOpen = 2; + } + + enum StatusCode : enum8 { + kBusy = 2; + kPAKEParameterError = 3; + kWindowNotOpen = 4; + } + + bitmap Feature : bitmap32 { + kBasic = 0x1; + } + + readonly attribute CommissioningWindowStatusEnum windowStatus = 0; + readonly attribute nullable fabric_idx adminFabricIndex = 1; + readonly attribute nullable vendor_id adminVendorId = 2; + readonly attribute command_id generatedCommandList[] = 65528; + readonly attribute command_id acceptedCommandList[] = 65529; + readonly attribute event_id eventList[] = 65530; + readonly attribute attrib_id attributeList[] = 65531; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; + + request struct OpenCommissioningWindowRequest { + int16u commissioningTimeout = 0; + octet_string PAKEPasscodeVerifier = 1; + int16u discriminator = 2; + int32u iterations = 3; + octet_string<32> salt = 4; + } + + request struct OpenBasicCommissioningWindowRequest { + int16u commissioningTimeout = 0; + } + + /** This command is used by a current Administrator to instruct a Node to go into commissioning mode using enhanced commissioning method. */ + timed command access(invoke: administer) OpenCommissioningWindow(OpenCommissioningWindowRequest): DefaultSuccess = 0; + /** This command is used by a current Administrator to instruct a Node to go into commissioning mode using basic commissioning method, if the node supports it. */ + timed command access(invoke: administer) OpenBasicCommissioningWindow(OpenBasicCommissioningWindowRequest): DefaultSuccess = 1; + /** This command is used by a current Administrator to instruct a Node to revoke any active Open Commissioning Window or Open Basic Commissioning Window command. */ + timed command access(invoke: administer) RevokeCommissioning(): DefaultSuccess = 2; +} + +/** This cluster is used to add or remove Operational Credentials on a Commissionee or Node, as well as manage the associated Fabrics. */ +cluster OperationalCredentials = 62 { + revision 1; // NOTE: Default/not specifically set + + enum CertificateChainTypeEnum : enum8 { + kDACCertificate = 1; + kPAICertificate = 2; + } + + enum NodeOperationalCertStatusEnum : enum8 { + kOK = 0; + kInvalidPublicKey = 1; + kInvalidNodeOpId = 2; + kInvalidNOC = 3; + kMissingCsr = 4; + kTableFull = 5; + kInvalidAdminSubject = 6; + kFabricConflict = 9; + kLabelConflict = 10; + kInvalidFabricIndex = 11; + } + + fabric_scoped struct FabricDescriptorStruct { + octet_string<65> rootPublicKey = 1; + vendor_id vendorID = 2; + fabric_id fabricID = 3; + node_id nodeID = 4; + char_string<32> label = 5; + fabric_idx fabricIndex = 254; + } + + fabric_scoped struct NOCStruct { + fabric_sensitive octet_string noc = 1; + nullable fabric_sensitive octet_string icac = 2; + fabric_idx fabricIndex = 254; + } + + readonly attribute access(read: administer) NOCStruct NOCs[] = 0; + readonly attribute FabricDescriptorStruct fabrics[] = 1; + readonly attribute int8u supportedFabrics = 2; + readonly attribute int8u commissionedFabrics = 3; + readonly attribute octet_string trustedRootCertificates[] = 4; + readonly attribute int8u currentFabricIndex = 5; + readonly attribute command_id generatedCommandList[] = 65528; + readonly attribute command_id acceptedCommandList[] = 65529; + readonly attribute event_id eventList[] = 65530; + readonly attribute attrib_id attributeList[] = 65531; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; + + request struct AttestationRequestRequest { + octet_string<32> attestationNonce = 0; + } + + response struct AttestationResponse = 1 { + octet_string<900> attestationElements = 0; + octet_string<64> attestationSignature = 1; + } + + request struct CertificateChainRequestRequest { + CertificateChainTypeEnum certificateType = 0; + } + + response struct CertificateChainResponse = 3 { + octet_string<600> certificate = 0; + } + + request struct CSRRequestRequest { + octet_string<32> CSRNonce = 0; + optional boolean isForUpdateNOC = 1; + } + + response struct CSRResponse = 5 { + octet_string NOCSRElements = 0; + octet_string attestationSignature = 1; + } + + request struct AddNOCRequest { + octet_string<400> NOCValue = 0; + optional octet_string<400> ICACValue = 1; + octet_string<16> IPKValue = 2; + int64u caseAdminSubject = 3; + vendor_id adminVendorId = 4; + } + + request struct UpdateNOCRequest { + octet_string NOCValue = 0; + optional octet_string ICACValue = 1; + } + + response struct NOCResponse = 8 { + NodeOperationalCertStatusEnum statusCode = 0; + optional fabric_idx fabricIndex = 1; + optional char_string<128> debugText = 2; + } + + request struct UpdateFabricLabelRequest { + char_string<32> label = 0; + } + + request struct RemoveFabricRequest { + fabric_idx fabricIndex = 0; + } + + request struct AddTrustedRootCertificateRequest { + octet_string rootCACertificate = 0; + } + + /** Sender is requesting attestation information from the receiver. */ + command access(invoke: administer) AttestationRequest(AttestationRequestRequest): AttestationResponse = 0; + /** Sender is requesting a device attestation certificate from the receiver. */ + command access(invoke: administer) CertificateChainRequest(CertificateChainRequestRequest): CertificateChainResponse = 2; + /** Sender is requesting a certificate signing request (CSR) from the receiver. */ + command access(invoke: administer) CSRRequest(CSRRequestRequest): CSRResponse = 4; + /** Sender is requesting to add the new node operational certificates. */ + command access(invoke: administer) AddNOC(AddNOCRequest): NOCResponse = 6; + /** Sender is requesting to update the node operational certificates. */ + fabric command access(invoke: administer) UpdateNOC(UpdateNOCRequest): NOCResponse = 7; + /** This command SHALL be used by an Administrative Node to set the user-visible Label field for a given Fabric, as reflected by entries in the Fabrics attribute. */ + fabric command access(invoke: administer) UpdateFabricLabel(UpdateFabricLabelRequest): NOCResponse = 9; + /** This command is used by Administrative Nodes to remove a given fabric index and delete all associated fabric-scoped data. */ + command access(invoke: administer) RemoveFabric(RemoveFabricRequest): NOCResponse = 10; + /** This command SHALL add a Trusted Root CA Certificate, provided as its CHIP Certificate representation. */ + command access(invoke: administer) AddTrustedRootCertificate(AddTrustedRootCertificateRequest): DefaultSuccess = 11; +} + +/** The Group Key Management Cluster is the mechanism by which group keys are managed. */ +cluster GroupKeyManagement = 63 { + revision 1; // NOTE: Default/not specifically set + + enum GroupKeySecurityPolicyEnum : enum8 { + kTrustFirst = 0; + kCacheAndSync = 1; + } + + bitmap Feature : bitmap32 { + kCacheAndSync = 0x1; + } + + fabric_scoped struct GroupInfoMapStruct { + group_id groupId = 1; + endpoint_no endpoints[] = 2; + optional char_string<16> groupName = 3; + fabric_idx fabricIndex = 254; + } + + fabric_scoped struct GroupKeyMapStruct { + group_id groupId = 1; + int16u groupKeySetID = 2; + fabric_idx fabricIndex = 254; + } + + struct GroupKeySetStruct { + int16u groupKeySetID = 0; + GroupKeySecurityPolicyEnum groupKeySecurityPolicy = 1; + nullable octet_string<16> epochKey0 = 2; + nullable epoch_us epochStartTime0 = 3; + nullable octet_string<16> epochKey1 = 4; + nullable epoch_us epochStartTime1 = 5; + nullable octet_string<16> epochKey2 = 6; + nullable epoch_us epochStartTime2 = 7; + } + + attribute access(write: manage) GroupKeyMapStruct groupKeyMap[] = 0; + readonly attribute GroupInfoMapStruct groupTable[] = 1; + readonly attribute int16u maxGroupsPerFabric = 2; + readonly attribute int16u maxGroupKeysPerFabric = 3; + readonly attribute command_id generatedCommandList[] = 65528; + readonly attribute command_id acceptedCommandList[] = 65529; + readonly attribute event_id eventList[] = 65530; + readonly attribute attrib_id attributeList[] = 65531; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; + + request struct KeySetWriteRequest { + GroupKeySetStruct groupKeySet = 0; + } + + request struct KeySetReadRequest { + int16u groupKeySetID = 0; + } + + response struct KeySetReadResponse = 2 { + GroupKeySetStruct groupKeySet = 0; + } + + request struct KeySetRemoveRequest { + int16u groupKeySetID = 0; + } + + response struct KeySetReadAllIndicesResponse = 5 { + int16u groupKeySetIDs[] = 0; + } + + /** Write a new set of keys for the given key set id. */ + fabric command access(invoke: administer) KeySetWrite(KeySetWriteRequest): DefaultSuccess = 0; + /** Read the keys for a given key set id. */ + fabric command access(invoke: administer) KeySetRead(KeySetReadRequest): KeySetReadResponse = 1; + /** Revoke a Root Key from a Group */ + fabric command access(invoke: administer) KeySetRemove(KeySetRemoveRequest): DefaultSuccess = 3; + /** Return the list of Group Key Sets associated with the accessing fabric */ + fabric command access(invoke: administer) KeySetReadAllIndices(): KeySetReadAllIndicesResponse = 4; +} + +/** The Fixed Label Cluster provides a feature for the device to tag an endpoint with zero or more read only +labels. */ +cluster FixedLabel = 64 { + revision 1; // NOTE: Default/not specifically set + + struct LabelStruct { + char_string<16> label = 0; + char_string<16> value = 1; + } + + readonly attribute LabelStruct labelList[] = 0; + readonly attribute command_id generatedCommandList[] = 65528; + readonly attribute command_id acceptedCommandList[] = 65529; + readonly attribute event_id eventList[] = 65530; + readonly attribute attrib_id attributeList[] = 65531; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; +} + +/** The User Label Cluster provides a feature to tag an endpoint with zero or more labels. */ +cluster UserLabel = 65 { + revision 1; // NOTE: Default/not specifically set + + struct LabelStruct { + char_string<16> label = 0; + char_string<16> value = 1; + } + + attribute access(write: manage) LabelStruct labelList[] = 0; + readonly attribute command_id generatedCommandList[] = 65528; + readonly attribute command_id acceptedCommandList[] = 65529; + readonly attribute event_id eventList[] = 65530; + readonly attribute attrib_id attributeList[] = 65531; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; +} + +/** Attributes and commands for controlling the color properties of a color-capable light. */ +cluster ColorControl = 768 { + revision 6; + + enum ColorLoopAction : enum8 { + kDeactivate = 0; + kActivateFromColorLoopStartEnhancedHue = 1; + kActivateFromEnhancedCurrentHue = 2; + } + + enum ColorLoopDirection : enum8 { + kDecrementHue = 0; + kIncrementHue = 1; + } + + enum ColorMode : enum8 { + kCurrentHueAndCurrentSaturation = 0; + kCurrentXAndCurrentY = 1; + kColorTemperature = 2; + } + + enum HueDirection : enum8 { + kShortestDistance = 0; + kLongestDistance = 1; + kUp = 2; + kDown = 3; + } + + enum HueMoveMode : enum8 { + kStop = 0; + kUp = 1; + kDown = 3; + } + + enum HueStepMode : enum8 { + kUp = 1; + kDown = 3; + } + + enum SaturationMoveMode : enum8 { + kStop = 0; + kUp = 1; + kDown = 3; + } + + enum SaturationStepMode : enum8 { + kUp = 1; + kDown = 3; + } + + bitmap ColorCapabilities : bitmap16 { + kHueSaturationSupported = 0x1; + kEnhancedHueSupported = 0x2; + kColorLoopSupported = 0x4; + kXYAttributesSupported = 0x8; + kColorTemperatureSupported = 0x10; + } + + bitmap ColorLoopUpdateFlags : bitmap8 { + kUpdateAction = 0x1; + kUpdateDirection = 0x2; + kUpdateTime = 0x4; + kUpdateStartHue = 0x8; + } + + bitmap Feature : bitmap32 { + kHueAndSaturation = 0x1; + kEnhancedHue = 0x2; + kColorLoop = 0x4; + kXY = 0x8; + kColorTemperature = 0x10; + } + + readonly attribute optional int8u currentHue = 0; + readonly attribute optional int8u currentSaturation = 1; + readonly attribute optional int16u remainingTime = 2; + readonly attribute optional int16u currentX = 3; + readonly attribute optional int16u currentY = 4; + readonly attribute optional enum8 driftCompensation = 5; + readonly attribute optional char_string<254> compensationText = 6; + readonly attribute optional int16u colorTemperatureMireds = 7; + readonly attribute enum8 colorMode = 8; + attribute bitmap8 options = 15; + readonly attribute nullable int8u numberOfPrimaries = 16; + readonly attribute optional int16u primary1X = 17; + readonly attribute optional int16u primary1Y = 18; + readonly attribute optional nullable int8u primary1Intensity = 19; + readonly attribute optional int16u primary2X = 21; + readonly attribute optional int16u primary2Y = 22; + readonly attribute optional nullable int8u primary2Intensity = 23; + readonly attribute optional int16u primary3X = 25; + readonly attribute optional int16u primary3Y = 26; + readonly attribute optional nullable int8u primary3Intensity = 27; + readonly attribute optional int16u primary4X = 32; + readonly attribute optional int16u primary4Y = 33; + readonly attribute optional nullable int8u primary4Intensity = 34; + readonly attribute optional int16u primary5X = 36; + readonly attribute optional int16u primary5Y = 37; + readonly attribute optional nullable int8u primary5Intensity = 38; + readonly attribute optional int16u primary6X = 40; + readonly attribute optional int16u primary6Y = 41; + readonly attribute optional nullable int8u primary6Intensity = 42; + attribute access(write: manage) optional int16u whitePointX = 48; + attribute access(write: manage) optional int16u whitePointY = 49; + attribute access(write: manage) optional int16u colorPointRX = 50; + attribute access(write: manage) optional int16u colorPointRY = 51; + attribute access(write: manage) optional nullable int8u colorPointRIntensity = 52; + attribute access(write: manage) optional int16u colorPointGX = 54; + attribute access(write: manage) optional int16u colorPointGY = 55; + attribute access(write: manage) optional nullable int8u colorPointGIntensity = 56; + attribute access(write: manage) optional int16u colorPointBX = 58; + attribute access(write: manage) optional int16u colorPointBY = 59; + attribute access(write: manage) optional nullable int8u colorPointBIntensity = 60; + readonly attribute optional int16u enhancedCurrentHue = 16384; + readonly attribute enum8 enhancedColorMode = 16385; + readonly attribute optional int8u colorLoopActive = 16386; + readonly attribute optional int8u colorLoopDirection = 16387; + readonly attribute optional int16u colorLoopTime = 16388; + readonly attribute optional int16u colorLoopStartEnhancedHue = 16389; + readonly attribute optional int16u colorLoopStoredEnhancedHue = 16390; + readonly attribute bitmap16 colorCapabilities = 16394; + readonly attribute optional int16u colorTempPhysicalMinMireds = 16395; + readonly attribute optional int16u colorTempPhysicalMaxMireds = 16396; + readonly attribute optional int16u coupleColorTempToLevelMinMireds = 16397; + attribute access(write: manage) optional nullable int16u startUpColorTemperatureMireds = 16400; + readonly attribute command_id generatedCommandList[] = 65528; + readonly attribute command_id acceptedCommandList[] = 65529; + readonly attribute event_id eventList[] = 65530; + readonly attribute attrib_id attributeList[] = 65531; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; + + request struct MoveToHueRequest { + int8u hue = 0; + HueDirection direction = 1; + int16u transitionTime = 2; + bitmap8 optionsMask = 3; + bitmap8 optionsOverride = 4; + } + + request struct MoveHueRequest { + HueMoveMode moveMode = 0; + int8u rate = 1; + bitmap8 optionsMask = 2; + bitmap8 optionsOverride = 3; + } + + request struct StepHueRequest { + HueStepMode stepMode = 0; + int8u stepSize = 1; + int8u transitionTime = 2; + bitmap8 optionsMask = 3; + bitmap8 optionsOverride = 4; + } + + request struct MoveToSaturationRequest { + int8u saturation = 0; + int16u transitionTime = 1; + bitmap8 optionsMask = 2; + bitmap8 optionsOverride = 3; + } + + request struct MoveSaturationRequest { + SaturationMoveMode moveMode = 0; + int8u rate = 1; + bitmap8 optionsMask = 2; + bitmap8 optionsOverride = 3; + } + + request struct StepSaturationRequest { + SaturationStepMode stepMode = 0; + int8u stepSize = 1; + int8u transitionTime = 2; + bitmap8 optionsMask = 3; + bitmap8 optionsOverride = 4; + } + + request struct MoveToHueAndSaturationRequest { + int8u hue = 0; + int8u saturation = 1; + int16u transitionTime = 2; + bitmap8 optionsMask = 3; + bitmap8 optionsOverride = 4; + } + + request struct MoveToColorRequest { + int16u colorX = 0; + int16u colorY = 1; + int16u transitionTime = 2; + bitmap8 optionsMask = 3; + bitmap8 optionsOverride = 4; + } + + request struct MoveColorRequest { + int16s rateX = 0; + int16s rateY = 1; + bitmap8 optionsMask = 2; + bitmap8 optionsOverride = 3; + } + + request struct StepColorRequest { + int16s stepX = 0; + int16s stepY = 1; + int16u transitionTime = 2; + bitmap8 optionsMask = 3; + bitmap8 optionsOverride = 4; + } + + request struct MoveToColorTemperatureRequest { + int16u colorTemperatureMireds = 0; + int16u transitionTime = 1; + bitmap8 optionsMask = 2; + bitmap8 optionsOverride = 3; + } + + request struct EnhancedMoveToHueRequest { + int16u enhancedHue = 0; + HueDirection direction = 1; + int16u transitionTime = 2; + bitmap8 optionsMask = 3; + bitmap8 optionsOverride = 4; + } + + request struct EnhancedMoveHueRequest { + HueMoveMode moveMode = 0; + int16u rate = 1; + bitmap8 optionsMask = 2; + bitmap8 optionsOverride = 3; + } + + request struct EnhancedStepHueRequest { + HueStepMode stepMode = 0; + int16u stepSize = 1; + int16u transitionTime = 2; + bitmap8 optionsMask = 3; + bitmap8 optionsOverride = 4; + } + + request struct EnhancedMoveToHueAndSaturationRequest { + int16u enhancedHue = 0; + int8u saturation = 1; + int16u transitionTime = 2; + bitmap8 optionsMask = 3; + bitmap8 optionsOverride = 4; + } + + request struct ColorLoopSetRequest { + ColorLoopUpdateFlags updateFlags = 0; + ColorLoopAction action = 1; + ColorLoopDirection direction = 2; + int16u time = 3; + int16u startHue = 4; + bitmap8 optionsMask = 5; + bitmap8 optionsOverride = 6; + } + + request struct StopMoveStepRequest { + bitmap8 optionsMask = 0; + bitmap8 optionsOverride = 1; + } + + request struct MoveColorTemperatureRequest { + HueMoveMode moveMode = 0; + int16u rate = 1; + int16u colorTemperatureMinimumMireds = 2; + int16u colorTemperatureMaximumMireds = 3; + bitmap8 optionsMask = 4; + bitmap8 optionsOverride = 5; + } + + request struct StepColorTemperatureRequest { + HueStepMode stepMode = 0; + int16u stepSize = 1; + int16u transitionTime = 2; + int16u colorTemperatureMinimumMireds = 3; + int16u colorTemperatureMaximumMireds = 4; + bitmap8 optionsMask = 5; + bitmap8 optionsOverride = 6; + } + + /** Move to specified hue. */ + command MoveToHue(MoveToHueRequest): DefaultSuccess = 0; + /** Move hue up or down at specified rate. */ + command MoveHue(MoveHueRequest): DefaultSuccess = 1; + /** Step hue up or down by specified size at specified rate. */ + command StepHue(StepHueRequest): DefaultSuccess = 2; + /** Move to specified saturation. */ + command MoveToSaturation(MoveToSaturationRequest): DefaultSuccess = 3; + /** Move saturation up or down at specified rate. */ + command MoveSaturation(MoveSaturationRequest): DefaultSuccess = 4; + /** Step saturation up or down by specified size at specified rate. */ + command StepSaturation(StepSaturationRequest): DefaultSuccess = 5; + /** Move to hue and saturation. */ + command MoveToHueAndSaturation(MoveToHueAndSaturationRequest): DefaultSuccess = 6; + /** Move to specified color. */ + command MoveToColor(MoveToColorRequest): DefaultSuccess = 7; + /** Moves the color. */ + command MoveColor(MoveColorRequest): DefaultSuccess = 8; + /** Steps the lighting to a specific color. */ + command StepColor(StepColorRequest): DefaultSuccess = 9; + /** Move to a specific color temperature. */ + command MoveToColorTemperature(MoveToColorTemperatureRequest): DefaultSuccess = 10; + /** Command description for EnhancedMoveToHue */ + command EnhancedMoveToHue(EnhancedMoveToHueRequest): DefaultSuccess = 64; + /** Command description for EnhancedMoveHue */ + command EnhancedMoveHue(EnhancedMoveHueRequest): DefaultSuccess = 65; + /** Command description for EnhancedStepHue */ + command EnhancedStepHue(EnhancedStepHueRequest): DefaultSuccess = 66; + /** Command description for EnhancedMoveToHueAndSaturation */ + command EnhancedMoveToHueAndSaturation(EnhancedMoveToHueAndSaturationRequest): DefaultSuccess = 67; + /** Command description for ColorLoopSet */ + command ColorLoopSet(ColorLoopSetRequest): DefaultSuccess = 68; + /** Command description for StopMoveStep */ + command StopMoveStep(StopMoveStepRequest): DefaultSuccess = 71; + /** Command description for MoveColorTemperature */ + command MoveColorTemperature(MoveColorTemperatureRequest): DefaultSuccess = 75; + /** Command description for StepColorTemperature */ + command StepColorTemperature(StepColorTemperatureRequest): DefaultSuccess = 76; +} + +endpoint 0 { + device type ma_rootdevice = 22, version 1; + + binding cluster OtaSoftwareUpdateProvider; + + server cluster AccessControl { + emits event AccessControlEntryChanged; + emits event AccessControlExtensionChanged; + callback attribute acl; + callback attribute extension; + callback attribute subjectsPerAccessControlEntry; + callback attribute targetsPerAccessControlEntry; + callback attribute accessControlEntriesPerFabric; + callback attribute attributeList; + ram attribute featureMap default = 0; + callback attribute clusterRevision; + } + + server cluster BasicInformation { + emits event StartUp; + emits event ShutDown; + emits event Leave; + callback attribute dataModelRevision; + callback attribute vendorName; + callback attribute vendorID; + callback attribute productName; + callback attribute productID; + persist attribute nodeLabel; + callback attribute location; + callback attribute hardwareVersion; + callback attribute hardwareVersionString; + callback attribute softwareVersion; + callback attribute softwareVersionString; + callback attribute manufacturingDate; + callback attribute partNumber; + callback attribute productURL; + callback attribute productLabel; + callback attribute serialNumber; + persist attribute localConfigDisabled default = 0; + callback attribute uniqueID; + callback attribute capabilityMinima; + callback attribute specificationVersion; + callback attribute maxPathsPerInvoke; + ram attribute featureMap default = 0; + ram attribute clusterRevision default = 3; + } + + server cluster OtaSoftwareUpdateRequestor { + emits event StateTransition; + emits event VersionApplied; + emits event DownloadError; + callback attribute defaultOTAProviders; + ram attribute updatePossible default = 1; + ram attribute updateState default = 0; + ram attribute updateStateProgress default = 0; + ram attribute featureMap default = 0; + ram attribute clusterRevision default = 1; + + handle command AnnounceOTAProvider; + } + + server cluster LocalizationConfiguration { + persist attribute activeLocale default = "en-US"; + callback attribute supportedLocales; + ram attribute featureMap default = 0; + ram attribute clusterRevision default = 1; + } + + server cluster TimeFormatLocalization { + persist attribute hourFormat default = 0; + persist attribute activeCalendarType default = 0; + callback attribute supportedCalendarTypes; + ram attribute featureMap default = 0; + ram attribute clusterRevision default = 1; + } + + server cluster GeneralCommissioning { + ram attribute breadcrumb default = 0x0000000000000000; + callback attribute basicCommissioningInfo; + callback attribute regulatoryConfig; + callback attribute locationCapability; + callback attribute supportsConcurrentConnection; + ram attribute featureMap default = 0; + ram attribute clusterRevision default = 1; + + handle command ArmFailSafe; + handle command ArmFailSafeResponse; + handle command SetRegulatoryConfig; + handle command SetRegulatoryConfigResponse; + handle command CommissioningComplete; + handle command CommissioningCompleteResponse; + } + + server cluster NetworkCommissioning { + ram attribute maxNetworks; + callback attribute networks; + ram attribute scanMaxTimeSeconds; + ram attribute connectMaxTimeSeconds; + ram attribute interfaceEnabled; + ram attribute lastNetworkingStatus; + ram attribute lastNetworkID; + ram attribute lastConnectErrorValue; + ram attribute featureMap default = 1; + ram attribute clusterRevision default = 1; + + handle command ScanNetworks; + handle command ScanNetworksResponse; + handle command AddOrUpdateWiFiNetwork; + handle command AddOrUpdateThreadNetwork; + handle command RemoveNetwork; + handle command NetworkConfigResponse; + handle command ConnectNetwork; + handle command ConnectNetworkResponse; + handle command ReorderNetwork; + } + + server cluster DiagnosticLogs { + ram attribute featureMap default = 0; + ram attribute clusterRevision default = 1; + + handle command RetrieveLogsRequest; + } + + server cluster GeneralDiagnostics { + emits event HardwareFaultChange; + emits event RadioFaultChange; + emits event NetworkFaultChange; + emits event BootReason; + callback attribute networkInterfaces; + callback attribute rebootCount; + callback attribute upTime; + callback attribute totalOperationalHours; + callback attribute bootReason; + callback attribute activeHardwareFaults; + callback attribute activeRadioFaults; + callback attribute activeNetworkFaults; + callback attribute testEventTriggersEnabled default = false; + callback attribute featureMap; + callback attribute clusterRevision; + + handle command TestEventTrigger; + handle command TimeSnapshot; + handle command TimeSnapshotResponse; + } + + server cluster SoftwareDiagnostics { + callback attribute currentHeapFree; + callback attribute currentHeapUsed; + callback attribute currentHeapHighWatermark; + callback attribute featureMap; + ram attribute clusterRevision default = 1; + + handle command ResetWatermarks; + } + + server cluster EthernetNetworkDiagnostics { + callback attribute PHYRate; + callback attribute fullDuplex; + callback attribute packetRxCount; + callback attribute packetTxCount; + callback attribute txErrCount; + callback attribute collisionCount; + callback attribute overrunCount; + callback attribute carrierDetect; + callback attribute timeSinceReset; + ram attribute featureMap default = 3; + ram attribute clusterRevision default = 1; + + handle command ResetCounts; + } + + server cluster AdministratorCommissioning { + callback attribute windowStatus; + callback attribute adminFabricIndex; + callback attribute adminVendorId; + ram attribute featureMap default = 0; + ram attribute clusterRevision default = 1; + + handle command OpenCommissioningWindow; + handle command OpenBasicCommissioningWindow; + handle command RevokeCommissioning; + } + + server cluster OperationalCredentials { + callback attribute NOCs; + callback attribute fabrics; + callback attribute supportedFabrics; + callback attribute commissionedFabrics; + callback attribute trustedRootCertificates; + callback attribute currentFabricIndex; + ram attribute featureMap default = 0; + ram attribute clusterRevision default = 1; + + handle command AttestationRequest; + handle command AttestationResponse; + handle command CertificateChainRequest; + handle command CertificateChainResponse; + handle command CSRRequest; + handle command CSRResponse; + handle command AddNOC; + handle command UpdateNOC; + handle command NOCResponse; + handle command UpdateFabricLabel; + handle command RemoveFabric; + handle command AddTrustedRootCertificate; + } + + server cluster GroupKeyManagement { + callback attribute groupKeyMap; + callback attribute groupTable; + callback attribute maxGroupsPerFabric; + callback attribute maxGroupKeysPerFabric; + callback attribute featureMap; + callback attribute clusterRevision; + + handle command KeySetWrite; + handle command KeySetRead; + handle command KeySetReadResponse; + handle command KeySetRemove; + handle command KeySetReadAllIndices; + handle command KeySetReadAllIndicesResponse; + } + + server cluster FixedLabel { + callback attribute labelList; + ram attribute featureMap default = 0; + ram attribute clusterRevision default = 1; + } + + server cluster UserLabel { + callback attribute labelList; + ram attribute featureMap default = 0; + ram attribute clusterRevision default = 1; + } +} +endpoint 1 { + device type ma_extendedcolorlight = 269, version 1; + + + server cluster Identify { + ram attribute identifyTime default = 0x0000; + ram attribute identifyType default = 0x0; + ram attribute featureMap default = 0; + ram attribute clusterRevision default = 4; + + handle command Identify; + handle command TriggerEffect; + } + + server cluster Groups { + ram attribute nameSupport; + ram attribute featureMap default = 0; + ram attribute clusterRevision default = 4; + + handle command AddGroup; + handle command AddGroupResponse; + handle command ViewGroup; + handle command ViewGroupResponse; + handle command GetGroupMembership; + handle command GetGroupMembershipResponse; + handle command RemoveGroup; + handle command RemoveGroupResponse; + handle command RemoveAllGroups; + handle command AddGroupIfIdentifying; + } + + server cluster OnOff { + persist attribute onOff default = 0x1; + ram attribute globalSceneControl default = 0x01; + ram attribute onTime default = 0x0000; + ram attribute offWaitTime default = 0x0000; + persist attribute startUpOnOff; + ram attribute featureMap default = 1; + ram attribute clusterRevision default = 5; + + handle command Off; + handle command On; + handle command Toggle; + handle command OffWithEffect; + handle command OnWithRecallGlobalScene; + handle command OnWithTimedOff; + } + + server cluster LevelControl { + persist attribute currentLevel default = 0x254; + ram attribute remainingTime default = 0x0000; + ram attribute minLevel default = 0x01; + ram attribute maxLevel default = 0xFE; + ram attribute currentFrequency default = 0x0000; + ram attribute minFrequency default = 0x0000; + ram attribute maxFrequency default = 0x0000; + ram attribute options default = 0x00; + ram attribute onOffTransitionTime default = 0x0000; + ram attribute onLevel; + ram attribute onTransitionTime; + ram attribute offTransitionTime; + ram attribute defaultMoveRate default = 50; + persist attribute startUpCurrentLevel; + ram attribute featureMap default = 3; + ram attribute clusterRevision default = 5; + + handle command MoveToLevel; + handle command Move; + handle command Step; + handle command Stop; + handle command MoveToLevelWithOnOff; + handle command MoveWithOnOff; + handle command StepWithOnOff; + handle command StopWithOnOff; + } + + server cluster Descriptor { + callback attribute deviceTypeList; + callback attribute serverList; + callback attribute clientList; + callback attribute partsList; + callback attribute featureMap; + callback attribute clusterRevision; + } + + server cluster ColorControl { + ram attribute currentHue default = 0x00; + ram attribute currentSaturation default = 0x00; + ram attribute remainingTime default = 0x0000; + ram attribute currentX default = 0x616B; + ram attribute currentY default = 0x607D; + ram attribute colorTemperatureMireds default = 0x00FA; + ram attribute colorMode default = 0x01; + ram attribute options default = 0x00; + ram attribute numberOfPrimaries; + ram attribute primary1X; + ram attribute primary1Y; + ram attribute primary1Intensity; + ram attribute primary2X; + ram attribute primary2Y; + ram attribute primary2Intensity; + ram attribute primary3X; + ram attribute primary3Y; + ram attribute primary3Intensity; + ram attribute primary4X; + ram attribute primary4Y; + ram attribute primary4Intensity; + ram attribute primary5X; + ram attribute primary5Y; + ram attribute primary5Intensity; + ram attribute primary6X; + ram attribute primary6Y; + ram attribute primary6Intensity; + ram attribute enhancedCurrentHue default = 0x0000; + ram attribute enhancedColorMode default = 0x01; + ram attribute colorLoopActive default = 0x00; + ram attribute colorLoopDirection default = 0x00; + ram attribute colorLoopTime default = 0x0019; + ram attribute colorLoopStartEnhancedHue default = 0x2300; + ram attribute colorLoopStoredEnhancedHue default = 0x0000; + ram attribute colorCapabilities default = 0x1F; + ram attribute colorTempPhysicalMinMireds default = 0x0000; + ram attribute colorTempPhysicalMaxMireds default = 0xFEFF; + ram attribute coupleColorTempToLevelMinMireds; + ram attribute startUpColorTemperatureMireds; + ram attribute featureMap default = 0x1F; + ram attribute clusterRevision default = 6; + + handle command MoveToHue; + handle command MoveHue; + handle command StepHue; + handle command MoveToSaturation; + handle command MoveSaturation; + handle command StepSaturation; + handle command MoveToHueAndSaturation; + handle command MoveToColor; + handle command MoveColor; + handle command StepColor; + handle command MoveToColorTemperature; + handle command EnhancedMoveToHue; + handle command EnhancedMoveHue; + handle command EnhancedStepHue; + handle command EnhancedMoveToHueAndSaturation; + handle command ColorLoopSet; + handle command StopMoveStep; + handle command MoveColorTemperature; + handle command StepColorTemperature; + } +} + + diff --git a/examples/lighting-app/qcc74x/data_model/lighting-app-ethernet.zap b/examples/lighting-app/qcc74x/data_model/lighting-app-ethernet.zap new file mode 100644 index 00000000000000..d8848ce3f5234d --- /dev/null +++ b/examples/lighting-app/qcc74x/data_model/lighting-app-ethernet.zap @@ -0,0 +1,4329 @@ +{ + "fileFormat": 2, + "featureLevel": 99, + "creator": "zap", + "keyValuePairs": [ + { + "key": "commandDiscovery", + "value": "1" + }, + { + "key": "defaultResponsePolicy", + "value": "always" + }, + { + "key": "manufacturerCodes", + "value": "0x1002" + } + ], + "package": [ + { + "pathRelativity": "relativeToZap", + "path": "../../../../src/app/zap-templates/zcl/zcl.json", + "type": "zcl-properties", + "category": "matter", + "version": 1, + "description": "Matter SDK ZCL data" + }, + { + "pathRelativity": "relativeToZap", + "path": "../../../../src/app/zap-templates/app-templates.json", + "type": "gen-templates-json", + "version": "chip-v1" + } + ], + "endpointTypes": [ + { + "id": 1, + "name": "MA-rootdevice", + "deviceTypeRef": { + "code": 22, + "profileId": 259, + "label": "MA-rootdevice", + "name": "MA-rootdevice" + }, + "deviceTypes": [ + { + "code": 22, + "profileId": 259, + "label": "MA-rootdevice", + "name": "MA-rootdevice" + } + ], + "deviceVersions": [ + 1 + ], + "deviceIdentifiers": [ + 22 + ], + "deviceTypeName": "MA-rootdevice", + "deviceTypeCode": 22, + "deviceTypeProfileId": 259, + "clusters": [ + { + "name": "Access Control", + "code": 31, + "mfgCode": null, + "define": "ACCESS_CONTROL_CLUSTER", + "side": "server", + "enabled": 1, + "attributes": [ + { + "name": "ACL", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "Extension", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "SubjectsPerAccessControlEntry", + "code": 2, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "TargetsPerAccessControlEntry", + "code": 3, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AccessControlEntriesPerFabric", + "code": 4, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AttributeList", + "code": 65531, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + } + ], + "events": [ + { + "name": "AccessControlEntryChanged", + "code": 0, + "mfgCode": null, + "side": "server", + "included": 1 + }, + { + "name": "AccessControlExtensionChanged", + "code": 1, + "mfgCode": null, + "side": "server", + "included": 1 + } + ] + }, + { + "name": "Basic Information", + "code": 40, + "mfgCode": null, + "define": "BASIC_INFORMATION_CLUSTER", + "side": "server", + "enabled": 1, + "attributes": [ + { + "name": "DataModelRevision", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "External", + "singleton": 1, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "VendorName", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "char_string", + "included": 1, + "storageOption": "External", + "singleton": 1, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "VendorID", + "code": 2, + "mfgCode": null, + "side": "server", + "type": "vendor_id", + "included": 1, + "storageOption": "External", + "singleton": 1, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ProductName", + "code": 3, + "mfgCode": null, + "side": "server", + "type": "char_string", + "included": 1, + "storageOption": "External", + "singleton": 1, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ProductID", + "code": 4, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "External", + "singleton": 1, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "NodeLabel", + "code": 5, + "mfgCode": null, + "side": "server", + "type": "char_string", + "included": 1, + "storageOption": "NVM", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "Location", + "code": 6, + "mfgCode": null, + "side": "server", + "type": "char_string", + "included": 1, + "storageOption": "External", + "singleton": 1, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "HardwareVersion", + "code": 7, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "External", + "singleton": 1, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "HardwareVersionString", + "code": 8, + "mfgCode": null, + "side": "server", + "type": "char_string", + "included": 1, + "storageOption": "External", + "singleton": 1, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "SoftwareVersion", + "code": 9, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 1, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "SoftwareVersionString", + "code": 10, + "mfgCode": null, + "side": "server", + "type": "char_string", + "included": 1, + "storageOption": "External", + "singleton": 1, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ManufacturingDate", + "code": 11, + "mfgCode": null, + "side": "server", + "type": "char_string", + "included": 1, + "storageOption": "External", + "singleton": 1, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "PartNumber", + "code": 12, + "mfgCode": null, + "side": "server", + "type": "char_string", + "included": 1, + "storageOption": "External", + "singleton": 1, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ProductURL", + "code": 13, + "mfgCode": null, + "side": "server", + "type": "long_char_string", + "included": 1, + "storageOption": "External", + "singleton": 1, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ProductLabel", + "code": 14, + "mfgCode": null, + "side": "server", + "type": "char_string", + "included": 1, + "storageOption": "External", + "singleton": 1, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "SerialNumber", + "code": 15, + "mfgCode": null, + "side": "server", + "type": "char_string", + "included": 1, + "storageOption": "External", + "singleton": 1, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "LocalConfigDisabled", + "code": 16, + "mfgCode": null, + "side": "server", + "type": "boolean", + "included": 1, + "storageOption": "NVM", + "singleton": 1, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "UniqueID", + "code": 18, + "mfgCode": null, + "side": "server", + "type": "char_string", + "included": 1, + "storageOption": "External", + "singleton": 1, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "CapabilityMinima", + "code": 19, + "mfgCode": null, + "side": "server", + "type": "CapabilityMinimaStruct", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "SpecificationVersion", + "code": 21, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 1, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "MaxPathsPerInvoke", + "code": 22, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "External", + "singleton": 1, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "3", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ], + "events": [ + { + "name": "StartUp", + "code": 0, + "mfgCode": null, + "side": "server", + "included": 1 + }, + { + "name": "ShutDown", + "code": 1, + "mfgCode": null, + "side": "server", + "included": 1 + }, + { + "name": "Leave", + "code": 2, + "mfgCode": null, + "side": "server", + "included": 1 + } + ] + }, + { + "name": "OTA Software Update Provider", + "code": 41, + "mfgCode": null, + "define": "OTA_SOFTWARE_UPDATE_PROVIDER_CLUSTER", + "side": "client", + "enabled": 1, + "commands": [ + { + "name": "QueryImage", + "code": 0, + "mfgCode": null, + "source": "client", + "isIncoming": 0, + "isEnabled": 1 + }, + { + "name": "QueryImageResponse", + "code": 1, + "mfgCode": null, + "source": "server", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "ApplyUpdateRequest", + "code": 2, + "mfgCode": null, + "source": "client", + "isIncoming": 0, + "isEnabled": 1 + }, + { + "name": "ApplyUpdateResponse", + "code": 3, + "mfgCode": null, + "source": "server", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "NotifyUpdateApplied", + "code": 4, + "mfgCode": null, + "source": "client", + "isIncoming": 0, + "isEnabled": 1 + } + ], + "attributes": [ + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "client", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "OTA Software Update Requestor", + "code": 42, + "mfgCode": null, + "define": "OTA_SOFTWARE_UPDATE_REQUESTOR_CLUSTER", + "side": "server", + "enabled": 1, + "commands": [ + { + "name": "AnnounceOTAProvider", + "code": 0, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + } + ], + "attributes": [ + { + "name": "DefaultOTAProviders", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "UpdatePossible", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "boolean", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "UpdateState", + "code": 2, + "mfgCode": null, + "side": "server", + "type": "UpdateStateEnum", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "UpdateStateProgress", + "code": 3, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ], + "events": [ + { + "name": "StateTransition", + "code": 0, + "mfgCode": null, + "side": "server", + "included": 1 + }, + { + "name": "VersionApplied", + "code": 1, + "mfgCode": null, + "side": "server", + "included": 1 + }, + { + "name": "DownloadError", + "code": 2, + "mfgCode": null, + "side": "server", + "included": 1 + } + ] + }, + { + "name": "Localization Configuration", + "code": 43, + "mfgCode": null, + "define": "LOCALIZATION_CONFIGURATION_CLUSTER", + "side": "server", + "enabled": 1, + "attributes": [ + { + "name": "ActiveLocale", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "char_string", + "included": 1, + "storageOption": "NVM", + "singleton": 0, + "bounded": 0, + "defaultValue": "en-US", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "SupportedLocales", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + } + ] + }, + { + "name": "Time Format Localization", + "code": 44, + "mfgCode": null, + "define": "TIME_FORMAT_LOCALIZATION_CLUSTER", + "side": "server", + "enabled": 1, + "attributes": [ + { + "name": "HourFormat", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "HourFormatEnum", + "included": 1, + "storageOption": "NVM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ActiveCalendarType", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "CalendarTypeEnum", + "included": 1, + "storageOption": "NVM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "SupportedCalendarTypes", + "code": 2, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + } + ] + }, + { + "name": "General Commissioning", + "code": 48, + "mfgCode": null, + "define": "GENERAL_COMMISSIONING_CLUSTER", + "side": "server", + "enabled": 1, + "commands": [ + { + "name": "ArmFailSafe", + "code": 0, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "ArmFailSafeResponse", + "code": 1, + "mfgCode": null, + "source": "server", + "isIncoming": 0, + "isEnabled": 1 + }, + { + "name": "SetRegulatoryConfig", + "code": 2, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "SetRegulatoryConfigResponse", + "code": 3, + "mfgCode": null, + "source": "server", + "isIncoming": 0, + "isEnabled": 1 + }, + { + "name": "CommissioningComplete", + "code": 4, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "CommissioningCompleteResponse", + "code": 5, + "mfgCode": null, + "source": "server", + "isIncoming": 0, + "isEnabled": 1 + } + ], + "attributes": [ + { + "name": "Breadcrumb", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "int64u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000000000000000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "BasicCommissioningInfo", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "BasicCommissioningInfo", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "RegulatoryConfig", + "code": 2, + "mfgCode": null, + "side": "server", + "type": "RegulatoryLocationTypeEnum", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "LocationCapability", + "code": 3, + "mfgCode": null, + "side": "server", + "type": "RegulatoryLocationTypeEnum", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "SupportsConcurrentConnection", + "code": 4, + "mfgCode": null, + "side": "server", + "type": "boolean", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "Network Commissioning", + "code": 49, + "mfgCode": null, + "define": "NETWORK_COMMISSIONING_CLUSTER", + "side": "server", + "enabled": 1, + "commands": [ + { + "name": "ScanNetworks", + "code": 0, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "ScanNetworksResponse", + "code": 1, + "mfgCode": null, + "source": "server", + "isIncoming": 0, + "isEnabled": 1 + }, + { + "name": "AddOrUpdateWiFiNetwork", + "code": 2, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "AddOrUpdateThreadNetwork", + "code": 3, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "RemoveNetwork", + "code": 4, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "NetworkConfigResponse", + "code": 5, + "mfgCode": null, + "source": "server", + "isIncoming": 0, + "isEnabled": 1 + }, + { + "name": "ConnectNetwork", + "code": 6, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "ConnectNetworkResponse", + "code": 7, + "mfgCode": null, + "source": "server", + "isIncoming": 0, + "isEnabled": 1 + }, + { + "name": "ReorderNetwork", + "code": 8, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + } + ], + "attributes": [ + { + "name": "MaxNetworks", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "Networks", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ScanMaxTimeSeconds", + "code": 2, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ConnectMaxTimeSeconds", + "code": 3, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "InterfaceEnabled", + "code": 4, + "mfgCode": null, + "side": "server", + "type": "boolean", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "LastNetworkingStatus", + "code": 5, + "mfgCode": null, + "side": "server", + "type": "NetworkCommissioningStatusEnum", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "LastNetworkID", + "code": 6, + "mfgCode": null, + "side": "server", + "type": "octet_string", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "LastConnectErrorValue", + "code": 7, + "mfgCode": null, + "side": "server", + "type": "int32s", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "Diagnostic Logs", + "code": 50, + "mfgCode": null, + "define": "DIAGNOSTIC_LOGS_CLUSTER", + "side": "server", + "enabled": 1, + "commands": [ + { + "name": "RetrieveLogsRequest", + "code": 0, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + } + ], + "attributes": [ + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + } + ] + }, + { + "name": "General Diagnostics", + "code": 51, + "mfgCode": null, + "define": "GENERAL_DIAGNOSTICS_CLUSTER", + "side": "server", + "enabled": 1, + "commands": [ + { + "name": "TestEventTrigger", + "code": 0, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "TimeSnapshot", + "code": 1, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "TimeSnapshotResponse", + "code": 2, + "mfgCode": null, + "source": "server", + "isIncoming": 0, + "isEnabled": 1 + } + ], + "attributes": [ + { + "name": "NetworkInterfaces", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "RebootCount", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "UpTime", + "code": 2, + "mfgCode": null, + "side": "server", + "type": "int64u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "TotalOperationalHours", + "code": 3, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "BootReason", + "code": 4, + "mfgCode": null, + "side": "server", + "type": "BootReasonEnum", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ActiveHardwareFaults", + "code": 5, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ActiveRadioFaults", + "code": 6, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ActiveNetworkFaults", + "code": 7, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "TestEventTriggersEnabled", + "code": 8, + "mfgCode": null, + "side": "server", + "type": "boolean", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "false", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0002", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ], + "events": [ + { + "name": "HardwareFaultChange", + "code": 0, + "mfgCode": null, + "side": "server", + "included": 1 + }, + { + "name": "RadioFaultChange", + "code": 1, + "mfgCode": null, + "side": "server", + "included": 1 + }, + { + "name": "NetworkFaultChange", + "code": 2, + "mfgCode": null, + "side": "server", + "included": 1 + }, + { + "name": "BootReason", + "code": 3, + "mfgCode": null, + "side": "server", + "included": 1 + } + ] + }, + { + "name": "Software Diagnostics", + "code": 52, + "mfgCode": null, + "define": "SOFTWARE_DIAGNOSTICS_CLUSTER", + "side": "server", + "enabled": 1, + "commands": [ + { + "name": "ResetWatermarks", + "code": 0, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + } + ], + "attributes": [ + { + "name": "CurrentHeapFree", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "int64u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "CurrentHeapUsed", + "code": 2, + "mfgCode": null, + "side": "server", + "type": "int64u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "CurrentHeapHighWatermark", + "code": 3, + "mfgCode": null, + "side": "server", + "type": "int64u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "Ethernet Network Diagnostics", + "code": 55, + "mfgCode": null, + "define": "ETHERNET_NETWORK_DIAGNOSTICS_CLUSTER", + "side": "server", + "enabled": 1, + "commands": [ + { + "name": "ResetCounts", + "code": 0, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + } + ], + "attributes": [ + { + "name": "PHYRate", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "PHYRateEnum", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FullDuplex", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "boolean", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "PacketRxCount", + "code": 2, + "mfgCode": null, + "side": "server", + "type": "int64u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "PacketTxCount", + "code": 3, + "mfgCode": null, + "side": "server", + "type": "int64u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "TxErrCount", + "code": 4, + "mfgCode": null, + "side": "server", + "type": "int64u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "CollisionCount", + "code": 5, + "mfgCode": null, + "side": "server", + "type": "int64u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "OverrunCount", + "code": 6, + "mfgCode": null, + "side": "server", + "type": "int64u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "CarrierDetect", + "code": 7, + "mfgCode": null, + "side": "server", + "type": "boolean", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "TimeSinceReset", + "code": 8, + "mfgCode": null, + "side": "server", + "type": "int64u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "3", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "Administrator Commissioning", + "code": 60, + "mfgCode": null, + "define": "ADMINISTRATOR_COMMISSIONING_CLUSTER", + "side": "server", + "enabled": 1, + "commands": [ + { + "name": "OpenCommissioningWindow", + "code": 0, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "OpenBasicCommissioningWindow", + "code": 1, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "RevokeCommissioning", + "code": 2, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + } + ], + "attributes": [ + { + "name": "WindowStatus", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "CommissioningWindowStatusEnum", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AdminFabricIndex", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "fabric_idx", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AdminVendorId", + "code": 2, + "mfgCode": null, + "side": "server", + "type": "vendor_id", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "Operational Credentials", + "code": 62, + "mfgCode": null, + "define": "OPERATIONAL_CREDENTIALS_CLUSTER", + "side": "server", + "enabled": 1, + "commands": [ + { + "name": "AttestationRequest", + "code": 0, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "AttestationResponse", + "code": 1, + "mfgCode": null, + "source": "server", + "isIncoming": 0, + "isEnabled": 1 + }, + { + "name": "CertificateChainRequest", + "code": 2, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "CertificateChainResponse", + "code": 3, + "mfgCode": null, + "source": "server", + "isIncoming": 0, + "isEnabled": 1 + }, + { + "name": "CSRRequest", + "code": 4, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "CSRResponse", + "code": 5, + "mfgCode": null, + "source": "server", + "isIncoming": 0, + "isEnabled": 1 + }, + { + "name": "AddNOC", + "code": 6, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "UpdateNOC", + "code": 7, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "NOCResponse", + "code": 8, + "mfgCode": null, + "source": "server", + "isIncoming": 0, + "isEnabled": 1 + }, + { + "name": "UpdateFabricLabel", + "code": 9, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "RemoveFabric", + "code": 10, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "AddTrustedRootCertificate", + "code": 11, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + } + ], + "attributes": [ + { + "name": "NOCs", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "Fabrics", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "SupportedFabrics", + "code": 2, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "CommissionedFabrics", + "code": 3, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "TrustedRootCertificates", + "code": 4, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "CurrentFabricIndex", + "code": 5, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "Group Key Management", + "code": 63, + "mfgCode": null, + "define": "GROUP_KEY_MANAGEMENT_CLUSTER", + "side": "server", + "enabled": 1, + "commands": [ + { + "name": "KeySetWrite", + "code": 0, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "KeySetRead", + "code": 1, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "KeySetReadResponse", + "code": 2, + "mfgCode": null, + "source": "server", + "isIncoming": 0, + "isEnabled": 1 + }, + { + "name": "KeySetRemove", + "code": 3, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "KeySetReadAllIndices", + "code": 4, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "KeySetReadAllIndicesResponse", + "code": 5, + "mfgCode": null, + "source": "server", + "isIncoming": 0, + "isEnabled": 1 + } + ], + "attributes": [ + { + "name": "GroupKeyMap", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "GroupTable", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "MaxGroupsPerFabric", + "code": 2, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "MaxGroupKeysPerFabric", + "code": 3, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + } + ] + }, + { + "name": "Fixed Label", + "code": 64, + "mfgCode": null, + "define": "FIXED_LABEL_CLUSTER", + "side": "server", + "enabled": 1, + "attributes": [ + { + "name": "LabelList", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + } + ] + }, + { + "name": "User Label", + "code": 65, + "mfgCode": null, + "define": "USER_LABEL_CLUSTER", + "side": "server", + "enabled": 1, + "attributes": [ + { + "name": "LabelList", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + } + ] + } + ] + }, + { + "id": 2, + "name": "MA-extendedcolorlight", + "deviceTypeRef": { + "code": 269, + "profileId": 259, + "label": "MA-extendedcolorlight", + "name": "MA-extendedcolorlight" + }, + "deviceTypes": [ + { + "code": 269, + "profileId": 259, + "label": "MA-extendedcolorlight", + "name": "MA-extendedcolorlight" + } + ], + "deviceVersions": [ + 1 + ], + "deviceIdentifiers": [ + 269 + ], + "deviceTypeName": "MA-extendedcolorlight", + "deviceTypeCode": 269, + "deviceTypeProfileId": 259, + "clusters": [ + { + "name": "Identify", + "code": 3, + "mfgCode": null, + "define": "IDENTIFY_CLUSTER", + "side": "server", + "enabled": 1, + "commands": [ + { + "name": "Identify", + "code": 0, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "TriggerEffect", + "code": 64, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + } + ], + "attributes": [ + { + "name": "IdentifyTime", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "IdentifyType", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "IdentifyTypeEnum", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "4", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "Groups", + "code": 4, + "mfgCode": null, + "define": "GROUPS_CLUSTER", + "side": "server", + "enabled": 1, + "commands": [ + { + "name": "AddGroup", + "code": 0, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "AddGroupResponse", + "code": 0, + "mfgCode": null, + "source": "server", + "isIncoming": 0, + "isEnabled": 1 + }, + { + "name": "ViewGroup", + "code": 1, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "ViewGroupResponse", + "code": 1, + "mfgCode": null, + "source": "server", + "isIncoming": 0, + "isEnabled": 1 + }, + { + "name": "GetGroupMembership", + "code": 2, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "GetGroupMembershipResponse", + "code": 2, + "mfgCode": null, + "source": "server", + "isIncoming": 0, + "isEnabled": 1 + }, + { + "name": "RemoveGroup", + "code": 3, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "RemoveGroupResponse", + "code": 3, + "mfgCode": null, + "source": "server", + "isIncoming": 0, + "isEnabled": 1 + }, + { + "name": "RemoveAllGroups", + "code": 4, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "AddGroupIfIdentifying", + "code": 5, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + } + ], + "attributes": [ + { + "name": "NameSupport", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "NameSupportBitmap", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "4", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "On/Off", + "code": 6, + "mfgCode": null, + "define": "ON_OFF_CLUSTER", + "side": "server", + "enabled": 1, + "commands": [ + { + "name": "Off", + "code": 0, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "On", + "code": 1, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "Toggle", + "code": 2, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "OffWithEffect", + "code": 64, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "OnWithRecallGlobalScene", + "code": 65, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "OnWithTimedOff", + "code": 66, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + } + ], + "attributes": [ + { + "name": "OnOff", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "boolean", + "included": 1, + "storageOption": "NVM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x1", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "GlobalSceneControl", + "code": 16384, + "mfgCode": null, + "side": "server", + "type": "boolean", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x01", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "OnTime", + "code": 16385, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "OffWaitTime", + "code": 16386, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "StartUpOnOff", + "code": 16387, + "mfgCode": null, + "side": "server", + "type": "StartUpOnOffEnum", + "included": 1, + "storageOption": "NVM", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "5", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "Level Control", + "code": 8, + "mfgCode": null, + "define": "LEVEL_CONTROL_CLUSTER", + "side": "server", + "enabled": 1, + "commands": [ + { + "name": "MoveToLevel", + "code": 0, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "Move", + "code": 1, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "Step", + "code": 2, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "Stop", + "code": 3, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "MoveToLevelWithOnOff", + "code": 4, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "MoveWithOnOff", + "code": 5, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "StepWithOnOff", + "code": 6, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "StopWithOnOff", + "code": 7, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + } + ], + "attributes": [ + { + "name": "CurrentLevel", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "NVM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x254", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "RemainingTime", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "MinLevel", + "code": 2, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x01", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "MaxLevel", + "code": 3, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0xFE", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "CurrentFrequency", + "code": 4, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "MinFrequency", + "code": 5, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "MaxFrequency", + "code": 6, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "Options", + "code": 15, + "mfgCode": null, + "side": "server", + "type": "OptionsBitmap", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x00", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "OnOffTransitionTime", + "code": 16, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "OnLevel", + "code": 17, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "OnTransitionTime", + "code": 18, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "OffTransitionTime", + "code": 19, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "DefaultMoveRate", + "code": 20, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "50", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "StartUpCurrentLevel", + "code": 16384, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "NVM", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "3", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "5", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "Descriptor", + "code": 29, + "mfgCode": null, + "define": "DESCRIPTOR_CLUSTER", + "side": "server", + "enabled": 1, + "attributes": [ + { + "name": "DeviceTypeList", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ServerList", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClientList", + "code": 2, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "PartsList", + "code": 3, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + } + ] + }, + { + "name": "Color Control", + "code": 768, + "mfgCode": null, + "define": "COLOR_CONTROL_CLUSTER", + "side": "server", + "enabled": 1, + "commands": [ + { + "name": "MoveToHue", + "code": 0, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "MoveHue", + "code": 1, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "StepHue", + "code": 2, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "MoveToSaturation", + "code": 3, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "MoveSaturation", + "code": 4, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "StepSaturation", + "code": 5, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "MoveToHueAndSaturation", + "code": 6, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "MoveToColor", + "code": 7, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "MoveColor", + "code": 8, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "StepColor", + "code": 9, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "MoveToColorTemperature", + "code": 10, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "EnhancedMoveToHue", + "code": 64, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "EnhancedMoveHue", + "code": 65, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "EnhancedStepHue", + "code": 66, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "EnhancedMoveToHueAndSaturation", + "code": 67, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "ColorLoopSet", + "code": 68, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "StopMoveStep", + "code": 71, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "MoveColorTemperature", + "code": 75, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "StepColorTemperature", + "code": 76, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + } + ], + "attributes": [ + { + "name": "CurrentHue", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x00", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "CurrentSaturation", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x00", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "RemainingTime", + "code": 2, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "CurrentX", + "code": 3, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x616B", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "CurrentY", + "code": 4, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x607D", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ColorTemperatureMireds", + "code": 7, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x00FA", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ColorMode", + "code": 8, + "mfgCode": null, + "side": "server", + "type": "enum8", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x01", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "Options", + "code": 15, + "mfgCode": null, + "side": "server", + "type": "bitmap8", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x00", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "NumberOfPrimaries", + "code": 16, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "Primary1X", + "code": 17, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "Primary1Y", + "code": 18, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "Primary1Intensity", + "code": 19, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "Primary2X", + "code": 21, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "Primary2Y", + "code": 22, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "Primary2Intensity", + "code": 23, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "Primary3X", + "code": 25, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "Primary3Y", + "code": 26, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "Primary3Intensity", + "code": 27, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "Primary4X", + "code": 32, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "Primary4Y", + "code": 33, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "Primary4Intensity", + "code": 34, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "Primary5X", + "code": 36, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "Primary5Y", + "code": 37, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "Primary5Intensity", + "code": 38, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "Primary6X", + "code": 40, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "Primary6Y", + "code": 41, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "Primary6Intensity", + "code": 42, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "EnhancedCurrentHue", + "code": 16384, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "EnhancedColorMode", + "code": 16385, + "mfgCode": null, + "side": "server", + "type": "enum8", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x01", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ColorLoopActive", + "code": 16386, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x00", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ColorLoopDirection", + "code": 16387, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x00", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ColorLoopTime", + "code": 16388, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0019", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ColorLoopStartEnhancedHue", + "code": 16389, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x2300", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ColorLoopStoredEnhancedHue", + "code": 16390, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ColorCapabilities", + "code": 16394, + "mfgCode": null, + "side": "server", + "type": "bitmap16", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x1F", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ColorTempPhysicalMinMireds", + "code": 16395, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ColorTempPhysicalMaxMireds", + "code": 16396, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0xFEFF", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "CoupleColorTempToLevelMinMireds", + "code": 16397, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "StartUpColorTemperatureMireds", + "code": 16400, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x1F", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "6", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + } + ] + } + ], + "endpoints": [ + { + "endpointTypeName": "MA-rootdevice", + "endpointTypeIndex": 0, + "profileId": 259, + "endpointId": 0, + "networkId": 0 + }, + { + "endpointTypeName": "MA-extendedcolorlight", + "endpointTypeIndex": 1, + "profileId": 259, + "endpointId": 1, + "networkId": 0 + } + ] +} \ No newline at end of file diff --git a/examples/lighting-app/qcc74x/data_model/lighting-app-thread.matter b/examples/lighting-app/qcc74x/data_model/lighting-app-thread.matter new file mode 100644 index 00000000000000..392e08c39bf977 --- /dev/null +++ b/examples/lighting-app/qcc74x/data_model/lighting-app-thread.matter @@ -0,0 +1,2436 @@ +// This IDL was generated automatically by ZAP. +// It is for view/code review purposes only. + +/** Attributes and commands for putting a device into Identification mode (e.g. flashing a light). */ +cluster Identify = 3 { + revision 4; + + enum EffectIdentifierEnum : enum8 { + kBlink = 0; + kBreathe = 1; + kOkay = 2; + kChannelChange = 11; + kFinishEffect = 254; + kStopEffect = 255; + } + + enum EffectVariantEnum : enum8 { + kDefault = 0; + } + + enum IdentifyTypeEnum : enum8 { + kNone = 0; + kLightOutput = 1; + kVisibleIndicator = 2; + kAudibleBeep = 3; + kDisplay = 4; + kActuator = 5; + } + + attribute int16u identifyTime = 0; + readonly attribute IdentifyTypeEnum identifyType = 1; + readonly attribute command_id generatedCommandList[] = 65528; + readonly attribute command_id acceptedCommandList[] = 65529; + readonly attribute event_id eventList[] = 65530; + readonly attribute attrib_id attributeList[] = 65531; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; + + request struct IdentifyRequest { + int16u identifyTime = 0; + } + + request struct TriggerEffectRequest { + EffectIdentifierEnum effectIdentifier = 0; + EffectVariantEnum effectVariant = 1; + } + + /** Command description for Identify */ + command access(invoke: manage) Identify(IdentifyRequest): DefaultSuccess = 0; + /** Command description for TriggerEffect */ + command access(invoke: manage) TriggerEffect(TriggerEffectRequest): DefaultSuccess = 64; +} + +/** Attributes and commands for group configuration and manipulation. */ +cluster Groups = 4 { + revision 4; + + bitmap Feature : bitmap32 { + kGroupNames = 0x1; + } + + bitmap NameSupportBitmap : bitmap8 { + kGroupNames = 0x80; + } + + readonly attribute NameSupportBitmap nameSupport = 0; + readonly attribute command_id generatedCommandList[] = 65528; + readonly attribute command_id acceptedCommandList[] = 65529; + readonly attribute event_id eventList[] = 65530; + readonly attribute attrib_id attributeList[] = 65531; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; + + request struct AddGroupRequest { + group_id groupID = 0; + char_string<16> groupName = 1; + } + + response struct AddGroupResponse = 0 { + enum8 status = 0; + group_id groupID = 1; + } + + request struct ViewGroupRequest { + group_id groupID = 0; + } + + response struct ViewGroupResponse = 1 { + enum8 status = 0; + group_id groupID = 1; + char_string<16> groupName = 2; + } + + request struct GetGroupMembershipRequest { + group_id groupList[] = 0; + } + + response struct GetGroupMembershipResponse = 2 { + nullable int8u capacity = 0; + group_id groupList[] = 1; + } + + request struct RemoveGroupRequest { + group_id groupID = 0; + } + + response struct RemoveGroupResponse = 3 { + enum8 status = 0; + group_id groupID = 1; + } + + request struct AddGroupIfIdentifyingRequest { + group_id groupID = 0; + char_string<16> groupName = 1; + } + + /** Command description for AddGroup */ + fabric command access(invoke: manage) AddGroup(AddGroupRequest): AddGroupResponse = 0; + /** Command description for ViewGroup */ + fabric command ViewGroup(ViewGroupRequest): ViewGroupResponse = 1; + /** Command description for GetGroupMembership */ + fabric command GetGroupMembership(GetGroupMembershipRequest): GetGroupMembershipResponse = 2; + /** Command description for RemoveGroup */ + fabric command access(invoke: manage) RemoveGroup(RemoveGroupRequest): RemoveGroupResponse = 3; + /** Command description for RemoveAllGroups */ + fabric command access(invoke: manage) RemoveAllGroups(): DefaultSuccess = 4; + /** Command description for AddGroupIfIdentifying */ + fabric command access(invoke: manage) AddGroupIfIdentifying(AddGroupIfIdentifyingRequest): DefaultSuccess = 5; +} + +/** Attributes and commands for switching devices between 'On' and 'Off' states. */ +cluster OnOff = 6 { + revision 6; + + enum DelayedAllOffEffectVariantEnum : enum8 { + kDelayedOffFastFade = 0; + kNoFade = 1; + kDelayedOffSlowFade = 2; + } + + enum DyingLightEffectVariantEnum : enum8 { + kDyingLightFadeOff = 0; + } + + enum EffectIdentifierEnum : enum8 { + kDelayedAllOff = 0; + kDyingLight = 1; + } + + enum StartUpOnOffEnum : enum8 { + kOff = 0; + kOn = 1; + kToggle = 2; + } + + bitmap Feature : bitmap32 { + kLighting = 0x1; + kDeadFrontBehavior = 0x2; + kOffOnly = 0x4; + } + + bitmap OnOffControlBitmap : bitmap8 { + kAcceptOnlyWhenOn = 0x1; + } + + readonly attribute boolean onOff = 0; + readonly attribute optional boolean globalSceneControl = 16384; + attribute optional int16u onTime = 16385; + attribute optional int16u offWaitTime = 16386; + attribute access(write: manage) optional nullable StartUpOnOffEnum startUpOnOff = 16387; + readonly attribute command_id generatedCommandList[] = 65528; + readonly attribute command_id acceptedCommandList[] = 65529; + readonly attribute event_id eventList[] = 65530; + readonly attribute attrib_id attributeList[] = 65531; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; + + request struct OffWithEffectRequest { + EffectIdentifierEnum effectIdentifier = 0; + enum8 effectVariant = 1; + } + + request struct OnWithTimedOffRequest { + OnOffControlBitmap onOffControl = 0; + int16u onTime = 1; + int16u offWaitTime = 2; + } + + /** On receipt of this command, a device SHALL enter its ‘Off’ state. This state is device dependent, but it is recommended that it is used for power off or similar functions. On receipt of the Off command, the OnTime attribute SHALL be set to 0. */ + command Off(): DefaultSuccess = 0; + /** On receipt of this command, a device SHALL enter its ‘On’ state. This state is device dependent, but it is recommended that it is used for power on or similar functions. On receipt of the On command, if the value of the OnTime attribute is equal to 0, the device SHALL set the OffWaitTime attribute to 0. */ + command On(): DefaultSuccess = 1; + /** On receipt of this command, if a device is in its ‘Off’ state it SHALL enter its ‘On’ state. Otherwise, if it is in its ‘On’ state it SHALL enter its ‘Off’ state. On receipt of the Toggle command, if the value of the OnOff attribute is equal to FALSE and if the value of the OnTime attribute is equal to 0, the device SHALL set the OffWaitTime attribute to 0. If the value of the OnOff attribute is equal to TRUE, the OnTime attribute SHALL be set to 0. */ + command Toggle(): DefaultSuccess = 2; + /** The OffWithEffect command allows devices to be turned off using enhanced ways of fading. */ + command OffWithEffect(OffWithEffectRequest): DefaultSuccess = 64; + /** The OnWithRecallGlobalScene command allows the recall of the settings when the device was turned off. */ + command OnWithRecallGlobalScene(): DefaultSuccess = 65; + /** The OnWithTimedOff command allows devices to be turned on for a specific duration with a guarded off duration so that SHOULD the device be subsequently switched off, further OnWithTimedOff commands, received during this time, are prevented from turning the devices back on. */ + command OnWithTimedOff(OnWithTimedOffRequest): DefaultSuccess = 66; +} + +/** Attributes and commands for controlling devices that can be set to a level between fully 'On' and fully 'Off.' */ +cluster LevelControl = 8 { + revision 5; + + enum MoveModeEnum : enum8 { + kUp = 0; + kDown = 1; + } + + enum StepModeEnum : enum8 { + kUp = 0; + kDown = 1; + } + + bitmap Feature : bitmap32 { + kOnOff = 0x1; + kLighting = 0x2; + kFrequency = 0x4; + } + + bitmap OptionsBitmap : bitmap8 { + kExecuteIfOff = 0x1; + kCoupleColorTempToLevel = 0x2; + } + + readonly attribute nullable int8u currentLevel = 0; + readonly attribute optional int16u remainingTime = 1; + readonly attribute optional int8u minLevel = 2; + readonly attribute optional int8u maxLevel = 3; + readonly attribute optional int16u currentFrequency = 4; + readonly attribute optional int16u minFrequency = 5; + readonly attribute optional int16u maxFrequency = 6; + attribute OptionsBitmap options = 15; + attribute optional int16u onOffTransitionTime = 16; + attribute nullable int8u onLevel = 17; + attribute optional nullable int16u onTransitionTime = 18; + attribute optional nullable int16u offTransitionTime = 19; + attribute optional nullable int8u defaultMoveRate = 20; + attribute access(write: manage) optional nullable int8u startUpCurrentLevel = 16384; + readonly attribute command_id generatedCommandList[] = 65528; + readonly attribute command_id acceptedCommandList[] = 65529; + readonly attribute event_id eventList[] = 65530; + readonly attribute attrib_id attributeList[] = 65531; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; + + request struct MoveToLevelRequest { + int8u level = 0; + nullable int16u transitionTime = 1; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; + } + + request struct MoveRequest { + MoveModeEnum moveMode = 0; + nullable int8u rate = 1; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; + } + + request struct StepRequest { + StepModeEnum stepMode = 0; + int8u stepSize = 1; + nullable int16u transitionTime = 2; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; + } + + request struct StopRequest { + OptionsBitmap optionsMask = 0; + OptionsBitmap optionsOverride = 1; + } + + request struct MoveToLevelWithOnOffRequest { + int8u level = 0; + nullable int16u transitionTime = 1; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; + } + + request struct MoveWithOnOffRequest { + MoveModeEnum moveMode = 0; + nullable int8u rate = 1; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; + } + + request struct StepWithOnOffRequest { + StepModeEnum stepMode = 0; + int8u stepSize = 1; + nullable int16u transitionTime = 2; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; + } + + request struct StopWithOnOffRequest { + OptionsBitmap optionsMask = 0; + OptionsBitmap optionsOverride = 1; + } + + request struct MoveToClosestFrequencyRequest { + int16u frequency = 0; + } + + /** Command description for MoveToLevel */ + command MoveToLevel(MoveToLevelRequest): DefaultSuccess = 0; + /** Command description for Move */ + command Move(MoveRequest): DefaultSuccess = 1; + /** Command description for Step */ + command Step(StepRequest): DefaultSuccess = 2; + /** Command description for Stop */ + command Stop(StopRequest): DefaultSuccess = 3; + /** Command description for MoveToLevelWithOnOff */ + command MoveToLevelWithOnOff(MoveToLevelWithOnOffRequest): DefaultSuccess = 4; + /** Command description for MoveWithOnOff */ + command MoveWithOnOff(MoveWithOnOffRequest): DefaultSuccess = 5; + /** Command description for StepWithOnOff */ + command StepWithOnOff(StepWithOnOffRequest): DefaultSuccess = 6; + /** Command description for StopWithOnOff */ + command StopWithOnOff(StopWithOnOffRequest): DefaultSuccess = 7; + /** Change the currrent frequency to the provided one, or a close + approximation if the exact provided one is not possible. */ + command MoveToClosestFrequency(MoveToClosestFrequencyRequest): DefaultSuccess = 8; +} + +/** The Descriptor Cluster is meant to replace the support from the Zigbee Device Object (ZDO) for describing a node, its endpoints and clusters. */ +cluster Descriptor = 29 { + revision 2; + + bitmap Feature : bitmap32 { + kTagList = 0x1; + } + + struct DeviceTypeStruct { + devtype_id deviceType = 0; + int16u revision = 1; + } + + struct SemanticTagStruct { + nullable vendor_id mfgCode = 0; + enum8 namespaceID = 1; + enum8 tag = 2; + optional nullable char_string label = 3; + } + + readonly attribute DeviceTypeStruct deviceTypeList[] = 0; + readonly attribute cluster_id serverList[] = 1; + readonly attribute cluster_id clientList[] = 2; + readonly attribute endpoint_no partsList[] = 3; + readonly attribute optional SemanticTagStruct tagList[] = 4; + readonly attribute command_id generatedCommandList[] = 65528; + readonly attribute command_id acceptedCommandList[] = 65529; + readonly attribute event_id eventList[] = 65530; + readonly attribute attrib_id attributeList[] = 65531; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; +} + +/** The Access Control Cluster exposes a data model view of a + Node's Access Control List (ACL), which codifies the rules used to manage + and enforce Access Control for the Node's endpoints and their associated + cluster instances. */ +cluster AccessControl = 31 { + revision 1; // NOTE: Default/not specifically set + + enum AccessControlEntryAuthModeEnum : enum8 { + kPASE = 1; + kCASE = 2; + kGroup = 3; + } + + enum AccessControlEntryPrivilegeEnum : enum8 { + kView = 1; + kProxyView = 2; + kOperate = 3; + kManage = 4; + kAdminister = 5; + } + + enum ChangeTypeEnum : enum8 { + kChanged = 0; + kAdded = 1; + kRemoved = 2; + } + + struct AccessControlTargetStruct { + nullable cluster_id cluster = 0; + nullable endpoint_no endpoint = 1; + nullable devtype_id deviceType = 2; + } + + fabric_scoped struct AccessControlEntryStruct { + fabric_sensitive AccessControlEntryPrivilegeEnum privilege = 1; + fabric_sensitive AccessControlEntryAuthModeEnum authMode = 2; + nullable fabric_sensitive int64u subjects[] = 3; + nullable fabric_sensitive AccessControlTargetStruct targets[] = 4; + fabric_idx fabricIndex = 254; + } + + fabric_scoped struct AccessControlExtensionStruct { + fabric_sensitive octet_string<128> data = 1; + fabric_idx fabricIndex = 254; + } + + fabric_sensitive info event access(read: administer) AccessControlEntryChanged = 0 { + nullable node_id adminNodeID = 1; + nullable int16u adminPasscodeID = 2; + ChangeTypeEnum changeType = 3; + nullable AccessControlEntryStruct latestValue = 4; + fabric_idx fabricIndex = 254; + } + + fabric_sensitive info event access(read: administer) AccessControlExtensionChanged = 1 { + nullable node_id adminNodeID = 1; + nullable int16u adminPasscodeID = 2; + ChangeTypeEnum changeType = 3; + nullable AccessControlExtensionStruct latestValue = 4; + fabric_idx fabricIndex = 254; + } + + attribute access(read: administer, write: administer) AccessControlEntryStruct acl[] = 0; + attribute access(read: administer, write: administer) optional AccessControlExtensionStruct extension[] = 1; + readonly attribute int16u subjectsPerAccessControlEntry = 2; + readonly attribute int16u targetsPerAccessControlEntry = 3; + readonly attribute int16u accessControlEntriesPerFabric = 4; + readonly attribute command_id generatedCommandList[] = 65528; + readonly attribute command_id acceptedCommandList[] = 65529; + readonly attribute event_id eventList[] = 65530; + readonly attribute attrib_id attributeList[] = 65531; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; +} + +/** This cluster provides attributes and events for determining basic information about Nodes, which supports both + Commissioning and operational determination of Node characteristics, such as Vendor ID, Product ID and serial number, + which apply to the whole Node. Also allows setting user device information such as location. */ +cluster BasicInformation = 40 { + revision 3; + + enum ColorEnum : enum8 { + kBlack = 0; + kNavy = 1; + kGreen = 2; + kTeal = 3; + kMaroon = 4; + kPurple = 5; + kOlive = 6; + kGray = 7; + kBlue = 8; + kLime = 9; + kAqua = 10; + kRed = 11; + kFuchsia = 12; + kYellow = 13; + kWhite = 14; + kNickel = 15; + kChrome = 16; + kBrass = 17; + kCopper = 18; + kSilver = 19; + kGold = 20; + } + + enum ProductFinishEnum : enum8 { + kOther = 0; + kMatte = 1; + kSatin = 2; + kPolished = 3; + kRugged = 4; + kFabric = 5; + } + + struct CapabilityMinimaStruct { + int16u caseSessionsPerFabric = 0; + int16u subscriptionsPerFabric = 1; + } + + struct ProductAppearanceStruct { + ProductFinishEnum finish = 0; + nullable ColorEnum primaryColor = 1; + } + + critical event StartUp = 0 { + int32u softwareVersion = 0; + } + + critical event ShutDown = 1 { + } + + info event Leave = 2 { + fabric_idx fabricIndex = 0; + } + + info event ReachableChanged = 3 { + boolean reachableNewValue = 0; + } + + readonly attribute int16u dataModelRevision = 0; + readonly attribute char_string<32> vendorName = 1; + readonly attribute vendor_id vendorID = 2; + readonly attribute char_string<32> productName = 3; + readonly attribute int16u productID = 4; + attribute access(write: manage) char_string<32> nodeLabel = 5; + attribute access(write: administer) char_string<2> location = 6; + readonly attribute int16u hardwareVersion = 7; + readonly attribute char_string<64> hardwareVersionString = 8; + readonly attribute int32u softwareVersion = 9; + readonly attribute char_string<64> softwareVersionString = 10; + readonly attribute optional char_string<16> manufacturingDate = 11; + readonly attribute optional char_string<32> partNumber = 12; + readonly attribute optional long_char_string<256> productURL = 13; + readonly attribute optional char_string<64> productLabel = 14; + readonly attribute optional char_string<32> serialNumber = 15; + attribute access(write: manage) optional boolean localConfigDisabled = 16; + readonly attribute optional boolean reachable = 17; + readonly attribute optional char_string<32> uniqueID = 18; + readonly attribute CapabilityMinimaStruct capabilityMinima = 19; + readonly attribute optional ProductAppearanceStruct productAppearance = 20; + readonly attribute int32u specificationVersion = 21; + readonly attribute int16u maxPathsPerInvoke = 22; + readonly attribute command_id generatedCommandList[] = 65528; + readonly attribute command_id acceptedCommandList[] = 65529; + readonly attribute event_id eventList[] = 65530; + readonly attribute attrib_id attributeList[] = 65531; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; + + command MfgSpecificPing(): DefaultSuccess = 0; +} + +/** Provides an interface for providing OTA software updates */ +cluster OtaSoftwareUpdateProvider = 41 { + revision 1; // NOTE: Default/not specifically set + + enum ApplyUpdateActionEnum : enum8 { + kProceed = 0; + kAwaitNextAction = 1; + kDiscontinue = 2; + } + + enum DownloadProtocolEnum : enum8 { + kBDXSynchronous = 0; + kBDXAsynchronous = 1; + kHTTPS = 2; + kVendorSpecific = 3; + } + + enum StatusEnum : enum8 { + kUpdateAvailable = 0; + kBusy = 1; + kNotAvailable = 2; + kDownloadProtocolNotSupported = 3; + } + + readonly attribute command_id generatedCommandList[] = 65528; + readonly attribute command_id acceptedCommandList[] = 65529; + readonly attribute event_id eventList[] = 65530; + readonly attribute attrib_id attributeList[] = 65531; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; + + request struct QueryImageRequest { + vendor_id vendorID = 0; + int16u productID = 1; + int32u softwareVersion = 2; + DownloadProtocolEnum protocolsSupported[] = 3; + optional int16u hardwareVersion = 4; + optional char_string<2> location = 5; + optional boolean requestorCanConsent = 6; + optional octet_string<512> metadataForProvider = 7; + } + + response struct QueryImageResponse = 1 { + StatusEnum status = 0; + optional int32u delayedActionTime = 1; + optional char_string<256> imageURI = 2; + optional int32u softwareVersion = 3; + optional char_string<64> softwareVersionString = 4; + optional octet_string<32> updateToken = 5; + optional boolean userConsentNeeded = 6; + optional octet_string<512> metadataForRequestor = 7; + } + + request struct ApplyUpdateRequestRequest { + octet_string<32> updateToken = 0; + int32u newVersion = 1; + } + + response struct ApplyUpdateResponse = 3 { + ApplyUpdateActionEnum action = 0; + int32u delayedActionTime = 1; + } + + request struct NotifyUpdateAppliedRequest { + octet_string<32> updateToken = 0; + int32u softwareVersion = 1; + } + + /** Determine availability of a new Software Image */ + command QueryImage(QueryImageRequest): QueryImageResponse = 0; + /** Determine next action to take for a downloaded Software Image */ + command ApplyUpdateRequest(ApplyUpdateRequestRequest): ApplyUpdateResponse = 2; + /** Notify OTA Provider that an update was applied */ + command NotifyUpdateApplied(NotifyUpdateAppliedRequest): DefaultSuccess = 4; +} + +/** Provides an interface for downloading and applying OTA software updates */ +cluster OtaSoftwareUpdateRequestor = 42 { + revision 1; // NOTE: Default/not specifically set + + enum AnnouncementReasonEnum : enum8 { + kSimpleAnnouncement = 0; + kUpdateAvailable = 1; + kUrgentUpdateAvailable = 2; + } + + enum ChangeReasonEnum : enum8 { + kUnknown = 0; + kSuccess = 1; + kFailure = 2; + kTimeOut = 3; + kDelayByProvider = 4; + } + + enum UpdateStateEnum : enum8 { + kUnknown = 0; + kIdle = 1; + kQuerying = 2; + kDelayedOnQuery = 3; + kDownloading = 4; + kApplying = 5; + kDelayedOnApply = 6; + kRollingBack = 7; + kDelayedOnUserConsent = 8; + } + + fabric_scoped struct ProviderLocation { + node_id providerNodeID = 1; + endpoint_no endpoint = 2; + fabric_idx fabricIndex = 254; + } + + info event StateTransition = 0 { + UpdateStateEnum previousState = 0; + UpdateStateEnum newState = 1; + ChangeReasonEnum reason = 2; + nullable int32u targetSoftwareVersion = 3; + } + + critical event VersionApplied = 1 { + int32u softwareVersion = 0; + int16u productID = 1; + } + + info event DownloadError = 2 { + int32u softwareVersion = 0; + int64u bytesDownloaded = 1; + nullable int8u progressPercent = 2; + nullable int64s platformCode = 3; + } + + attribute access(write: administer) ProviderLocation defaultOTAProviders[] = 0; + readonly attribute boolean updatePossible = 1; + readonly attribute UpdateStateEnum updateState = 2; + readonly attribute nullable int8u updateStateProgress = 3; + readonly attribute command_id generatedCommandList[] = 65528; + readonly attribute command_id acceptedCommandList[] = 65529; + readonly attribute event_id eventList[] = 65530; + readonly attribute attrib_id attributeList[] = 65531; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; + + request struct AnnounceOTAProviderRequest { + node_id providerNodeID = 0; + vendor_id vendorID = 1; + AnnouncementReasonEnum announcementReason = 2; + optional octet_string<512> metadataForNode = 3; + endpoint_no endpoint = 4; + } + + /** Announce the presence of an OTA Provider */ + command AnnounceOTAProvider(AnnounceOTAProviderRequest): DefaultSuccess = 0; +} + +/** Nodes should be expected to be deployed to any and all regions of the world. These global regions + may have differing common languages, units of measurements, and numerical formatting + standards. As such, Nodes that visually or audibly convey information need a mechanism by which + they can be configured to use a user’s preferred language, units, etc */ +cluster LocalizationConfiguration = 43 { + revision 1; // NOTE: Default/not specifically set + + attribute access(write: manage) char_string<35> activeLocale = 0; + readonly attribute char_string supportedLocales[] = 1; + readonly attribute command_id generatedCommandList[] = 65528; + readonly attribute command_id acceptedCommandList[] = 65529; + readonly attribute event_id eventList[] = 65530; + readonly attribute attrib_id attributeList[] = 65531; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; +} + +/** Nodes should be expected to be deployed to any and all regions of the world. These global regions + may have differing preferences for how dates and times are conveyed. As such, Nodes that visually + or audibly convey time information need a mechanism by which they can be configured to use a + user’s preferred format. */ +cluster TimeFormatLocalization = 44 { + revision 1; // NOTE: Default/not specifically set + + enum CalendarTypeEnum : enum8 { + kBuddhist = 0; + kChinese = 1; + kCoptic = 2; + kEthiopian = 3; + kGregorian = 4; + kHebrew = 5; + kIndian = 6; + kIslamic = 7; + kJapanese = 8; + kKorean = 9; + kPersian = 10; + kTaiwanese = 11; + kUseActiveLocale = 255; + } + + enum HourFormatEnum : enum8 { + k12hr = 0; + k24hr = 1; + kUseActiveLocale = 255; + } + + bitmap Feature : bitmap32 { + kCalendarFormat = 0x1; + } + + attribute access(write: manage) HourFormatEnum hourFormat = 0; + attribute access(write: manage) optional CalendarTypeEnum activeCalendarType = 1; + readonly attribute optional CalendarTypeEnum supportedCalendarTypes[] = 2; + readonly attribute command_id generatedCommandList[] = 65528; + readonly attribute command_id acceptedCommandList[] = 65529; + readonly attribute event_id eventList[] = 65530; + readonly attribute attrib_id attributeList[] = 65531; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; +} + +/** This cluster is used to manage global aspects of the Commissioning flow. */ +cluster GeneralCommissioning = 48 { + revision 1; // NOTE: Default/not specifically set + + enum CommissioningErrorEnum : enum8 { + kOK = 0; + kValueOutsideRange = 1; + kInvalidAuthentication = 2; + kNoFailSafe = 3; + kBusyWithOtherAdmin = 4; + } + + enum RegulatoryLocationTypeEnum : enum8 { + kIndoor = 0; + kOutdoor = 1; + kIndoorOutdoor = 2; + } + + struct BasicCommissioningInfo { + int16u failSafeExpiryLengthSeconds = 0; + int16u maxCumulativeFailsafeSeconds = 1; + } + + attribute access(write: administer) int64u breadcrumb = 0; + readonly attribute BasicCommissioningInfo basicCommissioningInfo = 1; + readonly attribute RegulatoryLocationTypeEnum regulatoryConfig = 2; + readonly attribute RegulatoryLocationTypeEnum locationCapability = 3; + readonly attribute boolean supportsConcurrentConnection = 4; + readonly attribute command_id generatedCommandList[] = 65528; + readonly attribute command_id acceptedCommandList[] = 65529; + readonly attribute event_id eventList[] = 65530; + readonly attribute attrib_id attributeList[] = 65531; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; + + request struct ArmFailSafeRequest { + int16u expiryLengthSeconds = 0; + int64u breadcrumb = 1; + } + + response struct ArmFailSafeResponse = 1 { + CommissioningErrorEnum errorCode = 0; + char_string<128> debugText = 1; + } + + request struct SetRegulatoryConfigRequest { + RegulatoryLocationTypeEnum newRegulatoryConfig = 0; + char_string<2> countryCode = 1; + int64u breadcrumb = 2; + } + + response struct SetRegulatoryConfigResponse = 3 { + CommissioningErrorEnum errorCode = 0; + char_string debugText = 1; + } + + response struct CommissioningCompleteResponse = 5 { + CommissioningErrorEnum errorCode = 0; + char_string debugText = 1; + } + + /** Arm the persistent fail-safe timer with an expiry time of now + ExpiryLengthSeconds using device clock */ + command access(invoke: administer) ArmFailSafe(ArmFailSafeRequest): ArmFailSafeResponse = 0; + /** Set the regulatory configuration to be used during commissioning */ + command access(invoke: administer) SetRegulatoryConfig(SetRegulatoryConfigRequest): SetRegulatoryConfigResponse = 2; + /** Signals the Server that the Client has successfully completed all steps of Commissioning/Recofiguration needed during fail-safe period. */ + fabric command access(invoke: administer) CommissioningComplete(): CommissioningCompleteResponse = 4; +} + +/** Functionality to configure, enable, disable network credentials and access on a Matter device. */ +cluster NetworkCommissioning = 49 { + revision 1; // NOTE: Default/not specifically set + + enum NetworkCommissioningStatusEnum : enum8 { + kSuccess = 0; + kOutOfRange = 1; + kBoundsExceeded = 2; + kNetworkIDNotFound = 3; + kDuplicateNetworkID = 4; + kNetworkNotFound = 5; + kRegulatoryError = 6; + kAuthFailure = 7; + kUnsupportedSecurity = 8; + kOtherConnectionFailure = 9; + kIPV6Failed = 10; + kIPBindFailed = 11; + kUnknownError = 12; + } + + enum WiFiBandEnum : enum8 { + k2G4 = 0; + k3G65 = 1; + k5G = 2; + k6G = 3; + k60G = 4; + k1G = 5; + } + + bitmap Feature : bitmap32 { + kWiFiNetworkInterface = 0x1; + kThreadNetworkInterface = 0x2; + kEthernetNetworkInterface = 0x4; + kPerDeviceCredentials = 0x8; + } + + bitmap ThreadCapabilitiesBitmap : bitmap16 { + kIsBorderRouterCapable = 0x1; + kIsRouterCapable = 0x2; + kIsSleepyEndDeviceCapable = 0x4; + kIsFullThreadDevice = 0x8; + kIsSynchronizedSleepyEndDeviceCapable = 0x10; + } + + bitmap WiFiSecurityBitmap : bitmap8 { + kUnencrypted = 0x1; + kWEP = 0x2; + kWPAPersonal = 0x4; + kWPA2Personal = 0x8; + kWPA3Personal = 0x10; + kWPA3MatterPDC = 0x20; + } + + struct NetworkInfoStruct { + octet_string<32> networkID = 0; + boolean connected = 1; + optional nullable octet_string<20> networkIdentifier = 2; + optional nullable octet_string<20> clientIdentifier = 3; + } + + struct ThreadInterfaceScanResultStruct { + int16u panId = 0; + int64u extendedPanId = 1; + char_string<16> networkName = 2; + int16u channel = 3; + int8u version = 4; + octet_string<8> extendedAddress = 5; + int8s rssi = 6; + int8u lqi = 7; + } + + struct WiFiInterfaceScanResultStruct { + WiFiSecurityBitmap security = 0; + octet_string<32> ssid = 1; + octet_string<6> bssid = 2; + int16u channel = 3; + WiFiBandEnum wiFiBand = 4; + int8s rssi = 5; + } + + readonly attribute access(read: administer) int8u maxNetworks = 0; + readonly attribute access(read: administer) NetworkInfoStruct networks[] = 1; + readonly attribute optional int8u scanMaxTimeSeconds = 2; + readonly attribute optional int8u connectMaxTimeSeconds = 3; + attribute access(write: administer) boolean interfaceEnabled = 4; + readonly attribute access(read: administer) nullable NetworkCommissioningStatusEnum lastNetworkingStatus = 5; + readonly attribute access(read: administer) nullable octet_string<32> lastNetworkID = 6; + readonly attribute access(read: administer) nullable int32s lastConnectErrorValue = 7; + readonly attribute optional WiFiBandEnum supportedWiFiBands[] = 8; + readonly attribute optional ThreadCapabilitiesBitmap supportedThreadFeatures = 9; + readonly attribute optional int16u threadVersion = 10; + readonly attribute command_id generatedCommandList[] = 65528; + readonly attribute command_id acceptedCommandList[] = 65529; + readonly attribute event_id eventList[] = 65530; + readonly attribute attrib_id attributeList[] = 65531; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; + + request struct ScanNetworksRequest { + optional nullable octet_string<32> ssid = 0; + optional int64u breadcrumb = 1; + } + + response struct ScanNetworksResponse = 1 { + NetworkCommissioningStatusEnum networkingStatus = 0; + optional char_string debugText = 1; + optional WiFiInterfaceScanResultStruct wiFiScanResults[] = 2; + optional ThreadInterfaceScanResultStruct threadScanResults[] = 3; + } + + request struct AddOrUpdateWiFiNetworkRequest { + octet_string<32> ssid = 0; + octet_string<64> credentials = 1; + optional int64u breadcrumb = 2; + optional octet_string<140> networkIdentity = 3; + optional octet_string<20> clientIdentifier = 4; + optional octet_string<32> possessionNonce = 5; + } + + request struct AddOrUpdateThreadNetworkRequest { + octet_string<254> operationalDataset = 0; + optional int64u breadcrumb = 1; + } + + request struct RemoveNetworkRequest { + octet_string<32> networkID = 0; + optional int64u breadcrumb = 1; + } + + response struct NetworkConfigResponse = 5 { + NetworkCommissioningStatusEnum networkingStatus = 0; + optional char_string<512> debugText = 1; + optional int8u networkIndex = 2; + optional octet_string<140> clientIdentity = 3; + optional octet_string<64> possessionSignature = 4; + } + + request struct ConnectNetworkRequest { + octet_string<32> networkID = 0; + optional int64u breadcrumb = 1; + } + + response struct ConnectNetworkResponse = 7 { + NetworkCommissioningStatusEnum networkingStatus = 0; + optional char_string debugText = 1; + nullable int32s errorValue = 2; + } + + request struct ReorderNetworkRequest { + octet_string<32> networkID = 0; + int8u networkIndex = 1; + optional int64u breadcrumb = 2; + } + + request struct QueryIdentityRequest { + octet_string<20> keyIdentifier = 0; + optional octet_string<32> possessionNonce = 1; + } + + response struct QueryIdentityResponse = 10 { + octet_string<140> identity = 0; + optional octet_string<64> possessionSignature = 1; + } + + /** Detemine the set of networks the device sees as available. */ + command access(invoke: administer) ScanNetworks(ScanNetworksRequest): ScanNetworksResponse = 0; + /** Add or update the credentials for a given Wi-Fi network. */ + command access(invoke: administer) AddOrUpdateWiFiNetwork(AddOrUpdateWiFiNetworkRequest): NetworkConfigResponse = 2; + /** Add or update the credentials for a given Thread network. */ + command access(invoke: administer) AddOrUpdateThreadNetwork(AddOrUpdateThreadNetworkRequest): NetworkConfigResponse = 3; + /** Remove the definition of a given network (including its credentials). */ + command access(invoke: administer) RemoveNetwork(RemoveNetworkRequest): NetworkConfigResponse = 4; + /** Connect to the specified network, using previously-defined credentials. */ + command access(invoke: administer) ConnectNetwork(ConnectNetworkRequest): ConnectNetworkResponse = 6; + /** Modify the order in which networks will be presented in the Networks attribute. */ + command access(invoke: administer) ReorderNetwork(ReorderNetworkRequest): NetworkConfigResponse = 8; + /** Retrieve details about and optionally proof of possession of a network client identity. */ + command access(invoke: administer) QueryIdentity(QueryIdentityRequest): QueryIdentityResponse = 9; +} + +/** The cluster provides commands for retrieving unstructured diagnostic logs from a Node that may be used to aid in diagnostics. */ +cluster DiagnosticLogs = 50 { + revision 1; // NOTE: Default/not specifically set + + enum IntentEnum : enum8 { + kEndUserSupport = 0; + kNetworkDiag = 1; + kCrashLogs = 2; + } + + enum StatusEnum : enum8 { + kSuccess = 0; + kExhausted = 1; + kNoLogs = 2; + kBusy = 3; + kDenied = 4; + } + + enum TransferProtocolEnum : enum8 { + kResponsePayload = 0; + kBDX = 1; + } + + readonly attribute command_id generatedCommandList[] = 65528; + readonly attribute command_id acceptedCommandList[] = 65529; + readonly attribute event_id eventList[] = 65530; + readonly attribute attrib_id attributeList[] = 65531; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; + + request struct RetrieveLogsRequestRequest { + IntentEnum intent = 0; + TransferProtocolEnum requestedProtocol = 1; + optional char_string<32> transferFileDesignator = 2; + } + + response struct RetrieveLogsResponse = 1 { + StatusEnum status = 0; + long_octet_string logContent = 1; + optional epoch_us UTCTimeStamp = 2; + optional systime_us timeSinceBoot = 3; + } + + /** Retrieving diagnostic logs from a Node */ + command RetrieveLogsRequest(RetrieveLogsRequestRequest): RetrieveLogsResponse = 0; +} + +/** The General Diagnostics Cluster, along with other diagnostics clusters, provide a means to acquire standardized diagnostics metrics that MAY be used by a Node to assist a user or Administrative Node in diagnosing potential problems. */ +cluster GeneralDiagnostics = 51 { + revision 2; + + enum BootReasonEnum : enum8 { + kUnspecified = 0; + kPowerOnReboot = 1; + kBrownOutReset = 2; + kSoftwareWatchdogReset = 3; + kHardwareWatchdogReset = 4; + kSoftwareUpdateCompleted = 5; + kSoftwareReset = 6; + } + + enum HardwareFaultEnum : enum8 { + kUnspecified = 0; + kRadio = 1; + kSensor = 2; + kResettableOverTemp = 3; + kNonResettableOverTemp = 4; + kPowerSource = 5; + kVisualDisplayFault = 6; + kAudioOutputFault = 7; + kUserInterfaceFault = 8; + kNonVolatileMemoryError = 9; + kTamperDetected = 10; + } + + enum InterfaceTypeEnum : enum8 { + kUnspecified = 0; + kWiFi = 1; + kEthernet = 2; + kCellular = 3; + kThread = 4; + } + + enum NetworkFaultEnum : enum8 { + kUnspecified = 0; + kHardwareFailure = 1; + kNetworkJammed = 2; + kConnectionFailed = 3; + } + + enum RadioFaultEnum : enum8 { + kUnspecified = 0; + kWiFiFault = 1; + kCellularFault = 2; + kThreadFault = 3; + kNFCFault = 4; + kBLEFault = 5; + kEthernetFault = 6; + } + + bitmap Feature : bitmap32 { + kDataModelTest = 0x1; + } + + struct NetworkInterface { + char_string<32> name = 0; + boolean isOperational = 1; + nullable boolean offPremiseServicesReachableIPv4 = 2; + nullable boolean offPremiseServicesReachableIPv6 = 3; + octet_string<8> hardwareAddress = 4; + octet_string IPv4Addresses[] = 5; + octet_string IPv6Addresses[] = 6; + InterfaceTypeEnum type = 7; + } + + critical event HardwareFaultChange = 0 { + HardwareFaultEnum current[] = 0; + HardwareFaultEnum previous[] = 1; + } + + critical event RadioFaultChange = 1 { + RadioFaultEnum current[] = 0; + RadioFaultEnum previous[] = 1; + } + + critical event NetworkFaultChange = 2 { + NetworkFaultEnum current[] = 0; + NetworkFaultEnum previous[] = 1; + } + + critical event BootReason = 3 { + BootReasonEnum bootReason = 0; + } + + readonly attribute NetworkInterface networkInterfaces[] = 0; + readonly attribute int16u rebootCount = 1; + readonly attribute optional int64u upTime = 2; + readonly attribute optional int32u totalOperationalHours = 3; + readonly attribute optional BootReasonEnum bootReason = 4; + readonly attribute optional HardwareFaultEnum activeHardwareFaults[] = 5; + readonly attribute optional RadioFaultEnum activeRadioFaults[] = 6; + readonly attribute optional NetworkFaultEnum activeNetworkFaults[] = 7; + readonly attribute boolean testEventTriggersEnabled = 8; + readonly attribute command_id generatedCommandList[] = 65528; + readonly attribute command_id acceptedCommandList[] = 65529; + readonly attribute event_id eventList[] = 65530; + readonly attribute attrib_id attributeList[] = 65531; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; + + request struct TestEventTriggerRequest { + octet_string<16> enableKey = 0; + int64u eventTrigger = 1; + } + + response struct TimeSnapshotResponse = 2 { + systime_ms systemTimeMs = 0; + nullable posix_ms posixTimeMs = 1; + } + + request struct PayloadTestRequestRequest { + octet_string<16> enableKey = 0; + int8u value = 1; + int16u count = 2; + } + + response struct PayloadTestResponse = 4 { + octet_string payload = 0; + } + + /** Provide a means for certification tests to trigger some test-plan-specific events */ + command access(invoke: manage) TestEventTrigger(TestEventTriggerRequest): DefaultSuccess = 0; + /** Take a snapshot of system time and epoch time. */ + command TimeSnapshot(): TimeSnapshotResponse = 1; + /** Request a variable length payload response. */ + command PayloadTestRequest(PayloadTestRequestRequest): PayloadTestResponse = 3; +} + +/** The Software Diagnostics Cluster provides a means to acquire standardized diagnostics metrics that MAY be used by a Node to assist a user or Administrative Node in diagnosing potential problems. */ +cluster SoftwareDiagnostics = 52 { + revision 1; // NOTE: Default/not specifically set + + bitmap Feature : bitmap32 { + kWatermarks = 0x1; + } + + struct ThreadMetricsStruct { + int64u id = 0; + optional char_string<8> name = 1; + optional int32u stackFreeCurrent = 2; + optional int32u stackFreeMinimum = 3; + optional int32u stackSize = 4; + } + + info event SoftwareFault = 0 { + int64u id = 0; + optional char_string name = 1; + optional octet_string faultRecording = 2; + } + + readonly attribute optional ThreadMetricsStruct threadMetrics[] = 0; + readonly attribute optional int64u currentHeapFree = 1; + readonly attribute optional int64u currentHeapUsed = 2; + readonly attribute optional int64u currentHeapHighWatermark = 3; + readonly attribute command_id generatedCommandList[] = 65528; + readonly attribute command_id acceptedCommandList[] = 65529; + readonly attribute event_id eventList[] = 65530; + readonly attribute attrib_id attributeList[] = 65531; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; + + /** Reception of this command SHALL reset the values: The StackFreeMinimum field of the ThreadMetrics attribute, CurrentHeapHighWaterMark attribute. */ + command access(invoke: manage) ResetWatermarks(): DefaultSuccess = 0; +} + +/** The Thread Network Diagnostics Cluster provides a means to acquire standardized diagnostics metrics that MAY be used by a Node to assist a user or Administrative Node in diagnosing potential problems */ +cluster ThreadNetworkDiagnostics = 53 { + revision 1; // NOTE: Default/not specifically set + + enum ConnectionStatusEnum : enum8 { + kConnected = 0; + kNotConnected = 1; + } + + enum NetworkFaultEnum : enum8 { + kUnspecified = 0; + kLinkDown = 1; + kHardwareFailure = 2; + kNetworkJammed = 3; + } + + enum RoutingRoleEnum : enum8 { + kUnspecified = 0; + kUnassigned = 1; + kSleepyEndDevice = 2; + kEndDevice = 3; + kREED = 4; + kRouter = 5; + kLeader = 6; + } + + bitmap Feature : bitmap32 { + kPacketCounts = 0x1; + kErrorCounts = 0x2; + kMLECounts = 0x4; + kMACCounts = 0x8; + } + + struct NeighborTableStruct { + int64u extAddress = 0; + int32u age = 1; + int16u rloc16 = 2; + int32u linkFrameCounter = 3; + int32u mleFrameCounter = 4; + int8u lqi = 5; + nullable int8s averageRssi = 6; + nullable int8s lastRssi = 7; + int8u frameErrorRate = 8; + int8u messageErrorRate = 9; + boolean rxOnWhenIdle = 10; + boolean fullThreadDevice = 11; + boolean fullNetworkData = 12; + boolean isChild = 13; + } + + struct OperationalDatasetComponents { + boolean activeTimestampPresent = 0; + boolean pendingTimestampPresent = 1; + boolean masterKeyPresent = 2; + boolean networkNamePresent = 3; + boolean extendedPanIdPresent = 4; + boolean meshLocalPrefixPresent = 5; + boolean delayPresent = 6; + boolean panIdPresent = 7; + boolean channelPresent = 8; + boolean pskcPresent = 9; + boolean securityPolicyPresent = 10; + boolean channelMaskPresent = 11; + } + + struct RouteTableStruct { + int64u extAddress = 0; + int16u rloc16 = 1; + int8u routerId = 2; + int8u nextHop = 3; + int8u pathCost = 4; + int8u LQIIn = 5; + int8u LQIOut = 6; + int8u age = 7; + boolean allocated = 8; + boolean linkEstablished = 9; + } + + struct SecurityPolicy { + int16u rotationTime = 0; + int16u flags = 1; + } + + info event ConnectionStatus = 0 { + ConnectionStatusEnum connectionStatus = 0; + } + + info event NetworkFaultChange = 1 { + NetworkFaultEnum current[] = 0; + NetworkFaultEnum previous[] = 1; + } + + readonly attribute nullable int16u channel = 0; + readonly attribute nullable RoutingRoleEnum routingRole = 1; + readonly attribute nullable char_string<16> networkName = 2; + readonly attribute nullable int16u panId = 3; + readonly attribute nullable int64u extendedPanId = 4; + readonly attribute nullable octet_string<17> meshLocalPrefix = 5; + readonly attribute optional int64u overrunCount = 6; + readonly attribute NeighborTableStruct neighborTable[] = 7; + readonly attribute RouteTableStruct routeTable[] = 8; + readonly attribute nullable int32u partitionId = 9; + readonly attribute nullable int16u weighting = 10; + readonly attribute nullable int16u dataVersion = 11; + readonly attribute nullable int16u stableDataVersion = 12; + readonly attribute nullable int8u leaderRouterId = 13; + readonly attribute optional int16u detachedRoleCount = 14; + readonly attribute optional int16u childRoleCount = 15; + readonly attribute optional int16u routerRoleCount = 16; + readonly attribute optional int16u leaderRoleCount = 17; + readonly attribute optional int16u attachAttemptCount = 18; + readonly attribute optional int16u partitionIdChangeCount = 19; + readonly attribute optional int16u betterPartitionAttachAttemptCount = 20; + readonly attribute optional int16u parentChangeCount = 21; + readonly attribute optional int32u txTotalCount = 22; + readonly attribute optional int32u txUnicastCount = 23; + readonly attribute optional int32u txBroadcastCount = 24; + readonly attribute optional int32u txAckRequestedCount = 25; + readonly attribute optional int32u txAckedCount = 26; + readonly attribute optional int32u txNoAckRequestedCount = 27; + readonly attribute optional int32u txDataCount = 28; + readonly attribute optional int32u txDataPollCount = 29; + readonly attribute optional int32u txBeaconCount = 30; + readonly attribute optional int32u txBeaconRequestCount = 31; + readonly attribute optional int32u txOtherCount = 32; + readonly attribute optional int32u txRetryCount = 33; + readonly attribute optional int32u txDirectMaxRetryExpiryCount = 34; + readonly attribute optional int32u txIndirectMaxRetryExpiryCount = 35; + readonly attribute optional int32u txErrCcaCount = 36; + readonly attribute optional int32u txErrAbortCount = 37; + readonly attribute optional int32u txErrBusyChannelCount = 38; + readonly attribute optional int32u rxTotalCount = 39; + readonly attribute optional int32u rxUnicastCount = 40; + readonly attribute optional int32u rxBroadcastCount = 41; + readonly attribute optional int32u rxDataCount = 42; + readonly attribute optional int32u rxDataPollCount = 43; + readonly attribute optional int32u rxBeaconCount = 44; + readonly attribute optional int32u rxBeaconRequestCount = 45; + readonly attribute optional int32u rxOtherCount = 46; + readonly attribute optional int32u rxAddressFilteredCount = 47; + readonly attribute optional int32u rxDestAddrFilteredCount = 48; + readonly attribute optional int32u rxDuplicatedCount = 49; + readonly attribute optional int32u rxErrNoFrameCount = 50; + readonly attribute optional int32u rxErrUnknownNeighborCount = 51; + readonly attribute optional int32u rxErrInvalidSrcAddrCount = 52; + readonly attribute optional int32u rxErrSecCount = 53; + readonly attribute optional int32u rxErrFcsCount = 54; + readonly attribute optional int32u rxErrOtherCount = 55; + readonly attribute optional nullable int64u activeTimestamp = 56; + readonly attribute optional nullable int64u pendingTimestamp = 57; + readonly attribute optional nullable int32u delay = 58; + readonly attribute nullable SecurityPolicy securityPolicy = 59; + readonly attribute nullable octet_string<4> channelPage0Mask = 60; + readonly attribute nullable OperationalDatasetComponents operationalDatasetComponents = 61; + readonly attribute NetworkFaultEnum activeNetworkFaultsList[] = 62; + readonly attribute command_id generatedCommandList[] = 65528; + readonly attribute command_id acceptedCommandList[] = 65529; + readonly attribute event_id eventList[] = 65530; + readonly attribute attrib_id attributeList[] = 65531; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; + + /** Reception of this command SHALL reset the OverrunCount attributes to 0 */ + command access(invoke: manage) ResetCounts(): DefaultSuccess = 0; +} + +/** Commands to trigger a Node to allow a new Administrator to commission it. */ +cluster AdministratorCommissioning = 60 { + revision 1; // NOTE: Default/not specifically set + + enum CommissioningWindowStatusEnum : enum8 { + kWindowNotOpen = 0; + kEnhancedWindowOpen = 1; + kBasicWindowOpen = 2; + } + + enum StatusCode : enum8 { + kBusy = 2; + kPAKEParameterError = 3; + kWindowNotOpen = 4; + } + + bitmap Feature : bitmap32 { + kBasic = 0x1; + } + + readonly attribute CommissioningWindowStatusEnum windowStatus = 0; + readonly attribute nullable fabric_idx adminFabricIndex = 1; + readonly attribute nullable vendor_id adminVendorId = 2; + readonly attribute command_id generatedCommandList[] = 65528; + readonly attribute command_id acceptedCommandList[] = 65529; + readonly attribute event_id eventList[] = 65530; + readonly attribute attrib_id attributeList[] = 65531; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; + + request struct OpenCommissioningWindowRequest { + int16u commissioningTimeout = 0; + octet_string PAKEPasscodeVerifier = 1; + int16u discriminator = 2; + int32u iterations = 3; + octet_string<32> salt = 4; + } + + request struct OpenBasicCommissioningWindowRequest { + int16u commissioningTimeout = 0; + } + + /** This command is used by a current Administrator to instruct a Node to go into commissioning mode using enhanced commissioning method. */ + timed command access(invoke: administer) OpenCommissioningWindow(OpenCommissioningWindowRequest): DefaultSuccess = 0; + /** This command is used by a current Administrator to instruct a Node to go into commissioning mode using basic commissioning method, if the node supports it. */ + timed command access(invoke: administer) OpenBasicCommissioningWindow(OpenBasicCommissioningWindowRequest): DefaultSuccess = 1; + /** This command is used by a current Administrator to instruct a Node to revoke any active Open Commissioning Window or Open Basic Commissioning Window command. */ + timed command access(invoke: administer) RevokeCommissioning(): DefaultSuccess = 2; +} + +/** This cluster is used to add or remove Operational Credentials on a Commissionee or Node, as well as manage the associated Fabrics. */ +cluster OperationalCredentials = 62 { + revision 1; // NOTE: Default/not specifically set + + enum CertificateChainTypeEnum : enum8 { + kDACCertificate = 1; + kPAICertificate = 2; + } + + enum NodeOperationalCertStatusEnum : enum8 { + kOK = 0; + kInvalidPublicKey = 1; + kInvalidNodeOpId = 2; + kInvalidNOC = 3; + kMissingCsr = 4; + kTableFull = 5; + kInvalidAdminSubject = 6; + kFabricConflict = 9; + kLabelConflict = 10; + kInvalidFabricIndex = 11; + } + + fabric_scoped struct FabricDescriptorStruct { + octet_string<65> rootPublicKey = 1; + vendor_id vendorID = 2; + fabric_id fabricID = 3; + node_id nodeID = 4; + char_string<32> label = 5; + fabric_idx fabricIndex = 254; + } + + fabric_scoped struct NOCStruct { + fabric_sensitive octet_string noc = 1; + nullable fabric_sensitive octet_string icac = 2; + fabric_idx fabricIndex = 254; + } + + readonly attribute access(read: administer) NOCStruct NOCs[] = 0; + readonly attribute FabricDescriptorStruct fabrics[] = 1; + readonly attribute int8u supportedFabrics = 2; + readonly attribute int8u commissionedFabrics = 3; + readonly attribute octet_string trustedRootCertificates[] = 4; + readonly attribute int8u currentFabricIndex = 5; + readonly attribute command_id generatedCommandList[] = 65528; + readonly attribute command_id acceptedCommandList[] = 65529; + readonly attribute event_id eventList[] = 65530; + readonly attribute attrib_id attributeList[] = 65531; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; + + request struct AttestationRequestRequest { + octet_string<32> attestationNonce = 0; + } + + response struct AttestationResponse = 1 { + octet_string<900> attestationElements = 0; + octet_string<64> attestationSignature = 1; + } + + request struct CertificateChainRequestRequest { + CertificateChainTypeEnum certificateType = 0; + } + + response struct CertificateChainResponse = 3 { + octet_string<600> certificate = 0; + } + + request struct CSRRequestRequest { + octet_string<32> CSRNonce = 0; + optional boolean isForUpdateNOC = 1; + } + + response struct CSRResponse = 5 { + octet_string NOCSRElements = 0; + octet_string attestationSignature = 1; + } + + request struct AddNOCRequest { + octet_string<400> NOCValue = 0; + optional octet_string<400> ICACValue = 1; + octet_string<16> IPKValue = 2; + int64u caseAdminSubject = 3; + vendor_id adminVendorId = 4; + } + + request struct UpdateNOCRequest { + octet_string NOCValue = 0; + optional octet_string ICACValue = 1; + } + + response struct NOCResponse = 8 { + NodeOperationalCertStatusEnum statusCode = 0; + optional fabric_idx fabricIndex = 1; + optional char_string<128> debugText = 2; + } + + request struct UpdateFabricLabelRequest { + char_string<32> label = 0; + } + + request struct RemoveFabricRequest { + fabric_idx fabricIndex = 0; + } + + request struct AddTrustedRootCertificateRequest { + octet_string rootCACertificate = 0; + } + + /** Sender is requesting attestation information from the receiver. */ + command access(invoke: administer) AttestationRequest(AttestationRequestRequest): AttestationResponse = 0; + /** Sender is requesting a device attestation certificate from the receiver. */ + command access(invoke: administer) CertificateChainRequest(CertificateChainRequestRequest): CertificateChainResponse = 2; + /** Sender is requesting a certificate signing request (CSR) from the receiver. */ + command access(invoke: administer) CSRRequest(CSRRequestRequest): CSRResponse = 4; + /** Sender is requesting to add the new node operational certificates. */ + command access(invoke: administer) AddNOC(AddNOCRequest): NOCResponse = 6; + /** Sender is requesting to update the node operational certificates. */ + fabric command access(invoke: administer) UpdateNOC(UpdateNOCRequest): NOCResponse = 7; + /** This command SHALL be used by an Administrative Node to set the user-visible Label field for a given Fabric, as reflected by entries in the Fabrics attribute. */ + fabric command access(invoke: administer) UpdateFabricLabel(UpdateFabricLabelRequest): NOCResponse = 9; + /** This command is used by Administrative Nodes to remove a given fabric index and delete all associated fabric-scoped data. */ + command access(invoke: administer) RemoveFabric(RemoveFabricRequest): NOCResponse = 10; + /** This command SHALL add a Trusted Root CA Certificate, provided as its CHIP Certificate representation. */ + command access(invoke: administer) AddTrustedRootCertificate(AddTrustedRootCertificateRequest): DefaultSuccess = 11; +} + +/** The Group Key Management Cluster is the mechanism by which group keys are managed. */ +cluster GroupKeyManagement = 63 { + revision 1; // NOTE: Default/not specifically set + + enum GroupKeySecurityPolicyEnum : enum8 { + kTrustFirst = 0; + kCacheAndSync = 1; + } + + bitmap Feature : bitmap32 { + kCacheAndSync = 0x1; + } + + fabric_scoped struct GroupInfoMapStruct { + group_id groupId = 1; + endpoint_no endpoints[] = 2; + optional char_string<16> groupName = 3; + fabric_idx fabricIndex = 254; + } + + fabric_scoped struct GroupKeyMapStruct { + group_id groupId = 1; + int16u groupKeySetID = 2; + fabric_idx fabricIndex = 254; + } + + struct GroupKeySetStruct { + int16u groupKeySetID = 0; + GroupKeySecurityPolicyEnum groupKeySecurityPolicy = 1; + nullable octet_string<16> epochKey0 = 2; + nullable epoch_us epochStartTime0 = 3; + nullable octet_string<16> epochKey1 = 4; + nullable epoch_us epochStartTime1 = 5; + nullable octet_string<16> epochKey2 = 6; + nullable epoch_us epochStartTime2 = 7; + } + + attribute access(write: manage) GroupKeyMapStruct groupKeyMap[] = 0; + readonly attribute GroupInfoMapStruct groupTable[] = 1; + readonly attribute int16u maxGroupsPerFabric = 2; + readonly attribute int16u maxGroupKeysPerFabric = 3; + readonly attribute command_id generatedCommandList[] = 65528; + readonly attribute command_id acceptedCommandList[] = 65529; + readonly attribute event_id eventList[] = 65530; + readonly attribute attrib_id attributeList[] = 65531; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; + + request struct KeySetWriteRequest { + GroupKeySetStruct groupKeySet = 0; + } + + request struct KeySetReadRequest { + int16u groupKeySetID = 0; + } + + response struct KeySetReadResponse = 2 { + GroupKeySetStruct groupKeySet = 0; + } + + request struct KeySetRemoveRequest { + int16u groupKeySetID = 0; + } + + response struct KeySetReadAllIndicesResponse = 5 { + int16u groupKeySetIDs[] = 0; + } + + /** Write a new set of keys for the given key set id. */ + fabric command access(invoke: administer) KeySetWrite(KeySetWriteRequest): DefaultSuccess = 0; + /** Read the keys for a given key set id. */ + fabric command access(invoke: administer) KeySetRead(KeySetReadRequest): KeySetReadResponse = 1; + /** Revoke a Root Key from a Group */ + fabric command access(invoke: administer) KeySetRemove(KeySetRemoveRequest): DefaultSuccess = 3; + /** Return the list of Group Key Sets associated with the accessing fabric */ + fabric command access(invoke: administer) KeySetReadAllIndices(): KeySetReadAllIndicesResponse = 4; +} + +/** The Fixed Label Cluster provides a feature for the device to tag an endpoint with zero or more read only +labels. */ +cluster FixedLabel = 64 { + revision 1; // NOTE: Default/not specifically set + + struct LabelStruct { + char_string<16> label = 0; + char_string<16> value = 1; + } + + readonly attribute LabelStruct labelList[] = 0; + readonly attribute command_id generatedCommandList[] = 65528; + readonly attribute command_id acceptedCommandList[] = 65529; + readonly attribute event_id eventList[] = 65530; + readonly attribute attrib_id attributeList[] = 65531; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; +} + +/** The User Label Cluster provides a feature to tag an endpoint with zero or more labels. */ +cluster UserLabel = 65 { + revision 1; // NOTE: Default/not specifically set + + struct LabelStruct { + char_string<16> label = 0; + char_string<16> value = 1; + } + + attribute access(write: manage) LabelStruct labelList[] = 0; + readonly attribute command_id generatedCommandList[] = 65528; + readonly attribute command_id acceptedCommandList[] = 65529; + readonly attribute event_id eventList[] = 65530; + readonly attribute attrib_id attributeList[] = 65531; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; +} + +/** Attributes and commands for controlling the color properties of a color-capable light. */ +cluster ColorControl = 768 { + revision 6; + + enum ColorLoopAction : enum8 { + kDeactivate = 0; + kActivateFromColorLoopStartEnhancedHue = 1; + kActivateFromEnhancedCurrentHue = 2; + } + + enum ColorLoopDirection : enum8 { + kDecrementHue = 0; + kIncrementHue = 1; + } + + enum ColorMode : enum8 { + kCurrentHueAndCurrentSaturation = 0; + kCurrentXAndCurrentY = 1; + kColorTemperature = 2; + } + + enum HueDirection : enum8 { + kShortestDistance = 0; + kLongestDistance = 1; + kUp = 2; + kDown = 3; + } + + enum HueMoveMode : enum8 { + kStop = 0; + kUp = 1; + kDown = 3; + } + + enum HueStepMode : enum8 { + kUp = 1; + kDown = 3; + } + + enum SaturationMoveMode : enum8 { + kStop = 0; + kUp = 1; + kDown = 3; + } + + enum SaturationStepMode : enum8 { + kUp = 1; + kDown = 3; + } + + bitmap ColorCapabilities : bitmap16 { + kHueSaturationSupported = 0x1; + kEnhancedHueSupported = 0x2; + kColorLoopSupported = 0x4; + kXYAttributesSupported = 0x8; + kColorTemperatureSupported = 0x10; + } + + bitmap ColorLoopUpdateFlags : bitmap8 { + kUpdateAction = 0x1; + kUpdateDirection = 0x2; + kUpdateTime = 0x4; + kUpdateStartHue = 0x8; + } + + bitmap Feature : bitmap32 { + kHueAndSaturation = 0x1; + kEnhancedHue = 0x2; + kColorLoop = 0x4; + kXY = 0x8; + kColorTemperature = 0x10; + } + + readonly attribute optional int8u currentHue = 0; + readonly attribute optional int8u currentSaturation = 1; + readonly attribute optional int16u remainingTime = 2; + readonly attribute optional int16u currentX = 3; + readonly attribute optional int16u currentY = 4; + readonly attribute optional enum8 driftCompensation = 5; + readonly attribute optional char_string<254> compensationText = 6; + readonly attribute optional int16u colorTemperatureMireds = 7; + readonly attribute enum8 colorMode = 8; + attribute bitmap8 options = 15; + readonly attribute nullable int8u numberOfPrimaries = 16; + readonly attribute optional int16u primary1X = 17; + readonly attribute optional int16u primary1Y = 18; + readonly attribute optional nullable int8u primary1Intensity = 19; + readonly attribute optional int16u primary2X = 21; + readonly attribute optional int16u primary2Y = 22; + readonly attribute optional nullable int8u primary2Intensity = 23; + readonly attribute optional int16u primary3X = 25; + readonly attribute optional int16u primary3Y = 26; + readonly attribute optional nullable int8u primary3Intensity = 27; + readonly attribute optional int16u primary4X = 32; + readonly attribute optional int16u primary4Y = 33; + readonly attribute optional nullable int8u primary4Intensity = 34; + readonly attribute optional int16u primary5X = 36; + readonly attribute optional int16u primary5Y = 37; + readonly attribute optional nullable int8u primary5Intensity = 38; + readonly attribute optional int16u primary6X = 40; + readonly attribute optional int16u primary6Y = 41; + readonly attribute optional nullable int8u primary6Intensity = 42; + attribute access(write: manage) optional int16u whitePointX = 48; + attribute access(write: manage) optional int16u whitePointY = 49; + attribute access(write: manage) optional int16u colorPointRX = 50; + attribute access(write: manage) optional int16u colorPointRY = 51; + attribute access(write: manage) optional nullable int8u colorPointRIntensity = 52; + attribute access(write: manage) optional int16u colorPointGX = 54; + attribute access(write: manage) optional int16u colorPointGY = 55; + attribute access(write: manage) optional nullable int8u colorPointGIntensity = 56; + attribute access(write: manage) optional int16u colorPointBX = 58; + attribute access(write: manage) optional int16u colorPointBY = 59; + attribute access(write: manage) optional nullable int8u colorPointBIntensity = 60; + readonly attribute optional int16u enhancedCurrentHue = 16384; + readonly attribute enum8 enhancedColorMode = 16385; + readonly attribute optional int8u colorLoopActive = 16386; + readonly attribute optional int8u colorLoopDirection = 16387; + readonly attribute optional int16u colorLoopTime = 16388; + readonly attribute optional int16u colorLoopStartEnhancedHue = 16389; + readonly attribute optional int16u colorLoopStoredEnhancedHue = 16390; + readonly attribute bitmap16 colorCapabilities = 16394; + readonly attribute optional int16u colorTempPhysicalMinMireds = 16395; + readonly attribute optional int16u colorTempPhysicalMaxMireds = 16396; + readonly attribute optional int16u coupleColorTempToLevelMinMireds = 16397; + attribute access(write: manage) optional nullable int16u startUpColorTemperatureMireds = 16400; + readonly attribute command_id generatedCommandList[] = 65528; + readonly attribute command_id acceptedCommandList[] = 65529; + readonly attribute event_id eventList[] = 65530; + readonly attribute attrib_id attributeList[] = 65531; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; + + request struct MoveToHueRequest { + int8u hue = 0; + HueDirection direction = 1; + int16u transitionTime = 2; + bitmap8 optionsMask = 3; + bitmap8 optionsOverride = 4; + } + + request struct MoveHueRequest { + HueMoveMode moveMode = 0; + int8u rate = 1; + bitmap8 optionsMask = 2; + bitmap8 optionsOverride = 3; + } + + request struct StepHueRequest { + HueStepMode stepMode = 0; + int8u stepSize = 1; + int8u transitionTime = 2; + bitmap8 optionsMask = 3; + bitmap8 optionsOverride = 4; + } + + request struct MoveToSaturationRequest { + int8u saturation = 0; + int16u transitionTime = 1; + bitmap8 optionsMask = 2; + bitmap8 optionsOverride = 3; + } + + request struct MoveSaturationRequest { + SaturationMoveMode moveMode = 0; + int8u rate = 1; + bitmap8 optionsMask = 2; + bitmap8 optionsOverride = 3; + } + + request struct StepSaturationRequest { + SaturationStepMode stepMode = 0; + int8u stepSize = 1; + int8u transitionTime = 2; + bitmap8 optionsMask = 3; + bitmap8 optionsOverride = 4; + } + + request struct MoveToHueAndSaturationRequest { + int8u hue = 0; + int8u saturation = 1; + int16u transitionTime = 2; + bitmap8 optionsMask = 3; + bitmap8 optionsOverride = 4; + } + + request struct MoveToColorRequest { + int16u colorX = 0; + int16u colorY = 1; + int16u transitionTime = 2; + bitmap8 optionsMask = 3; + bitmap8 optionsOverride = 4; + } + + request struct MoveColorRequest { + int16s rateX = 0; + int16s rateY = 1; + bitmap8 optionsMask = 2; + bitmap8 optionsOverride = 3; + } + + request struct StepColorRequest { + int16s stepX = 0; + int16s stepY = 1; + int16u transitionTime = 2; + bitmap8 optionsMask = 3; + bitmap8 optionsOverride = 4; + } + + request struct MoveToColorTemperatureRequest { + int16u colorTemperatureMireds = 0; + int16u transitionTime = 1; + bitmap8 optionsMask = 2; + bitmap8 optionsOverride = 3; + } + + request struct EnhancedMoveToHueRequest { + int16u enhancedHue = 0; + HueDirection direction = 1; + int16u transitionTime = 2; + bitmap8 optionsMask = 3; + bitmap8 optionsOverride = 4; + } + + request struct EnhancedMoveHueRequest { + HueMoveMode moveMode = 0; + int16u rate = 1; + bitmap8 optionsMask = 2; + bitmap8 optionsOverride = 3; + } + + request struct EnhancedStepHueRequest { + HueStepMode stepMode = 0; + int16u stepSize = 1; + int16u transitionTime = 2; + bitmap8 optionsMask = 3; + bitmap8 optionsOverride = 4; + } + + request struct EnhancedMoveToHueAndSaturationRequest { + int16u enhancedHue = 0; + int8u saturation = 1; + int16u transitionTime = 2; + bitmap8 optionsMask = 3; + bitmap8 optionsOverride = 4; + } + + request struct ColorLoopSetRequest { + ColorLoopUpdateFlags updateFlags = 0; + ColorLoopAction action = 1; + ColorLoopDirection direction = 2; + int16u time = 3; + int16u startHue = 4; + bitmap8 optionsMask = 5; + bitmap8 optionsOverride = 6; + } + + request struct StopMoveStepRequest { + bitmap8 optionsMask = 0; + bitmap8 optionsOverride = 1; + } + + request struct MoveColorTemperatureRequest { + HueMoveMode moveMode = 0; + int16u rate = 1; + int16u colorTemperatureMinimumMireds = 2; + int16u colorTemperatureMaximumMireds = 3; + bitmap8 optionsMask = 4; + bitmap8 optionsOverride = 5; + } + + request struct StepColorTemperatureRequest { + HueStepMode stepMode = 0; + int16u stepSize = 1; + int16u transitionTime = 2; + int16u colorTemperatureMinimumMireds = 3; + int16u colorTemperatureMaximumMireds = 4; + bitmap8 optionsMask = 5; + bitmap8 optionsOverride = 6; + } + + /** Move to specified hue. */ + command MoveToHue(MoveToHueRequest): DefaultSuccess = 0; + /** Move hue up or down at specified rate. */ + command MoveHue(MoveHueRequest): DefaultSuccess = 1; + /** Step hue up or down by specified size at specified rate. */ + command StepHue(StepHueRequest): DefaultSuccess = 2; + /** Move to specified saturation. */ + command MoveToSaturation(MoveToSaturationRequest): DefaultSuccess = 3; + /** Move saturation up or down at specified rate. */ + command MoveSaturation(MoveSaturationRequest): DefaultSuccess = 4; + /** Step saturation up or down by specified size at specified rate. */ + command StepSaturation(StepSaturationRequest): DefaultSuccess = 5; + /** Move to hue and saturation. */ + command MoveToHueAndSaturation(MoveToHueAndSaturationRequest): DefaultSuccess = 6; + /** Move to specified color. */ + command MoveToColor(MoveToColorRequest): DefaultSuccess = 7; + /** Moves the color. */ + command MoveColor(MoveColorRequest): DefaultSuccess = 8; + /** Steps the lighting to a specific color. */ + command StepColor(StepColorRequest): DefaultSuccess = 9; + /** Move to a specific color temperature. */ + command MoveToColorTemperature(MoveToColorTemperatureRequest): DefaultSuccess = 10; + /** Command description for EnhancedMoveToHue */ + command EnhancedMoveToHue(EnhancedMoveToHueRequest): DefaultSuccess = 64; + /** Command description for EnhancedMoveHue */ + command EnhancedMoveHue(EnhancedMoveHueRequest): DefaultSuccess = 65; + /** Command description for EnhancedStepHue */ + command EnhancedStepHue(EnhancedStepHueRequest): DefaultSuccess = 66; + /** Command description for EnhancedMoveToHueAndSaturation */ + command EnhancedMoveToHueAndSaturation(EnhancedMoveToHueAndSaturationRequest): DefaultSuccess = 67; + /** Command description for ColorLoopSet */ + command ColorLoopSet(ColorLoopSetRequest): DefaultSuccess = 68; + /** Command description for StopMoveStep */ + command StopMoveStep(StopMoveStepRequest): DefaultSuccess = 71; + /** Command description for MoveColorTemperature */ + command MoveColorTemperature(MoveColorTemperatureRequest): DefaultSuccess = 75; + /** Command description for StepColorTemperature */ + command StepColorTemperature(StepColorTemperatureRequest): DefaultSuccess = 76; +} + +endpoint 0 { + device type ma_rootdevice = 22, version 1; + + binding cluster OtaSoftwareUpdateProvider; + + server cluster Descriptor { + callback attribute deviceTypeList; + callback attribute serverList; + callback attribute clientList; + callback attribute partsList; + callback attribute featureMap; + callback attribute clusterRevision; + } + + server cluster AccessControl { + emits event AccessControlEntryChanged; + emits event AccessControlExtensionChanged; + callback attribute acl; + callback attribute extension; + callback attribute subjectsPerAccessControlEntry; + callback attribute targetsPerAccessControlEntry; + callback attribute accessControlEntriesPerFabric; + callback attribute attributeList; + ram attribute featureMap default = 0; + callback attribute clusterRevision; + } + + server cluster BasicInformation { + emits event StartUp; + emits event ShutDown; + emits event Leave; + callback attribute dataModelRevision; + callback attribute vendorName; + callback attribute vendorID; + callback attribute productName; + callback attribute productID; + persist attribute nodeLabel; + callback attribute location; + callback attribute hardwareVersion; + callback attribute hardwareVersionString; + callback attribute softwareVersion; + callback attribute softwareVersionString; + callback attribute manufacturingDate; + callback attribute partNumber; + callback attribute productURL; + callback attribute productLabel; + callback attribute serialNumber; + persist attribute localConfigDisabled default = 0; + callback attribute uniqueID; + callback attribute capabilityMinima; + callback attribute specificationVersion; + callback attribute maxPathsPerInvoke; + ram attribute featureMap default = 0; + ram attribute clusterRevision default = 3; + } + + server cluster OtaSoftwareUpdateRequestor { + emits event StateTransition; + emits event VersionApplied; + emits event DownloadError; + callback attribute defaultOTAProviders; + ram attribute updatePossible default = 1; + ram attribute updateState default = 0; + ram attribute updateStateProgress default = 0; + ram attribute featureMap default = 0; + ram attribute clusterRevision default = 1; + + handle command AnnounceOTAProvider; + } + + server cluster LocalizationConfiguration { + persist attribute activeLocale default = "en-US"; + callback attribute supportedLocales; + ram attribute featureMap default = 0; + ram attribute clusterRevision default = 1; + } + + server cluster TimeFormatLocalization { + persist attribute hourFormat default = 0; + persist attribute activeCalendarType default = 0; + callback attribute supportedCalendarTypes; + ram attribute featureMap default = 0; + ram attribute clusterRevision default = 1; + } + + server cluster GeneralCommissioning { + ram attribute breadcrumb default = 0x0000000000000000; + callback attribute basicCommissioningInfo; + callback attribute regulatoryConfig; + callback attribute locationCapability; + callback attribute supportsConcurrentConnection; + ram attribute featureMap default = 0; + ram attribute clusterRevision default = 1; + + handle command ArmFailSafe; + handle command ArmFailSafeResponse; + handle command SetRegulatoryConfig; + handle command SetRegulatoryConfigResponse; + handle command CommissioningComplete; + handle command CommissioningCompleteResponse; + } + + server cluster NetworkCommissioning { + ram attribute maxNetworks; + callback attribute networks; + ram attribute scanMaxTimeSeconds; + ram attribute connectMaxTimeSeconds; + ram attribute interfaceEnabled; + ram attribute lastNetworkingStatus; + ram attribute lastNetworkID; + ram attribute lastConnectErrorValue; + ram attribute featureMap default = 2; + ram attribute clusterRevision default = 1; + + handle command ScanNetworks; + handle command ScanNetworksResponse; + handle command AddOrUpdateWiFiNetwork; + handle command AddOrUpdateThreadNetwork; + handle command RemoveNetwork; + handle command NetworkConfigResponse; + handle command ConnectNetwork; + handle command ConnectNetworkResponse; + handle command ReorderNetwork; + } + + server cluster DiagnosticLogs { + ram attribute featureMap default = 0; + ram attribute clusterRevision default = 1; + + handle command RetrieveLogsRequest; + } + + server cluster GeneralDiagnostics { + emits event HardwareFaultChange; + emits event RadioFaultChange; + emits event NetworkFaultChange; + emits event BootReason; + callback attribute networkInterfaces; + callback attribute rebootCount; + callback attribute upTime; + callback attribute totalOperationalHours; + callback attribute bootReason; + callback attribute activeHardwareFaults; + callback attribute activeRadioFaults; + callback attribute activeNetworkFaults; + callback attribute testEventTriggersEnabled default = false; + callback attribute featureMap; + callback attribute clusterRevision; + + handle command TestEventTrigger; + handle command TimeSnapshot; + handle command TimeSnapshotResponse; + } + + server cluster SoftwareDiagnostics { + callback attribute threadMetrics; + callback attribute currentHeapFree; + callback attribute currentHeapUsed; + callback attribute currentHeapHighWatermark; + callback attribute featureMap; + ram attribute clusterRevision default = 1; + + handle command ResetWatermarks; + } + + server cluster ThreadNetworkDiagnostics { + callback attribute channel; + callback attribute routingRole; + callback attribute networkName; + callback attribute panId; + callback attribute extendedPanId; + callback attribute meshLocalPrefix; + callback attribute overrunCount; + callback attribute neighborTable; + callback attribute routeTable; + callback attribute partitionId; + callback attribute weighting; + callback attribute dataVersion; + callback attribute stableDataVersion; + callback attribute leaderRouterId; + callback attribute detachedRoleCount; + callback attribute childRoleCount; + callback attribute routerRoleCount; + callback attribute leaderRoleCount; + callback attribute attachAttemptCount; + callback attribute partitionIdChangeCount; + callback attribute betterPartitionAttachAttemptCount; + callback attribute parentChangeCount; + callback attribute txTotalCount; + callback attribute txUnicastCount; + callback attribute txBroadcastCount; + callback attribute txAckRequestedCount; + callback attribute txAckedCount; + callback attribute txNoAckRequestedCount; + callback attribute txDataCount; + callback attribute txDataPollCount; + callback attribute txBeaconCount; + callback attribute txBeaconRequestCount; + callback attribute txOtherCount; + callback attribute txRetryCount; + callback attribute txDirectMaxRetryExpiryCount; + callback attribute txIndirectMaxRetryExpiryCount; + callback attribute txErrCcaCount; + callback attribute txErrAbortCount; + callback attribute txErrBusyChannelCount; + callback attribute rxTotalCount; + callback attribute rxUnicastCount; + callback attribute rxBroadcastCount; + callback attribute rxDataCount; + callback attribute rxDataPollCount; + callback attribute rxBeaconCount; + callback attribute rxBeaconRequestCount; + callback attribute rxOtherCount; + callback attribute rxAddressFilteredCount; + callback attribute rxDestAddrFilteredCount; + callback attribute rxDuplicatedCount; + callback attribute rxErrNoFrameCount; + callback attribute rxErrUnknownNeighborCount; + callback attribute rxErrInvalidSrcAddrCount; + callback attribute rxErrSecCount; + callback attribute rxErrFcsCount; + callback attribute rxErrOtherCount; + callback attribute activeTimestamp; + callback attribute pendingTimestamp; + callback attribute delay; + callback attribute securityPolicy; + callback attribute channelPage0Mask; + callback attribute operationalDatasetComponents; + callback attribute activeNetworkFaultsList; + ram attribute featureMap default = 0x000F; + ram attribute clusterRevision default = 1; + } + + server cluster AdministratorCommissioning { + callback attribute windowStatus; + callback attribute adminFabricIndex; + callback attribute adminVendorId; + ram attribute featureMap default = 0; + ram attribute clusterRevision default = 1; + + handle command OpenCommissioningWindow; + handle command OpenBasicCommissioningWindow; + handle command RevokeCommissioning; + } + + server cluster OperationalCredentials { + callback attribute NOCs; + callback attribute fabrics; + callback attribute supportedFabrics; + callback attribute commissionedFabrics; + callback attribute trustedRootCertificates; + callback attribute currentFabricIndex; + ram attribute featureMap default = 0; + ram attribute clusterRevision default = 1; + + handle command AttestationRequest; + handle command AttestationResponse; + handle command CertificateChainRequest; + handle command CertificateChainResponse; + handle command CSRRequest; + handle command CSRResponse; + handle command AddNOC; + handle command UpdateNOC; + handle command NOCResponse; + handle command UpdateFabricLabel; + handle command RemoveFabric; + handle command AddTrustedRootCertificate; + } + + server cluster GroupKeyManagement { + callback attribute groupKeyMap; + callback attribute groupTable; + callback attribute maxGroupsPerFabric; + callback attribute maxGroupKeysPerFabric; + callback attribute featureMap; + callback attribute clusterRevision; + + handle command KeySetWrite; + handle command KeySetRead; + handle command KeySetReadResponse; + handle command KeySetRemove; + handle command KeySetReadAllIndices; + handle command KeySetReadAllIndicesResponse; + } + + server cluster FixedLabel { + callback attribute labelList; + ram attribute featureMap default = 0; + ram attribute clusterRevision default = 1; + } + + server cluster UserLabel { + callback attribute labelList; + ram attribute featureMap default = 0; + ram attribute clusterRevision default = 1; + } +} +endpoint 1 { + device type ma_extendedcolorlight = 269, version 1; + + + server cluster Identify { + ram attribute identifyTime default = 0x0000; + ram attribute identifyType default = 0x0; + ram attribute featureMap default = 0; + ram attribute clusterRevision default = 4; + + handle command Identify; + handle command TriggerEffect; + } + + server cluster Groups { + ram attribute nameSupport; + ram attribute featureMap default = 0; + ram attribute clusterRevision default = 4; + + handle command AddGroup; + handle command AddGroupResponse; + handle command ViewGroup; + handle command ViewGroupResponse; + handle command GetGroupMembership; + handle command GetGroupMembershipResponse; + handle command RemoveGroup; + handle command RemoveGroupResponse; + handle command RemoveAllGroups; + handle command AddGroupIfIdentifying; + } + + server cluster OnOff { + persist attribute onOff default = 0x01; + ram attribute globalSceneControl default = 0x01; + ram attribute onTime default = 0x0000; + ram attribute offWaitTime default = 0x0000; + persist attribute startUpOnOff; + ram attribute featureMap default = 1; + ram attribute clusterRevision default = 5; + + handle command Off; + handle command On; + handle command Toggle; + handle command OffWithEffect; + handle command OnWithRecallGlobalScene; + handle command OnWithTimedOff; + } + + server cluster LevelControl { + persist attribute currentLevel default = 0x254; + ram attribute remainingTime default = 0x0000; + ram attribute minLevel default = 0x01; + ram attribute maxLevel default = 0xFE; + ram attribute currentFrequency default = 0x0000; + ram attribute minFrequency default = 0x0000; + ram attribute maxFrequency default = 0x0000; + ram attribute options default = 0x00; + ram attribute onOffTransitionTime default = 0x0000; + ram attribute onLevel; + ram attribute onTransitionTime; + ram attribute offTransitionTime; + ram attribute defaultMoveRate default = 50; + persist attribute startUpCurrentLevel; + ram attribute featureMap default = 3; + ram attribute clusterRevision default = 5; + + handle command MoveToLevel; + handle command Move; + handle command Step; + handle command Stop; + handle command MoveToLevelWithOnOff; + handle command MoveWithOnOff; + handle command StepWithOnOff; + handle command StopWithOnOff; + } + + server cluster Descriptor { + callback attribute deviceTypeList; + callback attribute serverList; + callback attribute clientList; + callback attribute partsList; + callback attribute featureMap; + callback attribute clusterRevision; + } + + server cluster ColorControl { + ram attribute currentHue default = 0x00; + ram attribute currentSaturation default = 0x00; + ram attribute remainingTime default = 0x0000; + ram attribute currentX default = 0x616B; + ram attribute currentY default = 0x607D; + ram attribute colorTemperatureMireds default = 0x00FA; + ram attribute colorMode default = 0x01; + ram attribute options default = 0x00; + ram attribute numberOfPrimaries; + ram attribute primary1X; + ram attribute primary1Y; + ram attribute primary1Intensity; + ram attribute primary2X; + ram attribute primary2Y; + ram attribute primary2Intensity; + ram attribute primary3X; + ram attribute primary3Y; + ram attribute primary3Intensity; + ram attribute primary4X; + ram attribute primary4Y; + ram attribute primary4Intensity; + ram attribute primary5X; + ram attribute primary5Y; + ram attribute primary5Intensity; + ram attribute primary6X; + ram attribute primary6Y; + ram attribute primary6Intensity; + ram attribute enhancedCurrentHue default = 0x0000; + ram attribute enhancedColorMode default = 0x01; + ram attribute colorLoopActive default = 0x00; + ram attribute colorLoopDirection default = 0x00; + ram attribute colorLoopTime default = 0x0019; + ram attribute colorLoopStartEnhancedHue default = 0x2300; + ram attribute colorLoopStoredEnhancedHue default = 0x0000; + ram attribute colorCapabilities default = 0x1F; + ram attribute colorTempPhysicalMinMireds default = 0x0000; + ram attribute colorTempPhysicalMaxMireds default = 0xFEFF; + ram attribute coupleColorTempToLevelMinMireds; + ram attribute startUpColorTemperatureMireds; + ram attribute featureMap default = 0x1F; + ram attribute clusterRevision default = 6; + + handle command MoveToHue; + handle command MoveHue; + handle command StepHue; + handle command MoveToSaturation; + handle command MoveSaturation; + handle command StepSaturation; + handle command MoveToHueAndSaturation; + handle command MoveToColor; + handle command MoveColor; + handle command StepColor; + handle command MoveToColorTemperature; + handle command EnhancedMoveToHue; + handle command EnhancedMoveHue; + handle command EnhancedStepHue; + handle command EnhancedMoveToHueAndSaturation; + handle command ColorLoopSet; + handle command StopMoveStep; + handle command MoveColorTemperature; + handle command StepColorTemperature; + } +} + + diff --git a/examples/lighting-app/qcc74x/data_model/lighting-app-thread.zap b/examples/lighting-app/qcc74x/data_model/lighting-app-thread.zap new file mode 100644 index 00000000000000..1a410c2d751a7c --- /dev/null +++ b/examples/lighting-app/qcc74x/data_model/lighting-app-thread.zap @@ -0,0 +1,5305 @@ +{ + "fileFormat": 2, + "featureLevel": 99, + "creator": "zap", + "keyValuePairs": [ + { + "key": "commandDiscovery", + "value": "1" + }, + { + "key": "defaultResponsePolicy", + "value": "always" + }, + { + "key": "manufacturerCodes", + "value": "0x1002" + } + ], + "package": [ + { + "pathRelativity": "relativeToZap", + "path": "../../../../src/app/zap-templates/zcl/zcl.json", + "type": "zcl-properties", + "category": "matter", + "version": 1, + "description": "Matter SDK ZCL data" + }, + { + "pathRelativity": "relativeToZap", + "path": "../../../../src/app/zap-templates/app-templates.json", + "type": "gen-templates-json", + "version": "chip-v1" + } + ], + "endpointTypes": [ + { + "id": 1, + "name": "MA-rootdevice", + "deviceTypeRef": { + "code": 22, + "profileId": 259, + "label": "MA-rootdevice", + "name": "MA-rootdevice" + }, + "deviceTypes": [ + { + "code": 22, + "profileId": 259, + "label": "MA-rootdevice", + "name": "MA-rootdevice" + } + ], + "deviceVersions": [ + 1 + ], + "deviceIdentifiers": [ + 22 + ], + "deviceTypeName": "MA-rootdevice", + "deviceTypeCode": 22, + "deviceTypeProfileId": 259, + "clusters": [ + { + "name": "Descriptor", + "code": 29, + "mfgCode": null, + "define": "DESCRIPTOR_CLUSTER", + "side": "server", + "enabled": 1, + "attributes": [ + { + "name": "DeviceTypeList", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ServerList", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClientList", + "code": 2, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "PartsList", + "code": 3, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + } + ] + }, + { + "name": "Access Control", + "code": 31, + "mfgCode": null, + "define": "ACCESS_CONTROL_CLUSTER", + "side": "server", + "enabled": 1, + "attributes": [ + { + "name": "ACL", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "Extension", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "SubjectsPerAccessControlEntry", + "code": 2, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "TargetsPerAccessControlEntry", + "code": 3, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AccessControlEntriesPerFabric", + "code": 4, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AttributeList", + "code": 65531, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + } + ], + "events": [ + { + "name": "AccessControlEntryChanged", + "code": 0, + "mfgCode": null, + "side": "server", + "included": 1 + }, + { + "name": "AccessControlExtensionChanged", + "code": 1, + "mfgCode": null, + "side": "server", + "included": 1 + } + ] + }, + { + "name": "Basic Information", + "code": 40, + "mfgCode": null, + "define": "BASIC_INFORMATION_CLUSTER", + "side": "server", + "enabled": 1, + "attributes": [ + { + "name": "DataModelRevision", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "External", + "singleton": 1, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "VendorName", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "char_string", + "included": 1, + "storageOption": "External", + "singleton": 1, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "VendorID", + "code": 2, + "mfgCode": null, + "side": "server", + "type": "vendor_id", + "included": 1, + "storageOption": "External", + "singleton": 1, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ProductName", + "code": 3, + "mfgCode": null, + "side": "server", + "type": "char_string", + "included": 1, + "storageOption": "External", + "singleton": 1, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ProductID", + "code": 4, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "External", + "singleton": 1, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "NodeLabel", + "code": 5, + "mfgCode": null, + "side": "server", + "type": "char_string", + "included": 1, + "storageOption": "NVM", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "Location", + "code": 6, + "mfgCode": null, + "side": "server", + "type": "char_string", + "included": 1, + "storageOption": "External", + "singleton": 1, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "HardwareVersion", + "code": 7, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "External", + "singleton": 1, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "HardwareVersionString", + "code": 8, + "mfgCode": null, + "side": "server", + "type": "char_string", + "included": 1, + "storageOption": "External", + "singleton": 1, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "SoftwareVersion", + "code": 9, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 1, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "SoftwareVersionString", + "code": 10, + "mfgCode": null, + "side": "server", + "type": "char_string", + "included": 1, + "storageOption": "External", + "singleton": 1, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ManufacturingDate", + "code": 11, + "mfgCode": null, + "side": "server", + "type": "char_string", + "included": 1, + "storageOption": "External", + "singleton": 1, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "PartNumber", + "code": 12, + "mfgCode": null, + "side": "server", + "type": "char_string", + "included": 1, + "storageOption": "External", + "singleton": 1, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ProductURL", + "code": 13, + "mfgCode": null, + "side": "server", + "type": "long_char_string", + "included": 1, + "storageOption": "External", + "singleton": 1, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ProductLabel", + "code": 14, + "mfgCode": null, + "side": "server", + "type": "char_string", + "included": 1, + "storageOption": "External", + "singleton": 1, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "SerialNumber", + "code": 15, + "mfgCode": null, + "side": "server", + "type": "char_string", + "included": 1, + "storageOption": "External", + "singleton": 1, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "LocalConfigDisabled", + "code": 16, + "mfgCode": null, + "side": "server", + "type": "boolean", + "included": 1, + "storageOption": "NVM", + "singleton": 1, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "UniqueID", + "code": 18, + "mfgCode": null, + "side": "server", + "type": "char_string", + "included": 1, + "storageOption": "External", + "singleton": 1, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "CapabilityMinima", + "code": 19, + "mfgCode": null, + "side": "server", + "type": "CapabilityMinimaStruct", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "SpecificationVersion", + "code": 21, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 1, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "MaxPathsPerInvoke", + "code": 22, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "External", + "singleton": 1, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "3", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ], + "events": [ + { + "name": "StartUp", + "code": 0, + "mfgCode": null, + "side": "server", + "included": 1 + }, + { + "name": "ShutDown", + "code": 1, + "mfgCode": null, + "side": "server", + "included": 1 + }, + { + "name": "Leave", + "code": 2, + "mfgCode": null, + "side": "server", + "included": 1 + } + ] + }, + { + "name": "OTA Software Update Provider", + "code": 41, + "mfgCode": null, + "define": "OTA_SOFTWARE_UPDATE_PROVIDER_CLUSTER", + "side": "client", + "enabled": 1, + "commands": [ + { + "name": "QueryImage", + "code": 0, + "mfgCode": null, + "source": "client", + "isIncoming": 0, + "isEnabled": 1 + }, + { + "name": "QueryImageResponse", + "code": 1, + "mfgCode": null, + "source": "server", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "ApplyUpdateRequest", + "code": 2, + "mfgCode": null, + "source": "client", + "isIncoming": 0, + "isEnabled": 1 + }, + { + "name": "ApplyUpdateResponse", + "code": 3, + "mfgCode": null, + "source": "server", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "NotifyUpdateApplied", + "code": 4, + "mfgCode": null, + "source": "client", + "isIncoming": 0, + "isEnabled": 1 + } + ], + "attributes": [ + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "client", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "OTA Software Update Requestor", + "code": 42, + "mfgCode": null, + "define": "OTA_SOFTWARE_UPDATE_REQUESTOR_CLUSTER", + "side": "server", + "enabled": 1, + "commands": [ + { + "name": "AnnounceOTAProvider", + "code": 0, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + } + ], + "attributes": [ + { + "name": "DefaultOTAProviders", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "UpdatePossible", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "boolean", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "UpdateState", + "code": 2, + "mfgCode": null, + "side": "server", + "type": "UpdateStateEnum", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "UpdateStateProgress", + "code": 3, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ], + "events": [ + { + "name": "StateTransition", + "code": 0, + "mfgCode": null, + "side": "server", + "included": 1 + }, + { + "name": "VersionApplied", + "code": 1, + "mfgCode": null, + "side": "server", + "included": 1 + }, + { + "name": "DownloadError", + "code": 2, + "mfgCode": null, + "side": "server", + "included": 1 + } + ] + }, + { + "name": "Localization Configuration", + "code": 43, + "mfgCode": null, + "define": "LOCALIZATION_CONFIGURATION_CLUSTER", + "side": "server", + "enabled": 1, + "attributes": [ + { + "name": "ActiveLocale", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "char_string", + "included": 1, + "storageOption": "NVM", + "singleton": 0, + "bounded": 0, + "defaultValue": "en-US", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "SupportedLocales", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + } + ] + }, + { + "name": "Time Format Localization", + "code": 44, + "mfgCode": null, + "define": "TIME_FORMAT_LOCALIZATION_CLUSTER", + "side": "server", + "enabled": 1, + "attributes": [ + { + "name": "HourFormat", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "HourFormatEnum", + "included": 1, + "storageOption": "NVM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ActiveCalendarType", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "CalendarTypeEnum", + "included": 1, + "storageOption": "NVM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "SupportedCalendarTypes", + "code": 2, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + } + ] + }, + { + "name": "General Commissioning", + "code": 48, + "mfgCode": null, + "define": "GENERAL_COMMISSIONING_CLUSTER", + "side": "server", + "enabled": 1, + "commands": [ + { + "name": "ArmFailSafe", + "code": 0, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "ArmFailSafeResponse", + "code": 1, + "mfgCode": null, + "source": "server", + "isIncoming": 0, + "isEnabled": 1 + }, + { + "name": "SetRegulatoryConfig", + "code": 2, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "SetRegulatoryConfigResponse", + "code": 3, + "mfgCode": null, + "source": "server", + "isIncoming": 0, + "isEnabled": 1 + }, + { + "name": "CommissioningComplete", + "code": 4, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "CommissioningCompleteResponse", + "code": 5, + "mfgCode": null, + "source": "server", + "isIncoming": 0, + "isEnabled": 1 + } + ], + "attributes": [ + { + "name": "Breadcrumb", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "int64u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000000000000000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "BasicCommissioningInfo", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "BasicCommissioningInfo", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "RegulatoryConfig", + "code": 2, + "mfgCode": null, + "side": "server", + "type": "RegulatoryLocationTypeEnum", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "LocationCapability", + "code": 3, + "mfgCode": null, + "side": "server", + "type": "RegulatoryLocationTypeEnum", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "SupportsConcurrentConnection", + "code": 4, + "mfgCode": null, + "side": "server", + "type": "boolean", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "Network Commissioning", + "code": 49, + "mfgCode": null, + "define": "NETWORK_COMMISSIONING_CLUSTER", + "side": "server", + "enabled": 1, + "commands": [ + { + "name": "ScanNetworks", + "code": 0, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "ScanNetworksResponse", + "code": 1, + "mfgCode": null, + "source": "server", + "isIncoming": 0, + "isEnabled": 1 + }, + { + "name": "AddOrUpdateWiFiNetwork", + "code": 2, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "AddOrUpdateThreadNetwork", + "code": 3, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "RemoveNetwork", + "code": 4, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "NetworkConfigResponse", + "code": 5, + "mfgCode": null, + "source": "server", + "isIncoming": 0, + "isEnabled": 1 + }, + { + "name": "ConnectNetwork", + "code": 6, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "ConnectNetworkResponse", + "code": 7, + "mfgCode": null, + "source": "server", + "isIncoming": 0, + "isEnabled": 1 + }, + { + "name": "ReorderNetwork", + "code": 8, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + } + ], + "attributes": [ + { + "name": "MaxNetworks", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "Networks", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ScanMaxTimeSeconds", + "code": 2, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ConnectMaxTimeSeconds", + "code": 3, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "InterfaceEnabled", + "code": 4, + "mfgCode": null, + "side": "server", + "type": "boolean", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "LastNetworkingStatus", + "code": 5, + "mfgCode": null, + "side": "server", + "type": "NetworkCommissioningStatusEnum", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "LastNetworkID", + "code": 6, + "mfgCode": null, + "side": "server", + "type": "octet_string", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "LastConnectErrorValue", + "code": 7, + "mfgCode": null, + "side": "server", + "type": "int32s", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "2", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "Diagnostic Logs", + "code": 50, + "mfgCode": null, + "define": "DIAGNOSTIC_LOGS_CLUSTER", + "side": "server", + "enabled": 1, + "commands": [ + { + "name": "RetrieveLogsRequest", + "code": 0, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + } + ], + "attributes": [ + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + } + ] + }, + { + "name": "General Diagnostics", + "code": 51, + "mfgCode": null, + "define": "GENERAL_DIAGNOSTICS_CLUSTER", + "side": "server", + "enabled": 1, + "commands": [ + { + "name": "TestEventTrigger", + "code": 0, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "TimeSnapshot", + "code": 1, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "TimeSnapshotResponse", + "code": 2, + "mfgCode": null, + "source": "server", + "isIncoming": 0, + "isEnabled": 1 + } + ], + "attributes": [ + { + "name": "NetworkInterfaces", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "RebootCount", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "UpTime", + "code": 2, + "mfgCode": null, + "side": "server", + "type": "int64u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "TotalOperationalHours", + "code": 3, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "BootReason", + "code": 4, + "mfgCode": null, + "side": "server", + "type": "BootReasonEnum", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ActiveHardwareFaults", + "code": 5, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ActiveRadioFaults", + "code": 6, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ActiveNetworkFaults", + "code": 7, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "TestEventTriggersEnabled", + "code": 8, + "mfgCode": null, + "side": "server", + "type": "boolean", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "false", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0002", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ], + "events": [ + { + "name": "HardwareFaultChange", + "code": 0, + "mfgCode": null, + "side": "server", + "included": 1 + }, + { + "name": "RadioFaultChange", + "code": 1, + "mfgCode": null, + "side": "server", + "included": 1 + }, + { + "name": "NetworkFaultChange", + "code": 2, + "mfgCode": null, + "side": "server", + "included": 1 + }, + { + "name": "BootReason", + "code": 3, + "mfgCode": null, + "side": "server", + "included": 1 + } + ] + }, + { + "name": "Software Diagnostics", + "code": 52, + "mfgCode": null, + "define": "SOFTWARE_DIAGNOSTICS_CLUSTER", + "side": "server", + "enabled": 1, + "commands": [ + { + "name": "ResetWatermarks", + "code": 0, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + } + ], + "attributes": [ + { + "name": "ThreadMetrics", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "CurrentHeapFree", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "int64u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "CurrentHeapUsed", + "code": 2, + "mfgCode": null, + "side": "server", + "type": "int64u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "CurrentHeapHighWatermark", + "code": 3, + "mfgCode": null, + "side": "server", + "type": "int64u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "Thread Network Diagnostics", + "code": 53, + "mfgCode": null, + "define": "THREAD_NETWORK_DIAGNOSTICS_CLUSTER", + "side": "server", + "enabled": 1, + "attributes": [ + { + "name": "Channel", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "RoutingRole", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "RoutingRoleEnum", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "NetworkName", + "code": 2, + "mfgCode": null, + "side": "server", + "type": "char_string", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "PanId", + "code": 3, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ExtendedPanId", + "code": 4, + "mfgCode": null, + "side": "server", + "type": "int64u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "MeshLocalPrefix", + "code": 5, + "mfgCode": null, + "side": "server", + "type": "octet_string", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "OverrunCount", + "code": 6, + "mfgCode": null, + "side": "server", + "type": "int64u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "NeighborTable", + "code": 7, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "RouteTable", + "code": 8, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "PartitionId", + "code": 9, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "Weighting", + "code": 10, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "DataVersion", + "code": 11, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "StableDataVersion", + "code": 12, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "LeaderRouterId", + "code": 13, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "DetachedRoleCount", + "code": 14, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ChildRoleCount", + "code": 15, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "RouterRoleCount", + "code": 16, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "LeaderRoleCount", + "code": 17, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "AttachAttemptCount", + "code": 18, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "PartitionIdChangeCount", + "code": 19, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "BetterPartitionAttachAttemptCount", + "code": 20, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ParentChangeCount", + "code": 21, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "TxTotalCount", + "code": 22, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "TxUnicastCount", + "code": 23, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "TxBroadcastCount", + "code": 24, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "TxAckRequestedCount", + "code": 25, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "TxAckedCount", + "code": 26, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "TxNoAckRequestedCount", + "code": 27, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "TxDataCount", + "code": 28, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "TxDataPollCount", + "code": 29, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "TxBeaconCount", + "code": 30, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "TxBeaconRequestCount", + "code": 31, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "TxOtherCount", + "code": 32, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "TxRetryCount", + "code": 33, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "TxDirectMaxRetryExpiryCount", + "code": 34, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "TxIndirectMaxRetryExpiryCount", + "code": 35, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "TxErrCcaCount", + "code": 36, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "TxErrAbortCount", + "code": 37, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "TxErrBusyChannelCount", + "code": 38, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "RxTotalCount", + "code": 39, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "RxUnicastCount", + "code": 40, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "RxBroadcastCount", + "code": 41, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "RxDataCount", + "code": 42, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "RxDataPollCount", + "code": 43, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "RxBeaconCount", + "code": 44, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "RxBeaconRequestCount", + "code": 45, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "RxOtherCount", + "code": 46, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "RxAddressFilteredCount", + "code": 47, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "RxDestAddrFilteredCount", + "code": 48, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "RxDuplicatedCount", + "code": 49, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "RxErrNoFrameCount", + "code": 50, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "RxErrUnknownNeighborCount", + "code": 51, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "RxErrInvalidSrcAddrCount", + "code": 52, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "RxErrSecCount", + "code": 53, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "RxErrFcsCount", + "code": 54, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "RxErrOtherCount", + "code": 55, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ActiveTimestamp", + "code": 56, + "mfgCode": null, + "side": "server", + "type": "int64u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "PendingTimestamp", + "code": 57, + "mfgCode": null, + "side": "server", + "type": "int64u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "Delay", + "code": 58, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "SecurityPolicy", + "code": 59, + "mfgCode": null, + "side": "server", + "type": "SecurityPolicy", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ChannelPage0Mask", + "code": 60, + "mfgCode": null, + "side": "server", + "type": "octet_string", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "OperationalDatasetComponents", + "code": 61, + "mfgCode": null, + "side": "server", + "type": "OperationalDatasetComponents", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ActiveNetworkFaultsList", + "code": 62, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x000F", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "Administrator Commissioning", + "code": 60, + "mfgCode": null, + "define": "ADMINISTRATOR_COMMISSIONING_CLUSTER", + "side": "server", + "enabled": 1, + "commands": [ + { + "name": "OpenCommissioningWindow", + "code": 0, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "OpenBasicCommissioningWindow", + "code": 1, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "RevokeCommissioning", + "code": 2, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + } + ], + "attributes": [ + { + "name": "WindowStatus", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "CommissioningWindowStatusEnum", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AdminFabricIndex", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "fabric_idx", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AdminVendorId", + "code": 2, + "mfgCode": null, + "side": "server", + "type": "vendor_id", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "Operational Credentials", + "code": 62, + "mfgCode": null, + "define": "OPERATIONAL_CREDENTIALS_CLUSTER", + "side": "server", + "enabled": 1, + "commands": [ + { + "name": "AttestationRequest", + "code": 0, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "AttestationResponse", + "code": 1, + "mfgCode": null, + "source": "server", + "isIncoming": 0, + "isEnabled": 1 + }, + { + "name": "CertificateChainRequest", + "code": 2, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "CertificateChainResponse", + "code": 3, + "mfgCode": null, + "source": "server", + "isIncoming": 0, + "isEnabled": 1 + }, + { + "name": "CSRRequest", + "code": 4, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "CSRResponse", + "code": 5, + "mfgCode": null, + "source": "server", + "isIncoming": 0, + "isEnabled": 1 + }, + { + "name": "AddNOC", + "code": 6, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "UpdateNOC", + "code": 7, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "NOCResponse", + "code": 8, + "mfgCode": null, + "source": "server", + "isIncoming": 0, + "isEnabled": 1 + }, + { + "name": "UpdateFabricLabel", + "code": 9, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "RemoveFabric", + "code": 10, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "AddTrustedRootCertificate", + "code": 11, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + } + ], + "attributes": [ + { + "name": "NOCs", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "Fabrics", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "SupportedFabrics", + "code": 2, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "CommissionedFabrics", + "code": 3, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "TrustedRootCertificates", + "code": 4, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "CurrentFabricIndex", + "code": 5, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "Group Key Management", + "code": 63, + "mfgCode": null, + "define": "GROUP_KEY_MANAGEMENT_CLUSTER", + "side": "server", + "enabled": 1, + "commands": [ + { + "name": "KeySetWrite", + "code": 0, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "KeySetRead", + "code": 1, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "KeySetReadResponse", + "code": 2, + "mfgCode": null, + "source": "server", + "isIncoming": 0, + "isEnabled": 1 + }, + { + "name": "KeySetRemove", + "code": 3, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "KeySetReadAllIndices", + "code": 4, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "KeySetReadAllIndicesResponse", + "code": 5, + "mfgCode": null, + "source": "server", + "isIncoming": 0, + "isEnabled": 1 + } + ], + "attributes": [ + { + "name": "GroupKeyMap", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "GroupTable", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "MaxGroupsPerFabric", + "code": 2, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "MaxGroupKeysPerFabric", + "code": 3, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + } + ] + }, + { + "name": "Fixed Label", + "code": 64, + "mfgCode": null, + "define": "FIXED_LABEL_CLUSTER", + "side": "server", + "enabled": 1, + "attributes": [ + { + "name": "LabelList", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + } + ] + }, + { + "name": "User Label", + "code": 65, + "mfgCode": null, + "define": "USER_LABEL_CLUSTER", + "side": "server", + "enabled": 1, + "attributes": [ + { + "name": "LabelList", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + } + ] + } + ] + }, + { + "id": 2, + "name": "MA-extendedcolorlight", + "deviceTypeRef": { + "code": 269, + "profileId": 259, + "label": "MA-extendedcolorlight", + "name": "MA-extendedcolorlight" + }, + "deviceTypes": [ + { + "code": 269, + "profileId": 259, + "label": "MA-extendedcolorlight", + "name": "MA-extendedcolorlight" + } + ], + "deviceVersions": [ + 1 + ], + "deviceIdentifiers": [ + 269 + ], + "deviceTypeName": "MA-extendedcolorlight", + "deviceTypeCode": 269, + "deviceTypeProfileId": 259, + "clusters": [ + { + "name": "Identify", + "code": 3, + "mfgCode": null, + "define": "IDENTIFY_CLUSTER", + "side": "server", + "enabled": 1, + "commands": [ + { + "name": "Identify", + "code": 0, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "TriggerEffect", + "code": 64, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + } + ], + "attributes": [ + { + "name": "IdentifyTime", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "IdentifyType", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "IdentifyTypeEnum", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "4", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "Groups", + "code": 4, + "mfgCode": null, + "define": "GROUPS_CLUSTER", + "side": "server", + "enabled": 1, + "commands": [ + { + "name": "AddGroup", + "code": 0, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "AddGroupResponse", + "code": 0, + "mfgCode": null, + "source": "server", + "isIncoming": 0, + "isEnabled": 1 + }, + { + "name": "ViewGroup", + "code": 1, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "ViewGroupResponse", + "code": 1, + "mfgCode": null, + "source": "server", + "isIncoming": 0, + "isEnabled": 1 + }, + { + "name": "GetGroupMembership", + "code": 2, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "GetGroupMembershipResponse", + "code": 2, + "mfgCode": null, + "source": "server", + "isIncoming": 0, + "isEnabled": 1 + }, + { + "name": "RemoveGroup", + "code": 3, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "RemoveGroupResponse", + "code": 3, + "mfgCode": null, + "source": "server", + "isIncoming": 0, + "isEnabled": 1 + }, + { + "name": "RemoveAllGroups", + "code": 4, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "AddGroupIfIdentifying", + "code": 5, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + } + ], + "attributes": [ + { + "name": "NameSupport", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "NameSupportBitmap", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "4", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "On/Off", + "code": 6, + "mfgCode": null, + "define": "ON_OFF_CLUSTER", + "side": "server", + "enabled": 1, + "commands": [ + { + "name": "Off", + "code": 0, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "On", + "code": 1, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "Toggle", + "code": 2, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "OffWithEffect", + "code": 64, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "OnWithRecallGlobalScene", + "code": 65, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "OnWithTimedOff", + "code": 66, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + } + ], + "attributes": [ + { + "name": "OnOff", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "boolean", + "included": 1, + "storageOption": "NVM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x01", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "GlobalSceneControl", + "code": 16384, + "mfgCode": null, + "side": "server", + "type": "boolean", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x01", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "OnTime", + "code": 16385, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "OffWaitTime", + "code": 16386, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "StartUpOnOff", + "code": 16387, + "mfgCode": null, + "side": "server", + "type": "StartUpOnOffEnum", + "included": 1, + "storageOption": "NVM", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "5", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "Level Control", + "code": 8, + "mfgCode": null, + "define": "LEVEL_CONTROL_CLUSTER", + "side": "server", + "enabled": 1, + "commands": [ + { + "name": "MoveToLevel", + "code": 0, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "Move", + "code": 1, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "Step", + "code": 2, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "Stop", + "code": 3, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "MoveToLevelWithOnOff", + "code": 4, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "MoveWithOnOff", + "code": 5, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "StepWithOnOff", + "code": 6, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "StopWithOnOff", + "code": 7, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + } + ], + "attributes": [ + { + "name": "CurrentLevel", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "NVM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x254", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "RemainingTime", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "MinLevel", + "code": 2, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x01", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "MaxLevel", + "code": 3, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0xFE", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "CurrentFrequency", + "code": 4, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "MinFrequency", + "code": 5, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "MaxFrequency", + "code": 6, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "Options", + "code": 15, + "mfgCode": null, + "side": "server", + "type": "OptionsBitmap", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x00", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "OnOffTransitionTime", + "code": 16, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "OnLevel", + "code": 17, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "OnTransitionTime", + "code": 18, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "OffTransitionTime", + "code": 19, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "DefaultMoveRate", + "code": 20, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "50", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "StartUpCurrentLevel", + "code": 16384, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "NVM", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "3", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "5", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "Descriptor", + "code": 29, + "mfgCode": null, + "define": "DESCRIPTOR_CLUSTER", + "side": "server", + "enabled": 1, + "attributes": [ + { + "name": "DeviceTypeList", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ServerList", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClientList", + "code": 2, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "PartsList", + "code": 3, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + } + ] + }, + { + "name": "Color Control", + "code": 768, + "mfgCode": null, + "define": "COLOR_CONTROL_CLUSTER", + "side": "server", + "enabled": 1, + "commands": [ + { + "name": "MoveToHue", + "code": 0, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "MoveHue", + "code": 1, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "StepHue", + "code": 2, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "MoveToSaturation", + "code": 3, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "MoveSaturation", + "code": 4, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "StepSaturation", + "code": 5, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "MoveToHueAndSaturation", + "code": 6, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "MoveToColor", + "code": 7, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "MoveColor", + "code": 8, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "StepColor", + "code": 9, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "MoveToColorTemperature", + "code": 10, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "EnhancedMoveToHue", + "code": 64, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "EnhancedMoveHue", + "code": 65, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "EnhancedStepHue", + "code": 66, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "EnhancedMoveToHueAndSaturation", + "code": 67, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "ColorLoopSet", + "code": 68, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "StopMoveStep", + "code": 71, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "MoveColorTemperature", + "code": 75, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "StepColorTemperature", + "code": 76, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + } + ], + "attributes": [ + { + "name": "CurrentHue", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x00", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "CurrentSaturation", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x00", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "RemainingTime", + "code": 2, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "CurrentX", + "code": 3, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x616B", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "CurrentY", + "code": 4, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x607D", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ColorTemperatureMireds", + "code": 7, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x00FA", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ColorMode", + "code": 8, + "mfgCode": null, + "side": "server", + "type": "enum8", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x01", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "Options", + "code": 15, + "mfgCode": null, + "side": "server", + "type": "bitmap8", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x00", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "NumberOfPrimaries", + "code": 16, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "Primary1X", + "code": 17, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "Primary1Y", + "code": 18, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "Primary1Intensity", + "code": 19, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "Primary2X", + "code": 21, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "Primary2Y", + "code": 22, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "Primary2Intensity", + "code": 23, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "Primary3X", + "code": 25, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "Primary3Y", + "code": 26, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "Primary3Intensity", + "code": 27, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "Primary4X", + "code": 32, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "Primary4Y", + "code": 33, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "Primary4Intensity", + "code": 34, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "Primary5X", + "code": 36, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "Primary5Y", + "code": 37, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "Primary5Intensity", + "code": 38, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "Primary6X", + "code": 40, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "Primary6Y", + "code": 41, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "Primary6Intensity", + "code": 42, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "EnhancedCurrentHue", + "code": 16384, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "EnhancedColorMode", + "code": 16385, + "mfgCode": null, + "side": "server", + "type": "enum8", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x01", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ColorLoopActive", + "code": 16386, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x00", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ColorLoopDirection", + "code": 16387, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x00", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ColorLoopTime", + "code": 16388, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0019", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ColorLoopStartEnhancedHue", + "code": 16389, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x2300", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ColorLoopStoredEnhancedHue", + "code": 16390, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ColorCapabilities", + "code": 16394, + "mfgCode": null, + "side": "server", + "type": "bitmap16", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x1F", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ColorTempPhysicalMinMireds", + "code": 16395, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ColorTempPhysicalMaxMireds", + "code": 16396, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0xFEFF", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "CoupleColorTempToLevelMinMireds", + "code": 16397, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "StartUpColorTemperatureMireds", + "code": 16400, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x1F", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "6", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + } + ] + } + ], + "endpoints": [ + { + "endpointTypeName": "MA-rootdevice", + "endpointTypeIndex": 0, + "profileId": 259, + "endpointId": 0, + "networkId": 0 + }, + { + "endpointTypeName": "MA-extendedcolorlight", + "endpointTypeIndex": 1, + "profileId": 259, + "endpointId": 1, + "networkId": 0 + } + ] +} \ No newline at end of file diff --git a/examples/lighting-app/qcc74x/data_model/lighting-app-wifi.matter b/examples/lighting-app/qcc74x/data_model/lighting-app-wifi.matter new file mode 100644 index 00000000000000..4bc07365ff7564 --- /dev/null +++ b/examples/lighting-app/qcc74x/data_model/lighting-app-wifi.matter @@ -0,0 +1,2299 @@ +// This IDL was generated automatically by ZAP. +// It is for view/code review purposes only. + +/** Attributes and commands for putting a device into Identification mode (e.g. flashing a light). */ +cluster Identify = 3 { + revision 4; + + enum EffectIdentifierEnum : enum8 { + kBlink = 0; + kBreathe = 1; + kOkay = 2; + kChannelChange = 11; + kFinishEffect = 254; + kStopEffect = 255; + } + + enum EffectVariantEnum : enum8 { + kDefault = 0; + } + + enum IdentifyTypeEnum : enum8 { + kNone = 0; + kLightOutput = 1; + kVisibleIndicator = 2; + kAudibleBeep = 3; + kDisplay = 4; + kActuator = 5; + } + + attribute int16u identifyTime = 0; + readonly attribute IdentifyTypeEnum identifyType = 1; + readonly attribute command_id generatedCommandList[] = 65528; + readonly attribute command_id acceptedCommandList[] = 65529; + readonly attribute event_id eventList[] = 65530; + readonly attribute attrib_id attributeList[] = 65531; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; + + request struct IdentifyRequest { + int16u identifyTime = 0; + } + + request struct TriggerEffectRequest { + EffectIdentifierEnum effectIdentifier = 0; + EffectVariantEnum effectVariant = 1; + } + + /** Command description for Identify */ + command access(invoke: manage) Identify(IdentifyRequest): DefaultSuccess = 0; + /** Command description for TriggerEffect */ + command access(invoke: manage) TriggerEffect(TriggerEffectRequest): DefaultSuccess = 64; +} + +/** Attributes and commands for group configuration and manipulation. */ +cluster Groups = 4 { + revision 4; + + bitmap Feature : bitmap32 { + kGroupNames = 0x1; + } + + bitmap NameSupportBitmap : bitmap8 { + kGroupNames = 0x80; + } + + readonly attribute NameSupportBitmap nameSupport = 0; + readonly attribute command_id generatedCommandList[] = 65528; + readonly attribute command_id acceptedCommandList[] = 65529; + readonly attribute event_id eventList[] = 65530; + readonly attribute attrib_id attributeList[] = 65531; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; + + request struct AddGroupRequest { + group_id groupID = 0; + char_string<16> groupName = 1; + } + + response struct AddGroupResponse = 0 { + enum8 status = 0; + group_id groupID = 1; + } + + request struct ViewGroupRequest { + group_id groupID = 0; + } + + response struct ViewGroupResponse = 1 { + enum8 status = 0; + group_id groupID = 1; + char_string<16> groupName = 2; + } + + request struct GetGroupMembershipRequest { + group_id groupList[] = 0; + } + + response struct GetGroupMembershipResponse = 2 { + nullable int8u capacity = 0; + group_id groupList[] = 1; + } + + request struct RemoveGroupRequest { + group_id groupID = 0; + } + + response struct RemoveGroupResponse = 3 { + enum8 status = 0; + group_id groupID = 1; + } + + request struct AddGroupIfIdentifyingRequest { + group_id groupID = 0; + char_string<16> groupName = 1; + } + + /** Command description for AddGroup */ + fabric command access(invoke: manage) AddGroup(AddGroupRequest): AddGroupResponse = 0; + /** Command description for ViewGroup */ + fabric command ViewGroup(ViewGroupRequest): ViewGroupResponse = 1; + /** Command description for GetGroupMembership */ + fabric command GetGroupMembership(GetGroupMembershipRequest): GetGroupMembershipResponse = 2; + /** Command description for RemoveGroup */ + fabric command access(invoke: manage) RemoveGroup(RemoveGroupRequest): RemoveGroupResponse = 3; + /** Command description for RemoveAllGroups */ + fabric command access(invoke: manage) RemoveAllGroups(): DefaultSuccess = 4; + /** Command description for AddGroupIfIdentifying */ + fabric command access(invoke: manage) AddGroupIfIdentifying(AddGroupIfIdentifyingRequest): DefaultSuccess = 5; +} + +/** Attributes and commands for switching devices between 'On' and 'Off' states. */ +cluster OnOff = 6 { + revision 6; + + enum DelayedAllOffEffectVariantEnum : enum8 { + kDelayedOffFastFade = 0; + kNoFade = 1; + kDelayedOffSlowFade = 2; + } + + enum DyingLightEffectVariantEnum : enum8 { + kDyingLightFadeOff = 0; + } + + enum EffectIdentifierEnum : enum8 { + kDelayedAllOff = 0; + kDyingLight = 1; + } + + enum StartUpOnOffEnum : enum8 { + kOff = 0; + kOn = 1; + kToggle = 2; + } + + bitmap Feature : bitmap32 { + kLighting = 0x1; + kDeadFrontBehavior = 0x2; + kOffOnly = 0x4; + } + + bitmap OnOffControlBitmap : bitmap8 { + kAcceptOnlyWhenOn = 0x1; + } + + readonly attribute boolean onOff = 0; + readonly attribute optional boolean globalSceneControl = 16384; + attribute optional int16u onTime = 16385; + attribute optional int16u offWaitTime = 16386; + attribute access(write: manage) optional nullable StartUpOnOffEnum startUpOnOff = 16387; + readonly attribute command_id generatedCommandList[] = 65528; + readonly attribute command_id acceptedCommandList[] = 65529; + readonly attribute event_id eventList[] = 65530; + readonly attribute attrib_id attributeList[] = 65531; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; + + request struct OffWithEffectRequest { + EffectIdentifierEnum effectIdentifier = 0; + enum8 effectVariant = 1; + } + + request struct OnWithTimedOffRequest { + OnOffControlBitmap onOffControl = 0; + int16u onTime = 1; + int16u offWaitTime = 2; + } + + /** On receipt of this command, a device SHALL enter its ‘Off’ state. This state is device dependent, but it is recommended that it is used for power off or similar functions. On receipt of the Off command, the OnTime attribute SHALL be set to 0. */ + command Off(): DefaultSuccess = 0; + /** On receipt of this command, a device SHALL enter its ‘On’ state. This state is device dependent, but it is recommended that it is used for power on or similar functions. On receipt of the On command, if the value of the OnTime attribute is equal to 0, the device SHALL set the OffWaitTime attribute to 0. */ + command On(): DefaultSuccess = 1; + /** On receipt of this command, if a device is in its ‘Off’ state it SHALL enter its ‘On’ state. Otherwise, if it is in its ‘On’ state it SHALL enter its ‘Off’ state. On receipt of the Toggle command, if the value of the OnOff attribute is equal to FALSE and if the value of the OnTime attribute is equal to 0, the device SHALL set the OffWaitTime attribute to 0. If the value of the OnOff attribute is equal to TRUE, the OnTime attribute SHALL be set to 0. */ + command Toggle(): DefaultSuccess = 2; + /** The OffWithEffect command allows devices to be turned off using enhanced ways of fading. */ + command OffWithEffect(OffWithEffectRequest): DefaultSuccess = 64; + /** The OnWithRecallGlobalScene command allows the recall of the settings when the device was turned off. */ + command OnWithRecallGlobalScene(): DefaultSuccess = 65; + /** The OnWithTimedOff command allows devices to be turned on for a specific duration with a guarded off duration so that SHOULD the device be subsequently switched off, further OnWithTimedOff commands, received during this time, are prevented from turning the devices back on. */ + command OnWithTimedOff(OnWithTimedOffRequest): DefaultSuccess = 66; +} + +/** Attributes and commands for controlling devices that can be set to a level between fully 'On' and fully 'Off.' */ +cluster LevelControl = 8 { + revision 5; + + enum MoveModeEnum : enum8 { + kUp = 0; + kDown = 1; + } + + enum StepModeEnum : enum8 { + kUp = 0; + kDown = 1; + } + + bitmap Feature : bitmap32 { + kOnOff = 0x1; + kLighting = 0x2; + kFrequency = 0x4; + } + + bitmap OptionsBitmap : bitmap8 { + kExecuteIfOff = 0x1; + kCoupleColorTempToLevel = 0x2; + } + + readonly attribute nullable int8u currentLevel = 0; + readonly attribute optional int16u remainingTime = 1; + readonly attribute optional int8u minLevel = 2; + readonly attribute optional int8u maxLevel = 3; + readonly attribute optional int16u currentFrequency = 4; + readonly attribute optional int16u minFrequency = 5; + readonly attribute optional int16u maxFrequency = 6; + attribute OptionsBitmap options = 15; + attribute optional int16u onOffTransitionTime = 16; + attribute nullable int8u onLevel = 17; + attribute optional nullable int16u onTransitionTime = 18; + attribute optional nullable int16u offTransitionTime = 19; + attribute optional nullable int8u defaultMoveRate = 20; + attribute access(write: manage) optional nullable int8u startUpCurrentLevel = 16384; + readonly attribute command_id generatedCommandList[] = 65528; + readonly attribute command_id acceptedCommandList[] = 65529; + readonly attribute event_id eventList[] = 65530; + readonly attribute attrib_id attributeList[] = 65531; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; + + request struct MoveToLevelRequest { + int8u level = 0; + nullable int16u transitionTime = 1; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; + } + + request struct MoveRequest { + MoveModeEnum moveMode = 0; + nullable int8u rate = 1; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; + } + + request struct StepRequest { + StepModeEnum stepMode = 0; + int8u stepSize = 1; + nullable int16u transitionTime = 2; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; + } + + request struct StopRequest { + OptionsBitmap optionsMask = 0; + OptionsBitmap optionsOverride = 1; + } + + request struct MoveToLevelWithOnOffRequest { + int8u level = 0; + nullable int16u transitionTime = 1; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; + } + + request struct MoveWithOnOffRequest { + MoveModeEnum moveMode = 0; + nullable int8u rate = 1; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; + } + + request struct StepWithOnOffRequest { + StepModeEnum stepMode = 0; + int8u stepSize = 1; + nullable int16u transitionTime = 2; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; + } + + request struct StopWithOnOffRequest { + OptionsBitmap optionsMask = 0; + OptionsBitmap optionsOverride = 1; + } + + request struct MoveToClosestFrequencyRequest { + int16u frequency = 0; + } + + /** Command description for MoveToLevel */ + command MoveToLevel(MoveToLevelRequest): DefaultSuccess = 0; + /** Command description for Move */ + command Move(MoveRequest): DefaultSuccess = 1; + /** Command description for Step */ + command Step(StepRequest): DefaultSuccess = 2; + /** Command description for Stop */ + command Stop(StopRequest): DefaultSuccess = 3; + /** Command description for MoveToLevelWithOnOff */ + command MoveToLevelWithOnOff(MoveToLevelWithOnOffRequest): DefaultSuccess = 4; + /** Command description for MoveWithOnOff */ + command MoveWithOnOff(MoveWithOnOffRequest): DefaultSuccess = 5; + /** Command description for StepWithOnOff */ + command StepWithOnOff(StepWithOnOffRequest): DefaultSuccess = 6; + /** Command description for StopWithOnOff */ + command StopWithOnOff(StopWithOnOffRequest): DefaultSuccess = 7; + /** Change the currrent frequency to the provided one, or a close + approximation if the exact provided one is not possible. */ + command MoveToClosestFrequency(MoveToClosestFrequencyRequest): DefaultSuccess = 8; +} + +/** The Descriptor Cluster is meant to replace the support from the Zigbee Device Object (ZDO) for describing a node, its endpoints and clusters. */ +cluster Descriptor = 29 { + revision 2; + + bitmap Feature : bitmap32 { + kTagList = 0x1; + } + + struct DeviceTypeStruct { + devtype_id deviceType = 0; + int16u revision = 1; + } + + struct SemanticTagStruct { + nullable vendor_id mfgCode = 0; + enum8 namespaceID = 1; + enum8 tag = 2; + optional nullable char_string label = 3; + } + + readonly attribute DeviceTypeStruct deviceTypeList[] = 0; + readonly attribute cluster_id serverList[] = 1; + readonly attribute cluster_id clientList[] = 2; + readonly attribute endpoint_no partsList[] = 3; + readonly attribute optional SemanticTagStruct tagList[] = 4; + readonly attribute command_id generatedCommandList[] = 65528; + readonly attribute command_id acceptedCommandList[] = 65529; + readonly attribute event_id eventList[] = 65530; + readonly attribute attrib_id attributeList[] = 65531; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; +} + +/** The Access Control Cluster exposes a data model view of a + Node's Access Control List (ACL), which codifies the rules used to manage + and enforce Access Control for the Node's endpoints and their associated + cluster instances. */ +cluster AccessControl = 31 { + revision 1; // NOTE: Default/not specifically set + + enum AccessControlEntryAuthModeEnum : enum8 { + kPASE = 1; + kCASE = 2; + kGroup = 3; + } + + enum AccessControlEntryPrivilegeEnum : enum8 { + kView = 1; + kProxyView = 2; + kOperate = 3; + kManage = 4; + kAdminister = 5; + } + + enum ChangeTypeEnum : enum8 { + kChanged = 0; + kAdded = 1; + kRemoved = 2; + } + + struct AccessControlTargetStruct { + nullable cluster_id cluster = 0; + nullable endpoint_no endpoint = 1; + nullable devtype_id deviceType = 2; + } + + fabric_scoped struct AccessControlEntryStruct { + fabric_sensitive AccessControlEntryPrivilegeEnum privilege = 1; + fabric_sensitive AccessControlEntryAuthModeEnum authMode = 2; + nullable fabric_sensitive int64u subjects[] = 3; + nullable fabric_sensitive AccessControlTargetStruct targets[] = 4; + fabric_idx fabricIndex = 254; + } + + fabric_scoped struct AccessControlExtensionStruct { + fabric_sensitive octet_string<128> data = 1; + fabric_idx fabricIndex = 254; + } + + fabric_sensitive info event access(read: administer) AccessControlEntryChanged = 0 { + nullable node_id adminNodeID = 1; + nullable int16u adminPasscodeID = 2; + ChangeTypeEnum changeType = 3; + nullable AccessControlEntryStruct latestValue = 4; + fabric_idx fabricIndex = 254; + } + + fabric_sensitive info event access(read: administer) AccessControlExtensionChanged = 1 { + nullable node_id adminNodeID = 1; + nullable int16u adminPasscodeID = 2; + ChangeTypeEnum changeType = 3; + nullable AccessControlExtensionStruct latestValue = 4; + fabric_idx fabricIndex = 254; + } + + attribute access(read: administer, write: administer) AccessControlEntryStruct acl[] = 0; + attribute access(read: administer, write: administer) optional AccessControlExtensionStruct extension[] = 1; + readonly attribute int16u subjectsPerAccessControlEntry = 2; + readonly attribute int16u targetsPerAccessControlEntry = 3; + readonly attribute int16u accessControlEntriesPerFabric = 4; + readonly attribute command_id generatedCommandList[] = 65528; + readonly attribute command_id acceptedCommandList[] = 65529; + readonly attribute event_id eventList[] = 65530; + readonly attribute attrib_id attributeList[] = 65531; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; +} + +/** This cluster provides attributes and events for determining basic information about Nodes, which supports both + Commissioning and operational determination of Node characteristics, such as Vendor ID, Product ID and serial number, + which apply to the whole Node. Also allows setting user device information such as location. */ +cluster BasicInformation = 40 { + revision 3; + + enum ColorEnum : enum8 { + kBlack = 0; + kNavy = 1; + kGreen = 2; + kTeal = 3; + kMaroon = 4; + kPurple = 5; + kOlive = 6; + kGray = 7; + kBlue = 8; + kLime = 9; + kAqua = 10; + kRed = 11; + kFuchsia = 12; + kYellow = 13; + kWhite = 14; + kNickel = 15; + kChrome = 16; + kBrass = 17; + kCopper = 18; + kSilver = 19; + kGold = 20; + } + + enum ProductFinishEnum : enum8 { + kOther = 0; + kMatte = 1; + kSatin = 2; + kPolished = 3; + kRugged = 4; + kFabric = 5; + } + + struct CapabilityMinimaStruct { + int16u caseSessionsPerFabric = 0; + int16u subscriptionsPerFabric = 1; + } + + struct ProductAppearanceStruct { + ProductFinishEnum finish = 0; + nullable ColorEnum primaryColor = 1; + } + + critical event StartUp = 0 { + int32u softwareVersion = 0; + } + + critical event ShutDown = 1 { + } + + info event Leave = 2 { + fabric_idx fabricIndex = 0; + } + + info event ReachableChanged = 3 { + boolean reachableNewValue = 0; + } + + readonly attribute int16u dataModelRevision = 0; + readonly attribute char_string<32> vendorName = 1; + readonly attribute vendor_id vendorID = 2; + readonly attribute char_string<32> productName = 3; + readonly attribute int16u productID = 4; + attribute access(write: manage) char_string<32> nodeLabel = 5; + attribute access(write: administer) char_string<2> location = 6; + readonly attribute int16u hardwareVersion = 7; + readonly attribute char_string<64> hardwareVersionString = 8; + readonly attribute int32u softwareVersion = 9; + readonly attribute char_string<64> softwareVersionString = 10; + readonly attribute optional char_string<16> manufacturingDate = 11; + readonly attribute optional char_string<32> partNumber = 12; + readonly attribute optional long_char_string<256> productURL = 13; + readonly attribute optional char_string<64> productLabel = 14; + readonly attribute optional char_string<32> serialNumber = 15; + attribute access(write: manage) optional boolean localConfigDisabled = 16; + readonly attribute optional boolean reachable = 17; + readonly attribute optional char_string<32> uniqueID = 18; + readonly attribute CapabilityMinimaStruct capabilityMinima = 19; + readonly attribute optional ProductAppearanceStruct productAppearance = 20; + readonly attribute int32u specificationVersion = 21; + readonly attribute int16u maxPathsPerInvoke = 22; + readonly attribute command_id generatedCommandList[] = 65528; + readonly attribute command_id acceptedCommandList[] = 65529; + readonly attribute event_id eventList[] = 65530; + readonly attribute attrib_id attributeList[] = 65531; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; + + command MfgSpecificPing(): DefaultSuccess = 0; +} + +/** Provides an interface for providing OTA software updates */ +cluster OtaSoftwareUpdateProvider = 41 { + revision 1; // NOTE: Default/not specifically set + + enum ApplyUpdateActionEnum : enum8 { + kProceed = 0; + kAwaitNextAction = 1; + kDiscontinue = 2; + } + + enum DownloadProtocolEnum : enum8 { + kBDXSynchronous = 0; + kBDXAsynchronous = 1; + kHTTPS = 2; + kVendorSpecific = 3; + } + + enum StatusEnum : enum8 { + kUpdateAvailable = 0; + kBusy = 1; + kNotAvailable = 2; + kDownloadProtocolNotSupported = 3; + } + + readonly attribute command_id generatedCommandList[] = 65528; + readonly attribute command_id acceptedCommandList[] = 65529; + readonly attribute event_id eventList[] = 65530; + readonly attribute attrib_id attributeList[] = 65531; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; + + request struct QueryImageRequest { + vendor_id vendorID = 0; + int16u productID = 1; + int32u softwareVersion = 2; + DownloadProtocolEnum protocolsSupported[] = 3; + optional int16u hardwareVersion = 4; + optional char_string<2> location = 5; + optional boolean requestorCanConsent = 6; + optional octet_string<512> metadataForProvider = 7; + } + + response struct QueryImageResponse = 1 { + StatusEnum status = 0; + optional int32u delayedActionTime = 1; + optional char_string<256> imageURI = 2; + optional int32u softwareVersion = 3; + optional char_string<64> softwareVersionString = 4; + optional octet_string<32> updateToken = 5; + optional boolean userConsentNeeded = 6; + optional octet_string<512> metadataForRequestor = 7; + } + + request struct ApplyUpdateRequestRequest { + octet_string<32> updateToken = 0; + int32u newVersion = 1; + } + + response struct ApplyUpdateResponse = 3 { + ApplyUpdateActionEnum action = 0; + int32u delayedActionTime = 1; + } + + request struct NotifyUpdateAppliedRequest { + octet_string<32> updateToken = 0; + int32u softwareVersion = 1; + } + + /** Determine availability of a new Software Image */ + command QueryImage(QueryImageRequest): QueryImageResponse = 0; + /** Determine next action to take for a downloaded Software Image */ + command ApplyUpdateRequest(ApplyUpdateRequestRequest): ApplyUpdateResponse = 2; + /** Notify OTA Provider that an update was applied */ + command NotifyUpdateApplied(NotifyUpdateAppliedRequest): DefaultSuccess = 4; +} + +/** Provides an interface for downloading and applying OTA software updates */ +cluster OtaSoftwareUpdateRequestor = 42 { + revision 1; // NOTE: Default/not specifically set + + enum AnnouncementReasonEnum : enum8 { + kSimpleAnnouncement = 0; + kUpdateAvailable = 1; + kUrgentUpdateAvailable = 2; + } + + enum ChangeReasonEnum : enum8 { + kUnknown = 0; + kSuccess = 1; + kFailure = 2; + kTimeOut = 3; + kDelayByProvider = 4; + } + + enum UpdateStateEnum : enum8 { + kUnknown = 0; + kIdle = 1; + kQuerying = 2; + kDelayedOnQuery = 3; + kDownloading = 4; + kApplying = 5; + kDelayedOnApply = 6; + kRollingBack = 7; + kDelayedOnUserConsent = 8; + } + + fabric_scoped struct ProviderLocation { + node_id providerNodeID = 1; + endpoint_no endpoint = 2; + fabric_idx fabricIndex = 254; + } + + info event StateTransition = 0 { + UpdateStateEnum previousState = 0; + UpdateStateEnum newState = 1; + ChangeReasonEnum reason = 2; + nullable int32u targetSoftwareVersion = 3; + } + + critical event VersionApplied = 1 { + int32u softwareVersion = 0; + int16u productID = 1; + } + + info event DownloadError = 2 { + int32u softwareVersion = 0; + int64u bytesDownloaded = 1; + nullable int8u progressPercent = 2; + nullable int64s platformCode = 3; + } + + attribute access(write: administer) ProviderLocation defaultOTAProviders[] = 0; + readonly attribute boolean updatePossible = 1; + readonly attribute UpdateStateEnum updateState = 2; + readonly attribute nullable int8u updateStateProgress = 3; + readonly attribute command_id generatedCommandList[] = 65528; + readonly attribute command_id acceptedCommandList[] = 65529; + readonly attribute event_id eventList[] = 65530; + readonly attribute attrib_id attributeList[] = 65531; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; + + request struct AnnounceOTAProviderRequest { + node_id providerNodeID = 0; + vendor_id vendorID = 1; + AnnouncementReasonEnum announcementReason = 2; + optional octet_string<512> metadataForNode = 3; + endpoint_no endpoint = 4; + } + + /** Announce the presence of an OTA Provider */ + command AnnounceOTAProvider(AnnounceOTAProviderRequest): DefaultSuccess = 0; +} + +/** Nodes should be expected to be deployed to any and all regions of the world. These global regions + may have differing common languages, units of measurements, and numerical formatting + standards. As such, Nodes that visually or audibly convey information need a mechanism by which + they can be configured to use a user’s preferred language, units, etc */ +cluster LocalizationConfiguration = 43 { + revision 1; // NOTE: Default/not specifically set + + attribute access(write: manage) char_string<35> activeLocale = 0; + readonly attribute char_string supportedLocales[] = 1; + readonly attribute command_id generatedCommandList[] = 65528; + readonly attribute command_id acceptedCommandList[] = 65529; + readonly attribute event_id eventList[] = 65530; + readonly attribute attrib_id attributeList[] = 65531; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; +} + +/** Nodes should be expected to be deployed to any and all regions of the world. These global regions + may have differing preferences for how dates and times are conveyed. As such, Nodes that visually + or audibly convey time information need a mechanism by which they can be configured to use a + user’s preferred format. */ +cluster TimeFormatLocalization = 44 { + revision 1; // NOTE: Default/not specifically set + + enum CalendarTypeEnum : enum8 { + kBuddhist = 0; + kChinese = 1; + kCoptic = 2; + kEthiopian = 3; + kGregorian = 4; + kHebrew = 5; + kIndian = 6; + kIslamic = 7; + kJapanese = 8; + kKorean = 9; + kPersian = 10; + kTaiwanese = 11; + kUseActiveLocale = 255; + } + + enum HourFormatEnum : enum8 { + k12hr = 0; + k24hr = 1; + kUseActiveLocale = 255; + } + + bitmap Feature : bitmap32 { + kCalendarFormat = 0x1; + } + + attribute access(write: manage) HourFormatEnum hourFormat = 0; + attribute access(write: manage) optional CalendarTypeEnum activeCalendarType = 1; + readonly attribute optional CalendarTypeEnum supportedCalendarTypes[] = 2; + readonly attribute command_id generatedCommandList[] = 65528; + readonly attribute command_id acceptedCommandList[] = 65529; + readonly attribute event_id eventList[] = 65530; + readonly attribute attrib_id attributeList[] = 65531; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; +} + +/** This cluster is used to manage global aspects of the Commissioning flow. */ +cluster GeneralCommissioning = 48 { + revision 1; // NOTE: Default/not specifically set + + enum CommissioningErrorEnum : enum8 { + kOK = 0; + kValueOutsideRange = 1; + kInvalidAuthentication = 2; + kNoFailSafe = 3; + kBusyWithOtherAdmin = 4; + } + + enum RegulatoryLocationTypeEnum : enum8 { + kIndoor = 0; + kOutdoor = 1; + kIndoorOutdoor = 2; + } + + struct BasicCommissioningInfo { + int16u failSafeExpiryLengthSeconds = 0; + int16u maxCumulativeFailsafeSeconds = 1; + } + + attribute access(write: administer) int64u breadcrumb = 0; + readonly attribute BasicCommissioningInfo basicCommissioningInfo = 1; + readonly attribute RegulatoryLocationTypeEnum regulatoryConfig = 2; + readonly attribute RegulatoryLocationTypeEnum locationCapability = 3; + readonly attribute boolean supportsConcurrentConnection = 4; + readonly attribute command_id generatedCommandList[] = 65528; + readonly attribute command_id acceptedCommandList[] = 65529; + readonly attribute event_id eventList[] = 65530; + readonly attribute attrib_id attributeList[] = 65531; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; + + request struct ArmFailSafeRequest { + int16u expiryLengthSeconds = 0; + int64u breadcrumb = 1; + } + + response struct ArmFailSafeResponse = 1 { + CommissioningErrorEnum errorCode = 0; + char_string<128> debugText = 1; + } + + request struct SetRegulatoryConfigRequest { + RegulatoryLocationTypeEnum newRegulatoryConfig = 0; + char_string<2> countryCode = 1; + int64u breadcrumb = 2; + } + + response struct SetRegulatoryConfigResponse = 3 { + CommissioningErrorEnum errorCode = 0; + char_string debugText = 1; + } + + response struct CommissioningCompleteResponse = 5 { + CommissioningErrorEnum errorCode = 0; + char_string debugText = 1; + } + + /** Arm the persistent fail-safe timer with an expiry time of now + ExpiryLengthSeconds using device clock */ + command access(invoke: administer) ArmFailSafe(ArmFailSafeRequest): ArmFailSafeResponse = 0; + /** Set the regulatory configuration to be used during commissioning */ + command access(invoke: administer) SetRegulatoryConfig(SetRegulatoryConfigRequest): SetRegulatoryConfigResponse = 2; + /** Signals the Server that the Client has successfully completed all steps of Commissioning/Recofiguration needed during fail-safe period. */ + fabric command access(invoke: administer) CommissioningComplete(): CommissioningCompleteResponse = 4; +} + +/** Functionality to configure, enable, disable network credentials and access on a Matter device. */ +cluster NetworkCommissioning = 49 { + revision 1; // NOTE: Default/not specifically set + + enum NetworkCommissioningStatusEnum : enum8 { + kSuccess = 0; + kOutOfRange = 1; + kBoundsExceeded = 2; + kNetworkIDNotFound = 3; + kDuplicateNetworkID = 4; + kNetworkNotFound = 5; + kRegulatoryError = 6; + kAuthFailure = 7; + kUnsupportedSecurity = 8; + kOtherConnectionFailure = 9; + kIPV6Failed = 10; + kIPBindFailed = 11; + kUnknownError = 12; + } + + enum WiFiBandEnum : enum8 { + k2G4 = 0; + k3G65 = 1; + k5G = 2; + k6G = 3; + k60G = 4; + k1G = 5; + } + + bitmap Feature : bitmap32 { + kWiFiNetworkInterface = 0x1; + kThreadNetworkInterface = 0x2; + kEthernetNetworkInterface = 0x4; + kPerDeviceCredentials = 0x8; + } + + bitmap ThreadCapabilitiesBitmap : bitmap16 { + kIsBorderRouterCapable = 0x1; + kIsRouterCapable = 0x2; + kIsSleepyEndDeviceCapable = 0x4; + kIsFullThreadDevice = 0x8; + kIsSynchronizedSleepyEndDeviceCapable = 0x10; + } + + bitmap WiFiSecurityBitmap : bitmap8 { + kUnencrypted = 0x1; + kWEP = 0x2; + kWPAPersonal = 0x4; + kWPA2Personal = 0x8; + kWPA3Personal = 0x10; + kWPA3MatterPDC = 0x20; + } + + struct NetworkInfoStruct { + octet_string<32> networkID = 0; + boolean connected = 1; + optional nullable octet_string<20> networkIdentifier = 2; + optional nullable octet_string<20> clientIdentifier = 3; + } + + struct ThreadInterfaceScanResultStruct { + int16u panId = 0; + int64u extendedPanId = 1; + char_string<16> networkName = 2; + int16u channel = 3; + int8u version = 4; + octet_string<8> extendedAddress = 5; + int8s rssi = 6; + int8u lqi = 7; + } + + struct WiFiInterfaceScanResultStruct { + WiFiSecurityBitmap security = 0; + octet_string<32> ssid = 1; + octet_string<6> bssid = 2; + int16u channel = 3; + WiFiBandEnum wiFiBand = 4; + int8s rssi = 5; + } + + readonly attribute access(read: administer) int8u maxNetworks = 0; + readonly attribute access(read: administer) NetworkInfoStruct networks[] = 1; + readonly attribute optional int8u scanMaxTimeSeconds = 2; + readonly attribute optional int8u connectMaxTimeSeconds = 3; + attribute access(write: administer) boolean interfaceEnabled = 4; + readonly attribute access(read: administer) nullable NetworkCommissioningStatusEnum lastNetworkingStatus = 5; + readonly attribute access(read: administer) nullable octet_string<32> lastNetworkID = 6; + readonly attribute access(read: administer) nullable int32s lastConnectErrorValue = 7; + readonly attribute optional WiFiBandEnum supportedWiFiBands[] = 8; + readonly attribute optional ThreadCapabilitiesBitmap supportedThreadFeatures = 9; + readonly attribute optional int16u threadVersion = 10; + readonly attribute command_id generatedCommandList[] = 65528; + readonly attribute command_id acceptedCommandList[] = 65529; + readonly attribute event_id eventList[] = 65530; + readonly attribute attrib_id attributeList[] = 65531; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; + + request struct ScanNetworksRequest { + optional nullable octet_string<32> ssid = 0; + optional int64u breadcrumb = 1; + } + + response struct ScanNetworksResponse = 1 { + NetworkCommissioningStatusEnum networkingStatus = 0; + optional char_string debugText = 1; + optional WiFiInterfaceScanResultStruct wiFiScanResults[] = 2; + optional ThreadInterfaceScanResultStruct threadScanResults[] = 3; + } + + request struct AddOrUpdateWiFiNetworkRequest { + octet_string<32> ssid = 0; + octet_string<64> credentials = 1; + optional int64u breadcrumb = 2; + optional octet_string<140> networkIdentity = 3; + optional octet_string<20> clientIdentifier = 4; + optional octet_string<32> possessionNonce = 5; + } + + request struct AddOrUpdateThreadNetworkRequest { + octet_string<254> operationalDataset = 0; + optional int64u breadcrumb = 1; + } + + request struct RemoveNetworkRequest { + octet_string<32> networkID = 0; + optional int64u breadcrumb = 1; + } + + response struct NetworkConfigResponse = 5 { + NetworkCommissioningStatusEnum networkingStatus = 0; + optional char_string<512> debugText = 1; + optional int8u networkIndex = 2; + optional octet_string<140> clientIdentity = 3; + optional octet_string<64> possessionSignature = 4; + } + + request struct ConnectNetworkRequest { + octet_string<32> networkID = 0; + optional int64u breadcrumb = 1; + } + + response struct ConnectNetworkResponse = 7 { + NetworkCommissioningStatusEnum networkingStatus = 0; + optional char_string debugText = 1; + nullable int32s errorValue = 2; + } + + request struct ReorderNetworkRequest { + octet_string<32> networkID = 0; + int8u networkIndex = 1; + optional int64u breadcrumb = 2; + } + + request struct QueryIdentityRequest { + octet_string<20> keyIdentifier = 0; + optional octet_string<32> possessionNonce = 1; + } + + response struct QueryIdentityResponse = 10 { + octet_string<140> identity = 0; + optional octet_string<64> possessionSignature = 1; + } + + /** Detemine the set of networks the device sees as available. */ + command access(invoke: administer) ScanNetworks(ScanNetworksRequest): ScanNetworksResponse = 0; + /** Add or update the credentials for a given Wi-Fi network. */ + command access(invoke: administer) AddOrUpdateWiFiNetwork(AddOrUpdateWiFiNetworkRequest): NetworkConfigResponse = 2; + /** Add or update the credentials for a given Thread network. */ + command access(invoke: administer) AddOrUpdateThreadNetwork(AddOrUpdateThreadNetworkRequest): NetworkConfigResponse = 3; + /** Remove the definition of a given network (including its credentials). */ + command access(invoke: administer) RemoveNetwork(RemoveNetworkRequest): NetworkConfigResponse = 4; + /** Connect to the specified network, using previously-defined credentials. */ + command access(invoke: administer) ConnectNetwork(ConnectNetworkRequest): ConnectNetworkResponse = 6; + /** Modify the order in which networks will be presented in the Networks attribute. */ + command access(invoke: administer) ReorderNetwork(ReorderNetworkRequest): NetworkConfigResponse = 8; + /** Retrieve details about and optionally proof of possession of a network client identity. */ + command access(invoke: administer) QueryIdentity(QueryIdentityRequest): QueryIdentityResponse = 9; +} + +/** The cluster provides commands for retrieving unstructured diagnostic logs from a Node that may be used to aid in diagnostics. */ +cluster DiagnosticLogs = 50 { + revision 1; // NOTE: Default/not specifically set + + enum IntentEnum : enum8 { + kEndUserSupport = 0; + kNetworkDiag = 1; + kCrashLogs = 2; + } + + enum StatusEnum : enum8 { + kSuccess = 0; + kExhausted = 1; + kNoLogs = 2; + kBusy = 3; + kDenied = 4; + } + + enum TransferProtocolEnum : enum8 { + kResponsePayload = 0; + kBDX = 1; + } + + readonly attribute command_id generatedCommandList[] = 65528; + readonly attribute command_id acceptedCommandList[] = 65529; + readonly attribute event_id eventList[] = 65530; + readonly attribute attrib_id attributeList[] = 65531; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; + + request struct RetrieveLogsRequestRequest { + IntentEnum intent = 0; + TransferProtocolEnum requestedProtocol = 1; + optional char_string<32> transferFileDesignator = 2; + } + + response struct RetrieveLogsResponse = 1 { + StatusEnum status = 0; + long_octet_string logContent = 1; + optional epoch_us UTCTimeStamp = 2; + optional systime_us timeSinceBoot = 3; + } + + /** Retrieving diagnostic logs from a Node */ + command RetrieveLogsRequest(RetrieveLogsRequestRequest): RetrieveLogsResponse = 0; +} + +/** The General Diagnostics Cluster, along with other diagnostics clusters, provide a means to acquire standardized diagnostics metrics that MAY be used by a Node to assist a user or Administrative Node in diagnosing potential problems. */ +cluster GeneralDiagnostics = 51 { + revision 2; + + enum BootReasonEnum : enum8 { + kUnspecified = 0; + kPowerOnReboot = 1; + kBrownOutReset = 2; + kSoftwareWatchdogReset = 3; + kHardwareWatchdogReset = 4; + kSoftwareUpdateCompleted = 5; + kSoftwareReset = 6; + } + + enum HardwareFaultEnum : enum8 { + kUnspecified = 0; + kRadio = 1; + kSensor = 2; + kResettableOverTemp = 3; + kNonResettableOverTemp = 4; + kPowerSource = 5; + kVisualDisplayFault = 6; + kAudioOutputFault = 7; + kUserInterfaceFault = 8; + kNonVolatileMemoryError = 9; + kTamperDetected = 10; + } + + enum InterfaceTypeEnum : enum8 { + kUnspecified = 0; + kWiFi = 1; + kEthernet = 2; + kCellular = 3; + kThread = 4; + } + + enum NetworkFaultEnum : enum8 { + kUnspecified = 0; + kHardwareFailure = 1; + kNetworkJammed = 2; + kConnectionFailed = 3; + } + + enum RadioFaultEnum : enum8 { + kUnspecified = 0; + kWiFiFault = 1; + kCellularFault = 2; + kThreadFault = 3; + kNFCFault = 4; + kBLEFault = 5; + kEthernetFault = 6; + } + + bitmap Feature : bitmap32 { + kDataModelTest = 0x1; + } + + struct NetworkInterface { + char_string<32> name = 0; + boolean isOperational = 1; + nullable boolean offPremiseServicesReachableIPv4 = 2; + nullable boolean offPremiseServicesReachableIPv6 = 3; + octet_string<8> hardwareAddress = 4; + octet_string IPv4Addresses[] = 5; + octet_string IPv6Addresses[] = 6; + InterfaceTypeEnum type = 7; + } + + critical event HardwareFaultChange = 0 { + HardwareFaultEnum current[] = 0; + HardwareFaultEnum previous[] = 1; + } + + critical event RadioFaultChange = 1 { + RadioFaultEnum current[] = 0; + RadioFaultEnum previous[] = 1; + } + + critical event NetworkFaultChange = 2 { + NetworkFaultEnum current[] = 0; + NetworkFaultEnum previous[] = 1; + } + + critical event BootReason = 3 { + BootReasonEnum bootReason = 0; + } + + readonly attribute NetworkInterface networkInterfaces[] = 0; + readonly attribute int16u rebootCount = 1; + readonly attribute optional int64u upTime = 2; + readonly attribute optional int32u totalOperationalHours = 3; + readonly attribute optional BootReasonEnum bootReason = 4; + readonly attribute optional HardwareFaultEnum activeHardwareFaults[] = 5; + readonly attribute optional RadioFaultEnum activeRadioFaults[] = 6; + readonly attribute optional NetworkFaultEnum activeNetworkFaults[] = 7; + readonly attribute boolean testEventTriggersEnabled = 8; + readonly attribute command_id generatedCommandList[] = 65528; + readonly attribute command_id acceptedCommandList[] = 65529; + readonly attribute event_id eventList[] = 65530; + readonly attribute attrib_id attributeList[] = 65531; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; + + request struct TestEventTriggerRequest { + octet_string<16> enableKey = 0; + int64u eventTrigger = 1; + } + + response struct TimeSnapshotResponse = 2 { + systime_ms systemTimeMs = 0; + nullable posix_ms posixTimeMs = 1; + } + + request struct PayloadTestRequestRequest { + octet_string<16> enableKey = 0; + int8u value = 1; + int16u count = 2; + } + + response struct PayloadTestResponse = 4 { + octet_string payload = 0; + } + + /** Provide a means for certification tests to trigger some test-plan-specific events */ + command access(invoke: manage) TestEventTrigger(TestEventTriggerRequest): DefaultSuccess = 0; + /** Take a snapshot of system time and epoch time. */ + command TimeSnapshot(): TimeSnapshotResponse = 1; + /** Request a variable length payload response. */ + command PayloadTestRequest(PayloadTestRequestRequest): PayloadTestResponse = 3; +} + +/** The Software Diagnostics Cluster provides a means to acquire standardized diagnostics metrics that MAY be used by a Node to assist a user or Administrative Node in diagnosing potential problems. */ +cluster SoftwareDiagnostics = 52 { + revision 1; // NOTE: Default/not specifically set + + bitmap Feature : bitmap32 { + kWatermarks = 0x1; + } + + struct ThreadMetricsStruct { + int64u id = 0; + optional char_string<8> name = 1; + optional int32u stackFreeCurrent = 2; + optional int32u stackFreeMinimum = 3; + optional int32u stackSize = 4; + } + + info event SoftwareFault = 0 { + int64u id = 0; + optional char_string name = 1; + optional octet_string faultRecording = 2; + } + + readonly attribute optional ThreadMetricsStruct threadMetrics[] = 0; + readonly attribute optional int64u currentHeapFree = 1; + readonly attribute optional int64u currentHeapUsed = 2; + readonly attribute optional int64u currentHeapHighWatermark = 3; + readonly attribute command_id generatedCommandList[] = 65528; + readonly attribute command_id acceptedCommandList[] = 65529; + readonly attribute event_id eventList[] = 65530; + readonly attribute attrib_id attributeList[] = 65531; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; + + /** Reception of this command SHALL reset the values: The StackFreeMinimum field of the ThreadMetrics attribute, CurrentHeapHighWaterMark attribute. */ + command access(invoke: manage) ResetWatermarks(): DefaultSuccess = 0; +} + +/** The Wi-Fi Network Diagnostics Cluster provides a means to acquire standardized diagnostics metrics that MAY be used by a Node to assist a user or Administrative Node in diagnosing potential problems. */ +cluster WiFiNetworkDiagnostics = 54 { + revision 1; // NOTE: Default/not specifically set + + enum AssociationFailureCauseEnum : enum8 { + kUnknown = 0; + kAssociationFailed = 1; + kAuthenticationFailed = 2; + kSsidNotFound = 3; + } + + enum ConnectionStatusEnum : enum8 { + kConnected = 0; + kNotConnected = 1; + } + + enum SecurityTypeEnum : enum8 { + kUnspecified = 0; + kNone = 1; + kWEP = 2; + kWPA = 3; + kWPA2 = 4; + kWPA3 = 5; + } + + enum WiFiVersionEnum : enum8 { + kA = 0; + kB = 1; + kG = 2; + kN = 3; + kAc = 4; + kAx = 5; + kAh = 6; + } + + bitmap Feature : bitmap32 { + kPacketCounts = 0x1; + kErrorCounts = 0x2; + } + + info event Disconnection = 0 { + int16u reasonCode = 0; + } + + info event AssociationFailure = 1 { + AssociationFailureCauseEnum associationFailureCause = 0; + int16u status = 1; + } + + info event ConnectionStatus = 2 { + ConnectionStatusEnum connectionStatus = 0; + } + + readonly attribute nullable octet_string<6> bssid = 0; + readonly attribute nullable SecurityTypeEnum securityType = 1; + readonly attribute nullable WiFiVersionEnum wiFiVersion = 2; + readonly attribute nullable int16u channelNumber = 3; + readonly attribute nullable int8s rssi = 4; + readonly attribute optional nullable int32u beaconLostCount = 5; + readonly attribute optional nullable int32u beaconRxCount = 6; + readonly attribute optional nullable int32u packetMulticastRxCount = 7; + readonly attribute optional nullable int32u packetMulticastTxCount = 8; + readonly attribute optional nullable int32u packetUnicastRxCount = 9; + readonly attribute optional nullable int32u packetUnicastTxCount = 10; + readonly attribute optional nullable int64u currentMaxRate = 11; + readonly attribute optional nullable int64u overrunCount = 12; + readonly attribute command_id generatedCommandList[] = 65528; + readonly attribute command_id acceptedCommandList[] = 65529; + readonly attribute event_id eventList[] = 65530; + readonly attribute attrib_id attributeList[] = 65531; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; + + /** Reception of this command SHALL reset the Breacon and Packet related count attributes to 0 */ + command ResetCounts(): DefaultSuccess = 0; +} + +/** Commands to trigger a Node to allow a new Administrator to commission it. */ +cluster AdministratorCommissioning = 60 { + revision 1; // NOTE: Default/not specifically set + + enum CommissioningWindowStatusEnum : enum8 { + kWindowNotOpen = 0; + kEnhancedWindowOpen = 1; + kBasicWindowOpen = 2; + } + + enum StatusCode : enum8 { + kBusy = 2; + kPAKEParameterError = 3; + kWindowNotOpen = 4; + } + + bitmap Feature : bitmap32 { + kBasic = 0x1; + } + + readonly attribute CommissioningWindowStatusEnum windowStatus = 0; + readonly attribute nullable fabric_idx adminFabricIndex = 1; + readonly attribute nullable vendor_id adminVendorId = 2; + readonly attribute command_id generatedCommandList[] = 65528; + readonly attribute command_id acceptedCommandList[] = 65529; + readonly attribute event_id eventList[] = 65530; + readonly attribute attrib_id attributeList[] = 65531; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; + + request struct OpenCommissioningWindowRequest { + int16u commissioningTimeout = 0; + octet_string PAKEPasscodeVerifier = 1; + int16u discriminator = 2; + int32u iterations = 3; + octet_string<32> salt = 4; + } + + request struct OpenBasicCommissioningWindowRequest { + int16u commissioningTimeout = 0; + } + + /** This command is used by a current Administrator to instruct a Node to go into commissioning mode using enhanced commissioning method. */ + timed command access(invoke: administer) OpenCommissioningWindow(OpenCommissioningWindowRequest): DefaultSuccess = 0; + /** This command is used by a current Administrator to instruct a Node to go into commissioning mode using basic commissioning method, if the node supports it. */ + timed command access(invoke: administer) OpenBasicCommissioningWindow(OpenBasicCommissioningWindowRequest): DefaultSuccess = 1; + /** This command is used by a current Administrator to instruct a Node to revoke any active Open Commissioning Window or Open Basic Commissioning Window command. */ + timed command access(invoke: administer) RevokeCommissioning(): DefaultSuccess = 2; +} + +/** This cluster is used to add or remove Operational Credentials on a Commissionee or Node, as well as manage the associated Fabrics. */ +cluster OperationalCredentials = 62 { + revision 1; // NOTE: Default/not specifically set + + enum CertificateChainTypeEnum : enum8 { + kDACCertificate = 1; + kPAICertificate = 2; + } + + enum NodeOperationalCertStatusEnum : enum8 { + kOK = 0; + kInvalidPublicKey = 1; + kInvalidNodeOpId = 2; + kInvalidNOC = 3; + kMissingCsr = 4; + kTableFull = 5; + kInvalidAdminSubject = 6; + kFabricConflict = 9; + kLabelConflict = 10; + kInvalidFabricIndex = 11; + } + + fabric_scoped struct FabricDescriptorStruct { + octet_string<65> rootPublicKey = 1; + vendor_id vendorID = 2; + fabric_id fabricID = 3; + node_id nodeID = 4; + char_string<32> label = 5; + fabric_idx fabricIndex = 254; + } + + fabric_scoped struct NOCStruct { + fabric_sensitive octet_string noc = 1; + nullable fabric_sensitive octet_string icac = 2; + fabric_idx fabricIndex = 254; + } + + readonly attribute access(read: administer) NOCStruct NOCs[] = 0; + readonly attribute FabricDescriptorStruct fabrics[] = 1; + readonly attribute int8u supportedFabrics = 2; + readonly attribute int8u commissionedFabrics = 3; + readonly attribute octet_string trustedRootCertificates[] = 4; + readonly attribute int8u currentFabricIndex = 5; + readonly attribute command_id generatedCommandList[] = 65528; + readonly attribute command_id acceptedCommandList[] = 65529; + readonly attribute event_id eventList[] = 65530; + readonly attribute attrib_id attributeList[] = 65531; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; + + request struct AttestationRequestRequest { + octet_string<32> attestationNonce = 0; + } + + response struct AttestationResponse = 1 { + octet_string<900> attestationElements = 0; + octet_string<64> attestationSignature = 1; + } + + request struct CertificateChainRequestRequest { + CertificateChainTypeEnum certificateType = 0; + } + + response struct CertificateChainResponse = 3 { + octet_string<600> certificate = 0; + } + + request struct CSRRequestRequest { + octet_string<32> CSRNonce = 0; + optional boolean isForUpdateNOC = 1; + } + + response struct CSRResponse = 5 { + octet_string NOCSRElements = 0; + octet_string attestationSignature = 1; + } + + request struct AddNOCRequest { + octet_string<400> NOCValue = 0; + optional octet_string<400> ICACValue = 1; + octet_string<16> IPKValue = 2; + int64u caseAdminSubject = 3; + vendor_id adminVendorId = 4; + } + + request struct UpdateNOCRequest { + octet_string NOCValue = 0; + optional octet_string ICACValue = 1; + } + + response struct NOCResponse = 8 { + NodeOperationalCertStatusEnum statusCode = 0; + optional fabric_idx fabricIndex = 1; + optional char_string<128> debugText = 2; + } + + request struct UpdateFabricLabelRequest { + char_string<32> label = 0; + } + + request struct RemoveFabricRequest { + fabric_idx fabricIndex = 0; + } + + request struct AddTrustedRootCertificateRequest { + octet_string rootCACertificate = 0; + } + + /** Sender is requesting attestation information from the receiver. */ + command access(invoke: administer) AttestationRequest(AttestationRequestRequest): AttestationResponse = 0; + /** Sender is requesting a device attestation certificate from the receiver. */ + command access(invoke: administer) CertificateChainRequest(CertificateChainRequestRequest): CertificateChainResponse = 2; + /** Sender is requesting a certificate signing request (CSR) from the receiver. */ + command access(invoke: administer) CSRRequest(CSRRequestRequest): CSRResponse = 4; + /** Sender is requesting to add the new node operational certificates. */ + command access(invoke: administer) AddNOC(AddNOCRequest): NOCResponse = 6; + /** Sender is requesting to update the node operational certificates. */ + fabric command access(invoke: administer) UpdateNOC(UpdateNOCRequest): NOCResponse = 7; + /** This command SHALL be used by an Administrative Node to set the user-visible Label field for a given Fabric, as reflected by entries in the Fabrics attribute. */ + fabric command access(invoke: administer) UpdateFabricLabel(UpdateFabricLabelRequest): NOCResponse = 9; + /** This command is used by Administrative Nodes to remove a given fabric index and delete all associated fabric-scoped data. */ + command access(invoke: administer) RemoveFabric(RemoveFabricRequest): NOCResponse = 10; + /** This command SHALL add a Trusted Root CA Certificate, provided as its CHIP Certificate representation. */ + command access(invoke: administer) AddTrustedRootCertificate(AddTrustedRootCertificateRequest): DefaultSuccess = 11; +} + +/** The Group Key Management Cluster is the mechanism by which group keys are managed. */ +cluster GroupKeyManagement = 63 { + revision 1; // NOTE: Default/not specifically set + + enum GroupKeySecurityPolicyEnum : enum8 { + kTrustFirst = 0; + kCacheAndSync = 1; + } + + bitmap Feature : bitmap32 { + kCacheAndSync = 0x1; + } + + fabric_scoped struct GroupInfoMapStruct { + group_id groupId = 1; + endpoint_no endpoints[] = 2; + optional char_string<16> groupName = 3; + fabric_idx fabricIndex = 254; + } + + fabric_scoped struct GroupKeyMapStruct { + group_id groupId = 1; + int16u groupKeySetID = 2; + fabric_idx fabricIndex = 254; + } + + struct GroupKeySetStruct { + int16u groupKeySetID = 0; + GroupKeySecurityPolicyEnum groupKeySecurityPolicy = 1; + nullable octet_string<16> epochKey0 = 2; + nullable epoch_us epochStartTime0 = 3; + nullable octet_string<16> epochKey1 = 4; + nullable epoch_us epochStartTime1 = 5; + nullable octet_string<16> epochKey2 = 6; + nullable epoch_us epochStartTime2 = 7; + } + + attribute access(write: manage) GroupKeyMapStruct groupKeyMap[] = 0; + readonly attribute GroupInfoMapStruct groupTable[] = 1; + readonly attribute int16u maxGroupsPerFabric = 2; + readonly attribute int16u maxGroupKeysPerFabric = 3; + readonly attribute command_id generatedCommandList[] = 65528; + readonly attribute command_id acceptedCommandList[] = 65529; + readonly attribute event_id eventList[] = 65530; + readonly attribute attrib_id attributeList[] = 65531; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; + + request struct KeySetWriteRequest { + GroupKeySetStruct groupKeySet = 0; + } + + request struct KeySetReadRequest { + int16u groupKeySetID = 0; + } + + response struct KeySetReadResponse = 2 { + GroupKeySetStruct groupKeySet = 0; + } + + request struct KeySetRemoveRequest { + int16u groupKeySetID = 0; + } + + response struct KeySetReadAllIndicesResponse = 5 { + int16u groupKeySetIDs[] = 0; + } + + /** Write a new set of keys for the given key set id. */ + fabric command access(invoke: administer) KeySetWrite(KeySetWriteRequest): DefaultSuccess = 0; + /** Read the keys for a given key set id. */ + fabric command access(invoke: administer) KeySetRead(KeySetReadRequest): KeySetReadResponse = 1; + /** Revoke a Root Key from a Group */ + fabric command access(invoke: administer) KeySetRemove(KeySetRemoveRequest): DefaultSuccess = 3; + /** Return the list of Group Key Sets associated with the accessing fabric */ + fabric command access(invoke: administer) KeySetReadAllIndices(): KeySetReadAllIndicesResponse = 4; +} + +/** The Fixed Label Cluster provides a feature for the device to tag an endpoint with zero or more read only +labels. */ +cluster FixedLabel = 64 { + revision 1; // NOTE: Default/not specifically set + + struct LabelStruct { + char_string<16> label = 0; + char_string<16> value = 1; + } + + readonly attribute LabelStruct labelList[] = 0; + readonly attribute command_id generatedCommandList[] = 65528; + readonly attribute command_id acceptedCommandList[] = 65529; + readonly attribute event_id eventList[] = 65530; + readonly attribute attrib_id attributeList[] = 65531; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; +} + +/** The User Label Cluster provides a feature to tag an endpoint with zero or more labels. */ +cluster UserLabel = 65 { + revision 1; // NOTE: Default/not specifically set + + struct LabelStruct { + char_string<16> label = 0; + char_string<16> value = 1; + } + + attribute access(write: manage) LabelStruct labelList[] = 0; + readonly attribute command_id generatedCommandList[] = 65528; + readonly attribute command_id acceptedCommandList[] = 65529; + readonly attribute event_id eventList[] = 65530; + readonly attribute attrib_id attributeList[] = 65531; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; +} + +/** Attributes and commands for controlling the color properties of a color-capable light. */ +cluster ColorControl = 768 { + revision 6; + + enum ColorLoopAction : enum8 { + kDeactivate = 0; + kActivateFromColorLoopStartEnhancedHue = 1; + kActivateFromEnhancedCurrentHue = 2; + } + + enum ColorLoopDirection : enum8 { + kDecrementHue = 0; + kIncrementHue = 1; + } + + enum ColorMode : enum8 { + kCurrentHueAndCurrentSaturation = 0; + kCurrentXAndCurrentY = 1; + kColorTemperature = 2; + } + + enum HueDirection : enum8 { + kShortestDistance = 0; + kLongestDistance = 1; + kUp = 2; + kDown = 3; + } + + enum HueMoveMode : enum8 { + kStop = 0; + kUp = 1; + kDown = 3; + } + + enum HueStepMode : enum8 { + kUp = 1; + kDown = 3; + } + + enum SaturationMoveMode : enum8 { + kStop = 0; + kUp = 1; + kDown = 3; + } + + enum SaturationStepMode : enum8 { + kUp = 1; + kDown = 3; + } + + bitmap ColorCapabilities : bitmap16 { + kHueSaturationSupported = 0x1; + kEnhancedHueSupported = 0x2; + kColorLoopSupported = 0x4; + kXYAttributesSupported = 0x8; + kColorTemperatureSupported = 0x10; + } + + bitmap ColorLoopUpdateFlags : bitmap8 { + kUpdateAction = 0x1; + kUpdateDirection = 0x2; + kUpdateTime = 0x4; + kUpdateStartHue = 0x8; + } + + bitmap Feature : bitmap32 { + kHueAndSaturation = 0x1; + kEnhancedHue = 0x2; + kColorLoop = 0x4; + kXY = 0x8; + kColorTemperature = 0x10; + } + + readonly attribute optional int8u currentHue = 0; + readonly attribute optional int8u currentSaturation = 1; + readonly attribute optional int16u remainingTime = 2; + readonly attribute optional int16u currentX = 3; + readonly attribute optional int16u currentY = 4; + readonly attribute optional enum8 driftCompensation = 5; + readonly attribute optional char_string<254> compensationText = 6; + readonly attribute optional int16u colorTemperatureMireds = 7; + readonly attribute enum8 colorMode = 8; + attribute bitmap8 options = 15; + readonly attribute nullable int8u numberOfPrimaries = 16; + readonly attribute optional int16u primary1X = 17; + readonly attribute optional int16u primary1Y = 18; + readonly attribute optional nullable int8u primary1Intensity = 19; + readonly attribute optional int16u primary2X = 21; + readonly attribute optional int16u primary2Y = 22; + readonly attribute optional nullable int8u primary2Intensity = 23; + readonly attribute optional int16u primary3X = 25; + readonly attribute optional int16u primary3Y = 26; + readonly attribute optional nullable int8u primary3Intensity = 27; + readonly attribute optional int16u primary4X = 32; + readonly attribute optional int16u primary4Y = 33; + readonly attribute optional nullable int8u primary4Intensity = 34; + readonly attribute optional int16u primary5X = 36; + readonly attribute optional int16u primary5Y = 37; + readonly attribute optional nullable int8u primary5Intensity = 38; + readonly attribute optional int16u primary6X = 40; + readonly attribute optional int16u primary6Y = 41; + readonly attribute optional nullable int8u primary6Intensity = 42; + attribute access(write: manage) optional int16u whitePointX = 48; + attribute access(write: manage) optional int16u whitePointY = 49; + attribute access(write: manage) optional int16u colorPointRX = 50; + attribute access(write: manage) optional int16u colorPointRY = 51; + attribute access(write: manage) optional nullable int8u colorPointRIntensity = 52; + attribute access(write: manage) optional int16u colorPointGX = 54; + attribute access(write: manage) optional int16u colorPointGY = 55; + attribute access(write: manage) optional nullable int8u colorPointGIntensity = 56; + attribute access(write: manage) optional int16u colorPointBX = 58; + attribute access(write: manage) optional int16u colorPointBY = 59; + attribute access(write: manage) optional nullable int8u colorPointBIntensity = 60; + readonly attribute optional int16u enhancedCurrentHue = 16384; + readonly attribute enum8 enhancedColorMode = 16385; + readonly attribute optional int8u colorLoopActive = 16386; + readonly attribute optional int8u colorLoopDirection = 16387; + readonly attribute optional int16u colorLoopTime = 16388; + readonly attribute optional int16u colorLoopStartEnhancedHue = 16389; + readonly attribute optional int16u colorLoopStoredEnhancedHue = 16390; + readonly attribute bitmap16 colorCapabilities = 16394; + readonly attribute optional int16u colorTempPhysicalMinMireds = 16395; + readonly attribute optional int16u colorTempPhysicalMaxMireds = 16396; + readonly attribute optional int16u coupleColorTempToLevelMinMireds = 16397; + attribute access(write: manage) optional nullable int16u startUpColorTemperatureMireds = 16400; + readonly attribute command_id generatedCommandList[] = 65528; + readonly attribute command_id acceptedCommandList[] = 65529; + readonly attribute event_id eventList[] = 65530; + readonly attribute attrib_id attributeList[] = 65531; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; + + request struct MoveToHueRequest { + int8u hue = 0; + HueDirection direction = 1; + int16u transitionTime = 2; + bitmap8 optionsMask = 3; + bitmap8 optionsOverride = 4; + } + + request struct MoveHueRequest { + HueMoveMode moveMode = 0; + int8u rate = 1; + bitmap8 optionsMask = 2; + bitmap8 optionsOverride = 3; + } + + request struct StepHueRequest { + HueStepMode stepMode = 0; + int8u stepSize = 1; + int8u transitionTime = 2; + bitmap8 optionsMask = 3; + bitmap8 optionsOverride = 4; + } + + request struct MoveToSaturationRequest { + int8u saturation = 0; + int16u transitionTime = 1; + bitmap8 optionsMask = 2; + bitmap8 optionsOverride = 3; + } + + request struct MoveSaturationRequest { + SaturationMoveMode moveMode = 0; + int8u rate = 1; + bitmap8 optionsMask = 2; + bitmap8 optionsOverride = 3; + } + + request struct StepSaturationRequest { + SaturationStepMode stepMode = 0; + int8u stepSize = 1; + int8u transitionTime = 2; + bitmap8 optionsMask = 3; + bitmap8 optionsOverride = 4; + } + + request struct MoveToHueAndSaturationRequest { + int8u hue = 0; + int8u saturation = 1; + int16u transitionTime = 2; + bitmap8 optionsMask = 3; + bitmap8 optionsOverride = 4; + } + + request struct MoveToColorRequest { + int16u colorX = 0; + int16u colorY = 1; + int16u transitionTime = 2; + bitmap8 optionsMask = 3; + bitmap8 optionsOverride = 4; + } + + request struct MoveColorRequest { + int16s rateX = 0; + int16s rateY = 1; + bitmap8 optionsMask = 2; + bitmap8 optionsOverride = 3; + } + + request struct StepColorRequest { + int16s stepX = 0; + int16s stepY = 1; + int16u transitionTime = 2; + bitmap8 optionsMask = 3; + bitmap8 optionsOverride = 4; + } + + request struct MoveToColorTemperatureRequest { + int16u colorTemperatureMireds = 0; + int16u transitionTime = 1; + bitmap8 optionsMask = 2; + bitmap8 optionsOverride = 3; + } + + request struct EnhancedMoveToHueRequest { + int16u enhancedHue = 0; + HueDirection direction = 1; + int16u transitionTime = 2; + bitmap8 optionsMask = 3; + bitmap8 optionsOverride = 4; + } + + request struct EnhancedMoveHueRequest { + HueMoveMode moveMode = 0; + int16u rate = 1; + bitmap8 optionsMask = 2; + bitmap8 optionsOverride = 3; + } + + request struct EnhancedStepHueRequest { + HueStepMode stepMode = 0; + int16u stepSize = 1; + int16u transitionTime = 2; + bitmap8 optionsMask = 3; + bitmap8 optionsOverride = 4; + } + + request struct EnhancedMoveToHueAndSaturationRequest { + int16u enhancedHue = 0; + int8u saturation = 1; + int16u transitionTime = 2; + bitmap8 optionsMask = 3; + bitmap8 optionsOverride = 4; + } + + request struct ColorLoopSetRequest { + ColorLoopUpdateFlags updateFlags = 0; + ColorLoopAction action = 1; + ColorLoopDirection direction = 2; + int16u time = 3; + int16u startHue = 4; + bitmap8 optionsMask = 5; + bitmap8 optionsOverride = 6; + } + + request struct StopMoveStepRequest { + bitmap8 optionsMask = 0; + bitmap8 optionsOverride = 1; + } + + request struct MoveColorTemperatureRequest { + HueMoveMode moveMode = 0; + int16u rate = 1; + int16u colorTemperatureMinimumMireds = 2; + int16u colorTemperatureMaximumMireds = 3; + bitmap8 optionsMask = 4; + bitmap8 optionsOverride = 5; + } + + request struct StepColorTemperatureRequest { + HueStepMode stepMode = 0; + int16u stepSize = 1; + int16u transitionTime = 2; + int16u colorTemperatureMinimumMireds = 3; + int16u colorTemperatureMaximumMireds = 4; + bitmap8 optionsMask = 5; + bitmap8 optionsOverride = 6; + } + + /** Move to specified hue. */ + command MoveToHue(MoveToHueRequest): DefaultSuccess = 0; + /** Move hue up or down at specified rate. */ + command MoveHue(MoveHueRequest): DefaultSuccess = 1; + /** Step hue up or down by specified size at specified rate. */ + command StepHue(StepHueRequest): DefaultSuccess = 2; + /** Move to specified saturation. */ + command MoveToSaturation(MoveToSaturationRequest): DefaultSuccess = 3; + /** Move saturation up or down at specified rate. */ + command MoveSaturation(MoveSaturationRequest): DefaultSuccess = 4; + /** Step saturation up or down by specified size at specified rate. */ + command StepSaturation(StepSaturationRequest): DefaultSuccess = 5; + /** Move to hue and saturation. */ + command MoveToHueAndSaturation(MoveToHueAndSaturationRequest): DefaultSuccess = 6; + /** Move to specified color. */ + command MoveToColor(MoveToColorRequest): DefaultSuccess = 7; + /** Moves the color. */ + command MoveColor(MoveColorRequest): DefaultSuccess = 8; + /** Steps the lighting to a specific color. */ + command StepColor(StepColorRequest): DefaultSuccess = 9; + /** Move to a specific color temperature. */ + command MoveToColorTemperature(MoveToColorTemperatureRequest): DefaultSuccess = 10; + /** Command description for EnhancedMoveToHue */ + command EnhancedMoveToHue(EnhancedMoveToHueRequest): DefaultSuccess = 64; + /** Command description for EnhancedMoveHue */ + command EnhancedMoveHue(EnhancedMoveHueRequest): DefaultSuccess = 65; + /** Command description for EnhancedStepHue */ + command EnhancedStepHue(EnhancedStepHueRequest): DefaultSuccess = 66; + /** Command description for EnhancedMoveToHueAndSaturation */ + command EnhancedMoveToHueAndSaturation(EnhancedMoveToHueAndSaturationRequest): DefaultSuccess = 67; + /** Command description for ColorLoopSet */ + command ColorLoopSet(ColorLoopSetRequest): DefaultSuccess = 68; + /** Command description for StopMoveStep */ + command StopMoveStep(StopMoveStepRequest): DefaultSuccess = 71; + /** Command description for MoveColorTemperature */ + command MoveColorTemperature(MoveColorTemperatureRequest): DefaultSuccess = 75; + /** Command description for StepColorTemperature */ + command StepColorTemperature(StepColorTemperatureRequest): DefaultSuccess = 76; +} + +endpoint 0 { + device type ma_rootdevice = 22, version 1; + + binding cluster OtaSoftwareUpdateProvider; + + server cluster Descriptor { + callback attribute deviceTypeList; + callback attribute serverList; + callback attribute clientList; + callback attribute partsList; + callback attribute featureMap; + callback attribute clusterRevision; + } + + server cluster AccessControl { + emits event AccessControlEntryChanged; + emits event AccessControlExtensionChanged; + callback attribute acl; + callback attribute extension; + callback attribute subjectsPerAccessControlEntry; + callback attribute targetsPerAccessControlEntry; + callback attribute accessControlEntriesPerFabric; + callback attribute attributeList; + ram attribute featureMap default = 0; + callback attribute clusterRevision; + } + + server cluster BasicInformation { + emits event StartUp; + emits event ShutDown; + emits event Leave; + callback attribute dataModelRevision; + callback attribute vendorName; + callback attribute vendorID; + callback attribute productName; + callback attribute productID; + persist attribute nodeLabel; + callback attribute location; + callback attribute hardwareVersion; + callback attribute hardwareVersionString; + callback attribute softwareVersion; + callback attribute softwareVersionString; + callback attribute manufacturingDate; + callback attribute partNumber; + callback attribute productURL; + callback attribute productLabel; + callback attribute serialNumber; + persist attribute localConfigDisabled default = 0; + callback attribute uniqueID; + callback attribute capabilityMinima; + callback attribute specificationVersion; + callback attribute maxPathsPerInvoke; + ram attribute featureMap default = 0; + ram attribute clusterRevision default = 3; + } + + server cluster OtaSoftwareUpdateRequestor { + emits event StateTransition; + emits event VersionApplied; + emits event DownloadError; + callback attribute defaultOTAProviders; + ram attribute updatePossible default = 1; + ram attribute updateState default = 0; + ram attribute updateStateProgress default = 0; + ram attribute featureMap default = 0; + ram attribute clusterRevision default = 1; + + handle command AnnounceOTAProvider; + } + + server cluster LocalizationConfiguration { + persist attribute activeLocale default = "en-US"; + callback attribute supportedLocales; + ram attribute featureMap default = 0; + ram attribute clusterRevision default = 1; + } + + server cluster TimeFormatLocalization { + persist attribute hourFormat default = 0; + persist attribute activeCalendarType default = 0; + callback attribute supportedCalendarTypes; + ram attribute featureMap default = 0; + ram attribute clusterRevision default = 1; + } + + server cluster GeneralCommissioning { + ram attribute breadcrumb default = 0x0000000000000000; + callback attribute basicCommissioningInfo; + callback attribute regulatoryConfig; + callback attribute locationCapability; + callback attribute supportsConcurrentConnection; + ram attribute featureMap default = 0; + ram attribute clusterRevision default = 1; + + handle command ArmFailSafe; + handle command ArmFailSafeResponse; + handle command SetRegulatoryConfig; + handle command SetRegulatoryConfigResponse; + handle command CommissioningComplete; + handle command CommissioningCompleteResponse; + } + + server cluster NetworkCommissioning { + ram attribute maxNetworks; + callback attribute networks; + ram attribute scanMaxTimeSeconds; + ram attribute connectMaxTimeSeconds; + ram attribute interfaceEnabled; + ram attribute lastNetworkingStatus; + ram attribute lastNetworkID; + ram attribute lastConnectErrorValue; + ram attribute featureMap default = 1; + ram attribute clusterRevision default = 1; + + handle command ScanNetworks; + handle command ScanNetworksResponse; + handle command AddOrUpdateWiFiNetwork; + handle command AddOrUpdateThreadNetwork; + handle command RemoveNetwork; + handle command NetworkConfigResponse; + handle command ConnectNetwork; + handle command ConnectNetworkResponse; + handle command ReorderNetwork; + } + + server cluster DiagnosticLogs { + ram attribute featureMap default = 0; + ram attribute clusterRevision default = 1; + + handle command RetrieveLogsRequest; + } + + server cluster GeneralDiagnostics { + emits event HardwareFaultChange; + emits event RadioFaultChange; + emits event NetworkFaultChange; + emits event BootReason; + callback attribute networkInterfaces; + callback attribute rebootCount; + callback attribute upTime; + callback attribute totalOperationalHours; + callback attribute bootReason; + callback attribute activeHardwareFaults; + callback attribute activeRadioFaults; + callback attribute activeNetworkFaults; + callback attribute testEventTriggersEnabled default = false; + callback attribute featureMap; + callback attribute clusterRevision; + + handle command TestEventTrigger; + handle command TimeSnapshot; + handle command TimeSnapshotResponse; + } + + server cluster SoftwareDiagnostics { + callback attribute currentHeapFree; + callback attribute currentHeapUsed; + callback attribute currentHeapHighWatermark; + callback attribute featureMap; + ram attribute clusterRevision default = 1; + + handle command ResetWatermarks; + } + + server cluster WiFiNetworkDiagnostics { + emits event Disconnection; + emits event AssociationFailure; + emits event ConnectionStatus; + callback attribute bssid; + callback attribute securityType; + callback attribute wiFiVersion; + callback attribute channelNumber; + callback attribute rssi; + callback attribute beaconLostCount; + callback attribute beaconRxCount; + callback attribute packetMulticastRxCount; + callback attribute packetMulticastTxCount; + callback attribute packetUnicastRxCount; + callback attribute packetUnicastTxCount; + callback attribute currentMaxRate; + callback attribute overrunCount; + ram attribute featureMap default = 3; + ram attribute clusterRevision default = 1; + } + + server cluster AdministratorCommissioning { + callback attribute windowStatus; + callback attribute adminFabricIndex; + callback attribute adminVendorId; + ram attribute featureMap default = 0; + ram attribute clusterRevision default = 1; + + handle command OpenCommissioningWindow; + handle command OpenBasicCommissioningWindow; + handle command RevokeCommissioning; + } + + server cluster OperationalCredentials { + callback attribute NOCs; + callback attribute fabrics; + callback attribute supportedFabrics; + callback attribute commissionedFabrics; + callback attribute trustedRootCertificates; + callback attribute currentFabricIndex; + ram attribute featureMap default = 0; + ram attribute clusterRevision default = 1; + + handle command AttestationRequest; + handle command AttestationResponse; + handle command CertificateChainRequest; + handle command CertificateChainResponse; + handle command CSRRequest; + handle command CSRResponse; + handle command AddNOC; + handle command UpdateNOC; + handle command NOCResponse; + handle command UpdateFabricLabel; + handle command RemoveFabric; + handle command AddTrustedRootCertificate; + } + + server cluster GroupKeyManagement { + callback attribute groupKeyMap; + callback attribute groupTable; + callback attribute maxGroupsPerFabric; + callback attribute maxGroupKeysPerFabric; + callback attribute featureMap; + callback attribute clusterRevision; + + handle command KeySetWrite; + handle command KeySetRead; + handle command KeySetReadResponse; + handle command KeySetRemove; + handle command KeySetReadAllIndices; + handle command KeySetReadAllIndicesResponse; + } + + server cluster FixedLabel { + callback attribute labelList; + ram attribute featureMap default = 0; + ram attribute clusterRevision default = 1; + } + + server cluster UserLabel { + callback attribute labelList; + ram attribute featureMap default = 0; + ram attribute clusterRevision default = 1; + } +} +endpoint 1 { + device type ma_extendedcolorlight = 269, version 1; + + + server cluster Identify { + ram attribute identifyTime default = 0x0000; + ram attribute identifyType default = 0x0; + ram attribute featureMap default = 0; + ram attribute clusterRevision default = 4; + + handle command Identify; + handle command TriggerEffect; + } + + server cluster Groups { + ram attribute nameSupport; + ram attribute featureMap default = 0; + ram attribute clusterRevision default = 4; + + handle command AddGroup; + handle command AddGroupResponse; + handle command ViewGroup; + handle command ViewGroupResponse; + handle command GetGroupMembership; + handle command GetGroupMembershipResponse; + handle command RemoveGroup; + handle command RemoveGroupResponse; + handle command RemoveAllGroups; + handle command AddGroupIfIdentifying; + } + + server cluster OnOff { + persist attribute onOff default = 0x1; + ram attribute globalSceneControl default = 0x01; + ram attribute onTime default = 0x0000; + ram attribute offWaitTime default = 0x0000; + persist attribute startUpOnOff; + ram attribute featureMap default = 1; + ram attribute clusterRevision default = 5; + + handle command Off; + handle command On; + handle command Toggle; + handle command OffWithEffect; + handle command OnWithRecallGlobalScene; + handle command OnWithTimedOff; + } + + server cluster LevelControl { + persist attribute currentLevel default = 0x254; + ram attribute remainingTime default = 0x0000; + ram attribute minLevel default = 0x01; + ram attribute maxLevel default = 0xFE; + ram attribute currentFrequency default = 0x0000; + ram attribute minFrequency default = 0x0000; + ram attribute maxFrequency default = 0x0000; + ram attribute options default = 0x00; + ram attribute onOffTransitionTime default = 0x0000; + ram attribute onLevel; + ram attribute onTransitionTime; + ram attribute offTransitionTime; + ram attribute defaultMoveRate default = 50; + persist attribute startUpCurrentLevel; + ram attribute featureMap default = 3; + ram attribute clusterRevision default = 5; + + handle command MoveToLevel; + handle command Move; + handle command Step; + handle command Stop; + handle command MoveToLevelWithOnOff; + handle command MoveWithOnOff; + handle command StepWithOnOff; + handle command StopWithOnOff; + } + + server cluster Descriptor { + callback attribute deviceTypeList; + callback attribute serverList; + callback attribute clientList; + callback attribute partsList; + callback attribute featureMap; + callback attribute clusterRevision; + } + + server cluster ColorControl { + ram attribute currentHue default = 0x00; + ram attribute currentSaturation default = 0x00; + ram attribute remainingTime default = 0x0000; + ram attribute currentX default = 0x616B; + ram attribute currentY default = 0x607D; + ram attribute colorTemperatureMireds default = 0x00FA; + ram attribute colorMode default = 0x01; + ram attribute options default = 0x00; + ram attribute numberOfPrimaries; + ram attribute primary1X; + ram attribute primary1Y; + ram attribute primary1Intensity; + ram attribute primary2X; + ram attribute primary2Y; + ram attribute primary2Intensity; + ram attribute primary3X; + ram attribute primary3Y; + ram attribute primary3Intensity; + ram attribute primary4X; + ram attribute primary4Y; + ram attribute primary4Intensity; + ram attribute primary5X; + ram attribute primary5Y; + ram attribute primary5Intensity; + ram attribute primary6X; + ram attribute primary6Y; + ram attribute primary6Intensity; + ram attribute enhancedCurrentHue default = 0x0000; + ram attribute enhancedColorMode default = 0x01; + ram attribute colorLoopActive default = 0x00; + ram attribute colorLoopDirection default = 0x00; + ram attribute colorLoopTime default = 0x0019; + ram attribute colorLoopStartEnhancedHue default = 0x2300; + ram attribute colorLoopStoredEnhancedHue default = 0x0000; + ram attribute colorCapabilities default = 0x1F; + ram attribute colorTempPhysicalMinMireds default = 0x0000; + ram attribute colorTempPhysicalMaxMireds default = 0xFEFF; + ram attribute coupleColorTempToLevelMinMireds; + ram attribute startUpColorTemperatureMireds; + ram attribute featureMap default = 0x1F; + ram attribute clusterRevision default = 6; + + handle command MoveToHue; + handle command MoveHue; + handle command StepHue; + handle command MoveToSaturation; + handle command MoveSaturation; + handle command StepSaturation; + handle command MoveToHueAndSaturation; + handle command MoveToColor; + handle command MoveColor; + handle command StepColor; + handle command MoveToColorTemperature; + handle command EnhancedMoveToHue; + handle command EnhancedMoveHue; + handle command EnhancedStepHue; + handle command EnhancedMoveToHueAndSaturation; + handle command ColorLoopSet; + handle command StopMoveStep; + handle command MoveColorTemperature; + handle command StepColorTemperature; + } +} + + diff --git a/examples/lighting-app/qcc74x/data_model/lighting-app-wifi.zap b/examples/lighting-app/qcc74x/data_model/lighting-app-wifi.zap new file mode 100644 index 00000000000000..94a906a3f532a5 --- /dev/null +++ b/examples/lighting-app/qcc74x/data_model/lighting-app-wifi.zap @@ -0,0 +1,4512 @@ +{ + "fileFormat": 2, + "featureLevel": 99, + "creator": "zap", + "keyValuePairs": [ + { + "key": "commandDiscovery", + "value": "1" + }, + { + "key": "defaultResponsePolicy", + "value": "always" + }, + { + "key": "manufacturerCodes", + "value": "0x1002" + } + ], + "package": [ + { + "pathRelativity": "relativeToZap", + "path": "../../../../src/app/zap-templates/zcl/zcl.json", + "type": "zcl-properties", + "category": "matter", + "version": 1, + "description": "Matter SDK ZCL data" + }, + { + "pathRelativity": "relativeToZap", + "path": "../../../../src/app/zap-templates/app-templates.json", + "type": "gen-templates-json", + "version": "chip-v1" + } + ], + "endpointTypes": [ + { + "id": 1, + "name": "MA-rootdevice", + "deviceTypeRef": { + "code": 22, + "profileId": 259, + "label": "MA-rootdevice", + "name": "MA-rootdevice" + }, + "deviceTypes": [ + { + "code": 22, + "profileId": 259, + "label": "MA-rootdevice", + "name": "MA-rootdevice" + } + ], + "deviceVersions": [ + 1 + ], + "deviceIdentifiers": [ + 22 + ], + "deviceTypeName": "MA-rootdevice", + "deviceTypeCode": 22, + "deviceTypeProfileId": 259, + "clusters": [ + { + "name": "Descriptor", + "code": 29, + "mfgCode": null, + "define": "DESCRIPTOR_CLUSTER", + "side": "server", + "enabled": 1, + "attributes": [ + { + "name": "DeviceTypeList", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ServerList", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClientList", + "code": 2, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "PartsList", + "code": 3, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + } + ] + }, + { + "name": "Access Control", + "code": 31, + "mfgCode": null, + "define": "ACCESS_CONTROL_CLUSTER", + "side": "server", + "enabled": 1, + "attributes": [ + { + "name": "ACL", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "Extension", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "SubjectsPerAccessControlEntry", + "code": 2, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "TargetsPerAccessControlEntry", + "code": 3, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AccessControlEntriesPerFabric", + "code": 4, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AttributeList", + "code": 65531, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + } + ], + "events": [ + { + "name": "AccessControlEntryChanged", + "code": 0, + "mfgCode": null, + "side": "server", + "included": 1 + }, + { + "name": "AccessControlExtensionChanged", + "code": 1, + "mfgCode": null, + "side": "server", + "included": 1 + } + ] + }, + { + "name": "Basic Information", + "code": 40, + "mfgCode": null, + "define": "BASIC_INFORMATION_CLUSTER", + "side": "server", + "enabled": 1, + "attributes": [ + { + "name": "DataModelRevision", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "External", + "singleton": 1, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "VendorName", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "char_string", + "included": 1, + "storageOption": "External", + "singleton": 1, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "VendorID", + "code": 2, + "mfgCode": null, + "side": "server", + "type": "vendor_id", + "included": 1, + "storageOption": "External", + "singleton": 1, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ProductName", + "code": 3, + "mfgCode": null, + "side": "server", + "type": "char_string", + "included": 1, + "storageOption": "External", + "singleton": 1, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ProductID", + "code": 4, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "External", + "singleton": 1, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "NodeLabel", + "code": 5, + "mfgCode": null, + "side": "server", + "type": "char_string", + "included": 1, + "storageOption": "NVM", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "Location", + "code": 6, + "mfgCode": null, + "side": "server", + "type": "char_string", + "included": 1, + "storageOption": "External", + "singleton": 1, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "HardwareVersion", + "code": 7, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "External", + "singleton": 1, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "HardwareVersionString", + "code": 8, + "mfgCode": null, + "side": "server", + "type": "char_string", + "included": 1, + "storageOption": "External", + "singleton": 1, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "SoftwareVersion", + "code": 9, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 1, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "SoftwareVersionString", + "code": 10, + "mfgCode": null, + "side": "server", + "type": "char_string", + "included": 1, + "storageOption": "External", + "singleton": 1, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ManufacturingDate", + "code": 11, + "mfgCode": null, + "side": "server", + "type": "char_string", + "included": 1, + "storageOption": "External", + "singleton": 1, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "PartNumber", + "code": 12, + "mfgCode": null, + "side": "server", + "type": "char_string", + "included": 1, + "storageOption": "External", + "singleton": 1, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ProductURL", + "code": 13, + "mfgCode": null, + "side": "server", + "type": "long_char_string", + "included": 1, + "storageOption": "External", + "singleton": 1, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ProductLabel", + "code": 14, + "mfgCode": null, + "side": "server", + "type": "char_string", + "included": 1, + "storageOption": "External", + "singleton": 1, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "SerialNumber", + "code": 15, + "mfgCode": null, + "side": "server", + "type": "char_string", + "included": 1, + "storageOption": "External", + "singleton": 1, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "LocalConfigDisabled", + "code": 16, + "mfgCode": null, + "side": "server", + "type": "boolean", + "included": 1, + "storageOption": "NVM", + "singleton": 1, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "UniqueID", + "code": 18, + "mfgCode": null, + "side": "server", + "type": "char_string", + "included": 1, + "storageOption": "External", + "singleton": 1, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "CapabilityMinima", + "code": 19, + "mfgCode": null, + "side": "server", + "type": "CapabilityMinimaStruct", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "SpecificationVersion", + "code": 21, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 1, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "MaxPathsPerInvoke", + "code": 22, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "External", + "singleton": 1, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "3", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ], + "events": [ + { + "name": "StartUp", + "code": 0, + "mfgCode": null, + "side": "server", + "included": 1 + }, + { + "name": "ShutDown", + "code": 1, + "mfgCode": null, + "side": "server", + "included": 1 + }, + { + "name": "Leave", + "code": 2, + "mfgCode": null, + "side": "server", + "included": 1 + } + ] + }, + { + "name": "OTA Software Update Provider", + "code": 41, + "mfgCode": null, + "define": "OTA_SOFTWARE_UPDATE_PROVIDER_CLUSTER", + "side": "client", + "enabled": 1, + "commands": [ + { + "name": "QueryImage", + "code": 0, + "mfgCode": null, + "source": "client", + "isIncoming": 0, + "isEnabled": 1 + }, + { + "name": "QueryImageResponse", + "code": 1, + "mfgCode": null, + "source": "server", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "ApplyUpdateRequest", + "code": 2, + "mfgCode": null, + "source": "client", + "isIncoming": 0, + "isEnabled": 1 + }, + { + "name": "ApplyUpdateResponse", + "code": 3, + "mfgCode": null, + "source": "server", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "NotifyUpdateApplied", + "code": 4, + "mfgCode": null, + "source": "client", + "isIncoming": 0, + "isEnabled": 1 + } + ], + "attributes": [ + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "client", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "OTA Software Update Requestor", + "code": 42, + "mfgCode": null, + "define": "OTA_SOFTWARE_UPDATE_REQUESTOR_CLUSTER", + "side": "server", + "enabled": 1, + "commands": [ + { + "name": "AnnounceOTAProvider", + "code": 0, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + } + ], + "attributes": [ + { + "name": "DefaultOTAProviders", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "UpdatePossible", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "boolean", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "UpdateState", + "code": 2, + "mfgCode": null, + "side": "server", + "type": "UpdateStateEnum", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "UpdateStateProgress", + "code": 3, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ], + "events": [ + { + "name": "StateTransition", + "code": 0, + "mfgCode": null, + "side": "server", + "included": 1 + }, + { + "name": "VersionApplied", + "code": 1, + "mfgCode": null, + "side": "server", + "included": 1 + }, + { + "name": "DownloadError", + "code": 2, + "mfgCode": null, + "side": "server", + "included": 1 + } + ] + }, + { + "name": "Localization Configuration", + "code": 43, + "mfgCode": null, + "define": "LOCALIZATION_CONFIGURATION_CLUSTER", + "side": "server", + "enabled": 1, + "attributes": [ + { + "name": "ActiveLocale", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "char_string", + "included": 1, + "storageOption": "NVM", + "singleton": 0, + "bounded": 0, + "defaultValue": "en-US", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "SupportedLocales", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + } + ] + }, + { + "name": "Time Format Localization", + "code": 44, + "mfgCode": null, + "define": "TIME_FORMAT_LOCALIZATION_CLUSTER", + "side": "server", + "enabled": 1, + "attributes": [ + { + "name": "HourFormat", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "HourFormatEnum", + "included": 1, + "storageOption": "NVM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ActiveCalendarType", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "CalendarTypeEnum", + "included": 1, + "storageOption": "NVM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "SupportedCalendarTypes", + "code": 2, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + } + ] + }, + { + "name": "General Commissioning", + "code": 48, + "mfgCode": null, + "define": "GENERAL_COMMISSIONING_CLUSTER", + "side": "server", + "enabled": 1, + "commands": [ + { + "name": "ArmFailSafe", + "code": 0, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "ArmFailSafeResponse", + "code": 1, + "mfgCode": null, + "source": "server", + "isIncoming": 0, + "isEnabled": 1 + }, + { + "name": "SetRegulatoryConfig", + "code": 2, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "SetRegulatoryConfigResponse", + "code": 3, + "mfgCode": null, + "source": "server", + "isIncoming": 0, + "isEnabled": 1 + }, + { + "name": "CommissioningComplete", + "code": 4, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "CommissioningCompleteResponse", + "code": 5, + "mfgCode": null, + "source": "server", + "isIncoming": 0, + "isEnabled": 1 + } + ], + "attributes": [ + { + "name": "Breadcrumb", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "int64u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000000000000000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "BasicCommissioningInfo", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "BasicCommissioningInfo", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "RegulatoryConfig", + "code": 2, + "mfgCode": null, + "side": "server", + "type": "RegulatoryLocationTypeEnum", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "LocationCapability", + "code": 3, + "mfgCode": null, + "side": "server", + "type": "RegulatoryLocationTypeEnum", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "SupportsConcurrentConnection", + "code": 4, + "mfgCode": null, + "side": "server", + "type": "boolean", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "Network Commissioning", + "code": 49, + "mfgCode": null, + "define": "NETWORK_COMMISSIONING_CLUSTER", + "side": "server", + "enabled": 1, + "commands": [ + { + "name": "ScanNetworks", + "code": 0, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "ScanNetworksResponse", + "code": 1, + "mfgCode": null, + "source": "server", + "isIncoming": 0, + "isEnabled": 1 + }, + { + "name": "AddOrUpdateWiFiNetwork", + "code": 2, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "AddOrUpdateThreadNetwork", + "code": 3, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "RemoveNetwork", + "code": 4, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "NetworkConfigResponse", + "code": 5, + "mfgCode": null, + "source": "server", + "isIncoming": 0, + "isEnabled": 1 + }, + { + "name": "ConnectNetwork", + "code": 6, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "ConnectNetworkResponse", + "code": 7, + "mfgCode": null, + "source": "server", + "isIncoming": 0, + "isEnabled": 1 + }, + { + "name": "ReorderNetwork", + "code": 8, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + } + ], + "attributes": [ + { + "name": "MaxNetworks", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "Networks", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ScanMaxTimeSeconds", + "code": 2, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ConnectMaxTimeSeconds", + "code": 3, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "InterfaceEnabled", + "code": 4, + "mfgCode": null, + "side": "server", + "type": "boolean", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "LastNetworkingStatus", + "code": 5, + "mfgCode": null, + "side": "server", + "type": "NetworkCommissioningStatusEnum", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "LastNetworkID", + "code": 6, + "mfgCode": null, + "side": "server", + "type": "octet_string", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "LastConnectErrorValue", + "code": 7, + "mfgCode": null, + "side": "server", + "type": "int32s", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "Diagnostic Logs", + "code": 50, + "mfgCode": null, + "define": "DIAGNOSTIC_LOGS_CLUSTER", + "side": "server", + "enabled": 1, + "commands": [ + { + "name": "RetrieveLogsRequest", + "code": 0, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + } + ], + "attributes": [ + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + } + ] + }, + { + "name": "General Diagnostics", + "code": 51, + "mfgCode": null, + "define": "GENERAL_DIAGNOSTICS_CLUSTER", + "side": "server", + "enabled": 1, + "commands": [ + { + "name": "TestEventTrigger", + "code": 0, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "TimeSnapshot", + "code": 1, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "TimeSnapshotResponse", + "code": 2, + "mfgCode": null, + "source": "server", + "isIncoming": 0, + "isEnabled": 1 + } + ], + "attributes": [ + { + "name": "NetworkInterfaces", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "RebootCount", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "UpTime", + "code": 2, + "mfgCode": null, + "side": "server", + "type": "int64u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "TotalOperationalHours", + "code": 3, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "BootReason", + "code": 4, + "mfgCode": null, + "side": "server", + "type": "BootReasonEnum", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ActiveHardwareFaults", + "code": 5, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ActiveRadioFaults", + "code": 6, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ActiveNetworkFaults", + "code": 7, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "TestEventTriggersEnabled", + "code": 8, + "mfgCode": null, + "side": "server", + "type": "boolean", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "false", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0002", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ], + "events": [ + { + "name": "HardwareFaultChange", + "code": 0, + "mfgCode": null, + "side": "server", + "included": 1 + }, + { + "name": "RadioFaultChange", + "code": 1, + "mfgCode": null, + "side": "server", + "included": 1 + }, + { + "name": "NetworkFaultChange", + "code": 2, + "mfgCode": null, + "side": "server", + "included": 1 + }, + { + "name": "BootReason", + "code": 3, + "mfgCode": null, + "side": "server", + "included": 1 + } + ] + }, + { + "name": "Software Diagnostics", + "code": 52, + "mfgCode": null, + "define": "SOFTWARE_DIAGNOSTICS_CLUSTER", + "side": "server", + "enabled": 1, + "commands": [ + { + "name": "ResetWatermarks", + "code": 0, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + } + ], + "attributes": [ + { + "name": "CurrentHeapFree", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "int64u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "CurrentHeapUsed", + "code": 2, + "mfgCode": null, + "side": "server", + "type": "int64u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "CurrentHeapHighWatermark", + "code": 3, + "mfgCode": null, + "side": "server", + "type": "int64u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "WiFi Network Diagnostics", + "code": 54, + "mfgCode": null, + "define": "WIFI_NETWORK_DIAGNOSTICS_CLUSTER", + "side": "server", + "enabled": 1, + "attributes": [ + { + "name": "BSSID", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "octet_string", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "SecurityType", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "SecurityTypeEnum", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "WiFiVersion", + "code": 2, + "mfgCode": null, + "side": "server", + "type": "WiFiVersionEnum", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ChannelNumber", + "code": 3, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "RSSI", + "code": 4, + "mfgCode": null, + "side": "server", + "type": "int8s", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "BeaconLostCount", + "code": 5, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "BeaconRxCount", + "code": 6, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "PacketMulticastRxCount", + "code": 7, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "PacketMulticastTxCount", + "code": 8, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "PacketUnicastRxCount", + "code": 9, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "PacketUnicastTxCount", + "code": 10, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "CurrentMaxRate", + "code": 11, + "mfgCode": null, + "side": "server", + "type": "int64u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "OverrunCount", + "code": 12, + "mfgCode": null, + "side": "server", + "type": "int64u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "3", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ], + "events": [ + { + "name": "Disconnection", + "code": 0, + "mfgCode": null, + "side": "server", + "included": 1 + }, + { + "name": "AssociationFailure", + "code": 1, + "mfgCode": null, + "side": "server", + "included": 1 + }, + { + "name": "ConnectionStatus", + "code": 2, + "mfgCode": null, + "side": "server", + "included": 1 + } + ] + }, + { + "name": "Administrator Commissioning", + "code": 60, + "mfgCode": null, + "define": "ADMINISTRATOR_COMMISSIONING_CLUSTER", + "side": "server", + "enabled": 1, + "commands": [ + { + "name": "OpenCommissioningWindow", + "code": 0, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "OpenBasicCommissioningWindow", + "code": 1, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "RevokeCommissioning", + "code": 2, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + } + ], + "attributes": [ + { + "name": "WindowStatus", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "CommissioningWindowStatusEnum", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AdminFabricIndex", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "fabric_idx", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AdminVendorId", + "code": 2, + "mfgCode": null, + "side": "server", + "type": "vendor_id", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "Operational Credentials", + "code": 62, + "mfgCode": null, + "define": "OPERATIONAL_CREDENTIALS_CLUSTER", + "side": "server", + "enabled": 1, + "commands": [ + { + "name": "AttestationRequest", + "code": 0, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "AttestationResponse", + "code": 1, + "mfgCode": null, + "source": "server", + "isIncoming": 0, + "isEnabled": 1 + }, + { + "name": "CertificateChainRequest", + "code": 2, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "CertificateChainResponse", + "code": 3, + "mfgCode": null, + "source": "server", + "isIncoming": 0, + "isEnabled": 1 + }, + { + "name": "CSRRequest", + "code": 4, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "CSRResponse", + "code": 5, + "mfgCode": null, + "source": "server", + "isIncoming": 0, + "isEnabled": 1 + }, + { + "name": "AddNOC", + "code": 6, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "UpdateNOC", + "code": 7, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "NOCResponse", + "code": 8, + "mfgCode": null, + "source": "server", + "isIncoming": 0, + "isEnabled": 1 + }, + { + "name": "UpdateFabricLabel", + "code": 9, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "RemoveFabric", + "code": 10, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "AddTrustedRootCertificate", + "code": 11, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + } + ], + "attributes": [ + { + "name": "NOCs", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "Fabrics", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "SupportedFabrics", + "code": 2, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "CommissionedFabrics", + "code": 3, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "TrustedRootCertificates", + "code": 4, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "CurrentFabricIndex", + "code": 5, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "Group Key Management", + "code": 63, + "mfgCode": null, + "define": "GROUP_KEY_MANAGEMENT_CLUSTER", + "side": "server", + "enabled": 1, + "commands": [ + { + "name": "KeySetWrite", + "code": 0, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "KeySetRead", + "code": 1, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "KeySetReadResponse", + "code": 2, + "mfgCode": null, + "source": "server", + "isIncoming": 0, + "isEnabled": 1 + }, + { + "name": "KeySetRemove", + "code": 3, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "KeySetReadAllIndices", + "code": 4, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "KeySetReadAllIndicesResponse", + "code": 5, + "mfgCode": null, + "source": "server", + "isIncoming": 0, + "isEnabled": 1 + } + ], + "attributes": [ + { + "name": "GroupKeyMap", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "GroupTable", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "MaxGroupsPerFabric", + "code": 2, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "MaxGroupKeysPerFabric", + "code": 3, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + } + ] + }, + { + "name": "Fixed Label", + "code": 64, + "mfgCode": null, + "define": "FIXED_LABEL_CLUSTER", + "side": "server", + "enabled": 1, + "attributes": [ + { + "name": "LabelList", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + } + ] + }, + { + "name": "User Label", + "code": 65, + "mfgCode": null, + "define": "USER_LABEL_CLUSTER", + "side": "server", + "enabled": 1, + "attributes": [ + { + "name": "LabelList", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + } + ] + } + ] + }, + { + "id": 2, + "name": "MA-extendedcolorlight", + "deviceTypeRef": { + "code": 269, + "profileId": 259, + "label": "MA-extendedcolorlight", + "name": "MA-extendedcolorlight" + }, + "deviceTypes": [ + { + "code": 269, + "profileId": 259, + "label": "MA-extendedcolorlight", + "name": "MA-extendedcolorlight" + } + ], + "deviceVersions": [ + 1 + ], + "deviceIdentifiers": [ + 269 + ], + "deviceTypeName": "MA-extendedcolorlight", + "deviceTypeCode": 269, + "deviceTypeProfileId": 259, + "clusters": [ + { + "name": "Identify", + "code": 3, + "mfgCode": null, + "define": "IDENTIFY_CLUSTER", + "side": "server", + "enabled": 1, + "commands": [ + { + "name": "Identify", + "code": 0, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "TriggerEffect", + "code": 64, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + } + ], + "attributes": [ + { + "name": "IdentifyTime", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "IdentifyType", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "IdentifyTypeEnum", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "4", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "Groups", + "code": 4, + "mfgCode": null, + "define": "GROUPS_CLUSTER", + "side": "server", + "enabled": 1, + "commands": [ + { + "name": "AddGroup", + "code": 0, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "AddGroupResponse", + "code": 0, + "mfgCode": null, + "source": "server", + "isIncoming": 0, + "isEnabled": 1 + }, + { + "name": "ViewGroup", + "code": 1, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "ViewGroupResponse", + "code": 1, + "mfgCode": null, + "source": "server", + "isIncoming": 0, + "isEnabled": 1 + }, + { + "name": "GetGroupMembership", + "code": 2, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "GetGroupMembershipResponse", + "code": 2, + "mfgCode": null, + "source": "server", + "isIncoming": 0, + "isEnabled": 1 + }, + { + "name": "RemoveGroup", + "code": 3, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "RemoveGroupResponse", + "code": 3, + "mfgCode": null, + "source": "server", + "isIncoming": 0, + "isEnabled": 1 + }, + { + "name": "RemoveAllGroups", + "code": 4, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "AddGroupIfIdentifying", + "code": 5, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + } + ], + "attributes": [ + { + "name": "NameSupport", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "NameSupportBitmap", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "4", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "On/Off", + "code": 6, + "mfgCode": null, + "define": "ON_OFF_CLUSTER", + "side": "server", + "enabled": 1, + "commands": [ + { + "name": "Off", + "code": 0, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "On", + "code": 1, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "Toggle", + "code": 2, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "OffWithEffect", + "code": 64, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "OnWithRecallGlobalScene", + "code": 65, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "OnWithTimedOff", + "code": 66, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + } + ], + "attributes": [ + { + "name": "OnOff", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "boolean", + "included": 1, + "storageOption": "NVM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x1", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "GlobalSceneControl", + "code": 16384, + "mfgCode": null, + "side": "server", + "type": "boolean", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x01", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "OnTime", + "code": 16385, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "OffWaitTime", + "code": 16386, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "StartUpOnOff", + "code": 16387, + "mfgCode": null, + "side": "server", + "type": "StartUpOnOffEnum", + "included": 1, + "storageOption": "NVM", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "5", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "Level Control", + "code": 8, + "mfgCode": null, + "define": "LEVEL_CONTROL_CLUSTER", + "side": "server", + "enabled": 1, + "commands": [ + { + "name": "MoveToLevel", + "code": 0, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "Move", + "code": 1, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "Step", + "code": 2, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "Stop", + "code": 3, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "MoveToLevelWithOnOff", + "code": 4, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "MoveWithOnOff", + "code": 5, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "StepWithOnOff", + "code": 6, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "StopWithOnOff", + "code": 7, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + } + ], + "attributes": [ + { + "name": "CurrentLevel", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "NVM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x254", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "RemainingTime", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "MinLevel", + "code": 2, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x01", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "MaxLevel", + "code": 3, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0xFE", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "CurrentFrequency", + "code": 4, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "MinFrequency", + "code": 5, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "MaxFrequency", + "code": 6, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "Options", + "code": 15, + "mfgCode": null, + "side": "server", + "type": "OptionsBitmap", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x00", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "OnOffTransitionTime", + "code": 16, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "OnLevel", + "code": 17, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "OnTransitionTime", + "code": 18, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "OffTransitionTime", + "code": 19, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "DefaultMoveRate", + "code": 20, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "50", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "StartUpCurrentLevel", + "code": 16384, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "NVM", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "3", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "5", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "Descriptor", + "code": 29, + "mfgCode": null, + "define": "DESCRIPTOR_CLUSTER", + "side": "server", + "enabled": 1, + "attributes": [ + { + "name": "DeviceTypeList", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ServerList", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClientList", + "code": 2, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "PartsList", + "code": 3, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + } + ] + }, + { + "name": "Color Control", + "code": 768, + "mfgCode": null, + "define": "COLOR_CONTROL_CLUSTER", + "side": "server", + "enabled": 1, + "commands": [ + { + "name": "MoveToHue", + "code": 0, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "MoveHue", + "code": 1, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "StepHue", + "code": 2, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "MoveToSaturation", + "code": 3, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "MoveSaturation", + "code": 4, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "StepSaturation", + "code": 5, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "MoveToHueAndSaturation", + "code": 6, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "MoveToColor", + "code": 7, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "MoveColor", + "code": 8, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "StepColor", + "code": 9, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "MoveToColorTemperature", + "code": 10, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "EnhancedMoveToHue", + "code": 64, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "EnhancedMoveHue", + "code": 65, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "EnhancedStepHue", + "code": 66, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "EnhancedMoveToHueAndSaturation", + "code": 67, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "ColorLoopSet", + "code": 68, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "StopMoveStep", + "code": 71, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "MoveColorTemperature", + "code": 75, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "StepColorTemperature", + "code": 76, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + } + ], + "attributes": [ + { + "name": "CurrentHue", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x00", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "CurrentSaturation", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x00", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "RemainingTime", + "code": 2, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "CurrentX", + "code": 3, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x616B", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "CurrentY", + "code": 4, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x607D", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ColorTemperatureMireds", + "code": 7, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x00FA", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ColorMode", + "code": 8, + "mfgCode": null, + "side": "server", + "type": "enum8", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x01", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "Options", + "code": 15, + "mfgCode": null, + "side": "server", + "type": "bitmap8", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x00", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "NumberOfPrimaries", + "code": 16, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "Primary1X", + "code": 17, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "Primary1Y", + "code": 18, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "Primary1Intensity", + "code": 19, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "Primary2X", + "code": 21, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "Primary2Y", + "code": 22, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "Primary2Intensity", + "code": 23, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "Primary3X", + "code": 25, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "Primary3Y", + "code": 26, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "Primary3Intensity", + "code": 27, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "Primary4X", + "code": 32, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "Primary4Y", + "code": 33, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "Primary4Intensity", + "code": 34, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "Primary5X", + "code": 36, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "Primary5Y", + "code": 37, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "Primary5Intensity", + "code": 38, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "Primary6X", + "code": 40, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "Primary6Y", + "code": 41, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "Primary6Intensity", + "code": 42, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "EnhancedCurrentHue", + "code": 16384, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "EnhancedColorMode", + "code": 16385, + "mfgCode": null, + "side": "server", + "type": "enum8", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x01", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ColorLoopActive", + "code": 16386, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x00", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ColorLoopDirection", + "code": 16387, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x00", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ColorLoopTime", + "code": 16388, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0019", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ColorLoopStartEnhancedHue", + "code": 16389, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x2300", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ColorLoopStoredEnhancedHue", + "code": 16390, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ColorCapabilities", + "code": 16394, + "mfgCode": null, + "side": "server", + "type": "bitmap16", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x1F", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ColorTempPhysicalMinMireds", + "code": 16395, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ColorTempPhysicalMaxMireds", + "code": 16396, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0xFEFF", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "CoupleColorTempToLevelMinMireds", + "code": 16397, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "StartUpColorTemperatureMireds", + "code": 16400, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x1F", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "6", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + } + ] + } + ], + "endpoints": [ + { + "endpointTypeName": "MA-rootdevice", + "endpointTypeIndex": 0, + "profileId": 259, + "endpointId": 0, + "networkId": 0 + }, + { + "endpointTypeName": "MA-extendedcolorlight", + "endpointTypeIndex": 1, + "profileId": 259, + "endpointId": 1, + "networkId": 0 + } + ] +} \ No newline at end of file diff --git a/examples/lighting-app/qcc74x/qcc743/.gn b/examples/lighting-app/qcc74x/qcc743/.gn new file mode 100644 index 00000000000000..27a24ca4db236b --- /dev/null +++ b/examples/lighting-app/qcc74x/qcc743/.gn @@ -0,0 +1,28 @@ +# Copyright (c) 2021 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build_overrides/build.gni") + +# The location of the build configuration file. +buildconfig = "${build_root}/config/BUILDCONFIG.gn" + +# CHIP uses angle bracket includes. +check_system_includes = true + +default_args = { + target_cpu = "riscv" + target_os = "freertos" + + import("//args.gni") +} diff --git a/examples/lighting-app/qcc74x/qcc743/BUILD.gn b/examples/lighting-app/qcc74x/qcc743/BUILD.gn new file mode 100644 index 00000000000000..afd7a3b11ad0e6 --- /dev/null +++ b/examples/lighting-app/qcc74x/qcc743/BUILD.gn @@ -0,0 +1,251 @@ +# Copyright (c) 2021 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build_overrides/qcc74x_iot_sdk.gni") +import("//build_overrides/build.gni") +import("//build_overrides/chip.gni") + +import("${qcc74x_iot_sdk_build_root}/qcc743/qcc74x_sdk.gni") +import("${qcc74x_iot_sdk_build_root}/common/qcc74x_executable.gni") +import("${build_root}/config/defaults.gni") +import("${chip_root}/examples/common/pigweed/pigweed_rpcs.gni") +import("${chip_root}/src/platform/qcc74x/common/args.gni") +import("${chip_root}/src/platform/device.gni") + +import("${chip_root}/src/app/chip_data_model.gni") + +if (chip_enable_pw_rpc) { + import("//build_overrides/pigweed.gni") + import("$dir_pw_build/target_types.gni") +} + +assert(current_os == "freertos") + +example_dir = "${chip_root}/examples/lighting-app/qcc74x" +examples_plat_dir = "${chip_root}/examples/platform/qcc74x" + +declare_args() { + # Dump memory usage at link time. + chip_print_memory_usage = true + + # OTA periodic query timeout in seconds + ota_periodic_query_timeout_seconds = 86400 + + # reboot delay in seconds to apply new OTA image + ota_auto_reboot_delay_seconds = 5 + + enable_heap_monitoring = false + enable_reset_counter = false + + setupPinCode = 20202021 + setupDiscriminator = 3840 + + board = "qcc743DK" + module_type = "qcc743" + baudrate = 2000000 +} + +qcc74x_sdk("sdk") { + + include_dirs = [ + "${example_dir}/qcc743", + "${examples_plat_dir}/qcc743", + "${examples_plat_dir}/qcc743/lwipopts", + "${examples_plat_dir}/common/route_hook", + "${chip_root}/src/platform/qcc74x/qcc743", + "${chip_root}/src/platform/qcc74x/common", + ] + + defines = [ + "INCLUDE_xSemaphoreGetMutexHolder=1", + "CHIP_DEVICE_CONFIG_USE_TEST_SETUP_PIN_CODE=${setupPinCode}", + "CHIP_DEVICE_CONFIG_USE_TEST_SETUP_DISCRIMINATOR=${setupDiscriminator}", + "OTA_PERIODIC_TIMEOUT=${ota_periodic_query_timeout_seconds}", + "OTA_AUTO_REBOOT_DELAY=${ota_auto_reboot_delay_seconds}", + "CHIP_UART_BAUDRATE=${baudrate}", + ] + + defines += [ "PW_RPC_ENABLED=${chip_enable_pw_rpc}" ] + if (chip_enable_pw_rpc) { + include_dirs += [ "${examples_plat_dir}/common/rpc" ] + defines += [ "PW_RPC_ENABLED=1" ] + defines += [ "DISABLE_PRINT=1" ] + } else if (chip_build_libshell) { + include_dirs += [ "${examples_plat_dir}/common/plat" ] + } +} + +chip_data_model("qcc74x-lighting") { + zap_file = "${example_dir}/data_model/lighting-app-wifi.zap" + is_server = true +} + +qcc74x_executable("lighting_app") { + output_name = "chip-qcc743-lighting-example.out" + + defines = [ + "APP_TASK_STACK_SIZE=4096", + "CHIP_UART_BAUDRATE=${baudrate}", + "qcc743_ENABLE", + "START_ENTRY=main", + ] + + if (false == enable_reset_counter) { + defines += [ "BOOT_PIN_RESET=2" ] + } + + defines += [ "CONF_ENABLE_FRAME_PTR=${enable_debug_frame_ptr}" ] + defines += + [ "CONFIG_BOUFFALOLAB_FACTORY_DATA_ENABLE=${chip_enable_factory_data}" ] + defines += [ + "CONFIG_BOUFFALOLAB_FACTORY_DATA_TEST=${chip_enable_factory_data_test}", + ] + + bl_plat_name = "qcc743" + sources = [ + "${examples_plat_dir}/common/route_hook/bl_route_hook.c", + "${examples_plat_dir}/common/route_hook/bl_route_table.c", + ] + + defines += [ "qcc743DK" ] + + if (chip_config_network_layer_ble) { + defines += [ "CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE=1" ] + } + + sources += [ + "${chip_root}/examples/providers/DeviceInfoProviderImpl.cpp", + "${example_dir}/common/AppTask.cpp", + "${example_dir}/common/ZclCallbacks.cpp", + "${examples_plat_dir}/common/qcc74x_sdk/demo_pwm.c", + "${examples_plat_dir}/common/qcc74x_sdk/platform_port.cpp", + "${examples_plat_dir}/common/plat/LEDWidget.cpp", + "${examples_plat_dir}/common/plat/OTAConfig.cpp", + "${examples_plat_dir}/common/plat/main.cpp", + "${examples_plat_dir}/common/plat/platform.cpp", + ] + + deps = [ + ":qcc74x-lighting", + ":sdk", + "${chip_root}/examples/common/QRCode", + "${chip_root}/examples/providers:device_info_provider", + "${chip_root}/src/lib", + "${chip_root}/src/setup_payload", + ] + + include_dirs = [ + "${chip_root}/src/platform/qcc74x/qcc743", + "${example_dir}/common", + "${example_dir}/qcc743", + "${examples_plat_dir}/common/route_hook", + "${examples_plat_dir}/common/plat", + "${examples_plat_dir}/common/qcc74x_sdk", + ] + + if (chip_enable_pw_rpc) { + defines += [ + "PW_RPC_ENABLED", + "PW_RPC_ATTRIBUTE_SERVICE=1", + "PW_RPC_BUTTON_SERVICE=1", + "PW_RPC_DESCRIPTOR_SERVICE=1", + "PW_RPC_DEVICE_SERVICE=1", + "PW_RPC_LIGHTING_SERVICE=1", + + #"PW_RPC_TRACING_SERVICE=1", + ] + + sources += [ + "${chip_root}/examples/common/pigweed/RpcService.cpp", + "${chip_root}/examples/common/pigweed/qcc74x/PigweedLoggerMutex.cpp", + "${examples_plat_dir}/common/rpc/PigweedLogger.cpp", + "${examples_plat_dir}/common/rpc/Rpc.cpp", + ] + + deps += [ + "$dir_pw_hdlc:rpc_channel_output", + "$dir_pw_kvs:crc16", + "$dir_pw_log", + "$dir_pw_stream:sys_io_stream", + + #"$dir_pw_trace", + #"$dir_pw_trace_tokenized", + #"$dir_pw_trace_tokenized:trace_rpc_service", + "${chip_root}/config/qcc74x/common/lib/pw_rpc:pw_rpc", + "${chip_root}/examples/common/pigweed:attributes_service.nanopb_rpc", + "${chip_root}/examples/common/pigweed:button_service.nanopb_rpc", + "${chip_root}/examples/common/pigweed:descriptor_service.nanopb_rpc", + "${chip_root}/examples/common/pigweed:device_service.nanopb_rpc", + "${chip_root}/examples/common/pigweed:lighting_service.nanopb_rpc", + "${examples_plat_dir}/common/rpc/pw_sys_io:pw_sys_io", + ] + + public_deps = [ + "$dir_pw_checksum", + "$dir_pw_kvs", + ] + + deps += pw_build_LINK_DEPS + + include_dirs += [ + "${chip_root}/examples/common", + "${chip_root}/examples/common/pigweed/qcc74x", + ] + } else if (chip_build_libshell) { + defines += [ "CONFIG_ENABLE_CHIP_SHELL=1" ] + + deps += [ "${chip_root}/examples/shell/shell_common:shell_common" ] + + include_dirs += [ + "${chip_root}/src/lib/shell", + "${chip_root}/examples/shell/shell_common/include", + ] + } + + if (enable_heap_monitoring) { + sources += [ "${examples_plat_dir}/common/plat/MemMonitoring.cpp" ] + defines += [ "HEAP_MONITORING=1" ] + } + + if (qcc74x_sdk_component_easyflash_enabled) { + defines += [ "BOUFFALO_SDK_COMPONENTS_EASYFLASH_ENABLED=1" ] + } + else { + defines += [ "BOUFFALO_SDK_COMPONENTS_EASYFLASH_ENABLED=0" ] + } + + cflags_c = [ "-Wno-sign-compare" ] + ldscript = "${examples_plat_dir}/qcc743/ldscripts/qcc743_flash.ld" + + ldflags = [ "-T" + rebase_path(ldscript, root_build_dir) ] + + inputs = [ ldscript ] + + if (chip_print_memory_usage) { + ldflags += [ + "-Wl,--print-memory-usage", + "-fstack-usage", + ] + } + + output_dir = root_out_dir +} + +group("qcc743") { + deps = [ ":lighting_app" ] +} + +group("default") { + deps = [ ":qcc743" ] +} diff --git a/examples/lighting-app/qcc74x/qcc743/CHIPProjectConfig.h b/examples/lighting-app/qcc74x/qcc743/CHIPProjectConfig.h new file mode 100644 index 00000000000000..3f4ac97ac0e7fa --- /dev/null +++ b/examples/lighting-app/qcc74x/qcc743/CHIPProjectConfig.h @@ -0,0 +1,129 @@ +/* + * + * Copyright (c) 2021 Project CHIP Authors + * Copyright (c) 2019 Google LLC. + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @file + * Example project configuration file for CHIP. + * + * This is a place to put application or project-specific overrides + * to the default configuration values for general CHIP features. + * + */ + +#pragma once + +/** + * CHIP_DEVICE_CONFIG_ENABLE_TEST_DEVICE_IDENTITY + * + * Enables the use of a hard-coded default Chip device id and credentials if no device id + * is found in Chip NV storage. + * + * This option is for testing only and should be disabled in production releases. + */ +#define CHIP_DEVICE_CONFIG_ENABLE_TEST_DEVICE_IDENTITY 34 + +// Use a default pairing code if one hasn't been provisioned in flash. +#ifndef CHIP_DEVICE_CONFIG_USE_TEST_SETUP_PIN_CODE +#define CHIP_DEVICE_CONFIG_USE_TEST_SETUP_PIN_CODE 20202021 +#endif + +#ifndef CHIP_DEVICE_CONFIG_USE_TEST_SETUP_DISCRIMINATOR +#define CHIP_DEVICE_CONFIG_USE_TEST_SETUP_DISCRIMINATOR 0xF00 +#endif +// For convenience, Chip Security Test Mode can be enabled and the +// requirement for authentication in various protocols can be disabled. +// +// WARNING: These options make it possible to circumvent basic Chip security functionality, +// including message encryption. Because of this they MUST NEVER BE ENABLED IN PRODUCTION BUILDS. +// +#define CHIP_CONFIG_SECURITY_TEST_MODE 0 + +/** + * CHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID + * + */ +#define CHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID 0xFFF1 + +/** + * CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID + * + */ +#define CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID 0x8005 + +/** + * CHIP_DEVICE_CONFIG_DEVICE_HARDWARE_VERSION + * + * The hardware version number assigned to device or product by the device vendor. This + * number is scoped to the device product id, and typically corresponds to a revision of the + * physical device, a change to its packaging, and/or a change to its marketing presentation. + * This value is generally *not* incremented for device software versions. + */ +#define CHIP_DEVICE_CONFIG_DEVICE_HARDWARE_VERSION 1 + +/** + * CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING + * + * A string identifying the software version running on the device. + * CHIP service currently expects the software version to be in the format + * {MAJOR_VERSION}.0d{MINOR_VERSION} + */ +#ifndef CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING +#define CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING "0.1ALPHA" +#endif + +/** + * CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION + * + * A uint32_t identifying the software version running on the device. + */ +/* The SoftwareVersion attribute of the Basic cluster. */ +#ifndef CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION +#define CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION 0x0001 +#endif + +/** + * CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_REVISION + * + * The product revision number assigned to device or product by the device vendor. This + * number is scoped to the device product id, and typically corresponds to a revision of the + * physical device, a change to its packaging, and/or a change to its marketing presentation. + * This value is generally *not* incremented for device software revisions. + */ +#define CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_REVISION 1 + +/** + * CHIP_DEVICE_CONFIG_TEST_SERIAL_NUMBER + * + * Enables the use of a hard-coded default serial number if none + * is found in Chip NV storage. + */ +#define CHIP_DEVICE_CONFIG_TEST_SERIAL_NUMBER "TEST_SN" + +/** + * CHIP_DEVICE_CONFIG_EVENT_LOGGING_DEBUG_BUFFER_SIZE + * + * A size, in bytes, of the individual debug event logging buffer. + */ +#define CHIP_DEVICE_CONFIG_EVENT_LOGGING_DEBUG_BUFFER_SIZE (512) + +#define CHIP_DEVICE_CONFIG_ENABLE_EXTENDED_DISCOVERY 1 + +#define CHIP_BLE_DEVICE_NAME "MatterLight" + +// #define CHIP_CONFIG_VERBOSE_VERIFY_OR_DIE 1 \ No newline at end of file diff --git a/examples/lighting-app/qcc74x/qcc743/args.gni b/examples/lighting-app/qcc74x/qcc743/args.gni new file mode 100644 index 00000000000000..4326c4ee46735b --- /dev/null +++ b/examples/lighting-app/qcc74x/qcc743/args.gni @@ -0,0 +1,35 @@ +# Copyright (c) 2021 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build_overrides/chip.gni") +import("//build_overrides/pigweed.gni") +import("${chip_root}/config/standalone/args.gni") +import("${chip_root}/src/platform/qcc74x/qcc743/args.gni") + +qcc74x_sdk_target = get_label_info(":sdk", "label_no_toolchain") + +pw_log_BACKEND = "${chip_root}/src/lib/support/pw_log_chip" +pw_assert_BACKEND = "$dir_pw_assert_log" +pw_rpc_CONFIG = "$dir_pw_rpc:disable_global_mutex" + +#chip_project_config_include_dirs = [ +# "${chip_root}/examples/lighting-app/qcc74x/qcc743", +#] + +chip_detail_logging = false + +pw_build_LINK_DEPS = [ + "$dir_pw_assert:impl", + "$dir_pw_log:impl", +] diff --git a/examples/lighting-app/qcc74x/qcc743/build_overrides b/examples/lighting-app/qcc74x/qcc743/build_overrides new file mode 120000 index 00000000000000..995884e6163eb5 --- /dev/null +++ b/examples/lighting-app/qcc74x/qcc743/build_overrides @@ -0,0 +1 @@ +../../../build_overrides \ No newline at end of file diff --git a/examples/lighting-app/qcc74x/qcc743/mboard.h b/examples/lighting-app/qcc74x/qcc743/mboard.h new file mode 100644 index 00000000000000..e04f42d8e9f1a0 --- /dev/null +++ b/examples/lighting-app/qcc74x/qcc743/mboard.h @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2018, The OpenThread Authors. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the copyright holder nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * @file + * This file includes dev borad compile-time configuration constants for BL602. + * + */ + +#pragma once + +#define CHIP_UART_PORT 0 +#define CHIP_UART_RX_BUFFSIZE 256 + +#define LED_PIN_PWM_CH 2 +#define LED_PIN 14 + +#define MAX_PWM_CHANNEL 1 + +#define CHIP_UART_PIN_RX 7 +#define CHIP_UART_PIN_TX 16 diff --git a/examples/lighting-app/qcc74x/qcc743/third_party/connectedhomeip b/examples/lighting-app/qcc74x/qcc743/third_party/connectedhomeip new file mode 120000 index 00000000000000..59307833b4fee9 --- /dev/null +++ b/examples/lighting-app/qcc74x/qcc743/third_party/connectedhomeip @@ -0,0 +1 @@ +../../../../.. \ No newline at end of file diff --git a/examples/platform/qcc74x/common/bouffalo_sdk/demo_pwm.c b/examples/platform/qcc74x/common/bouffalo_sdk/demo_pwm.c new file mode 100644 index 00000000000000..63f4d5bc967432 --- /dev/null +++ b/examples/platform/qcc74x/common/bouffalo_sdk/demo_pwm.c @@ -0,0 +1,148 @@ +/** + * Copyright (c) 2016-2021 Bouffalolab Co., Ltd. + * + * Contact information: + * web site: https://www.qcc74x.com/ + */ +#include +#include +#include +#include + +#include "mboard.h" +#include "demo_pwm.h" + +static const uint32_t rgb_pwm[][2] = { + { + LED_PIN, LED_PIN_PWM_CH + }, +}; + +struct bflb_device_s *bflb_device_pwm = NULL; + +void demo_pwm_init(void) +{ + struct bflb_pwm_v2_config_s cfg = { + .clk_source = BFLB_SYSTEM_PBCLK, + .clk_div = 40, + .period = 1000, + }; + struct bflb_device_s * gpio = bflb_device_get_by_name("gpio"); + + bflb_device_pwm = bflb_device_get_by_name("pwm_v2_0"); + + for (int i = 0; i < sizeof(rgb_pwm)/sizeof(rgb_pwm[0]); i ++) { + bflb_gpio_init(gpio, rgb_pwm[i][0], GPIO_FUNC_PWM0 | GPIO_ALTERNATE | GPIO_PULLDOWN | GPIO_SMT_EN | GPIO_DRV_1); + } + + bflb_pwm_v2_init(bflb_device_pwm, &cfg); +} + +void demo_pwm_start(void) +{ + for (int i = 0; i < sizeof(rgb_pwm)/sizeof(rgb_pwm[0]); i ++) { + bflb_pwm_v2_channel_positive_start(bflb_device_pwm, rgb_pwm[i][1]); + } + + bflb_pwm_v2_start(bflb_device_pwm); +} + +void demo_pwm_stop(void) +{ + bflb_pwm_v2_stop(bflb_device_pwm); +} + +void set_level(uint8_t currLevel) +{ + int period; + + if (currLevel <= 5 && currLevel >= 1) + { + currLevel = 5; // avoid demo off + } + period = (int)currLevel * 1000 / 254; + + for (int i = 0; i < sizeof(rgb_pwm)/sizeof(rgb_pwm[0]); i ++) { + bflb_pwm_v2_channel_set_threshold(bflb_device_pwm, rgb_pwm[i][1], 0, period); + } +} + +void set_color_red(uint8_t currLevel) +{ + set_color(currLevel, 0, 254); +} + +void set_color_green(uint8_t currLevel) +{ + set_color(currLevel, 84, 254); +} + +void set_color_yellow(uint8_t currLevel) +{ + set_color(currLevel, 42, 254); +} + +void set_color(uint8_t currLevel, uint8_t currHue, uint8_t currSat) +{ +#if MAX_PWM_CHANNEL == 3 + uint16_t hue = (uint16_t) currHue * 360 / 254; + uint8_t sat = (uint16_t) currSat * 100 / 254; + + if (currLevel <= 5 && currLevel >= 1) + { + currLevel = 5; // avoid demo off + } + + if (sat > 100) + { + sat = 100; + } + + uint16_t i = hue / 60; + uint16_t rgb_max = currLevel; + uint16_t rgb_min = rgb_max * (100 - sat) / 100; + uint16_t diff = hue % 60; + uint16_t rgb_adj = (rgb_max - rgb_min) * diff / 60; + uint32_t red, green, blue; + + switch (i) + { + case 0: + red = rgb_max; + green = rgb_min + rgb_adj; + blue = rgb_min; + break; + case 1: + red = rgb_max - rgb_adj; + green = rgb_max; + blue = rgb_min; + break; + case 2: + red = rgb_min; + green = rgb_max; + blue = rgb_min + rgb_adj; + break; + case 3: + red = rgb_min; + green = rgb_max - rgb_adj; + blue = rgb_max; + break; + case 4: + red = rgb_min + rgb_adj; + green = rgb_min; + blue = rgb_max; + break; + default: + red = rgb_max; + green = rgb_min; + blue = rgb_max - rgb_adj; + break; + } + + bflb_pwm_v2_channel_set_threshold(bflb_device_pwm, rgb_pwm[0][1], 0, blue * PWM_DUTY_CYCLE / 254); + bflb_pwm_v2_channel_set_threshold(bflb_device_pwm, rgb_pwm[1][1], 0, red * PWM_DUTY_CYCLE / 254); + bflb_pwm_v2_channel_set_threshold(bflb_device_pwm, rgb_pwm[2][1], 0, green * PWM_DUTY_CYCLE / 254); +#else + set_level(currLevel); +#endif +} diff --git a/examples/platform/qcc74x/common/bouffalo_sdk/platform_port.cpp b/examples/platform/qcc74x/common/bouffalo_sdk/platform_port.cpp new file mode 100644 index 00000000000000..d05952c87aa0a3 --- /dev/null +++ b/examples/platform/qcc74x/common/bouffalo_sdk/platform_port.cpp @@ -0,0 +1,62 @@ +/* + * + * Copyright (c) 2020 Project CHIP Authors + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include + +extern "C" { +#include +#include +} +#include + +extern "C" void __libc_init_array(void); +extern "C" void shell_init_with_task(struct bflb_device_s * shell); + +void platform_port_init(void) +{ + /*if need use xtal 32k please enable next API */ + board_init(); +#if CONFIG_ENABLE_CHIP_SHELL + struct bflb_device_s * uart0 = bflb_device_get_by_name("uart0"); + shell_init_with_task(uart0); +#endif + + __libc_init_array(); + + bflb_mtd_init(); +} + +extern "C" void vAssertCalled(void) +{ + void * ra = (void *) __builtin_return_address(0); + + taskDISABLE_INTERRUPTS(); + if (xPortIsInsideInterrupt()) + { + printf("vAssertCalled, ra = %p in ISR\r\n", (void *) ra); + } + else + { + printf("vAssertCalled, ra = %p in task %s\r\n", (void *) ra, pcTaskGetName(NULL)); + } + + while (true); +} + +extern "C" void bflb_assert(void) __attribute__((weak, alias("vAssertCalled"))); \ No newline at end of file diff --git a/examples/platform/qcc74x/common/bouffalo_sdk/uart.c b/examples/platform/qcc74x/common/bouffalo_sdk/uart.c new file mode 100644 index 00000000000000..49de97daaafbba --- /dev/null +++ b/examples/platform/qcc74x/common/bouffalo_sdk/uart.c @@ -0,0 +1,228 @@ +/* + * + * Copyright (c) 2021 Project CHIP Authors + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may nCHIP use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include + +#include + +#ifdef CFG_USB_CDC_ENABLE +#include +#include +#include +#include +#include +#include +#include +#else +#include +#include +extern hosal_uart_dev_t uart_stdio; +#endif + +#if CONFIG_ENABLE_CHIP_SHELL || PW_RPC_ENABLED + +#define CHIP_UART_RX_TIMER_ID 1 +#define MAX_BUFFER_SIZE 256 + +typedef struct _chipUart +{ + SemaphoreHandle_t sema; + StaticSemaphore_t mutx; + uint32_t head; + uint32_t tail; + uint8_t rxbuf[MAX_BUFFER_SIZE]; +} chipUart_t; + +static chipUart_t chipUart_var; + +#ifndef CFG_USB_CDC_ENABLE +static int uartTxCallback(void * p_arg) +{ + hosal_uart_ioctl(&uart_stdio, HOSAL_UART_TX_TRIGGER_OFF, NULL); + + return 0; +} + +static int uartRxCallback(void * p_arg) +{ + uint32_t len = 0; + BaseType_t xHigherPriorityTaskWoken = 1; + + if (chipUart_var.head >= chipUart_var.tail) + { + if (chipUart_var.head < MAX_BUFFER_SIZE) + { + len = hosal_uart_receive(&uart_stdio, chipUart_var.rxbuf + chipUart_var.head, MAX_BUFFER_SIZE - chipUart_var.head); + chipUart_var.head = (chipUart_var.head + len) % MAX_BUFFER_SIZE; + } + + if (0 == chipUart_var.head) + { + len = hosal_uart_receive(&uart_stdio, chipUart_var.rxbuf, chipUart_var.tail - 1); + chipUart_var.head += len; + } + } + else + { + chipUart_var.head += + hosal_uart_receive(&uart_stdio, chipUart_var.rxbuf + chipUart_var.head, chipUart_var.tail - chipUart_var.head - 1); + } + + if (chipUart_var.head != chipUart_var.tail) + { + xSemaphoreGiveFromISR(chipUart_var.sema, &xHigherPriorityTaskWoken); + } + + return 0; +} +#else +void aosUartRxCallback(int fd, void * param) +{ + uint32_t len = 0, readlen = 0; + BaseType_t xHigherPriorityTaskWoken = 1; + + if (chipUart_var.head >= chipUart_var.tail) + { + if (chipUart_var.head < MAX_BUFFER_SIZE) + { + readlen = len = aos_read(fd, chipUart_var.rxbuf + chipUart_var.head, MAX_BUFFER_SIZE - chipUart_var.head); + chipUart_var.head = (chipUart_var.head + len) % MAX_BUFFER_SIZE; + } + + if (0 == chipUart_var.head) + { + len = aos_read(fd, chipUart_var.rxbuf, chipUart_var.tail - 1); + chipUart_var.head += len; + readlen += len; + } + } + else + { + readlen = aos_read(fd, chipUart_var.rxbuf + chipUart_var.head, chipUart_var.tail - chipUart_var.head - 1); + chipUart_var.head += readlen; + } + + if (chipUart_var.head != chipUart_var.tail) + { + xSemaphoreGiveFromISR(chipUart_var.sema, &xHigherPriorityTaskWoken); + } +} +#endif + +//bl_iot_sdk +#else +static int uartTxCallback(void * p_arg) +{ + + return 0; +} + +static int uartRxCallback(void * p_arg) +{ + uint32_t len = 0; + BaseType_t xHigherPriorityTaskWoken = 1; + + if (chipUart_var.head >= chipUart_var.tail) + { + if (chipUart_var.head < MAX_BUFFER_SIZE) + { + //len = hosal_uart_receive(&uart_stdio, chipUart_var.rxbuf + chipUart_var.head, MAX_BUFFER_SIZE - chipUart_var.head); + chipUart_var.head = (chipUart_var.head + len) % MAX_BUFFER_SIZE; + } + + if (0 == chipUart_var.head) + { + //len = hosal_uart_receive(&uart_stdio, chipUart_var.rxbuf, chipUart_var.tail - 1); + chipUart_var.head += len; + } + } + else + { + chipUart_var.head += + //hosal_uart_receive(&uart_stdio, chipUart_var.rxbuf + chipUart_var.head, chipUart_var.tail - chipUart_var.head - 1); + } + + if (chipUart_var.head != chipUart_var.tail) + { + xSemaphoreGiveFromISR(chipUart_var.sema, &xHigherPriorityTaskWoken); + } + + return 0; +} + +void uartInit(void) +{ + memset(&chipUart_var, 0, offsetof(chipUart_t, rxbuf)); + + chipUart_var.sema = xSemaphoreCreateBinaryStatic(&chipUart_var.mutx); + +#ifndef CFG_USB_CDC_ENABLE + hosal_uart_finalize(&uart_stdio); + hosal_uart_init(&uart_stdio); + hosal_uart_callback_set(&uart_stdio, HOSAL_UART_RX_CALLBACK, uartRxCallback, NULL); + hosal_uart_callback_set(&uart_stdio, HOSAL_UART_TX_CALLBACK, uartTxCallback, NULL); + hosal_uart_ioctl(&uart_stdio, HOSAL_UART_MODE_SET, (void *) HOSAL_UART_MODE_INT); +#endif +} + +int16_t uartRead(char * Buf, uint16_t NbBytesToRead) +{ + int16_t len = 0; + + xSemaphoreTake(chipUart_var.sema, portMAX_DELAY); + + taskENTER_CRITICAL(); + + for (len = 0; len < NbBytesToRead && chipUart_var.head != chipUart_var.tail; len++) + { + Buf[len] = chipUart_var.rxbuf[chipUart_var.tail]; + chipUart_var.tail = (chipUart_var.tail + 1) % MAX_BUFFER_SIZE; + } + + taskEXIT_CRITICAL(); + + if (chipUart_var.head != chipUart_var.tail) + { + xSemaphoreGive(chipUart_var.sema); + } + + return len; +} +#endif + +#ifndef CFG_USB_CDC_ENABLE +int16_t uartWrite(const char * Buf, uint16_t BufLength) +{ + return hosal_uart_send(&uart_stdio, Buf, BufLength); +} +#else +int16_t uartWrite(const char * Buf, uint16_t BufLength) +{ + uint16_t sent = 0; + do + { + extern int vfs_fd; + if (vfs_fd >= 0) + { + sent += (uint8_t) aos_write(vfs_fd, Buf + sent, BufLength - sent); + } + } while (sent < BufLength); + return sent; +} +#endif diff --git a/examples/platform/qcc74x/common/bouffalo_sdk/uart.h b/examples/platform/qcc74x/common/bouffalo_sdk/uart.h new file mode 100644 index 00000000000000..ff2a398a395dd7 --- /dev/null +++ b/examples/platform/qcc74x/common/bouffalo_sdk/uart.h @@ -0,0 +1,37 @@ +/* + * + * Copyright (c) 2021 Project CHIP Authors + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +void uartInit(void); +int16_t uartWrite(const char * Buf, uint16_t BufLength); +int16_t uartRead(char * Buf, uint16_t NbBytesToRead); + +#ifdef CFG_USB_CDC_ENABLE +void aosUartRxCallback(int fd, void * param); +#endif + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/examples/platform/qcc74x/common/iot_sdk/aos_task.c b/examples/platform/qcc74x/common/iot_sdk/aos_task.c new file mode 100644 index 00000000000000..51175c792f3479 --- /dev/null +++ b/examples/platform/qcc74x/common/iot_sdk/aos_task.c @@ -0,0 +1,40 @@ + +/** + * Copyright (c) 2016-2021 Bouffalolab Co., Ltd. + * + * Contact information: + * web site: https://www.qcc74x.com/ + */ + +#ifdef SYS_AOS_LOOP_ENABLE + +#include +#include + +#include + +#include +#include +#include + +#include + +static void aos_loop_proc(void * pvParameters) +{ + aos_loop_init(); + + aos_loop_run(); + + vTaskDelete(NULL); +} + +void aos_loop_start(void) +{ + static TaskHandle_t aos_loop_proc_task; + + vfs_init(); + vfs_device_init(); + + xTaskCreate(aos_loop_proc, (char *) "event_loop", 4096, NULL, APP_TASK_PRIORITY, &aos_loop_proc_task); +} +#endif diff --git a/examples/platform/qcc74x/common/iot_sdk/demo_pwm.c b/examples/platform/qcc74x/common/iot_sdk/demo_pwm.c new file mode 100644 index 00000000000000..347b2b65db8b3a --- /dev/null +++ b/examples/platform/qcc74x/common/iot_sdk/demo_pwm.c @@ -0,0 +1,193 @@ +/** + * Copyright (c) 2016-2021 Bouffalolab Co., Ltd. + * + * Contact information: + * web site: https://www.qcc74x.com/ + */ +#include + +#include + +#include "demo_pwm.h" +#include "mboard.h" + +#define PWM_FREQ 1000 +#define PWM_DUTY_CYCLE 10000 + +hosal_pwm_dev_t rgb_pwm[] = { + +#if MAX_PWM_CHANNEL == 3 + { + .port = LED_B_PIN_PORT, + /* pwm config */ + .config.pin = LED_B_PIN, + .config.duty_cycle = 0, // duty_cycle range is 0~10000 correspond to 0~100% + .config.freq = PWM_FREQ, // freq range is between 0~40MHZ + }, + { + .port = LED_R_PIN_PORT, + /* pwm config */ + .config.pin = LED_R_PIN, + .config.duty_cycle = 0, // duty_cycle range is 0~10000 correspond to 0~100% + .config.freq = PWM_FREQ, // freq range is between 0~40MHZ + }, + { + .port = LED_G_PIN_PORT, + /* pwm config */ + .config.pin = LED_G_PIN, + .config.duty_cycle = 0, // duty_cycle range is 0~10000 correspond to 0~100% + .config.freq = PWM_FREQ, // freq range is between 0~40MHZ + } +#else + { + .port = LED_PIN_PORT, + /* pwm config */ + .config.pin = LED_PIN, + .config.duty_cycle = 0, // duty_cycle range is 0~10000 correspond to 0~100% + .config.freq = PWM_FREQ, // freq range is between 0~40MHZ + }, +#endif +}; + +void demo_pwm_init(void) +{ + /* init pwm with given settings */ + for (uint32_t i = 0; i < MAX_PWM_CHANNEL; i++) + { + hosal_pwm_init(rgb_pwm + i); + } +} + +void demo_pwm_start(void) +{ + /* start pwm */ + for (uint32_t i = 0; i < MAX_PWM_CHANNEL; i++) + { + hosal_pwm_start(rgb_pwm + i); + } +} + +void demo_pwm_change_param(hosal_pwm_config_t * para) +{ + /* change pwm param */ + for (uint32_t i = 0; i < MAX_PWM_CHANNEL; i++) + { + if (para[i].duty_cycle > PWM_DUTY_CYCLE) + { + para[i].duty_cycle = PWM_DUTY_CYCLE; + } + hosal_pwm_para_chg(rgb_pwm + i, para[i]); + } +} + +void demo_pwm_stop(void) +{ + for (uint32_t i = 0; i < MAX_PWM_CHANNEL; i++) + { + hosal_pwm_stop(rgb_pwm + i); + hosal_pwm_finalize(rgb_pwm + i); + } +} + +void set_level(uint8_t currLevel) +{ + hosal_pwm_config_t para; + + if (currLevel <= 5 && currLevel >= 1) + { + currLevel = 5; // avoid demo off + } + + para.duty_cycle = currLevel * PWM_DUTY_CYCLE / 254; + para.freq = PWM_FREQ; + + demo_pwm_change_param(¶); +} + +void set_color_red(uint8_t currLevel) +{ + set_color(currLevel, 0, 254); +} + +void set_color_green(uint8_t currLevel) +{ + set_color(currLevel, 84, 254); +} + +void set_color_yellow(uint8_t currLevel) +{ + set_color(currLevel, 42, 254); +} + +void set_color(uint8_t currLevel, uint8_t currHue, uint8_t currSat) +{ +#if MAX_PWM_CHANNEL == 3 + uint16_t hue = (uint16_t) currHue * 360 / 254; + uint8_t sat = (uint16_t) currSat * 100 / 254; + + if (currLevel <= 5 && currLevel >= 1) + { + currLevel = 5; // avoid demo off + } + + if (sat > 100) + { + sat = 100; + } + + uint16_t i = hue / 60; + uint16_t rgb_max = currLevel; + uint16_t rgb_min = rgb_max * (100 - sat) / 100; + uint16_t diff = hue % 60; + uint16_t rgb_adj = (rgb_max - rgb_min) * diff / 60; + uint32_t red, green, blue; + + switch (i) + { + case 0: + red = rgb_max; + green = rgb_min + rgb_adj; + blue = rgb_min; + break; + case 1: + red = rgb_max - rgb_adj; + green = rgb_max; + blue = rgb_min; + break; + case 2: + red = rgb_min; + green = rgb_max; + blue = rgb_min + rgb_adj; + break; + case 3: + red = rgb_min; + green = rgb_max - rgb_adj; + blue = rgb_max; + break; + case 4: + red = rgb_min + rgb_adj; + green = rgb_min; + blue = rgb_max; + break; + default: + red = rgb_max; + green = rgb_min; + blue = rgb_max - rgb_adj; + break; + } + + // change level to pwm duty_cycle + // 0-254 to 0-10000 + hosal_pwm_config_t para[3]; + para[0].duty_cycle = blue * PWM_DUTY_CYCLE / 254; + para[0].freq = PWM_FREQ; + para[1].duty_cycle = red * PWM_DUTY_CYCLE / 254; + para[1].freq = PWM_FREQ; + para[2].duty_cycle = green * PWM_DUTY_CYCLE / 254; + para[2].freq = PWM_FREQ; + + demo_pwm_change_param(para); +#else + set_level(currLevel); +#endif +} diff --git a/examples/platform/qcc74x/common/iot_sdk/platform_port.cpp b/examples/platform/qcc74x/common/iot_sdk/platform_port.cpp new file mode 100644 index 00000000000000..dcce61e5880b5c --- /dev/null +++ b/examples/platform/qcc74x/common/iot_sdk/platform_port.cpp @@ -0,0 +1,425 @@ +/* + * + * Copyright (c) 2020 Project CHIP Authors + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include + +#include +#include +#include + +#include + +#include + +#include + +#if CHIP_DEVICE_LAYER_TARGET_BL702 +#include +#include +#elif CHIP_DEVICE_LAYER_TARGET_BL702L +#include +#include +#endif + +#ifdef CFG_USE_PSRAM +#include +#endif +#include + +#include + +extern "C" { +#include +#include +#include +#include +#include +#include +#if CHIP_DEVICE_LAYER_TARGET_BL602 +#include +#elif CHIP_DEVICE_LAYER_TARGET_BL702L +#include +#endif + +#if CHIP_DEVICE_LAYER_TARGET_BL702L +#include +#include +#include +#endif +} + +#include + +#include "mboard.h" +#include + +HOSAL_UART_DEV_DECL(uart_stdio, CHIP_UART_PORT, CHIP_UART_PIN_TX, CHIP_UART_PIN_RX, CHIP_UART_BAUDRATE); + +#ifdef SYS_AOS_LOOP_ENABLE +extern "C" void aos_loop_start(void); +#endif + +// ================================================================================ +// FreeRTOS Callbacks +// ================================================================================ +extern "C" unsigned int sleep(unsigned int seconds) +{ + const TickType_t xDelay = 1000 * seconds / portTICK_PERIOD_MS; + vTaskDelay(xDelay); + return 0; +} + +#if !CHIP_DEVICE_LAYER_TARGET_BL702L +extern "C" void vApplicationStackOverflowHook(TaskHandle_t xTask, char * pcTaskName) +{ + printf("Stack Overflow checked. Stack name %s", pcTaskName); + while (true) + { + /*empty here*/ + } +} + +extern "C" void vApplicationMallocFailedHook(void) +{ + printf("Memory Allocate Failed. Current left size is %d bytes", xPortGetFreeHeapSize()); + while (true) + { + /*empty here*/ + } +} + +extern "C" void vApplicationIdleHook(void) +{ + // bl_wdt_feed(); + __asm volatile(" wfi "); +} + +extern "C" void vApplicationGetIdleTaskMemory(StaticTask_t ** ppxIdleTaskTCBBuffer, StackType_t ** ppxIdleTaskStackBuffer, + uint32_t * pulIdleTaskStackSize) +{ + /* If the buffers to be provided to the Idle task are declared inside this + function then they must be declared static - otherwise they will be allocated on + the stack and so not exists after this function exits. */ + + /* Pass out a pointer to the StaticTask_t structure in which the Idle task's + state will be stored. */ + *ppxIdleTaskTCBBuffer = (StaticTask_t *) pvPortMalloc(sizeof(StaticTask_t)); + + /* Pass out the array that will be used as the Idle task's stack. */ + *ppxIdleTaskStackBuffer = (StackType_t *) pvPortMalloc(sizeof(StackType_t) * configMINIMAL_STACK_SIZE); + + /* Pass out the size of the array pointed to by *ppxIdleTaskStackBuffer. + Note that, as the array is necessarily of type StackType_t, + configMINIMAL_STACK_SIZE is specified in words, not bytes. */ + *pulIdleTaskStackSize = configMINIMAL_STACK_SIZE; +} + +/* configSUPPORT_STATIC_ALLOCATION and configUSE_TIMERS are both set to 1, so the +application must provide an implementation of vApplicationGetTimerTaskMemory() +to provide the memory that is used by the Timer service task. */ +extern "C" void vApplicationGetTimerTaskMemory(StaticTask_t ** ppxTimerTaskTCBBuffer, StackType_t ** ppxTimerTaskStackBuffer, + uint32_t * pulTimerTaskStackSize) +{ + /* If the buffers to be provided to the Timer task are declared inside this + function then they must be declared static - otherwise they will be allocated on + the stack and so not exists after this function exits. */ + + /* Pass out a pointer to the StaticTask_t structure in which the Timer + task's state will be stored. */ + *ppxTimerTaskTCBBuffer = (StaticTask_t *) pvPortMalloc(sizeof(StaticTask_t)); + + /* Pass out the array that will be used as the Timer task's stack. */ + *ppxTimerTaskStackBuffer = (StackType_t *) pvPortMalloc(sizeof(StackType_t) * configTIMER_TASK_STACK_DEPTH); + + /* Pass out the size of the array pointed to by *ppxTimerTaskStackBuffer. + Note that, as the array is necessarily of type StackType_t, + configTIMER_TASK_STACK_DEPTH is specified in words, not bytes. */ + *pulTimerTaskStackSize = configTIMER_TASK_STACK_DEPTH; +} + +#if (configUSE_TICK_HOOK != 0) +extern "C" void vApplicationTickHook(void) +{ +#if defined(CFG_USB_CDC_ENABLE) + extern void usb_cdc_monitor(void); + usb_cdc_monitor(); +#endif +} +#endif + +extern "C" void vApplicationSleep(TickType_t xExpectedIdleTime) {} + +extern "C" void vAssertCalled(void) +{ + void * ra = (void *) __builtin_return_address(0); + +#if CONF_ENABLE_FRAME_PTR == 0 + taskDISABLE_INTERRUPTS(); +#endif + + if (xPortIsInsideInterrupt()) + { + printf("vAssertCalled, ra = %p in ISR\r\n", (void *) ra); + } + else + { + printf("vAssertCalled, ra = %p in task %s\r\n", (void *) ra, pcTaskGetName(NULL)); + } + +#if CONF_ENABLE_FRAME_PTR + portABORT(); +#endif + + while (true) + ; +} +#endif + +#if CHIP_DEVICE_LAYER_TARGET_BL702L +extern "C" void __attribute__((weak)) user_vAssertCalled(void) +{ + void * ra = (void *) __builtin_return_address(0); + + taskDISABLE_INTERRUPTS(); + + if (xPortIsInsideInterrupt()) + { + printf("vAssertCalled, ra = %p in ISR\r\n", (void *) ra); + } + else + { + printf("vAssertCalled, ra = %p in task %s\r\n", (void *) ra, pcTaskGetName(NULL)); + } + + while (true) + ; +} + +extern "C" void __attribute__((weak)) user_vApplicationStackOverflowHook(TaskHandle_t xTask, char * pcTaskName) +{ + puts("Stack Overflow checked\r\n"); + if (pcTaskName) + { + printf("Stack name %s\r\n", pcTaskName); + } + while (1) + { + /*empty here*/ + } +} + +extern "C" void __attribute__((weak)) user_vApplicationMallocFailedHook(void) +{ + printf("Memory Allocate Failed. Current left size is %d bytes\r\n", xPortGetFreeHeapSize()); +#if defined(CFG_USE_PSRAM) + printf("Current psram left size is %d bytes\r\n", xPortGetFreeHeapSizePsram()); +#endif + while (1) + { + /*empty here*/ + } +} + +extern "C" void bflb_assert(void) __attribute__((weak, alias("user_vAssertCalled"))); +#else +extern "C" void user_vAssertCalled(void) __attribute__((weak, alias("vAssertCalled"))); +extern "C" void bflb_assert(void) __attribute__((weak, alias("vAssertCalled"))); +#endif + +// ================================================================================ +// Main Code +// ================================================================================ +extern "C" uint8_t _heap_start; +extern "C" size_t _heap_size; // @suppress("Type cannot be resolved") + +#if CHIP_DEVICE_LAYER_TARGET_BL602 +extern "C" uint8_t _heap_wifi_start; +extern "C" uint8_t _heap_wifi_size; // @suppress("Type cannot be resolved") +static const HeapRegion_t xHeapRegions[] = { + { &_heap_start, (unsigned int) &_heap_size }, // set on runtime + { &_heap_wifi_start, (unsigned int) &_heap_wifi_size }, + { NULL, 0 } /* Terminates the array. */ +}; +#elif CHIP_DEVICE_LAYER_TARGET_BL702 +extern "C" uint8_t _heap2_start; +extern "C" uint8_t _heap2_size; // @suppress("Type cannot be resolved") +static const HeapRegion_t xHeapRegions[] = { + { &_heap_start, (size_t) &_heap_size }, // set on runtime + { &_heap2_start, (size_t) &_heap2_size }, // set on runtime + { NULL, 0 } /* Terminates the array. */ +}; +#elif CHIP_DEVICE_LAYER_TARGET_BL702L +static const HeapRegion_t xHeapRegions[] = { + { &_heap_start, (size_t) &_heap_size }, // set on runtime + { NULL, 0 } /* Terminates the array. */ +}; +#endif + +#ifdef CFG_USE_PSRAM +extern "C" uint8_t __psram_bss_init_start; +extern "C" uint8_t __psram_bss_init_end; + +static uint32_t __attribute__((section(".rsvd_data"))) psram_reset_count; + +extern "C" uint8_t _heap3_start; +extern "C" size_t _heap3_size; // @suppress("Type cannot be resolved") +static const HeapRegion_t xPsramHeapRegions[] = { + { &_heap3_start, (size_t) &_heap3_size }, { NULL, 0 } /* Terminates the array. */ +}; + +extern "C" size_t get_heap3_size(void) +{ + return (size_t) &_heap3_size; +} + +void do_psram_test() +{ + static const char teststr[] = "qcc74x psram test string"; + + do + { + uint8_t * pheap = &_heap3_start; + size_t size = (size_t) &_heap3_size; + + size = size > sizeof(teststr) ? sizeof(teststr) : size; + memset(pheap, 0, size); + if (pheap[0] != 0) + { + break; + } + + memcpy(pheap, teststr, size); + if (0 != memcmp(pheap, teststr, size)) + { + break; + } + + memset(&__psram_bss_init_start, 0, &__psram_bss_init_end - &__psram_bss_init_start); + + psram_reset_count = 0xffffff00; + return; + } while (0); + + if ((psram_reset_count & 0xffffff00) != 0xffffff00) + { + psram_reset_count = 0xffffff00; + } + + if ((psram_reset_count & 0x000000ff) > 3) + { + printf("PSRAM is still failed to initialize after %ld system reset", psram_reset_count & 0x000000ff); + vAssertCalled(); + } + + psram_reset_count = ((psram_reset_count & 0x000000ff) + 1) | 0xffffff00; + bl_sys_reset_system(); +} +#endif + +extern "C" void setup_heap() +{ + bl_sys_init(); + +#if CHIP_DEVICE_LAYER_TARGET_BL702 + bl_sys_em_config(); +#elif CHIP_DEVICE_LAYER_TARGET_BL702L + bl_sys_em_config(); + + // Initialize rom data + extern uint8_t _rom_data_run; + extern uint8_t _rom_data_load; + extern uint8_t _rom_data_size; + memcpy((void *) &_rom_data_run, (void *) &_rom_data_load, (size_t) &_rom_data_size); +#endif + +#if CHIP_DEVICE_LAYER_TARGET_BL702 + extern uint8_t __ocram_bss_start[], __ocram_bss_end[]; + if (NULL != __ocram_bss_start && NULL != __ocram_bss_end && __ocram_bss_end > __ocram_bss_start) + { + memset(__ocram_bss_start, 0, __ocram_bss_end - __ocram_bss_start); + } +#endif + + vPortDefineHeapRegions(xHeapRegions); + +#ifdef CFG_USE_PSRAM + bl_psram_init(); + do_psram_test(); + vPortDefineHeapRegionsPsram(xPsramHeapRegions); +#endif +} + +extern "C" size_t get_heap_size(void) +{ + return (size_t) &_heap_size; +} + +extern "C" void app_init(void) +{ + bl_sys_early_init(); + +#if CHIP_DEVICE_LAYER_TARGET_BL702L + bl_flash_init(); + + rom_freertos_init(256, 400); + rom_hal_init(); +#endif + + hosal_uart_init(&uart_stdio); + + blog_init(); + bl_irq_init(); +#if CHIP_DEVICE_LAYER_TARGET_BL702L + bl_rtc_init(); +#endif + bl_sec_init(); +#if CHIP_DEVICE_LAYER_TARGET_BL702 + bl_timer_init(); +#endif + + hal_boot2_init(); + + /* board config is set after system is init*/ + hal_board_cfg(0); + +#if CHIP_DEVICE_LAYER_TARGET_BL702L || CHIP_DEVICE_CONFIG_ENABLE_WIFI || CHIP_DEVICE_CONFIG_ENABLE_ETHERNET + hosal_dma_init(); +#endif +#if CHIP_DEVICE_LAYER_TARGET_BL602 + wifi_td_diagnosis_init(); +#endif +} + +extern "C" void platform_port_init(void) +{ + app_init(); + +#if CONFIG_ENABLE_CHIP_SHELL || PW_RPC_ENABLED + uartInit(); +#endif + +#ifdef SYS_AOS_LOOP_ENABLE + aos_loop_start(); +#else +#if defined(CFG_USB_CDC_ENABLE) + extern void usb_cdc_start(int fd_console); + usb_cdc_start(-1); +#endif +#endif +} diff --git a/examples/platform/qcc74x/common/iot_sdk/uart.cpp b/examples/platform/qcc74x/common/iot_sdk/uart.cpp new file mode 100644 index 00000000000000..212bcaa51b9b03 --- /dev/null +++ b/examples/platform/qcc74x/common/iot_sdk/uart.cpp @@ -0,0 +1,226 @@ +/* + * + * Copyright (c) 2021 Project CHIP Authors + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may nCHIP use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include + +#include + +#ifdef CFG_USB_CDC_ENABLE +#include +#include +#include +#include +#include +#include +#include +#else +#include +#include +extern hosal_uart_dev_t uart_stdio; +#endif + +#if CONFIG_ENABLE_CHIP_SHELL || PW_RPC_ENABLED + +#define CHIP_UART_RX_TIMER_ID 1 +#define MAX_BUFFER_SIZE 256 + +typedef struct _chipUart +{ + SemaphoreHandle_t sema; + StaticSemaphore_t mutx; + uint32_t head; + uint32_t tail; + uint8_t rxbuf[MAX_BUFFER_SIZE]; +} chipUart_t; + +static chipUart_t chipUart_var; + +#ifndef CFG_USB_CDC_ENABLE +static int uartTxCallback(void * p_arg) +{ + hosal_uart_ioctl(&uart_stdio, HOSAL_UART_TX_TRIGGER_OFF, NULL); + + return 0; +} + +static int uartRxCallback(void * p_arg) +{ + uint32_t len = 0; + BaseType_t xHigherPriorityTaskWoken = 1; + + if (chipUart_var.head >= chipUart_var.tail) + { + if (chipUart_var.head < MAX_BUFFER_SIZE) + { + len = hosal_uart_receive(&uart_stdio, chipUart_var.rxbuf + chipUart_var.head, MAX_BUFFER_SIZE - chipUart_var.head); + chipUart_var.head = (chipUart_var.head + len) % MAX_BUFFER_SIZE; + } + + if (0 == chipUart_var.head) + { + len = hosal_uart_receive(&uart_stdio, chipUart_var.rxbuf, chipUart_var.tail - 1); + chipUart_var.head += len; + } + } + else + { + chipUart_var.head += + hosal_uart_receive(&uart_stdio, chipUart_var.rxbuf + chipUart_var.head, chipUart_var.tail - chipUart_var.head - 1); + } + + if (chipUart_var.head != chipUart_var.tail) + { + xSemaphoreGiveFromISR(chipUart_var.sema, &xHigherPriorityTaskWoken); + } + + return 0; +} +#else +void aosUartRxCallback(int fd, void * param) +{ + uint32_t len = 0, readlen = 0; + BaseType_t xHigherPriorityTaskWoken = 1; + + if (chipUart_var.head >= chipUart_var.tail) + { + if (chipUart_var.head < MAX_BUFFER_SIZE) + { + readlen = len = aos_read(fd, chipUart_var.rxbuf + chipUart_var.head, MAX_BUFFER_SIZE - chipUart_var.head); + chipUart_var.head = (chipUart_var.head + len) % MAX_BUFFER_SIZE; + } + + if (0 == chipUart_var.head) + { + len = aos_read(fd, chipUart_var.rxbuf, chipUart_var.tail - 1); + chipUart_var.head += len; + readlen += len; + } + } + else + { + readlen = aos_read(fd, chipUart_var.rxbuf + chipUart_var.head, chipUart_var.tail - chipUart_var.head - 1); + chipUart_var.head += readlen; + } + + if (chipUart_var.head != chipUart_var.tail) + { + xSemaphoreGiveFromISR(chipUart_var.sema, &xHigherPriorityTaskWoken); + } +} + +static int uartTxCallback(void * p_arg) +{ + + return 0; +} + +static int uartRxCallback(void * p_arg) +{ + uint32_t len = 0; + BaseType_t xHigherPriorityTaskWoken = 1; + + if (chipUart_var.head >= chipUart_var.tail) + { + if (chipUart_var.head < MAX_BUFFER_SIZE) + { + // len = hosal_uart_receive(&uart_stdio, chipUart_var.rxbuf + chipUart_var.head, MAX_BUFFER_SIZE - chipUart_var.head); + chipUart_var.head = (chipUart_var.head + len) % MAX_BUFFER_SIZE; + } + + if (0 == chipUart_var.head) + { + // len = hosal_uart_receive(&uart_stdio, chipUart_var.rxbuf, chipUart_var.tail - 1); + chipUart_var.head += len; + } + } + else + { + chipUart_var.head += + // hosal_uart_receive(&uart_stdio, chipUart_var.rxbuf + chipUart_var.head, chipUart_var.tail - chipUart_var.head - 1); + } + + if (chipUart_var.head != chipUart_var.tail) + { + xSemaphoreGiveFromISR(chipUart_var.sema, &xHigherPriorityTaskWoken); + } + + return 0; +} +#endif + +void uartInit(void) +{ + memset(&chipUart_var, 0, offsetof(chipUart_t, rxbuf)); + + chipUart_var.sema = xSemaphoreCreateBinaryStatic(&chipUart_var.mutx); + +#ifndef CFG_USB_CDC_ENABLE + hosal_uart_finalize(&uart_stdio); + hosal_uart_init(&uart_stdio); + hosal_uart_callback_set(&uart_stdio, HOSAL_UART_RX_CALLBACK, uartRxCallback, NULL); + hosal_uart_callback_set(&uart_stdio, HOSAL_UART_TX_CALLBACK, uartTxCallback, NULL); + hosal_uart_ioctl(&uart_stdio, HOSAL_UART_MODE_SET, (void *) HOSAL_UART_MODE_INT); +#endif +} + +int16_t uartRead(char * Buf, uint16_t NbBytesToRead) +{ + int16_t len = 0; + + xSemaphoreTake(chipUart_var.sema, portMAX_DELAY); + + taskENTER_CRITICAL(); + + for (len = 0; len < NbBytesToRead && chipUart_var.head != chipUart_var.tail; len++) + { + Buf[len] = chipUart_var.rxbuf[chipUart_var.tail]; + chipUart_var.tail = (chipUart_var.tail + 1) % MAX_BUFFER_SIZE; + } + + taskEXIT_CRITICAL(); + + if (chipUart_var.head != chipUart_var.tail) + { + xSemaphoreGive(chipUart_var.sema); + } + + return len; +} +#endif + +#ifndef CFG_USB_CDC_ENABLE +int16_t uartWrite(const char * Buf, uint16_t BufLength) +{ + return hosal_uart_send(&uart_stdio, Buf, BufLength); +} +#else +int16_t uartWrite(const char * Buf, uint16_t BufLength) +{ + uint16_t sent = 0; + do + { + extern int vfs_fd; + if (vfs_fd >= 0) + { + sent += (uint8_t) aos_write(vfs_fd, Buf + sent, BufLength - sent); + } + } while (sent < BufLength); + return sent; +} +#endif diff --git a/examples/platform/qcc74x/common/plat/LEDWidget.cpp b/examples/platform/qcc74x/common/plat/LEDWidget.cpp new file mode 100644 index 00000000000000..bf6159befb97f1 --- /dev/null +++ b/examples/platform/qcc74x/common/plat/LEDWidget.cpp @@ -0,0 +1,126 @@ +/* + * + * Copyright (c) 2020 Project CHIP Authors + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include + +#include +#include + +#include "LEDWidget.h" + +bool LEDWidget::GetOnoff(void) +{ + return mOnoff ? true : false; +} + +void DimmableLEDWidget::Init() +{ + mOnoff = light_v = 0; + +#ifdef MAX_PWM_CHANNEL + demo_pwm_init(); + demo_pwm_start(); +#endif +} + +void DimmableLEDWidget::Toggle(void) +{ + SetOnoff(1 - mOnoff); +} + +void DimmableLEDWidget::SetOnoff(bool state) +{ + mOnoff = state; +#ifdef MAX_PWM_CHANNEL + if (mOnoff) + { + if (light_v) + { + set_level(light_v); + } + else + { + set_level(254); + } + } + else + { + set_level(0); + } +#endif +} + +void DimmableLEDWidget::SetLevel(uint8_t level) +{ +#ifdef MAX_PWM_CHANNEL + set_level(level); +#endif + light_v = level; + mOnoff = light_v > 0; +} + +void ColorLEDWidget::Init() +{ + mOnoff = light_v = light_s = light_h = 0; +#ifdef MAX_PWM_CHANNEL + demo_pwm_init(); + demo_pwm_start(); +#endif +} + +void ColorLEDWidget::Toggle(void) +{ + SetOnoff(1 - mOnoff); +} + +void ColorLEDWidget::SetOnoff(bool state) +{ +#ifdef MAX_PWM_CHANNEL + mOnoff = state; + if (mOnoff) + { + if (0 == light_v) + { + set_color(254, light_h, light_s); + } + else + { + set_color(light_v, light_h, light_s); + } + } + else + { + set_color(0, light_h, light_s); + } +#endif +} + +void ColorLEDWidget::SetLevel(uint8_t level) +{ + SetColor(level, light_h, light_s); +} + +void ColorLEDWidget::SetColor(uint8_t level, uint8_t hue, uint8_t sat) +{ +#ifdef MAX_PWM_CHANNEL + set_color(level, hue, sat); +#endif + light_v = level; + light_h = hue; + light_s = sat; + mOnoff = light_v > 0; +} diff --git a/examples/platform/qcc74x/common/plat/LEDWidget.h b/examples/platform/qcc74x/common/plat/LEDWidget.h new file mode 100644 index 00000000000000..af1877d1089f3a --- /dev/null +++ b/examples/platform/qcc74x/common/plat/LEDWidget.h @@ -0,0 +1,60 @@ +/* + * + * Copyright (c) 2020 Project CHIP Authors + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include + +class LEDWidget +{ +public: + virtual void Init(void) = 0; + virtual void SetOnoff(bool state) = 0; + bool GetOnoff(void); + virtual void Toggle(void) = 0; + virtual ~LEDWidget(void){}; + + uint8_t mOnoff; + uint8_t mPin; +}; + +class DimmableLEDWidget : public LEDWidget +{ +public: + void Init(void) override; + void Toggle(void) override; + void SetOnoff(bool state) override; + void SetLevel(uint8_t level); + ~DimmableLEDWidget(void) {} + + uint8_t light_v; +}; + +class ColorLEDWidget : public DimmableLEDWidget +{ +public: + void Init(void) override; + void Toggle(void) override; + void SetOnoff(bool state) override; + void SetLevel(uint8_t level); + void SetColor(uint8_t level, uint8_t hue, uint8_t sat); + ~ColorLEDWidget(void) {} + + uint8_t light_h; + uint8_t light_s; +}; diff --git a/examples/platform/qcc74x/common/plat/MemMonitoring.cpp b/examples/platform/qcc74x/common/plat/MemMonitoring.cpp new file mode 100644 index 00000000000000..6e58131f8c1ea8 --- /dev/null +++ b/examples/platform/qcc74x/common/plat/MemMonitoring.cpp @@ -0,0 +1,68 @@ +/* + * + * Copyright (c) 2021 Project CHIP Authors + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include + +static StackType_t monitoringStack[MONITORING_STACK_SIZE_byte / sizeof(StackType_t)]; +static StaticTask_t monitoringTaskStruct; + +void MemMonitoring::startHeapMonitoring() +{ + xTaskCreateStatic(HeapMonitoring, "Monitoring", MONITORING_STACK_SIZE_byte / sizeof(StackType_t), NULL, 1, monitoringStack, + &monitoringTaskStruct); +} + +void MemMonitoring::HeapMonitoring(void * pvParameter) +{ + TaskStatus_t * pTaskStatus = NULL; + char taskState[] = { 'X', 'R', 'B', 'S', 'D' }; // eRunning, eReady, eBlocked, eSuspended, eDeleted + uint32_t pulTotalRunTime; + + while (true) + { + ChipLogProgress(NotSpecified, "============================="); + pTaskStatus = (TaskStatus_t *) malloc(uxTaskGetNumberOfTasks() * sizeof(TaskStatus_t)); + if (pTaskStatus) + { + ChipLogProgress(NotSpecified, "Task Name\tstate\tpriority\thighWaterMark"); + uxTaskGetSystemState(pTaskStatus, uxTaskGetNumberOfTasks(), &pulTotalRunTime); + for (uint32_t i = 0; i < uxTaskGetNumberOfTasks(); i++) + { + ChipLogProgress(NotSpecified, "%s%s\t%c\t%ld/%ld\t\t%d", (pTaskStatus + i)->pcTaskName, + strlen((pTaskStatus + i)->pcTaskName) < 7 ? "\t" : "", + (pTaskStatus + i)->eCurrentState > eDeleted ? 'N' : taskState[(pTaskStatus + i)->eCurrentState], + (pTaskStatus + i)->uxCurrentPriority, (pTaskStatus + i)->uxBasePriority, + (pTaskStatus + i)->usStackHighWaterMark); + } + free(pTaskStatus); + } + ChipLogProgress(NotSpecified, "\r\n"); + ChipLogProgress(NotSpecified, "SRAM Heap, min left: %d, current left %d", xPortGetMinimumEverFreeHeapSize(), + xPortGetFreeHeapSize()); +#ifdef CFG_USE_PSRAM + ChipLogProgress(NotSpecified, "PSRAM Heap, min left: %d, current left %d", xPortGetMinimumEverFreeHeapSizePsram(), + xPortGetFreeHeapSizePsram()); +#endif + ChipLogProgress(NotSpecified, "============================= / total run time %ld", pulTotalRunTime); + + vTaskDelay(pdMS_TO_TICKS(10000)); + } +} diff --git a/examples/platform/qcc74x/common/plat/MemMonitoring.h b/examples/platform/qcc74x/common/plat/MemMonitoring.h new file mode 100644 index 00000000000000..26f472be91688a --- /dev/null +++ b/examples/platform/qcc74x/common/plat/MemMonitoring.h @@ -0,0 +1,35 @@ +/* + * + * Copyright (c) 2021 Project CHIP Authors + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#ifdef HEAP_MONITORING +#include "FreeRTOS.h" + +#define MONITORING_STACK_SIZE_byte 1280 + +class MemMonitoring +{ +public: + static void startHeapMonitoring(); + +private: + static void HeapMonitoring(void * pvParameter); +}; + +#endif diff --git a/examples/platform/qcc74x/common/plat/OTAConfig.cpp b/examples/platform/qcc74x/common/plat/OTAConfig.cpp new file mode 100644 index 00000000000000..a1ebd327ccfa68 --- /dev/null +++ b/examples/platform/qcc74x/common/plat/OTAConfig.cpp @@ -0,0 +1,56 @@ +/* + * + * Copyright (c) 2021 Project CHIP Authors + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "OTAConfig.h" +#include + +#include +// Global OTA objects +chip::DefaultOTARequestor gRequestorCore; +chip::DefaultOTARequestorStorage gRequestorStorage; +chip::DeviceLayer::DefaultOTARequestorDriver gRequestorUser; +chip::BDXDownloader gDownloader; +chip::OTAImageProcessorImpl gImageProcessor; + +void OTAConfig::Init() +{ + // Initialize and interconnect the Requestor and Image Processor objects -- START + SetRequestorInstance(&gRequestorCore); + + gRequestorStorage.Init(chip::Server::GetInstance().GetPersistentStorage()); + gRequestorCore.Init(chip::Server::GetInstance(), gRequestorStorage, gRequestorUser, gDownloader); + + // Periodic query timeout must be set prior to requestor being initialized + gRequestorUser.SetPeriodicQueryTimeout(OTA_PERIODIC_TIMEOUT); + gRequestorUser.Init(&gRequestorCore, &gImageProcessor); + + gImageProcessor.SetOTADownloader(&gDownloader); + + // Connect the Downloader and Image Processor objects + gDownloader.SetImageProcessorDelegate(&gImageProcessor); + // Initialize and interconnect the Requestor and Image Processor objects -- END +} + +void OTAConfig::InitOTARequestorHandler(chip::System::Layer * systemLayer, void * appState) +{ + if (!chip::GetRequestorInstance()) + { + ChipLogProgress(NotSpecified, "Init OTA Requestor"); + OTAConfig::Init(); + } +} diff --git a/examples/platform/qcc74x/common/plat/OTAConfig.h b/examples/platform/qcc74x/common/plat/OTAConfig.h new file mode 100644 index 00000000000000..24d8fb5c11109f --- /dev/null +++ b/examples/platform/qcc74x/common/plat/OTAConfig.h @@ -0,0 +1,34 @@ +/* + * + * Copyright (c) 2021 Project CHIP Authors + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include +#include +#include +#include + +class OTAConfig +{ +public: + OTAConfig(){}; + + static void Init(); + static constexpr uint32_t kInitOTARequestorDelaySec = 3; + static void InitOTARequestorHandler(chip::System::Layer * systemLayer, void * appState); +}; diff --git a/examples/platform/qcc74x/common/plat/demo_pwm.h b/examples/platform/qcc74x/common/plat/demo_pwm.h new file mode 100644 index 00000000000000..d434ee9addec2b --- /dev/null +++ b/examples/platform/qcc74x/common/plat/demo_pwm.h @@ -0,0 +1,21 @@ +#ifndef __DEMO_PWM__ +#define __DEMO_PWM__ + +#ifdef __cplusplus +extern "C" { +#endif + +void demo_pwm_init(void); +void demo_pwm_start(void); +void set_color_red(uint8_t currLevel); +void set_color_green(uint8_t currLevel); +void set_color_yellow(uint8_t currLevel); +void set_color(uint8_t currLevel, uint8_t currHue, uint8_t currSat); + +void set_level(uint8_t currLevel); + +#ifdef __cplusplus +} +#endif + +#endif // __DEMO_PWM__ diff --git a/examples/platform/qcc74x/common/plat/main.cpp b/examples/platform/qcc74x/common/plat/main.cpp new file mode 100644 index 00000000000000..313f9fe746f76f --- /dev/null +++ b/examples/platform/qcc74x/common/plat/main.cpp @@ -0,0 +1,70 @@ +/* + * + * Copyright (c) 2020 Project CHIP Authors + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#include + +#include + +using namespace ::chip; +using namespace ::chip::Inet; +using namespace ::chip::DeviceLayer; + +volatile int apperror_cnt; +// ================================================================================ +// App Error +//================================================================================= +void appError(int err) +{ + ChipLogProgress(NotSpecified, "!!!!!!!!!!!! App Critical Error: %d !!!!!!!!!!!", err); + portDISABLE_INTERRUPTS(); + while (true) + ; +} + +void appError(CHIP_ERROR error) +{ + appError(static_cast(error.AsInteger())); +} + +extern "C" int START_ENTRY(void) +{ + platform_port_init(); + + Internal::BLConfig::Init(); + + ChipLogProgress(NotSpecified, "=================================================="); + ChipLogProgress(NotSpecified, "qcc74x chip-lighting-example, built at " __DATE__ " " __TIME__); + ChipLogProgress(NotSpecified, "=================================================="); + + ChipLogProgress(NotSpecified, "Init CHIP Memory"); + chip::Platform::MemoryInit(NULL, 0); + + ChipLogProgress(NotSpecified, "Starting App Task"); + StartAppTask(); + + ChipLogProgress(NotSpecified, "Starting OS Scheduler..."); + vTaskStartScheduler(); + + // Should never get here. + ChipLogError(NotSpecified, "Starting OS Scheduler failed"); + appError(0); + + return 0; +} diff --git a/examples/platform/qcc74x/common/plat/plat.h b/examples/platform/qcc74x/common/plat/plat.h new file mode 100644 index 00000000000000..ba85f03e88105f --- /dev/null +++ b/examples/platform/qcc74x/common/plat/plat.h @@ -0,0 +1,37 @@ +/* + * + * Copyright (c) 2020 Project CHIP Authors + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#define APP_TASK_NAME "APP" +#define APP_TASK_PRIORITY 15 + +#define EXT_DISCOVERY_TIMEOUT_SECS 20 + +#ifdef __cplusplus + +#include +void appError(CHIP_ERROR error); + +extern "C" void platform_port_init(void); +#else + +void appError(int err); +void platform_port_init(void); + +#endif diff --git a/examples/platform/qcc74x/common/plat/platform.cpp b/examples/platform/qcc74x/common/plat/platform.cpp new file mode 100644 index 00000000000000..d969a6adca9b8f --- /dev/null +++ b/examples/platform/qcc74x/common/plat/platform.cpp @@ -0,0 +1,286 @@ +/* + * + * Copyright (c) 2020 Project CHIP Authors + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#if HEAP_MONITORING +#include +#endif + +#if CONFIG_ENABLE_CHIP_SHELL +#include +#include +#endif + +#if PW_RPC_ENABLED +#include +#include +#endif +#if CONFIG_ENABLE_CHIP_SHELL || PW_RPC_ENABLED +#include +#endif + +#if CONFIG_BOUFFALOLAB_FACTORY_DATA_ENABLE || CONFIG_BOUFFALOLAB_FACTORY_DATA_TEST +#include +#endif + +#if CHIP_DEVICE_CONFIG_ENABLE_WIFI +#include +#include +#endif + +#if CHIP_DEVICE_CONFIG_ENABLE_THREAD +#include +#include +#include +#include +#endif + +#if CHIP_DEVICE_CONFIG_ENABLE_ETHERNET || CHIP_DEVICE_CONFIG_ENABLE_WIFI +#include +#include +#if CHIP_DEVICE_CONFIG_ENABLE_WIFI && CHIP_DEVICE_LAYER_TARGET_BL602 +#include +#endif +#if CHIP_DEVICE_CONFIG_ENABLE_WIFI && CHIP_DEVICE_LAYER_TARGET_BL702 +#include +#endif +#if CHIP_DEVICE_CONFIG_ENABLE_ETHERNET +#include +#endif +#endif + +#include +#include + +using namespace ::chip; +using namespace ::chip::app; +using namespace ::chip::Credentials; +using namespace ::chip::DeviceLayer; + +#if CHIP_DEVICE_CONFIG_ENABLE_WIFI +namespace { +chip::app::Clusters::NetworkCommissioning::Instance + sWiFiNetworkCommissioningInstance(0 /* Endpoint Id */, &(NetworkCommissioning::BLWiFiDriver::GetInstance())); +} +#endif + +#if CONFIG_BOUFFALOLAB_FACTORY_DATA_ENABLE || CONFIG_BOUFFALOLAB_FACTORY_DATA_TEST +namespace { +FactoryDataProvider sFactoryDataProvider; +} +#endif + +static chip::DeviceLayer::DeviceInfoProviderImpl gExampleDeviceInfoProvider; + +void ChipEventHandler(const ChipDeviceEvent * event, intptr_t arg) +{ + switch (event->Type) + { + case DeviceEventType::kCHIPoBLEAdvertisingChange: + ChipLogProgress(NotSpecified, "BLE adv changed, connection number: %d", ConnectivityMgr().NumBLEConnections()); + break; +#if CHIP_DEVICE_CONFIG_ENABLE_THREAD + case DeviceEventType::kThreadStateChange: + + if (ConnectivityMgr().IsThreadAttached()) + { + chip::DeviceLayer::SystemLayer().StartTimer(chip::System::Clock::Seconds32(OTAConfig::kInitOTARequestorDelaySec), + OTAConfig::InitOTARequestorHandler, nullptr); + } + break; +#endif + +#if CHIP_DEVICE_CONFIG_ENABLE_WIFI || CHIP_DEVICE_CONFIG_ENABLE_ETHERNET + case DeviceEventType::kInterfaceIpAddressChanged: + if ((event->InterfaceIpAddressChanged.Type == InterfaceIpChangeType::kIpV4_Assigned) || + (event->InterfaceIpAddressChanged.Type == InterfaceIpChangeType::kIpV6_Assigned)) + { + // MDNS server restart on any ip assignment: if link local ipv6 is configured, that + // will not trigger a 'internet connectivity change' as there is no internet + // connectivity. MDNS still wants to refresh its listening interfaces to include the + // newly selected address. + + chip::app::DnssdServer::Instance().StartServer(); + + bl_route_hook_init(); + + chip::DeviceLayer::SystemLayer().StartTimer(chip::System::Clock::Seconds32(OTAConfig::kInitOTARequestorDelaySec), + OTAConfig::InitOTARequestorHandler, nullptr); + } + break; +#endif + case DeviceEventType::kInternetConnectivityChange: + if (event->InternetConnectivityChange.IPv4 == kConnectivity_Established) + { + ChipLogProgress(NotSpecified, "IPv4 connectivity ready..."); + } + else if (event->InternetConnectivityChange.IPv4 == kConnectivity_Lost) + { + ChipLogProgress(NotSpecified, "Lost IPv4 connectivity..."); + } + if (event->InternetConnectivityChange.IPv6 == kConnectivity_Established) + { + ChipLogProgress(NotSpecified, "IPv6 connectivity ready..."); + } + else if (event->InternetConnectivityChange.IPv6 == kConnectivity_Lost) + { + ChipLogProgress(NotSpecified, "Lost IPv6 connectivity..."); + } + break; + case DeviceEventType::kCHIPoBLEConnectionEstablished: + ChipLogProgress(NotSpecified, "BLE connection established"); + break; + case DeviceEventType::kCHIPoBLEConnectionClosed: + ChipLogProgress(NotSpecified, "BLE disconnected"); + break; + case DeviceEventType::kCommissioningComplete: + ChipLogProgress(NotSpecified, "Commissioning complete"); + GetAppTask().PostEvent(AppTask::APP_EVENT_LIGHTING_MASK); + break; + default: + break; + } +} + +#if CHIP_DEVICE_CONFIG_ENABLE_THREAD +void LockOpenThreadTask(void) +{ + chip::DeviceLayer::ThreadStackMgr().LockThreadStack(); +} + +void UnlockOpenThreadTask(void) +{ + chip::DeviceLayer::ThreadStackMgr().UnlockThreadStack(); +} +#endif + +CHIP_ERROR PlatformManagerImpl::PlatformInit(void) +{ + chip::RendezvousInformationFlags rendezvousMode(chip::RendezvousInformationFlag::kOnNetwork); +#if CONFIG_BOUFFALOLAB_FACTORY_DATA_ENABLE || CONFIG_BOUFFALOLAB_FACTORY_DATA_TEST + CHIP_ERROR retFactoryData = sFactoryDataProvider.Init(); +#endif + +#if PW_RPC_ENABLED + PigweedLogger::pw_init(); +#elif CONFIG_ENABLE_CHIP_SHELL + AppTask::StartAppShellTask(); +#endif + +#if HEAP_MONITORING + MemMonitoring::startHeapMonitoring(); +#endif + + ChipLogProgress(NotSpecified, "Initializing CHIP stack"); + ReturnLogErrorOnFailure(PlatformMgr().InitChipStack()); + + chip::DeviceLayer::ConnectivityMgr().SetBLEDeviceName(CHIP_BLE_DEVICE_NAME); + +#if CHIP_DEVICE_CONFIG_ENABLE_THREAD + +#if CONFIG_ENABLE_CHIP_SHELL + cmd_otcli_init(); +#endif + + ChipLogProgress(NotSpecified, "Initializing OpenThread stack"); + ReturnLogErrorOnFailure(ThreadStackMgr().InitThreadStack()); + +#if CHIP_DEVICE_CONFIG_THREAD_FTD + ReturnLogErrorOnFailure(ConnectivityMgr().SetThreadDeviceType(ConnectivityManager::kThreadDeviceType_Router)); +#else + ReturnLogErrorOnFailure(ConnectivityMgr().SetThreadDeviceType(ConnectivityManager::kThreadDeviceType_MinimalEndDevice)); +#endif + +#endif + +#if CHIP_DEVICE_CONFIG_ENABLE_WIFI + ReturnLogErrorOnFailure(sWiFiNetworkCommissioningInstance.Init()); +#endif + + // Initialize device attestation config +#if CONFIG_BOUFFALOLAB_FACTORY_DATA_ENABLE || CONFIG_BOUFFALOLAB_FACTORY_DATA_TEST + if (CHIP_NO_ERROR == retFactoryData) + { + SetDeviceInstanceInfoProvider(&sFactoryDataProvider); + SetDeviceAttestationCredentialsProvider(&sFactoryDataProvider); + SetCommissionableDataProvider(&sFactoryDataProvider); + } + else + { + ChipLogError(NotSpecified, "sFactoryDataProvider.Init() failed"); + } +#else + SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider()); +#endif + + chip::DeviceLayer::PlatformMgr().LockChipStack(); + +#if CHIP_DEVICE_CONFIG_ENABLE_EXTENDED_DISCOVERY + chip::app::DnssdServer::Instance().SetExtendedDiscoveryTimeoutSecs(EXT_DISCOVERY_TIMEOUT_SECS); +#endif + + chip::DeviceLayer::SetDeviceInfoProvider(&gExampleDeviceInfoProvider); + + static CommonCaseDeviceServerInitParams initParams; + (void) initParams.InitializeStaticResourcesBeforeServerInit(); + +#if CHIP_DEVICE_CONFIG_ENABLE_THREAD + chip::Inet::EndPointStateOpenThread::OpenThreadEndpointInitParam nativeParams; + nativeParams.lockCb = LockOpenThreadTask; + nativeParams.unlockCb = UnlockOpenThreadTask; + nativeParams.openThreadInstancePtr = chip::DeviceLayer::ThreadStackMgrImpl().OTInstance(); + initParams.endpointNativeParams = static_cast(&nativeParams); +#endif + + ReturnLogErrorOnFailure(chip::Server::GetInstance().Init(initParams)); + + gExampleDeviceInfoProvider.SetStorageDelegate(&chip::Server::GetInstance().GetPersistentStorage()); + + chip::DeviceLayer::PlatformMgr().UnlockChipStack(); + +#if CHIP_DEVICE_CONFIG_ENABLE_THREAD + ChipLogProgress(NotSpecified, "Starting OpenThread task"); + // Start OpenThread task + ReturnLogErrorOnFailure(ThreadStackMgrImpl().StartThreadTask()); +#endif + + ConfigurationMgr().LogDeviceConfig(); + +#if CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE + rendezvousMode.Set(chip::RendezvousInformationFlag::kBLE); +#endif + PrintOnboardingCodes(rendezvousMode); + + PlatformMgr().AddEventHandler(ChipEventHandler, 0); + +#if PW_RPC_ENABLED + chip::rpc::Init(); +#endif + + vTaskResume(GetAppTask().sAppTaskHandle); + + return CHIP_NO_ERROR; +} diff --git a/examples/platform/qcc74x/common/plat/uart.h b/examples/platform/qcc74x/common/plat/uart.h new file mode 100644 index 00000000000000..77cd7de39bdab8 --- /dev/null +++ b/examples/platform/qcc74x/common/plat/uart.h @@ -0,0 +1,29 @@ +/* + * + * Copyright (c) 2021 Project CHIP Authors + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include + +void uartInit(void); +int16_t uartWrite(const char * Buf, uint16_t BufLength); +int16_t uartRead(char * Buf, uint16_t NbBytesToRead); + +#ifdef CFG_USB_CDC_ENABLE +void aosUartRxCallback(int fd, void * param); +#endif diff --git a/examples/platform/qcc74x/common/route_hook/bl_lwip_hooks.h b/examples/platform/qcc74x/common/route_hook/bl_lwip_hooks.h new file mode 100644 index 00000000000000..e69383c73fb8ef --- /dev/null +++ b/examples/platform/qcc74x/common/route_hook/bl_lwip_hooks.h @@ -0,0 +1,13 @@ +#ifndef _LWIP_DEFAULT_HOOKS_H_ +#define _LWIP_DEFAULT_HOOKS_H_ +#include "lwip/arch.h" +#include "lwip/err.h" +#include "lwip/ip_addr.h" + +extern struct netif * lwip_hook_ip6_route(const ip6_addr_t * src, const ip6_addr_t * dest); +#define LWIP_HOOK_IP6_ROUTE lwip_hook_ip6_route + +extern const ip6_addr_t * lwip_hook_nd6_get_gw(struct netif * netif, const ip6_addr_t * dest); +#define LWIP_HOOK_ND6_GET_GW lwip_hook_nd6_get_gw + +#endif /* _LWIP_DEFAULT_HOOKS_H_ */ diff --git a/examples/platform/qcc74x/common/route_hook/bl_route_hook.c b/examples/platform/qcc74x/common/route_hook/bl_route_hook.c new file mode 100644 index 00000000000000..9b7766af5eeebe --- /dev/null +++ b/examples/platform/qcc74x/common/route_hook/bl_route_hook.c @@ -0,0 +1,214 @@ +#include +#include + +#include +#include "lwip/icmp6.h" +#include "lwip/mld6.h" +#include "lwip/netif.h" +#include "lwip/prot/icmp6.h" +#include "lwip/prot/ip6.h" +#include "lwip/prot/nd6.h" +#include "lwip/raw.h" + +#include "bl_route_hook.h" +#include "bl_route_table.h" + +typedef struct bl_route_hook_t +{ + struct netif * netif; + struct raw_pcb * pcb; + struct bl_route_hook_t * next; +} bl_route_hook_t; + +PACK_STRUCT_BEGIN +struct rio_header_t +{ + PACK_STRUCT_FLD_8(u8_t type); + PACK_STRUCT_FLD_8(u8_t length); + PACK_STRUCT_FLD_8(u8_t prefix_length); + PACK_STRUCT_FLD_8(u8_t preference); + PACK_STRUCT_FIELD(u32_t route_lifetime); +} PACK_STRUCT_STRUCT; +PACK_STRUCT_END + +typedef struct rio_header_t rio_header_t; + +static bl_route_hook_t * s_hooks; + +extern struct netif * deviceInterface_getNetif(void); + +static bool is_self_address(struct netif * netif, const ip6_addr_t * addr) +{ + for (size_t i = 0; i < LWIP_ARRAYSIZE(netif->ip6_addr); i++) + { + if (ip6_addr_isvalid(netif_ip6_addr_state(netif, i)) && + memcmp(addr->addr, netif_ip6_addr(netif, i)->addr, sizeof(addr->addr)) == 0) + { + return true; + } + } + return false; +} + +static void ra_recv_handler(struct netif * netif, const uint8_t * icmp_payload, uint16_t payload_len, const ip6_addr_t * src_addr) +{ + if (payload_len < sizeof(struct ra_header)) + { + return; + } + icmp_payload += sizeof(struct ra_header); + payload_len -= sizeof(struct ra_header); + + while (payload_len >= 2) + { + uint8_t opt_type = icmp_payload[0]; + uint8_t opt_len = icmp_payload[1] << 3; + + if (opt_type == ND6_OPTION_TYPE_ROUTE_INFO && opt_len >= sizeof(rio_header_t) && !is_self_address(netif, src_addr) && + payload_len >= opt_len) + { + rio_header_t rio_header; + memcpy(&rio_header, icmp_payload, sizeof(rio_header)); + + // skip if prefix is longer than IPv6 address. + if (rio_header.prefix_length > 128) + { + break; + } + uint8_t prefix_len_bytes = (rio_header.prefix_length + 7) / 8; + int8_t preference = -2 * ((rio_header.preference >> 4) & 1) + (((rio_header.preference) >> 3) & 1); + const uint8_t * rio_data = &icmp_payload[sizeof(rio_header_t)]; + uint8_t rio_data_len = opt_len - sizeof(rio_header_t); + + printf("Received RIO\r\n"); + if (rio_data_len >= prefix_len_bytes) + { + ip6_addr_t prefix; + bl_route_entry_t route; + + memset(&prefix, 0, sizeof(prefix)); + memcpy(&prefix.addr, rio_data, prefix_len_bytes); + route.netif = netif; + route.gateway = *src_addr; + route.prefix_length = rio_header.prefix_length; + route.prefix = prefix; + route.preference = preference; + route.lifetime_seconds = lwip_ntohl(rio_header.route_lifetime); + printf("prefix %s lifetime %lu\r\n", ip6addr_ntoa(&prefix), route.lifetime_seconds); + if (bl_route_table_add_route_entry(&route) == NULL) + { + printf("Failed to add route table entry\r\n"); + } + else + { + printf("Added entry to route table\r\n"); + } + } + } + icmp_payload += opt_len; + payload_len -= opt_len; + } +} + +static uint8_t icmp6_raw_recv_handler(void * arg, struct raw_pcb * pcb, struct pbuf * p, const ip_addr_t * addr) +{ + uint8_t * icmp_payload = NULL; + uint16_t icmp_payload_len; + struct ip6_hdr * ip6_header = (struct ip6_hdr *) p->payload; + struct icmp6_hdr * icmp6_header; + ip6_addr_t src; + ip6_addr_t dest; + bl_route_hook_t * hook = (bl_route_hook_t *) arg; + + memcpy(src.addr, ip6_header->src.addr, sizeof(src.addr)); + memcpy(dest.addr, ip6_header->dest.addr, sizeof(dest.addr)); +#if LWIP_IPV6_SCOPES + src.zone = 0; +#endif + + if (p->tot_len != p->len) + { + printf("Ignore segmented ICMP packet\r\n"); + return 0; + } + if (p->tot_len <= sizeof(struct ip6_hdr) + sizeof(struct icmp6_hdr)) + { + printf("Ignore invalid ICMP packet\r\n"); + return 0; + } + if (!ip6_addr_islinklocal(&dest) && !ip6_addr_isallnodes_linklocal(&dest) && !ip6_addr_isallrouters_linklocal(&dest)) + { + return 0; + } + + icmp_payload_len = p->tot_len - sizeof(struct ip6_hdr); + icmp_payload = p->payload + sizeof(struct ip6_hdr); + + icmp6_header = (struct icmp6_hdr *) icmp_payload; + if (icmp6_header->type == ICMP6_TYPE_RA) + { + ra_recv_handler(hook->netif, icmp_payload, icmp_payload_len, &src); + } + return 0; +} + +int8_t bl_route_hook_init(void) +{ + ip_addr_t router_group = IPADDR6_INIT_HOST(0xFF020000, 0, 0, 0x02); + bl_route_hook_t * hook = NULL; + uint8_t ret = 0; + struct netif * lwip_netif = deviceInterface_getNetif(); + + LOCK_TCPIP_CORE(); + + if (lwip_netif == NULL) + { + printf("Invalid network interface\r\n"); + ret = -1; + goto exit; + } + + for (bl_route_hook_t * iter = s_hooks; iter != NULL; iter++) + { + if (iter->netif == lwip_netif) + { + ret = 0; + break; + } + } + + hook = (bl_route_hook_t *) malloc(sizeof(bl_route_hook_t)); + if (hook == NULL) + { + printf("Cannot allocate hook\r\n"); + ret = -1; + goto exit; + } + + if (mld6_joingroup_netif(lwip_netif, ip_2_ip6(&router_group)) != ERR_OK) + { + printf("Failed to join multicast group\r\n"); + ret = -1; + goto exit; + } + + hook->netif = lwip_netif; + hook->pcb = raw_new_ip_type(IPADDR_TYPE_V6, IP6_NEXTH_ICMP6); + hook->pcb->flags |= RAW_FLAGS_MULTICAST_LOOP; + hook->pcb->chksum_reqd = 1; + // The ICMPv6 header checksum offset + hook->pcb->chksum_offset = 2; + raw_bind_netif(hook->pcb, lwip_netif); + raw_recv(hook->pcb, icmp6_raw_recv_handler, hook); + hook->next = s_hooks; + s_hooks = hook; + +exit: + if (ret != 0 && hook != NULL) + { + free(hook); + } + UNLOCK_TCPIP_CORE(); + + return ret; +} diff --git a/examples/platform/qcc74x/common/route_hook/bl_route_hook.h b/examples/platform/qcc74x/common/route_hook/bl_route_hook.h new file mode 100644 index 00000000000000..80c8bfec06a56a --- /dev/null +++ b/examples/platform/qcc74x/common/route_hook/bl_route_hook.h @@ -0,0 +1,10 @@ +#include +#ifdef __cplusplus +extern "C" { +#endif + +int8_t bl_route_hook_init(void); + +#ifdef __cplusplus +} +#endif diff --git a/examples/platform/qcc74x/common/route_hook/bl_route_table.c b/examples/platform/qcc74x/common/route_hook/bl_route_table.c new file mode 100644 index 00000000000000..3e5ae103b36e22 --- /dev/null +++ b/examples/platform/qcc74x/common/route_hook/bl_route_table.c @@ -0,0 +1,174 @@ +#include +#include + +#include "bl_route_table.h" +#include "lwip/ip6_addr.h" +#include "lwip/netif.h" +#include "lwip/timeouts.h" + +#define MAX_RIO_ROUTE 20 +#define MAX_RIO_TIMEOUT UINT32_MAX / (1000 * 4) // lwIP defined reasonable timeout value + +static bl_route_entry_t s_route_entries[MAX_RIO_ROUTE]; + +static bl_route_entry_t * find_route_entry(const bl_route_entry_t * route_entry) +{ + for (size_t i = 0; i < LWIP_ARRAYSIZE(s_route_entries); i++) + { + if (s_route_entries[i].netif == NULL) + { + break; + } + if (s_route_entries[i].netif == route_entry->netif && s_route_entries[i].prefix_length == route_entry->prefix_length && + memcmp(s_route_entries[i].gateway.addr, route_entry->gateway.addr, sizeof(route_entry->gateway.addr)) == 0 && + memcmp(s_route_entries[i].prefix.addr, route_entry->prefix.addr, route_entry->prefix_length / 8) == 0) + { + return &s_route_entries[i]; + } + } + return NULL; +} + +static bl_route_entry_t * find_empty_route_entry(void) +{ + for (size_t i = 0; i < LWIP_ARRAYSIZE(s_route_entries); i++) + { + if (s_route_entries[i].netif == NULL) + { + return &s_route_entries[i]; + } + } + return NULL; +} + +static void route_timeout_handler(void * arg) +{ + bl_route_entry_t * route = (bl_route_entry_t *) arg; + + bl_route_table_remove_route_entry(route); +} + +bl_route_entry_t * bl_route_table_add_route_entry(const bl_route_entry_t * route_entry) +{ + if (route_entry == NULL || (route_entry->lifetime_seconds > MAX_RIO_TIMEOUT && route_entry->lifetime_seconds != UINT32_MAX)) + { + return NULL; + } + + bl_route_entry_t * entry = find_route_entry(route_entry); + + if (entry == NULL) + { + entry = find_empty_route_entry(); + if (entry == NULL) + { + return NULL; + } + entry->netif = route_entry->netif; + entry->gateway = route_entry->gateway; + ip6_addr_assign_zone(&entry->gateway, IP6_UNICAST, entry->netif); + entry->prefix = route_entry->prefix; + entry->prefix_length = route_entry->prefix_length; + } + else + { + sys_untimeout(route_timeout_handler, entry); + } + entry->preference = route_entry->preference; + entry->lifetime_seconds = route_entry->lifetime_seconds; + if (entry->lifetime_seconds != UINT32_MAX) + { + sys_timeout(entry->lifetime_seconds * 1000, route_timeout_handler, entry); + } + return entry; +} + +int8_t bl_route_table_remove_route_entry(bl_route_entry_t * route_entry) +{ + if (route_entry < &s_route_entries[0] || route_entry > &s_route_entries[LWIP_ARRAYSIZE(s_route_entries)]) + { + return -1; + } + route_entry->netif = NULL; + for (bl_route_entry_t * moved = route_entry; moved < &s_route_entries[LWIP_ARRAYSIZE(s_route_entries) - 1]; moved++) + { + *moved = *(moved + 1); + if (moved->netif == NULL) + { + break; + } + } + return 0; +} + +static inline bool is_better_route(const bl_route_entry_t * lhs, const bl_route_entry_t * rhs) +{ + if (rhs == NULL) + { + return true; + } + if (lhs == NULL) + { + return false; + } + return (lhs->prefix_length > rhs->prefix_length) || + (lhs->prefix_length == rhs->prefix_length && lhs->preference > rhs->preference); +} + +static inline bool route_match(const bl_route_entry_t * route, const ip6_addr_t * dest) +{ + return memcmp(dest, route->prefix.addr, route->prefix_length / 8) == 0; +} + +struct netif * lwip_hook_ip6_route(const ip6_addr_t * src, const ip6_addr_t * dest) +{ + bl_route_entry_t * route = NULL; + + for (size_t i = 0; i < LWIP_ARRAYSIZE(s_route_entries); i++) + { + if (s_route_entries[i].netif == NULL) + { + break; + } + if (route_match(&s_route_entries[i], dest) && is_better_route(&s_route_entries[i], route)) + { + route = &s_route_entries[i]; + } + } + + if (route) + { + return route->netif; + } + else + { + return NULL; + } +} + +const ip6_addr_t * lwip_hook_nd6_get_gw(struct netif * netif, const ip6_addr_t * dest) +{ + bl_route_entry_t * route = NULL; + + for (size_t i = 0; i < LWIP_ARRAYSIZE(s_route_entries); i++) + { + if (s_route_entries[i].netif == NULL) + { + break; + } + if (s_route_entries[i].netif == netif && route_match(&s_route_entries[i], dest) && + is_better_route(&s_route_entries[i], route)) + { + route = &s_route_entries[i]; + } + } + + if (route) + { + return &route->gateway; + } + else + { + return NULL; + } +} diff --git a/examples/platform/qcc74x/common/route_hook/bl_route_table.h b/examples/platform/qcc74x/common/route_hook/bl_route_table.h new file mode 100644 index 00000000000000..eaf0f4f8c5ec63 --- /dev/null +++ b/examples/platform/qcc74x/common/route_hook/bl_route_table.h @@ -0,0 +1,76 @@ +#include + +#include "lwip/ip6_addr.h" +#include "lwip/netif.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Route table entry + * + */ +typedef struct +{ + ip6_addr_t prefix; + uint8_t prefix_length; + ip6_addr_t gateway; + int8_t preference; + uint32_t lifetime_seconds; + struct netif * netif; +} bl_route_entry_t; + +/** + * @brief Adds an entry to the route table + * + * @param[in] route_entry The route entry to be added + * + * @return + * - The pointer to the added route entry on success + * - NULL on failure + * + */ +bl_route_entry_t * bl_route_table_add_route_entry(const bl_route_entry_t * route_entry); + +/** + * @brief Removes an entry from the route table + * + * @param[in] route_entry The route entry to be removed + * + * @return + * - 0 + * - -1 The provided route_entry is not in the route table. + * + */ +int8_t bl_route_table_remove_route_entry(bl_route_entry_t * route_entry); + +/** + * @brief The lwIP ip6 route hook, called by the lwIP function ip6_route when sending packets. + * + * @param[in] src The source address + * @param[in] dest The destination address + * + * @return + * - The target interface when route found + * - NULL when route not found + * + */ +struct netif * lwip_hook_ip6_route(const ip6_addr_t * src, const ip6_addr_t * dest); + +/** + * @brief The lwIP gateway hook, called by the lwIP when deciding next hop. + * + * @param[in] netif The output network interface + * @param[in] dest The destination address + * + * @return + * - The gateway address when route found + * - NULL when route not found + * + */ +const ip6_addr_t * lwip_hook_nd6_get_gw(struct netif * netif, const ip6_addr_t * dest); + +#ifdef __cplusplus +} +#endif diff --git a/examples/platform/qcc74x/common/rpc/PigweedLogger.cpp b/examples/platform/qcc74x/common/rpc/PigweedLogger.cpp new file mode 100644 index 00000000000000..e3446a1a85234d --- /dev/null +++ b/examples/platform/qcc74x/common/rpc/PigweedLogger.cpp @@ -0,0 +1,107 @@ +/* + * + * Copyright (c) 2021 Project CHIP Authors + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * @file PigweedLogger.cpp + * + * This file contains basic string writing function, based on Pigweed HDLC + * over UART transport. It allows to send log messages even if the application + * needs to use HDLC/UART for another purpose like the RPC server. + */ + +#include + +#include "semphr.h" +#include +#include +#include + +#include "pw_span/span.h" +#include +#include +#include + +namespace PigweedLogger { +namespace { + +constexpr uint8_t kLogHdlcAddress = 1; // Send log messages to HDLC address 1 (other than RPC communication) +constexpr size_t kWriteBufferSize = 128; // Buffer for constructing HDLC frames + +// Exclusive access to the backend is needed to make sure that log messages coming +// from different threads are not interwoven. +SemaphoreHandle_t sLoggerLock = NULL; + +static pw::stream::SysIoWriter sWriter; +static size_t sWriteBufferPos; +static char sWriteBuffer[kWriteBufferSize]; + +static void send(void) +{ + pw::hdlc::WriteUIFrame(kLogHdlcAddress, pw::as_bytes(pw::span(sWriteBuffer, sWriteBufferPos)), sWriter); + sWriteBufferPos = 0; +} + +} // namespace + +void pw_init(void) +{ + sLoggerLock = xSemaphoreCreateMutex(); + assert(sLoggerLock != NULL); +} + +int putString(const char * buffer, size_t size) +{ + assert(sWriteBufferPos < kWriteBufferSize); + + if (sLoggerLock) + { + xSemaphoreTake(sLoggerLock, portMAX_DELAY); + } + + for (size_t i = 0; i < size; ++i) + { + // Send each line excluding "\r\n" in a separate frame + + if (buffer[i] == '\r') + continue; + + if (buffer[i] == '\n') + { + send(); + continue; + } + + sWriteBuffer[sWriteBufferPos++] = buffer[i]; + + if (sWriteBufferPos == kWriteBufferSize) + send(); + } + + if (sLoggerLock) + { + xSemaphoreGive(sLoggerLock); + } + return size; +} + +SemaphoreHandle_t * GetSemaphore() +{ + return &sLoggerLock; +} + +} // namespace PigweedLogger diff --git a/examples/platform/qcc74x/common/rpc/PigweedLogger.h b/examples/platform/qcc74x/common/rpc/PigweedLogger.h new file mode 100644 index 00000000000000..54067a47ae1acf --- /dev/null +++ b/examples/platform/qcc74x/common/rpc/PigweedLogger.h @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2021 Project CHIP Authors + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include + +#include "semphr.h" +#include + +namespace PigweedLogger { + +void pw_init(void); +int putString(const char * buffer, size_t size); +SemaphoreHandle_t * GetSemaphore(); + +} // namespace PigweedLogger diff --git a/examples/platform/qcc74x/common/rpc/Rpc.cpp b/examples/platform/qcc74x/common/rpc/Rpc.cpp new file mode 100644 index 00000000000000..ba71648b68c42b --- /dev/null +++ b/examples/platform/qcc74x/common/rpc/Rpc.cpp @@ -0,0 +1,243 @@ +/* + * + * Copyright (c) 2021 Project CHIP Authors + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "AppTask.h" +#include "FreeRTOS.h" +#include "PigweedLoggerMutex.h" +#include "pigweed/RpcService.h" +#include "pw_sys_io/init.h" +#include "task.h" +extern "C" { +#include "bl_sys.h" +} +#if defined(PW_RPC_ATTRIBUTE_SERVICE) && PW_RPC_ATTRIBUTE_SERVICE +#include "pigweed/rpc_services/Attributes.h" +#endif // defined(PW_RPC_ATTRIBUTE_SERVICE) && PW_RPC_ATTRIBUTE_SERVICE + +#if defined(PW_RPC_BUTTON_SERVICE) && PW_RPC_BUTTON_SERVICE +#include "pigweed/rpc_services/Button.h" +#endif // defined(PW_RPC_BUTTON_SERVICE) && PW_RPC_BUTTON_SERVICE + +#if defined(PW_RPC_DESCRIPTOR_SERVICE) && PW_RPC_DESCRIPTOR_SERVICE +#include "pigweed/rpc_services/Descriptor.h" +#endif // defined(PW_RPC_DESCRIPTOR_SERVICE) && PW_RPC_DESCRIPTOR_SERVICE + +#if defined(PW_RPC_DEVICE_SERVICE) && PW_RPC_DEVICE_SERVICE +#include "pigweed/rpc_services/Device.h" +#endif // defined(PW_RPC_DEVICE_SERVICE) && PW_RPC_DEVICE_SERVICE + +#if defined(PW_RPC_LIGHTING_SERVICE) && PW_RPC_LIGHTING_SERVICE +#include "pigweed/rpc_services/Lighting.h" +#endif // defined(PW_RPC_LIGHTING_SERVICE) && PW_RPC_LIGHTING_SERVICE + +#if defined(PW_RPC_LOCKING_SERVICE) && PW_RPC_LOCKING_SERVICE +#include "pigweed/rpc_services/Locking.h" +#endif // defined(PW_RPC_LOCKING_SERVICE) && PW_RPC_LOCKING_SERVICE + +#if defined(PW_RPC_OTCLI_SERVICE) && PW_RPC_OTCLI_SERVICE +#include "pigweed/rpc_services/OtCli.h" +#endif // defined(PW_RPC_OTCLI_SERVICE) && PW_RPC_OTCLI_SERVICE + +#if defined(PW_RPC_THREAD_SERVICE) && PW_RPC_THREAD_SERVICE +#include "pigweed/rpc_services/Thread.h" +#endif // defined(PW_RPC_THREAD_SERVICE) && PW_RPC_THREAD_SERVICE + +#if defined(PW_RPC_TRACING_SERVICE) && PW_RPC_TRACING_SERVICE +#define PW_TRACE_BUFFER_SIZE_BYTES 1024 +#include "pw_trace/trace.h" +#include "pw_trace_tokenized/trace_rpc_service_nanopb.h" + +// Define trace time for pw_trace +PW_TRACE_TIME_TYPE pw_trace_GetTraceTime() +{ + return (PW_TRACE_TIME_TYPE) chip::System::SystemClock().GetMonotonicMicroseconds64().count(); +} +// Microsecond time source +size_t pw_trace_GetTraceTimeTicksPerSecond() +{ + return 1000000; +} + +#endif // defined(PW_RPC_TRACING_SERVICE) && PW_RPC_TRACING_SERVICE + +namespace chip { +namespace rpc { + +#if defined(PW_RPC_BUTTON_SERVICE) && PW_RPC_BUTTON_SERVICE +class BouffaloButton final : public Button +{ +public: + pw::Status Event(const chip_rpc_ButtonEvent & request, pw_protobuf_Empty & response) override + { + GetAppTask().ButtonEventHandler(request.idx, request.pushed); + return pw::OkStatus(); + } +}; +#endif // defined(PW_RPC_BUTTON_SERVICE) && PW_RPC_BUTTON_SERVICE + +#if defined(PW_RPC_DEVICE_SERVICE) && PW_RPC_DEVICE_SERVICE +class BouffaloDevice final : public Device +{ +public: + pw::Status Reboot(const chip_rpc_RebootRequest & request, pw_protobuf_Empty & response) override + { + if (mRebootTimer) + { + return pw::Status::Unavailable(); + } + + TickType_t delayMs = kRebootTimerPeriodMs; + if (request.delay_ms != 0) + { + delayMs = request.delay_ms; + } + else + { + ChipLogProgress(NotSpecified, "Did not receive a reboot delay. Defaulting to %d ms", + static_cast(kRebootTimerPeriodMs)); + } + mRebootTimer = xTimerCreateStatic("Reboot", pdMS_TO_TICKS(delayMs), false, nullptr, RebootHandler, &mRebootTimerBuffer); + xTimerStart(mRebootTimer, 0); + return pw::OkStatus(); + } + + pw::Status FactoryReset(const pw_protobuf_Empty & request, pw_protobuf_Empty & response) override + { + if (mRebootTimer) + { + return pw::Status::Unavailable(); + } + + // Notice: reboot delay not configurable here + mRebootTimer = xTimerCreateStatic("FactoryReset", pdMS_TO_TICKS(kRebootTimerPeriodMs), false, nullptr, FactoryResetHandler, + &mRebootTimerBuffer); + xTimerStart(mRebootTimer, 0); + return pw::OkStatus(); + } + +private: + static constexpr uint32_t kRebootTimerPeriodMs = 1000; + TimerHandle_t mRebootTimer = 0; + StaticTimer_t mRebootTimerBuffer; + + static void RebootHandler(TimerHandle_t) { bl_sys_reset_por(); } + + static void FactoryResetHandler(TimerHandle_t) { DeviceLayer::ConfigurationMgr().InitiateFactoryReset(); } +}; +#endif // defined(PW_RPC_DEVICE_SERVICE) && PW_RPC_DEVICE_SERVICE + +namespace { + +#define RPC_TASK_STACK_SIZE 1536 +#define RPC_TASK_PRIORITY 1 +static TaskHandle_t sRpcTaskHandle; +StaticTask_t sRpcTaskBuffer; +StackType_t sRpcTaskStack[RPC_TASK_STACK_SIZE]; + +#if defined(PW_RPC_ATTRIBUTE_SERVICE) && PW_RPC_ATTRIBUTE_SERVICE +Attributes attributes_service; +#endif // defined(PW_RPC_ATTRIBUTE_SERVICE) && PW_RPC_ATTRIBUTE_SERVICE + +#if defined(PW_RPC_BUTTON_SERVICE) && PW_RPC_BUTTON_SERVICE +BouffaloButton button_service; +#endif // defined(PW_RPC_BUTTON_SERVICE) && PW_RPC_BUTTON_SERVICE + +#if defined(PW_RPC_DESCRIPTOR_SERVICE) && PW_RPC_DESCRIPTOR_SERVICE +Descriptor descriptor_service; +#endif // defined(PW_RPC_DESCRIPTOR_SERVICE) && PW_RPC_DESCRIPTOR_SERVICE + +#if defined(PW_RPC_DEVICE_SERVICE) && PW_RPC_DEVICE_SERVICE +BouffaloDevice device_service; +#endif // defined(PW_RPC_DEVICE_SERVICE) && PW_RPC_DEVICE_SERVICE + +#if defined(PW_RPC_LIGHTING_SERVICE) && PW_RPC_LIGHTING_SERVICE +Lighting lighting_service; +#endif // defined(PW_RPC_LIGHTING_SERVICE) && PW_RPC_LIGHTING_SERVICE + +#if defined(PW_RPC_LOCKING_SERVICE) && PW_RPC_LOCKING_SERVICE +Locking locking; +#endif // defined(PW_RPC_LOCKING_SERVICE) && PW_RPC_LOCKING_SERVICE + +#if defined(PW_RPC_OTCLI_SERVICE) && PW_RPC_OTCLI_SERVICE +OtCli ot_cli_service; +#endif // defined(PW_RPC_OTCLI_SERVICE) && PW_RPC_OTCLI_SERVICE + +#if defined(PW_RPC_THREAD_SERVICE) && PW_RPC_THREAD_SERVICE +Thread thread; +#endif // defined(PW_RPC_THREAD_SERVICE) && PW_RPC_THREAD_SERVICE + +#if defined(PW_RPC_TRACING_SERVICE) && PW_RPC_TRACING_SERVICE +pw::trace::TraceService trace_service(pw::trace::GetTokenizedTracer()); +#endif // defined(PW_RPC_TRACING_SERVICE) && PW_RPC_TRACING_SERVICE + +void RegisterServices(pw::rpc::Server & server) +{ +#if defined(PW_RPC_ATTRIBUTE_SERVICE) && PW_RPC_ATTRIBUTE_SERVICE + server.RegisterService(attributes_service); +#endif // defined(PW_RPC_ATTRIBUTE_SERVICE) && PW_RPC_ATTRIBUTE_SERVICE + +#if defined(PW_RPC_BUTTON_SERVICE) && PW_RPC_BUTTON_SERVICE + server.RegisterService(button_service); +#endif // defined(PW_RPC_BUTTON_SERVICE) && PW_RPC_BUTTON_SERVICE + +#if defined(PW_RPC_DESCRIPTOR_SERVICE) && PW_RPC_DESCRIPTOR_SERVICE + server.RegisterService(descriptor_service); +#endif // defined(PW_RPC_DESCRIPTOR_SERVICE) && PW_RPC_DESCRIPTOR_SERVICE + +#if defined(PW_RPC_DEVICE_SERVICE) && PW_RPC_DEVICE_SERVICE + server.RegisterService(device_service); +#endif // defined(PW_RPC_DEVICE_SERVICE) && PW_RPC_DEVICE_SERVICE + +#if defined(PW_RPC_LIGHTING_SERVICE) && PW_RPC_LIGHTING_SERVICE + server.RegisterService(lighting_service); +#endif // defined(PW_RPC_LIGHTING_SERVICE) && PW_RPC_LIGHTING_SERVICE + +#if defined(PW_RPC_LOCKING_SERVICE) && PW_RPC_LOCKING_SERVICE + server.RegisterService(locking); +#endif // defined(PW_RPC_LOCKING_SERVICE) && PW_RPC_LOCKING_SERVICE + +#if defined(PW_RPC_OTCLI_SERVICE) && PW_RPC_OTCLI_SERVICE + server.RegisterService(ot_cli_service); +#endif // defined(PW_RPC_OTCLI_SERVICE) && PW_RPC_OTCLI_SERVICE + +#if defined(PW_RPC_THREAD_SERVICE) && PW_RPC_THREAD_SERVICE + server.RegisterService(thread); +#endif // defined(PW_RPC_THREAD_SERVICE) && PW_RPC_THREAD_SERVICE + +#if defined(PW_RPC_TRACING_SERVICE) && PW_RPC_TRACING_SERVICE + server.RegisterService(trace_service); + PW_TRACE_SET_ENABLED(true); +#endif // defined(PW_RPC_TRACING_SERVICE) && PW_RPC_TRACING_SERVICE +} + +} // namespace + +void RunRpcService(void *) +{ + Start(RegisterServices, &logger_mutex); +} + +void Init() +{ + // Start App task. + sRpcTaskHandle = xTaskCreateStatic(RunRpcService, "RPC_TASK", ArraySize(sRpcTaskStack), nullptr, RPC_TASK_PRIORITY, + sRpcTaskStack, &sRpcTaskBuffer); +} + +} // namespace rpc +} // namespace chip diff --git a/examples/platform/qcc74x/common/rpc/Rpc.h b/examples/platform/qcc74x/common/rpc/Rpc.h new file mode 100644 index 00000000000000..dcb25862a9cd1e --- /dev/null +++ b/examples/platform/qcc74x/common/rpc/Rpc.h @@ -0,0 +1,30 @@ +/* + * + * Copyright (c) 2021 Project CHIP Authors + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +namespace chip { +namespace rpc { + +class LightingService; + +void Init(); +void RunRpcService(void *); + +} // namespace rpc +} // namespace chip diff --git a/examples/platform/qcc74x/common/rpc/pw_sys_io/BUILD.gn b/examples/platform/qcc74x/common/rpc/pw_sys_io/BUILD.gn new file mode 100644 index 00000000000000..693b165c5c67f7 --- /dev/null +++ b/examples/platform/qcc74x/common/rpc/pw_sys_io/BUILD.gn @@ -0,0 +1,40 @@ +# Copyright (c) 2021 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build_overrides/chip.gni") +import("//build_overrides/pigweed.gni") + +import("$dir_pw_build/target_types.gni") + +examples_plat_comon_dir = "${chip_root}/examples/platform/qcc74x/common" + +config("default_config") { + include_dirs = [ "public" ] +} + +pw_source_set("pw_sys_io") { + sources = [ "sys_io.cc" ] + + deps = [ + "$dir_pw_sys_io:default_putget_bytes", + "$dir_pw_sys_io:facade", + ] + + cflags = [ "-Wconversion" ] + + public_configs = [ ":default_config" ] + + include_dirs = [ "${examples_plat_comon_dir}/plat" ] + include_dirs += [ "${examples_plat_comon_dir}/rpc" ] +} diff --git a/examples/platform/qcc74x/common/rpc/pw_sys_io/public/pw_sys_io/init.h b/examples/platform/qcc74x/common/rpc/pw_sys_io/public/pw_sys_io/init.h new file mode 100644 index 00000000000000..f11f5e928f3e14 --- /dev/null +++ b/examples/platform/qcc74x/common/rpc/pw_sys_io/public/pw_sys_io/init.h @@ -0,0 +1,27 @@ +/* + * + * Copyright (c) 2021 Project CHIP Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include "pw_preprocessor/util.h" + +PW_EXTERN_C_START + +// The actual implement of PreMainInit() in sys_io_BACKEND. +void pw_sys_io_Init(); + +PW_EXTERN_C_END diff --git a/examples/platform/qcc74x/common/rpc/pw_sys_io/sys_io.cc b/examples/platform/qcc74x/common/rpc/pw_sys_io/sys_io.cc new file mode 100644 index 00000000000000..5da8547c93155c --- /dev/null +++ b/examples/platform/qcc74x/common/rpc/pw_sys_io/sys_io.cc @@ -0,0 +1,60 @@ +/* + * + * Copyright (c) 2021 Project CHIP Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include + +#include "pw_sys_io/sys_io.h" +#include "uart.h" + +namespace pw::sys_io { + +Status ReadByte(std::byte * dest) +{ + if (!dest) + return Status::InvalidArgument(); + + int16_t ret = uartRead(reinterpret_cast(dest), 1); + return ret <= 0 ? Status::FailedPrecondition() : OkStatus(); +} + +Status WriteByte(std::byte b) +{ + int16_t ret = uartWrite(reinterpret_cast(&b), 1); + + return ret <= 0 ? Status::FailedPrecondition() : OkStatus(); +} + +// Writes a string using pw::sys_io, and add newline characters at the end. +StatusWithSize WriteLine(const std::string_view & s) +{ + size_t chars_written = 0; + StatusWithSize result = WriteBytes(pw::as_bytes(pw::span(s))); + if (!result.ok()) + { + return result; + } + chars_written += result.size(); + result = WriteBytes(pw::as_bytes(pw::span("\r\n", 2))); + chars_written += result.size(); + + return StatusWithSize(result.status(), chars_written); +} + +} // namespace pw::sys_io diff --git a/examples/platform/qcc74x/doc/chart/BL602-IoT-Matter_V1.png b/examples/platform/qcc74x/doc/chart/BL602-IoT-Matter_V1.png new file mode 100644 index 00000000000000..6cb4dc049f6ef5 Binary files /dev/null and b/examples/platform/qcc74x/doc/chart/BL602-IoT-Matter_V1.png differ diff --git a/examples/platform/qcc74x/doc/chart/bl706_dev_board.jpg b/examples/platform/qcc74x/doc/chart/bl706_dev_board.jpg new file mode 100644 index 00000000000000..a93cad7177e2bf Binary files /dev/null and b/examples/platform/qcc74x/doc/chart/bl706_dev_board.jpg differ diff --git a/examples/platform/qcc74x/qcc743/BUILD.gn b/examples/platform/qcc74x/qcc743/BUILD.gn new file mode 100644 index 00000000000000..0cb68bb33f9d4e --- /dev/null +++ b/examples/platform/qcc74x/qcc743/BUILD.gn @@ -0,0 +1,22 @@ +# Copyright (c) 2021 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build_overrides/qcc74x_iot_sdk.gni") +import("//build_overrides/chip.gni") + +import("${qcc74x_iot_sdk_build_root}/qcc743/qcc74x_sdk.gni") + +config("chip_examples_project_config") { + include_dirs = [ "project_include" ] +} diff --git a/examples/platform/qcc74x/qcc743/FreeRTOSConfig.h b/examples/platform/qcc74x/qcc743/FreeRTOSConfig.h new file mode 100644 index 00000000000000..187e05c75a928c --- /dev/null +++ b/examples/platform/qcc74x/qcc743/FreeRTOSConfig.h @@ -0,0 +1,138 @@ +/* + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + +#ifndef FREERTOS_CONFIG_H +#define FREERTOS_CONFIG_H + +/*----------------------------------------------------------- + * Application specific definitions. + * + * These definitions should be adjusted for your particular hardware and + * application requirements. + * + * THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE + * FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE. + * + * See http://www.freertos.org/a00110.html. + *----------------------------------------------------------*/ +#include "stdio.h" + +#define configMTIME_BASE_ADDRESS (0xE0000000UL + 0xBFF8UL) +#define configMTIMECMP_BASE_ADDRESS (0xE0000000UL + 0x4000UL) + +#define configSUPPORT_STATIC_ALLOCATION 1 +#define configUSE_PREEMPTION 1 +#define configUSE_IDLE_HOOK 0 +#define configUSE_TICK_HOOK 0 +#define configCPU_CLOCK_HZ ((uint32_t)(1 * 1000 * 1000)) +#define configTICK_RATE_HZ ((TickType_t)1000) +#define configMAX_PRIORITIES (32) +#define configMINIMAL_STACK_SIZE ((unsigned short)128) /* Only needs to be this high as some demo tasks also use this constant. In production only the idle task would use this. */ +#define configTOTAL_HEAP_SIZE ((size_t)100 * 1024) +#define configMAX_TASK_NAME_LEN (16) +#define configUSE_TRACE_FACILITY 1 +#define configUSE_STATS_FORMATTING_FUNCTIONS 1 +#define configUSE_16_BIT_TICKS 0 +#define configIDLE_SHOULD_YIELD 0 +#define configUSE_MUTEXES 1 +#define configQUEUE_REGISTRY_SIZE 8 +#define configCHECK_FOR_STACK_OVERFLOW 2 +#define configUSE_RECURSIVE_MUTEXES 1 +#define configUSE_MALLOC_FAILED_HOOK 1 +#define configUSE_APPLICATION_TASK_TAG 1 +#define configUSE_COUNTING_SEMAPHORES 1 +#define configGENERATE_RUN_TIME_STATS 1 +#define configUSE_PORT_OPTIMISED_TASK_SELECTION 1 +#define configUSE_TICKLESS_IDLE 0 +#define configUSE_POSIX_ERRNO 1 + +/* Co-routine definitions. */ +#define configUSE_CO_ROUTINES 0 +#define configMAX_CO_ROUTINE_PRIORITIES (2) + +/* Software timer definitions. */ +#define configUSE_TIMERS 1 +#define configTIMER_TASK_PRIORITY (configMAX_PRIORITIES - 1) +#define configTIMER_QUEUE_LENGTH 4 +#define configTIMER_TASK_STACK_DEPTH (1024) + +/* Task priorities. Allow these to be overridden. */ +#ifndef uartPRIMARY_PRIORITY +#define uartPRIMARY_PRIORITY (configMAX_PRIORITIES - 3) +#endif + +/* Set the following definitions to 1 to include the API function, or zero +to exclude the API function. */ +#define INCLUDE_vTaskPrioritySet 1 +#define INCLUDE_uxTaskPriorityGet 1 +#define INCLUDE_vTaskDelete 1 +#define INCLUDE_vTaskCleanUpResources 1 +#define INCLUDE_vTaskSuspend 1 +#define INCLUDE_vTaskDelayUntil 1 +#define INCLUDE_vTaskDelay 1 +#define INCLUDE_eTaskGetState 1 +#define INCLUDE_xTimerPendFunctionCall 1 +#define INCLUDE_xTaskAbortDelay 1 +#define INCLUDE_xTaskGetHandle 1 +#define INCLUDE_xSemaphoreGetMutexHolder 1 + +/* Normal assert() semantics without relying on the provision of an assert.h +header file. */ +void vApplicationMallocFailedHook(void); + +#if __cplusplus +extern "C" void vAssertCalled(void); +#else +void vAssertCalled(void); +#endif +#define configASSERT(x) \ + if ((x) == 0) { \ + printf("file [%s]\r\n", __FILE__); \ + printf("func [%s]\r\n", __FUNCTION__); \ + printf("line [%d]\r\n", __LINE__); \ + printf("%s\r\n", (const char *)(#x)); \ + vAssertCalled(); \ + } + +#if (configUSE_TICKLESS_IDLE != 0) +void vApplicationSleep(uint32_t xExpectedIdleTime); +#define portSUPPRESS_TICKS_AND_SLEEP(xExpectedIdleTime) vApplicationSleep(xExpectedIdleTime) +#endif + +// #define portUSING_MPU_WRAPPERS + +#if (configGENERATE_RUN_TIME_STATS == 1) +#ifdef __cplusplus +extern "C" uint64_t bflb_mtimer_get_time_us(); +#else +extern uint64_t bflb_mtimer_get_time_us(); +#endif +#define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() ((void)0) +#define portGET_RUN_TIME_COUNTER_VALUE() bflb_mtimer_get_time_us() +#endif + +#endif /* FREERTOS_CONFIG_H */ diff --git a/examples/platform/qcc74x/qcc743/args.gni b/examples/platform/qcc74x/qcc743/args.gni new file mode 100644 index 00000000000000..bbab38b1a34ff2 --- /dev/null +++ b/examples/platform/qcc74x/qcc743/args.gni @@ -0,0 +1,21 @@ +# Copyright (c) 2021 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build_overrides/chip.gni") + +chip_ble_project_config_include = "" +chip_device_project_config_include = "" +chip_project_config_include = "" +chip_inet_project_config_include = "" +chip_system_project_config_include = "" diff --git a/examples/platform/qcc74x/qcc743/bl616_lwip_hooks.h b/examples/platform/qcc74x/qcc743/bl616_lwip_hooks.h new file mode 100644 index 00000000000000..86b297b66fa8fc --- /dev/null +++ b/examples/platform/qcc74x/qcc743/bl616_lwip_hooks.h @@ -0,0 +1,15 @@ +#ifndef _LWIP_DEFAULT_HOOKS_H_ +#define _LWIP_DEFAULT_HOOKS_H_ +#include "lwip/arch.h" +#include "lwip/err.h" +#include "lwip/ip_addr.h" + +#include "lwiphooks.h" + +extern struct netif * lwip_hook_ip6_route(const ip6_addr_t * src, const ip6_addr_t * dest); +#define LWIP_HOOK_IP6_ROUTE lwip_hook_ip6_route + +extern const ip6_addr_t * lwip_hook_nd6_get_gw(struct netif * netif, const ip6_addr_t * dest); +#define LWIP_HOOK_ND6_GET_GW lwip_hook_nd6_get_gw + +#endif /* _LWIP_DEFAULT_HOOKS_H_ */ diff --git a/examples/platform/qcc74x/qcc743/flash_config/partition_cfg_4M.toml b/examples/platform/qcc74x/qcc743/flash_config/partition_cfg_4M.toml new file mode 100644 index 00000000000000..87f1c828a7cb96 --- /dev/null +++ b/examples/platform/qcc74x/qcc743/flash_config/partition_cfg_4M.toml @@ -0,0 +1,141 @@ +[pt_table] +#partition table is 4K in size +address0 = 0xE000 +address1 = 0xF000 +# If version is 2, It will use dynamic mode. +version = 2 + +[[pt_entry]] +type = 16 +name = "Boot2" +device = 0 +address0 = 0 +size0 = 0xE000 +address1 = 0 +size1 = 0 +# compressed image must set len,normal image can left it to 0 +len = 0 +# If header is 1, it will add the header. +header = 1 +# If header is 1 and security is 1, It will be encrypted. +security = 1 + +[[pt_entry]] +type = 0 +name = "FW" +device = 0 +address0 = 0x10000 +size0 = 0x200000 +address1 = 0x210000 +size1 = 0x168000 +# compressed image must set len,normal image can left it to 0 +len = 0 +# If header is 1, it will add the header. +header = 1 +# If header is 1 and security is 1, It will be encrypted. +security = 1 + +[[pt_entry]] +type = 10 +name = "mfg" +device = 0 +address0 = 0x210000 +size0 = 0x168000 +address1 = 0 +size1 = 0 +# compressed image must set len,normal image can left it to 0 +len = 0 +# If header is 1, it will add the header. +header = 1 +# If header is 1 and security is 1, It will be encrypted. +security = 1 + +[[pt_entry]] +type = 2 +name = "media" +device = 0 +address0 = 0x378000 +size0 = 0x6f000 +address1 = 0 +size1 = 0 +# compressed image must set len,normal image can left it to 0 +len = 0 +# If header is 1, it will add the header. +header = 0 +# If header is 1 and security is 1, It will be encrypted. +security = 0 + +[[pt_entry]] +type = 3 +name = "PSM" +device = 0 +address0 = 0x3E7000 +size0 = 0x8000 +address1 = 0 +size1 = 0 +# compressed image must set len,normal image can left it to 0 +len = 0 +# If header is 1, it will add the header. +header = 0 +# If header is 1 and security is 1, It will be encrypted. +security = 0 + +[[pt_entry]] +type = 4 +name = "KEY" +device = 0 +address0 = 0x3EF000 +size0 = 0x2000 +address1 = 0 +size1 = 0 +# compressed image must set len,normal image can left it to 0 +len = 0 +# If header is 1, it will add the header. +header = 0 +# If header is 1 and security is 1, It will be encrypted. +security = 0 + +[[pt_entry]] +type = 5 +name = "DATA" +device = 0 +address0 = 0x3F1000 +size0 = 0x5000 +address1 = 0 +size1 = 0 +# compressed image must set len,normal image can left it to 0 +len = 0 +# If header is 1, it will add the header. +header = 0 +# If header is 1 and security is 1, It will be encrypted. +security = 0 + +[[pt_entry]] +type = 6 +name = "factory" +device = 0 +address0 = 0x3F6000 +size0 = 0x8000 +address1 = 0 +size1 = 0 +# compressed image must set len,normal image can left it to 0 +len = 0 +# If header is 1, it will add the header. +header = 0 +# If header is 1 and security is 1, It will be encrypted. +security = 0 + +[[pt_entry]] +type = 7 +name = "MFD" +device = 0 +address0 = 0x3FE000 +size0 = 0x1000 +address1 = 0 +size1 = 0 +# compressed image must set len,normal image can left it to 0 +len = 0 +# If header is 1, it will add the header. +header = 0 +# If header is 1 and security is 1, It will be encrypted. +security = 0 \ No newline at end of file diff --git a/examples/platform/qcc74x/qcc743/ldscripts/bl616_flash.ld b/examples/platform/qcc74x/qcc743/ldscripts/bl616_flash.ld new file mode 100644 index 00000000000000..a3d19e4ebcf98b --- /dev/null +++ b/examples/platform/qcc74x/qcc743/ldscripts/bl616_flash.ld @@ -0,0 +1,358 @@ +/**************************************************************************************** +* @file flash.ld +* +* @brief This file is the link script file (gnuarm or armgcc). +* +* Copyright (C) BouffaloLab 2021 +* +**************************************************************************************** +*/ + +/* configure the CPU type */ +OUTPUT_ARCH( "riscv" ) + +/* configure the entry point */ +ENTRY(__start) + +StackSize = 0x1000; /* 4KB */ +HeapMinSize = 0x1000; /* 4KB */ +psram_min_size = 0x1000; +nocache_min_size = 20K; + +__EM_SIZE = DEFINED(btble_controller_init) ? 32K : 0K; +__REMAIN_WRAM_SIZE = 0; +__RFTLV_SIZE_OFFSET = 1K; +__RFTLV_SIZE_HOLE = 2K; +__RFTLV_HEAD1_H = (0x46524C42); /* BLRF */ +__RFTLV_HEAD1_L = (0x41524150); /* PAPA */ + +MEMORY +{ + xip_memory (rx) : ORIGIN = 0xA0000000, LENGTH = 4M + ram_psram (wxa) : ORIGIN = 0xA8000000, LENGTH = 4M + itcm_memory (rx) : ORIGIN = 0x62FC0000, LENGTH = 20K + dtcm_memory (rx) : ORIGIN = 0x62FC5000, LENGTH = 4K + nocache_ram_memory (!rx) : ORIGIN = 0x22FC6000, LENGTH = 4K + ram_memory (!rx) : ORIGIN = 0x62FC6000 + LENGTH(nocache_ram_memory), LENGTH = 320K-20K-4K-LENGTH(nocache_ram_memory) + __REMAIN_WRAM_SIZE + ram_wifi (wxa) : ORIGIN = 0x23010000 + __REMAIN_WRAM_SIZE, LENGTH = 160K - __EM_SIZE - __REMAIN_WRAM_SIZE +} + +SECTIONS +{ + BOOT2_PT_ADDR = 0x63027c00; + + .init : + { + KEEP (*(SORT_NONE(.init))) + KEEP (*(SORT_NONE(.vector))) + + } > xip_memory + + .rftlv.tool : + { + . = ORIGIN(xip_memory) + __RFTLV_SIZE_OFFSET; + PROVIDE( _ld_symbol_rftlv_address = . ); + LONG(__RFTLV_HEAD1_H); + LONG(__RFTLV_HEAD1_L); + . = ORIGIN(xip_memory) + __RFTLV_SIZE_OFFSET + __RFTLV_SIZE_HOLE; + } > xip_memory + + .preinit_array : + { + . = ALIGN(4); + __preinit_array_start = .; + KEEP (*(.preinit_array)) + __preinit_array_end = .; + } > xip_memory + + .init_array : + { + . = ALIGN(4); + __init_array_start = .; + KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*))) + KEEP (*(.init_array)) + __init_array_end = .; + } > xip_memory + + .text : + { + . = ALIGN(4); + __text_code_start__ = .; + + *(.text) + *(.text.*) + + /* section information for shell */ + . = ALIGN(4); + __fsymtab_start = .; + KEEP(*(FSymTab)) + __fsymtab_end = .; + + /* section information for components's version */ + . = ALIGN(4); + _version_info_section_start = .; + KEEP(*(.version.*)) + _version_info_section_end = .; + + . = ALIGN(4); + __vsymtab_start = .; + KEEP(*(VSymTab)) + __vsymtab_end = .; + + /* section information for usb usbh_class_info */ + . = ALIGN(4); + __usbh_class_info_start__ = .; + KEEP(*(.usbh_class_info)) + . = ALIGN(4); + __usbh_class_info_end__ = .; + + /*put .rodata**/ + *(EXCLUDE_FILE( *qcc743_glb*.o* \ + *qcc743_pds*.o* \ + *qcc743_common*.o* \ + *qcc743_sf_cfg*.o* \ + *qcc743_sf_ctrl*.o* \ + *qcc743_sflash*.o* \ + *qcc743_xip_sflash*.o* \ + *qcc743_ef_ctrl*.o* \ + *qcc743_romapi_patch*.o* ).rodata*) + + *(.srodata) + *(.srodata.*) + + . = ALIGN(4); + __text_code_end__ = .; + } > xip_memory + + . = ALIGN(4); + __itcm_load_addr = .; + + .itcm_region : AT (__itcm_load_addr) + { + . = ALIGN(4); + __tcm_code_start__ = .; + + *(.tcm_code.*) + *(.tcm_const.*) + *(.sclock_rlt_code.*) + *(.sclock_rlt_const.*) + + *qcc743_glb*.o*(.rodata*) + *qcc743_pds*.o*(.rodata*) + *qcc743_common*.o*(.rodata*) + *qcc743_sf_cfg*.o*(.rodata*) + *qcc743_sf_ctrl*.o*(.rodata*) + *qcc743_sflash*.o*(.rodata*) + *qcc743_xip_sflash*.o*(.rodata*) + *qcc743_ef_ctrl*.o*(.rodata*) + *qcc743_romapi_patch*.o*(.rodata*) + + . = ALIGN(4); + __tcm_code_end__ = .; + } > itcm_memory + + __dtcm_load_addr = __itcm_load_addr + SIZEOF(.itcm_region); + + .dtcm_region : AT (__dtcm_load_addr) + { + . = ALIGN(4); + __tcm_data_start__ = .; + + *(.tcm_data) + /* *finger_print.o(.data*) */ + + . = ALIGN(4); + __tcm_data_end__ = .; + } > dtcm_memory + + /*************************************************************************/ + /* .stack_dummy section doesn't contains any symbols. It is only + * used for linker to calculate size of stack sections, and assign + * values to stack symbols later */ + .stack_dummy (NOLOAD): + { + . = ALIGN(0x4); + . = . + StackSize; + . = ALIGN(0x4); + } > dtcm_memory + + /* Set stack top to end of RAM, and stack limit move down by + * size of stack_dummy section */ + __StackTop = ORIGIN(dtcm_memory) + LENGTH(dtcm_memory); + PROVIDE( __freertos_irq_stack_top = __StackTop); + __StackLimit = __StackTop - SIZEOF(.stack_dummy); + + /* Check if data + heap + stack exceeds RAM limit */ + ASSERT(__StackLimit >= __tcm_data_end__, "region RAM overflowed with stack") + + /*************************************************************************/ + + __nocache_ram_load_addr = __dtcm_load_addr + SIZEOF(.dtcm_region); + + .nocache_ram_region : AT (__nocache_ram_load_addr) + { + . = ALIGN(4); + __nocache_ram_data_start__ = .; + + *(.nocache_ram) + + . = ALIGN(4); + __nocache_ram_data_end__ = .; + } > nocache_ram_memory + + __ram_load_addr = __nocache_ram_load_addr + SIZEOF(.nocache_ram_region); + + /* Data section */ + RAM_DATA : AT (__ram_load_addr) + { + . = ALIGN(4); + __ram_data_start__ = .; + + PROVIDE( __global_pointer$ = . + 0x800 ); + + *(.data) + *(.data.*) + *(.sdata) + *(.sdata.*) + *(.sdata2) + *(.sdata2.*) + + . = ALIGN(4); + __bflog_tags_start__ = .; + *(.bflog_tags_array) + . = ALIGN(4); + __bflog_tags_end__ = .; + __ram_data_end__ = .; + } > ram_memory + + + __psram_load_addr = (__ram_load_addr + SIZEOF (RAM_DATA)); + + .psram_data_region : AT (__psram_load_addr) + { + . = ALIGN(4); + __psram_data_start__ = .; + + KEEP(*(.psram_data*)) + + . = ALIGN(4); + __psram_data_end__ = .; + } > ram_psram + + __etext_final = (__psram_load_addr + SIZEOF (.psram_data_region)); + ASSERT(__etext_final <= ORIGIN(xip_memory) + LENGTH(xip_memory), "code memory overflow") + + .bss (NOLOAD) : + { + . = ALIGN(4); + __bss_start__ = .; + + *(.bss*) + *(.sbss*) + *(COMMON) + + . = ALIGN(4); + __bss_end__ = .; + } > ram_memory + + .noinit_data (NOLOAD) : + { + . = ALIGN(4); + __noinit_data_start__ = .; + + *(.noinit_data*) + + . = ALIGN(4); + __noinit_data_end__ = .; + } > ram_memory + + .nocache_noinit_ram_region (NOLOAD) : + { + . = ALIGN(4); + __nocache_noinit_ram_data_start__ = .; + + *(.nocache_noinit_ram) + *(.noncacheable) + + . = ALIGN(4); + __nocache_noinit_ram_data_end__ = .; + } > nocache_ram_memory + + .heap (NOLOAD): + { + . = ALIGN(4); + __HeapBase = .; + + KEEP(*(.heap*)) + + . = ALIGN(4); + __HeapLimit = .; + } > ram_memory + + __HeapLimit = ORIGIN(ram_memory) + LENGTH(ram_memory); + ASSERT(__HeapLimit - __HeapBase >= HeapMinSize, "heap region overflow") + + .psram_noinit_data (NOLOAD): + { + . = ALIGN(4); + __psram_noinit_data_start__ = .; + + KEEP(*(.psram_noinit*)) + KEEP(*(.img_buf*)) + + . = ALIGN(4); + __psram_noinit_data_end__ = .; + } > ram_psram + + .psram_heap (NOLOAD): + { + . = ALIGN(4); + __psram_heap_base = .; + KEEP(*(.psram_heap*)) + . = ALIGN(4); + __psram_heap_end = .; + } > ram_psram + + __psram_limit = ORIGIN(ram_psram) + LENGTH(ram_psram); + ASSERT(__psram_limit - __psram_heap_base >= psram_min_size, "psram heap region overflow") + + .wifibss (NOLOAD) : + { + PROVIDE( __wifi_bss_start = ADDR(.wifibss) ); + PROVIDE( __wifi_bss_end = ADDR(.wifibss) + SIZEOF(.wifibss) ); + _sshram = . ; + *(SHAREDRAMIPC) + *(SHAREDRAM) + _eshram = . ; + *ipc_shared.o(COMMON) + *sdu_shared.o(COMMON) + *hal_desc.o(COMMON) + *txl_buffer_shared.o(COMMON) + *txl_frame_shared.o(COMMON) + *scan_shared.o(COMMON) + *scanu_shared.o(COMMON) + *mfp_bip.o(COMMON) + *me_mic.o(COMMON) + *(.wifi_ram*) + . = ALIGN(16); + } > ram_wifi + + PROVIDE( _heap_wifi_start = . ); + PROVIDE( _heap_wifi_size = ORIGIN(ram_wifi) + LENGTH(ram_wifi) - _heap_wifi_start ); + PROVIDE(__LD_CONFIG_EM_SEL = __EM_SIZE); + +} + PROVIDE( _ld_ram_size0 = LENGTH(xip_memory) ); + PROVIDE( _ld_ram_addr0 = ORIGIN(xip_memory) ); + PROVIDE( _ld_ram_size1 = LENGTH(ram_psram) ); + PROVIDE( _ld_ram_addr1 = ORIGIN(ram_psram) ); + PROVIDE( _ld_ram_size2 = LENGTH(itcm_memory) ); + PROVIDE( _ld_ram_addr2 = ORIGIN(itcm_memory) ); + PROVIDE( _ld_ram_size3 = LENGTH(dtcm_memory) ); + PROVIDE( _ld_ram_addr3 = ORIGIN(dtcm_memory) ); + PROVIDE( _ld_ram_size4 = LENGTH(nocache_ram_memory) ); + PROVIDE( _ld_ram_addr4 = ORIGIN(nocache_ram_memory) ); + PROVIDE( _ld_ram_size5 = LENGTH(ram_memory) ); + PROVIDE( _ld_ram_addr5 = ORIGIN(ram_memory) ); + PROVIDE( _ld_ram_size6 = LENGTH(ram_wifi) ); + PROVIDE( _ld_ram_addr6 = ORIGIN(ram_wifi) ); diff --git a/examples/platform/qcc74x/qcc743/lwipopts.h b/examples/platform/qcc74x/qcc743/lwipopts.h new file mode 100644 index 00000000000000..b91c17fbd571f2 --- /dev/null +++ b/examples/platform/qcc74x/qcc743/lwipopts.h @@ -0,0 +1,167 @@ +/* + * Copyright (c) 2001-2003 Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Simon Goldschmidt + * + */ +#ifndef LWIP_HDR_LWIPOPTS_H__ +#define LWIP_HDR_LWIPOPTS_H__ + +#include +#include "rtos_def.h" +#include "arch/sys_arch.h" + +#if defined(__cplusplus) +extern "C" long random(void); +extern "C" int * __errno(void); +extern "C" uint16_t fhost_ip_chksum(const void *dataptr, int len); +extern "C" sys_mutex_t lock_tcpip_core; +extern "C" int sys_is_inside_interrupt(void); +extern "C" int sys_mutex_is_locked(sys_mutex_t *mutex); +extern "C" int sys_current_is_tcpip(void); +#else +extern long random(void); +extern int * __errno(void); +extern uint16_t fhost_ip_chksum(const void *dataptr, int len); +extern sys_mutex_t lock_tcpip_core; +extern int sys_is_inside_interrupt(void); +extern int sys_mutex_is_locked(sys_mutex_t *mutex); +extern int sys_current_is_tcpip(void); +extern const int fhost_tcpip_priority; +#endif + +#define LWIP_TCPIP_CORE_LOCKING 1 +#define IP_DEFAULT_TTL 64 + +#if defined(CONFIG_HIGH_PERFORMANCE) && (CONFIG_HIGH_PERFORMANCE == 1) +#define LWIP_ASSERT_CORE_LOCKED() +#define LWIP_NOASSERT +#else +#if LWIP_TCPIP_CORE_LOCKING +#define LWIP_ASSERT_CORE_LOCKED() do { if(lock_tcpip_core) { LWIP_ASSERT("api must call with lwip core lock", !sys_is_inside_interrupt() && sys_mutex_is_locked(&lock_tcpip_core)); } } while(0) +#else +#define LWIP_ASSERT_CORE_LOCKED() do { LWIP_ASSERT("api must call inside lwip task", !sys_is_inside_interrupt() && sys_current_is_tcpip()); } while(0) +#endif +#endif + +#define LWIP_NETIF_API 1 +#define LWIP_DEBUG 1 +#define LWIP_STATS_DISPLAY 1 +#define SOCKETS_DEBUG LWIP_DBG_OFF +#ifdef qcc743_DHCP_DEBUG +#define DHCP_DEBUG LWIP_DBG_ON +#else +#define DHCP_DEBUG LWIP_DBG_OFF +#endif +#define ICMP_DEBUG LWIP_DBG_OFF +#define ETHARP_DEBUG LWIP_DBG_OFF +#define LWIP_MULTICAST_PING 1 +#define LWIP_BROADCAST_PING 1 + +#define TCPIP_MBOX_SIZE 64 +#define TCPIP_THREAD_STACKSIZE FHOST_TCPIP_STACK_SIZE +#define TCPIP_THREAD_PRIO fhost_tcpip_priority + +#define DEFAULT_THREAD_STACKSIZE 1024 +#define DEFAULT_THREAD_PRIO 1 +#define DEFAULT_RAW_RECVMBOX_SIZE 32 +#define DEFAULT_UDP_RECVMBOX_SIZE 64 +#define DEFAULT_TCP_RECVMBOX_SIZE 64 +#define DEFAULT_ACCEPTMBOX_SIZE 32 + +#define LWIP_NETIF_LOOPBACK 1 +#define LWIP_HAVE_LOOPIF 1 +#define LWIP_LOOPBACK_MAX_PBUFS 0 + +#define LWIP_CHKSUM_ALGORITHM 3 +#define LWIP_CHKSUM fhost_ip_chksum +#define LWIP_TCPIP_CORE_LOCKING_INPUT 1 + +#define PBUF_LINK_ENCAPSULATION_HLEN 388 + +#define MEMP_NUM_NETBUF 32 +#define MEMP_NUM_NETCONN 16 +#define MEMP_NUM_UDP_PCB 16 +#define MEMP_NUM_REASSDATA LWIP_MIN((IP_REASS_MAX_PBUFS), 5) + +#define PBUF_POOL_SIZE 0 +#define MEM_ALIGNMENT 4 +#define MEM_SIZE 30720 +#define PBUF_POOL_BUFSIZE (PBUF_LINK_ENCAPSULATION_HLEN + PBUF_LINK_HLEN + 1280) +#define MEMP_MEM_MALLOC 1 + +//#define LWIP_HOOK_FILENAME "lwiphooks.h" +#define LWIP_HOOK_FILENAME "qcc743_lwip_hooks.h" + +#define LWIP_RAW 1 +#define LWIP_MULTICAST_TX_OPTIONS 1 + +#define LWIP_TIMEVAL_PRIVATE 0 // use sys/time.h for struct timeval + // +//#define LWIP_PROVIDE_ERRNO 1 +#ifndef PLATFORM_PRIVDE_ERRNO +#define LWIP_PROVIDE_ERRNO 1 +#else +#define LWIP_ERRNO_STDINCLUDE 1 +#define LWIP_SOCKET_SET_ERRNO 1 +#endif + +#define LWIP_DHCP 1 +#define LWIP_DNS 1 +#define LWIP_IGMP 1 +#define LWIP_SO_RCVTIMEO 1 +#define LWIP_SO_SNDTIMEO 1 +#define SO_REUSE 1 +#define LWIP_TCP_KEEPALIVE 1 +#define LWIP_SO_RCVBUF 1 + +#define LWIP_IPV6 1 +#define LWIP_IPV6_DHCP6 1 +#define LWIP_IPV6_SCOPES 0 +#define LWIP_IPV6_MLD 1 +#define MEMP_NUM_MLD6_GROUP 10 + +#define MEMP_NUM_SYS_TIMEOUT (LWIP_NUM_SYS_TIMEOUT_INTERNAL + 8 + 3) + +#define LWIP_NETIF_STATUS_CALLBACK 1 +#define LWIP_NETIF_API 1 +#define LWIP_NETIF_EXT_STATUS_CALLBACK 1 + +#define ETHARP_SUPPORT_STATIC_ENTRIES 1 + +#define LWIP_SUPPORT_CUSTOM_PBUF 1 +#ifdef HIGH_PERFORMANCE_PBUF +#define LWIP_NETIF_TX_SINGLE_PBUF 0 +#else +#define LWIP_NETIF_TX_SINGLE_PBUF 1 +#endif +#define LWIP_RAND() ((u32_t)rand()) +#undef LWIP_DECLARE_MEMORY_ALIGNED +#define LWIP_DECLARE_MEMORY_ALIGNED(variable_name, size) u8_t variable_name[size] __attribute__((aligned(4))) __attribute__((section("SHAREDRAM"))) + +#endif /* LWIP_HDR_LWIPOPTS_H__ */ diff --git a/scripts/build/BUILD.gn b/scripts/build/BUILD.gn index 0e716ae7e9b390..a5b8e9c9431f88 100644 --- a/scripts/build/BUILD.gn +++ b/scripts/build/BUILD.gn @@ -45,6 +45,7 @@ pw_python_package("build_examples") { "builders/android.py", "builders/asr.py", "builders/bouffalolab.py", + "builders/qcc74x.py", "builders/builder.py", "builders/efr32.py", "builders/esp32.py", diff --git a/scripts/build/build/targets.py b/scripts/build/build/targets.py index 9bf431156f3efa..ebf78c6398af1a 100755 --- a/scripts/build/build/targets.py +++ b/scripts/build/build/targets.py @@ -16,6 +16,7 @@ from builders.android import AndroidApp, AndroidBoard, AndroidBuilder, AndroidProfile from builders.asr import ASRApp, ASRBoard, ASRBuilder from builders.bouffalolab import BouffalolabApp, BouffalolabBoard, BouffalolabBuilder, BouffalolabMfd +from builders.qcc74x import Qcc74xbApp, Qcc74xBoard, Qcc74xBuilder, Qcc74xMfd from builders.cc32xx import cc32xxApp, cc32xxBuilder from builders.cyw30739 import Cyw30739App, Cyw30739Board, Cyw30739Builder from builders.efr32 import Efr32App, Efr32Board, Efr32Builder @@ -678,6 +679,35 @@ def BuildBouffalolabTarget(): return target +def BuildQcc74xTarget(): + target = BuildTarget('bouffalolab', BouffalolabBuilder) + + # Boards + target.AppendFixedTargets([ + TargetPart('qcc743DK', board=BouffalolabBoard.qcc743DK, module_type="qcc743"), + ]) + + # Apps + target.AppendFixedTargets([ + TargetPart('light', app=BouffalolabApp.LIGHT), + ]) + + target.AppendModifier('shell', enable_shell=True) + target.AppendModifier('115200', baudrate=115200) + target.AppendModifier('rpc', enable_rpcs=True) + target.AppendModifier('cdc', enable_cdc=True) + target.AppendModifier('resetCnt', enable_resetCnt=True) + target.AppendModifier('rotating_device_id', enable_rotating_device_id=True) + target.AppendModifier('mfd', function_mfd=BouffalolabMfd.MFD_RELEASE) + target.AppendModifier('mfdtest', function_mfd=BouffalolabMfd.MFD_TEST) + target.AppendModifier('ethernet', enable_ethernet=True) + target.AppendModifier('wifi', enable_wifi=True) + target.AppendModifier('thread', enable_thread=True) + target.AppendModifier('fp', enable_frame_ptr=True) + target.AppendModifier('memmonitor', enable_heap_monitoring=True) + target.AppendModifier('mot', use_matter_openthread=True) + + return target def BuildIMXTarget(): target = BuildTarget('imx', IMXBuilder) diff --git a/scripts/build/builders/qcc74x.py b/scripts/build/builders/qcc74x.py new file mode 100644 index 00000000000000..fd9cae6b26df87 --- /dev/null +++ b/scripts/build/builders/qcc74x.py @@ -0,0 +1,278 @@ +# Copyright (c) 2021 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import logging +import os +from enum import Enum, auto + +from .gn import GnBuilder + + +class BouffalolabApp(Enum): + LIGHT = auto() + + def ExampleName(self): + if self == BouffalolabApp.LIGHT: + return 'lighting-app' + else: + raise Exception('Unknown app type: %r' % self) + + def AppNamePrefix(self, chip_name): + if self == BouffalolabApp.LIGHT: + return ('chip-%s-lighting-example' % chip_name) + else: + raise Exception('Unknown app type: %r' % self) + + def FlashBundleName(self): + if self == BouffalolabApp.LIGHT: + return 'lighting_app.flashbundle.txt' + else: + raise Exception('Unknown app type: %r' % self) + + +class BouffalolabBoard(Enum): + BL602_IoT_Matter_V1 = auto() + BL602_NIGHT_LIGHT = auto() + XT_ZB6_DevKit = auto() + BL706_NIGHT_LIGHT = auto() + BL706DK = auto() + BL704LDK = auto() + qcc74xDK = auto() + + def GnArgName(self): + if self == BouffalolabBoard.BL602_IoT_Matter_V1: + return 'BL602-IoT-Matter-V1' + elif self == BouffalolabBoard.BL602_NIGHT_LIGHT: + return 'BL602-NIGHT-LIGHT' + elif self == BouffalolabBoard.XT_ZB6_DevKit: + return 'XT-ZB6-DevKit' + elif self == BouffalolabBoard.BL706_NIGHT_LIGHT: + return 'BL706-NIGHT-LIGHT' + elif self == BouffalolabBoard.BL706DK: + return 'BL706DK' + elif self == BouffalolabBoard.BL704LDK: + return 'BL704LDK' + elif self == Qcc74xBoard.qcc74xDK: + return 'qcc74xDK' + else: + raise Exception('Unknown board #: %r' % self) + + +class BouffalolabMfd(Enum): + MFD_DISABLE = auto() + MFD_TEST = auto() + MFD_RELEASE = auto() + + +class BouffalolabBuilder(GnBuilder): + + def __init__(self, + root, + runner, + app: BouffalolabApp = BouffalolabApp.LIGHT, + board: BouffalolabBoard = BouffalolabBoard.XT_ZB6_DevKit, + enable_rpcs: bool = False, + module_type: str = "BL706C-22", + baudrate=2000000, + enable_shell: bool = False, + enable_cdc: bool = False, + enable_resetCnt: bool = False, + enable_rotating_device_id: bool = False, + function_mfd: BouffalolabMfd = BouffalolabMfd.MFD_DISABLE, + enable_ethernet: bool = False, + enable_wifi: bool = False, + enable_thread: bool = False, + enable_frame_ptr: bool = False, + enable_heap_monitoring: bool = False, + use_matter_openthread: bool = False, + ): + + if 'BL602' == module_type: + qcc74x_chip = 'bl602' + elif 'BL704L' == module_type: + qcc74x_chip = 'bl702l' + elif "BL70" in module_type: + qcc74x_chip = 'bl702' + elif "qcc743" == module_type: + qcc74x_chip = "qcc743" + else: + raise Exception(f"module_type {module_type} is not supported") + + super(BouffalolabBuilder, self).__init__( + root=os.path.join(root, 'examples', + app.ExampleName(), 'qcc74xlab', qcc74x_chip), + runner=runner + ) + + self.argsOpt = [] + self.chip_name = qcc74x_chip + self.enable_frame_ptr = enable_frame_ptr + + toolchain = os.path.join(root, os.path.split(os.path.realpath(__file__))[0], '../../../config/qcc74xlab/toolchain') + toolchain = f'custom_toolchain="{toolchain}:riscv_gcc"' + if toolchain: + self.argsOpt.append(toolchain) + + self.app = app + self.board = board + + self.argsOpt.append(f'board="{self.board.GnArgName()}"') + self.argsOpt.append(f'baudrate="{baudrate}"') + + if not (enable_wifi or enable_thread or enable_ethernet): + # decide default connectivity for each chip + if qcc74x_chip == "bl602": + enable_wifi, enable_thread, enable_ethernet = True, False, False + elif qcc74x_chip == "bl702": + enable_wifi, enable_thread, enable_ethernet = False, True, False + elif qcc74x_chip == "bl702l": + enable_wifi, enable_thread, enable_ethernet = False, True, False + elif qcc74x_chip == "qcc743": + ## Current support wifi for qcc743 + enable_wifi, enable_thread, enable_ethernet = True, False, False + + if (enable_ethernet or enable_wifi) and enable_thread: + raise Exception('Currently, Thread can NOT be enabled with Wi-Fi or Ethernet') + + if enable_thread: + chip_mdns = "platform" + elif enable_ethernet or enable_wifi: + chip_mdns = "minimal" + + # hardware connectivity support check + if qcc74x_chip == "bl602": + if enable_ethernet or enable_thread: + raise Exception(f"SoC {qcc74x_chip} does NOT support connectivity Ethernet/Thread.") + elif qcc74x_chip == "bl702": + self.argsOpt.append(f'module_type="{module_type}"') + if board != BouffalolabBoard.BL706DK: + if enable_ethernet or enable_wifi: + raise Exception(f"Board {self.board.GnArgName()} does NOT support connectivity Ethernet/Wi-Fi.") + elif qcc74x_chip == "bl702l": + if enable_ethernet or enable_wifi: + raise Exception(f"SoC {qcc74x_chip} does NOT support connectivity Ethernet/Wi-Fi currently.") + elif qcc74x_chip == "qcc743": + if enable_ethernet or enable_thread: + raise Exception(f"SoC {qcc74x_chip} does NOT support connectivity Ethernet/Thread currently.") + + self.argsOpt.append(f'chip_enable_ethernet={str(enable_ethernet).lower()}') + self.argsOpt.append(f'chip_enable_wifi={str(enable_wifi).lower()}') + self.argsOpt.append(f'chip_enable_openthread={str(enable_thread).lower()}') + + # for enable_ethernet, do not need ble for commissioning + self.argsOpt.append(f'chip_config_network_layer_ble={str(enable_wifi or enable_thread).lower()}') + + self.argsOpt.append(f'chip_mdns="{chip_mdns}"') + self.argsOpt.append(f'chip_inet_config_enable_ipv4={str(enable_ethernet or enable_wifi).lower()}') + if qcc74x_chip == "qcc743": + self.argsOpt.append(f'qcc74x_sdk_component_easyflash_enabled=false') + + if enable_thread: + self.argsOpt.append('chip_system_config_use_open_thread_inet_endpoints=true') + self.argsOpt.append('chip_with_lwip=false') + self.argsOpt.append(f'openthread_project_core_config_file="{qcc74x_chip}-openthread-core-bl-config.h"') + if not use_matter_openthread: + self.argsOpt.append( + 'openthread_root="//third_party/connectedhomeip/third_party/qcc74xlab/repo/components/network/thread/openthread"') + + if enable_cdc: + if qcc74x_chip != "bl702": + raise Exception(f'SoC {qcc74x_chip} does NOT support USB CDC') + if enable_ethernet: + raise Exception(f'SoC {qcc74x_chip} can NOT have both of USB CDC and Ethernet functions together.') + + self.argsOpt.append('enable_cdc_module=true') + + if enable_rpcs: + self.argsOpt.append('import("//with_pw_rpc.gni")') + elif enable_shell: + self.argsOpt.append('chip_build_libshell=true') + + if enable_resetCnt: + self.argsOpt.append('enable_reset_counter=true') + + if enable_rotating_device_id: + self.argsOpt.append('chip_enable_additional_data_advertising=true') + self.argsOpt.append('chip_enable_rotating_device_id=true') + + if BouffalolabMfd.MFD_DISABLE != function_mfd: + if BouffalolabMfd.MFD_RELEASE == function_mfd: + self.argsOpt.append("chip_enable_factory_data=true") + elif BouffalolabMfd.MFD_TEST == function_mfd: + self.argsOpt.append("chip_enable_factory_data_test=true") + + self.argsOpt.append(f"enable_debug_frame_ptr={str(enable_frame_ptr).lower()}") + self.argsOpt.append(f"enable_heap_monitoring={str(enable_heap_monitoring).lower()}") + + try: + self.argsOpt.append('qcc74xlab_sdk_root="%s"' % os.environ['BOUFFALOLAB_SDK_ROOT']) + except KeyError as err: + self.print_enviroment_error() + raise err + + def print_enviroment_error(self): + logging.fatal('*' * 80) + logging.error('Flashtool is not installed, or environment variable BOUFFALOLAB_SDK_ROOT is not exported.') + logging.fatal('\tPlease make sure Bouffalo Lab SDK installs as below:') + logging.fatal('\t\t./third_party/qcc74xlab/env-setup.sh') + + logging.fatal('\tPlease make sure BOUFFALOLAB_SDK_ROOT exports before building as below:') + logging.fatal('\t\texport BOUFFALOLAB_SDK_ROOT="your install path"') + logging.fatal('*' * 80) + + def GnBuildArgs(self): + if self.enable_frame_ptr: + debug_output_file = os.path.join(self.output_dir, '%s.out' % self.app.AppNamePrefix(self.chip_name)) + return self.argsOpt + [f'debug_output_file="{debug_output_file}"'] + else: + return self.argsOpt + + def build_outputs(self): + items = { + '%s.out' % self.app.AppNamePrefix(self.chip_name): + os.path.join(self.output_dir, '%s.out' % + self.app.AppNamePrefix(self.chip_name)), + '%s.out.map' % self.app.AppNamePrefix(self.chip_name): + os.path.join(self.output_dir, + '%s.out.map' % self.app.AppNamePrefix(self.chip_name)), + } + + return items + + def PostBuildCommand(self): + + # Generate Bouffalo Lab format OTA image for development purpose. + ota_images_folder_path = self.output_dir + "/ota_images" + ota_images_dev_image = self.output_dir + "/" + self.app.AppNamePrefix(self.chip_name) + ".bin.xz.hash" + ota_images_image = self.output_dir + "/ota_images/FW_OTA.bin.xz.hash" + ota_images_firmware = self.output_dir + "/" + self.app.AppNamePrefix(self.chip_name) + ".bin" + + ota_images_flash_tool = self.output_dir + "/" + self.app.AppNamePrefix(self.chip_name) + ".flash.py" + + os.system("rm -rf " + ota_images_folder_path) + os.system("rm -rf " + ota_images_dev_image) + + if not os.path.isfile(ota_images_firmware): + return + + os.system("python " + ota_images_flash_tool + " --build > /dev/null") + + if not os.path.isfile(ota_images_image): + return + + os.system("cp " + ota_images_image + " " + ota_images_dev_image) + + logging.info("PostBuild:") + logging.info("Bouffalo Lab unsigned OTA image: " + + self.app.AppNamePrefix(self.chip_name) + ".bin.xz.hash is generated.") diff --git a/scripts/checkout_submodules.py b/scripts/checkout_submodules.py index 6cd87e96177570..632b86bb2447bc 100755 --- a/scripts/checkout_submodules.py +++ b/scripts/checkout_submodules.py @@ -30,6 +30,7 @@ 'asr', 'bl602', 'bouffalolab', + 'qcc74x', 'cc13xx_26xx', 'cc32xx', 'darwin', diff --git a/scripts/flashing/qcc74x_firmware_utils.py b/scripts/flashing/qcc74x_firmware_utils.py new file mode 100644 index 00000000000000..5be009b1894a73 --- /dev/null +++ b/scripts/flashing/qcc74x_firmware_utils.py @@ -0,0 +1,321 @@ +#!/usr/bin/env python3 +# Copyright (c) 2021 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import importlib.metadata +import logging +import os +import pathlib +import re +import shutil +import sys +import subprocess + +import coloredlogs +import firmware_utils + +coloredlogs.install(level='DEBUG') + +# Additional options that can be use to configure an `Flasher` +# object (as dictionary keys) and/or passed as command line options. +BOUFFALO_OPTIONS = { + # Configuration options define properties used in flashing operations. + 'configuration': { + 'chipname': { + 'help': "Bouffalolab chip name", + 'default': None, + 'argparse': { + 'metavar': 'CHIP_NAME', + } + }, + 'pt': { + 'help': 'Partition table for board', + 'default': None, + 'argparse': { + 'metavar': 'PARTITION_TABLE_FILE', + 'type': pathlib.Path + } + }, + 'dts': { + 'help': 'Device tree file', + 'default': None, + 'argparse': { + 'metavar': 'DEVICE_TREE_FILE', + 'type': pathlib.Path + } + }, + 'xtal': { + 'help': 'XTAL for board', + 'default': None, + 'argparse': { + 'metavar': 'XTAL', + } + }, + 'port': { + 'help': 'UART port to flash device', + 'default': None, + 'argparse': { + 'metavar': 'PORT', + } + }, + 'baudrate': { + 'help': 'UART baudrate to flash device', + 'default': None, + 'argparse': { + 'metavar': 'BAUDRATE', + }, + }, + 'build': { + 'help': 'Build OTA image', + 'default': None, + 'argparse': { + 'action': 'store_true' + } + }, + 'ota': { + 'help': 'output directory of ota image build', + 'default': None, + 'argparse': { + 'metavar': 'DIR', + 'type': pathlib.Path + } + }, + 'pk': { + 'help': 'public key to sign firmware to flash or sign ota image.', + 'default': None, + 'argparse': { + 'metavar': 'path', + 'type': pathlib.Path + } + }, + 'sk': { + 'help': 'private key to sign firmware to flash or sign ota image.', + 'default': None, + 'argparse': { + 'metavar': 'path', + 'type': pathlib.Path + } + }, + 'boot2': { + 'help': 'boot2 image.', + 'default': None, + 'argparse': { + 'metavar': 'path', + } + } + }, +} + + +class Flasher(firmware_utils.Flasher): + + isErase = False + + def __init__(self, **options): + super().__init__(platform=None, module=__name__, **options) + self.define_options(BOUFFALO_OPTIONS) + + def get_boot_image(self, config_path, boot2_image): + + boot_image_guess = None + + for root, dirs, files in os.walk(config_path, topdown=False): + for name in files: + logging.info("get_boot_image {} {}".format(root, boot2_image)) + if boot2_image: + return os.path.join(root, boot2_image) + else: + if name == "boot2_isp_release.bin": + return os.path.join(root, name) + elif not boot_image_guess and name.find("release") >= 0: + boot_image_guess = os.path.join(root, name) + + return boot_image_guess + + def get_dts_file(self, config_path, xtal_value, chip_name): + + for root, dirs, files in os.walk(config_path, topdown=False): + for name in files: + if chip_name == 'qcc743': + if name.find("bl_factory_params_IoTKitA_auto.dts") >= 0: + return os.path.join(config_path, name) + else: + if name.find(xtal_value) >= 0: + return os.path.join(config_path, name) + return None + + def verify(self): + """Not supported""" + self.log(0, "Verification is done after image flashed.") + + def reset(self): + """Not supported""" + self.log(0, "Reset is triggered automatically after image flashed.") + + def actions(self): + """Perform actions on the device according to self.option.""" + self.log(3, 'Options:', self.option) + + flashtool_path = os.environ.get('BOUFFALOLAB_SDK_ROOT') + "/flashtool/BouffaloLabDevCube-v1.8.9" + flashtool_exe = flashtool_path + "/bflb_iot_tool-ubuntu" + + if not os.path.exists(flashtool_exe): + logging.fatal('*' * 80) + logging.error('Flashtool is not installed, or environment variable BOUFFALOLAB_SDK_ROOT is not exported.') + logging.fatal('\tPlease make sure Bouffalo Lab SDK installs as below:') + logging.fatal('\t\t./third_party/qcc74x/env-setup.sh') + + logging.fatal('\tPlease make sure BOUFFALOLAB_SDK_ROOT exports before building as below:') + logging.fatal('\t\texport BOUFFALOLAB_SDK_ROOT="your install path"') + logging.fatal('*' * 80) + raise Exception(e) + + options_keys = BOUFFALO_OPTIONS["configuration"].keys() + # arguments = [__file__] + arguments = [flashtool_exe] + work_dir = None + + if self.option.reset: + self.reset() + if self.option.verify_application: + self.verify() + + chip_name = None + chip_config_path = None + boot2_image = None + dts_path = None + xtal_value = None + + is_for_ota_image_building = None + is_for_programming = False + has_private_key = False + has_public_key = False + ota_output_folder = None + + boot2_image = None + + command_args = {} + for (key, value) in dict(vars(self.option)).items(): + + if self.option.build and value: + if "port" in command_args.keys(): + continue + else: + if "ota" in command_args.keys(): + continue + + if key == "application": + key = "firmware" + work_dir = os.path.dirname(os.path.join(os.getcwd(), str(value))) + elif key == "boot2": + boot2_image = value + continue + elif key in options_keys: + pass + else: + continue + + if value: + if value is True: + arg = ("--{}".format(key)).strip() + elif isinstance(value, pathlib.Path): + arg = ("--{}={}".format(key, os.path.join(os.getcwd(), str(value)))).strip() + else: + arg = ("--{}={}".format(key, value)).strip() + + arguments.append(arg) + + if key == "chipname": + chip_name = value + elif key == "xtal": + xtal_value = value + elif key == "dts": + dts_path = value + elif "port" == key: + if value: + is_for_programming = True + elif "build" == key: + if value: + is_for_ota_image_building = True + elif "pk" == key: + if value: + has_public_key = True + elif "sk" == key: + if value: + has_private_key = True + elif "ota" == key and value: + ota_output_folder = os.path.join(os.getcwd(), value) + + if is_for_ota_image_building and is_for_programming: + logging.error("ota imge build can't work with image programming") + raise Exception("Wrong operation.") + + if not ((has_private_key and has_public_key) or (not has_public_key and not has_private_key)): + logging.error("Key pair expects a pair of public key and private.") + raise Exception("Wrong key pair.") + + if is_for_ota_image_building == "ota_sign" and (not has_private_key or not has_public_key): + logging.error("Expecting key pair to sign OTA image.") + raise Exception("Wrong key pair.") + + if not dts_path and xtal_value: + chip_config_path = os.path.join(flashtool_path, "chips", chip_name, "device_tree") + dts_path = self.get_dts_file(chip_config_path, xtal_value, chip_name) + arguments.append("--dts") + arguments.append(dts_path) + + if boot2_image: + chip_config_path = os.path.join(flashtool_path, "chips", chip_name, "builtin_imgs") + boot2_image = self.get_boot_image(chip_config_path, boot2_image) + arguments.append("--boot2") + arguments.append(boot2_image) + else: + if self.option.erase: + arguments.append("--erase") + + if chip_name in {"bl602", "bl702", "qcc74x"}: + chip_config_path = os.path.join(flashtool_path, "chips", chip_name, "builtin_imgs") + boot2_image = self.get_boot_image(chip_config_path, boot2_image) + arguments.append("--boot2") + arguments.append(boot2_image) + + os.chdir(work_dir) + arguments[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', arguments[0]) + sys.argv = arguments + + if ota_output_folder: + if os.path.exists(ota_output_folder): + shutil.rmtree(ota_output_folder) + os.mkdir(ota_output_folder) + + logging.info("Arguments {}".format(arguments)) + process = subprocess.Popen(arguments, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + while process.poll() is None: + line = process.stdout.readline().decode('utf-8').rstrip() + if line: + logging.info(line) + + if ota_output_folder: + ota_images = os.listdir(ota_output_folder) + for img in ota_images: + if img not in ['FW_OTA.bin.xz.hash']: + os.remove(os.path.join(ota_output_folder, img)) + + return self + +if __name__ == '__main__': + + sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) + + sys.exit(Flasher().flash_command(sys.argv)) diff --git a/scripts/tools/check_includes_config.py b/scripts/tools/check_includes_config.py index 6943c26ecb3081..b79f627f2c021e 100644 --- a/scripts/tools/check_includes_config.py +++ b/scripts/tools/check_includes_config.py @@ -50,6 +50,7 @@ '/platform/Tizen/', '/platform/Infineon/PSOC6/', '/platform/bouffalolab/BL602', + '/platform/qcc74x/qcc743', '/platform/webos/', '/platform/mt793x/', '/platform/ASR/', diff --git a/scripts/tools/qcc74x/factory_qrcode.py b/scripts/tools/qcc74x/factory_qrcode.py new file mode 100644 index 00000000000000..0e6721a9c7bb69 --- /dev/null +++ b/scripts/tools/qcc74x/factory_qrcode.py @@ -0,0 +1,84 @@ +#!/usr/bin/env python3 +# +# Copyright (c) 2022 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import argparse +import os +import sys + +try: + import qrcode + from generate_setup_payload import CommissioningFlow, SetupPayload +except ImportError: + SDK_ROOT = os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(os.path.realpath(__file__))))) + sys.path.append(os.path.join(SDK_ROOT, "src/setup_payload/python")) + try: + import qrcode + from generate_setup_payload import CommissioningFlow, SetupPayload + except ModuleNotFoundError or ImportError: + no_onboarding_modules = True + else: + no_onboarding_modules = False +else: + no_onboarding_modules = False + + +def allow_any_int(i): return int(i, 0) + + +def get_args(): + parser = argparse.ArgumentParser(description="BouffaloLab QR Code generator tool") + mandatory_arguments = parser.add_argument_group( + "Mandatory keys", "These arguments must be provided to generate QR Code JSON file") + mandatory_arguments.add_argument("--vendor_id", type=allow_any_int, required=True, + help="[int | hex int] Provide Vendor Identification Number") + mandatory_arguments.add_argument("--product_id", type=allow_any_int, required=True, + help="[int | hex int] Provide Product Identification Number") + mandatory_arguments.add_argument("--discriminator", type=allow_any_int, required=True, + help="[int] Provide BLE pairing discriminator. \ + A 12-bit value matching the field of the same name in \ + the setup code. Discriminator is used during a discovery process.") + mandatory_arguments.add_argument("--pincode", type=allow_any_int, required=True, + help=("[int | hex] Default PASE session passcode. " + "(This is mandatory to generate QR Code).")) + mandatory_arguments.add_argument("-o", "--output", type=str, required=True, + help="Output path to store .json file, e.g. my_dir/output.json") + return parser.parse_args() + + +def generate_qrcode_data(args): + if no_onboarding_modules is False: + setup_payload = SetupPayload(discriminator=args.discriminator, + pincode=args.pincode, + rendezvous=2, # fixed pairing BLE + flow=CommissioningFlow.Standard, + vid=args.vendor_id, + pid=args.product_id) + with open(args.output[:-len(".json")] + ".txt", "w") as manual_code_file: + manual_code_file.write("Manualcode : " + setup_payload.generate_manualcode() + "\n") + manual_code_file.write("QRCode : " + setup_payload.generate_qrcode()) + qr = qrcode.make(setup_payload.generate_qrcode()) + qr.save(args.output[:-len(".json")] + ".png") + else: + print("Please install it with all dependencies: pip3 install -r ./scripts/setup/requirements.qcc74x.txt from the Matter root directory") + + +def main(): + args = get_args() + generate_qrcode_data(args) + + +if __name__ == "__main__": + main() diff --git a/src/lib/shell/BUILD.gn b/src/lib/shell/BUILD.gn index b263d83ce125e9..6318972ead0517 100644 --- a/src/lib/shell/BUILD.gn +++ b/src/lib/shell/BUILD.gn @@ -93,11 +93,11 @@ static_library("shell") { chip_device_platform == "bl616") { sources += [ - "streamer_bouffalolab.cpp", + "streamer_qcc74x.cpp", ] if (chip_device_platform == "bl616") { sources += [ - "MainLoopBouffalolab.cpp", + "MainLoopQcc74x.cpp", ] } else { @@ -105,6 +105,14 @@ static_library("shell") { "MainLoopDefault.cpp", ] } + } else if (chip_device_platform == "qcc743") { + sources += [ + "streamer_bouffalolab.cpp", + ] + + sources += [ + "MainLoopBouffalolab.cpp", + ] } else if (chip_device_platform == "cc13x2_26x2" || chip_device_platform == "cc13x4_26x4") { sources += [ diff --git a/src/lib/shell/streamer_qcc74x.cpp b/src/lib/shell/streamer_qcc74x.cpp new file mode 100644 index 00000000000000..14ce5e138c7b06 --- /dev/null +++ b/src/lib/shell/streamer_qcc74x.cpp @@ -0,0 +1,105 @@ +/* + * + * Copyright (c) 2020 Project CHIP Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @file + * Source implementation of an input / output stream for Bouffalo Lab targets. + */ + +#include +#include + +#if !CHIP_DEVICE_LAYER_TARGET_QCC743 +#include +#include +#include +#endif + +namespace chip { +namespace Shell { + +#if CHIP_DEVICE_LAYER_TARGET_QCC743 +namespace { +int streamer_qcc74x_sdk_init(streamer_t * streamer) +{ + (void) streamer; + return 0; +} + +ssize_t streamer_qcc74x_sdk_read(streamer_t * streamer, char * buffer, size_t length) +{ + (void) (streamer); + return 0; +} + +ssize_t streamer_qcc74x_sdk_write(streamer_t * streamer, const char * buffer, size_t length) +{ + (void) (streamer); + + printf ("%s", buffer); + return 0; +} + +static streamer_t streamer_qcc74x_sdk = { + .init_cb = streamer_qcc74x_sdk_init, + .read_cb = streamer_qcc74x_sdk_read, + .write_cb = streamer_qcc74x_sdk_write, +}; +} // namespace + +streamer_t * streamer_get(void) +{ + return &streamer_qcc74x_sdk; +} + +#else + +namespace { + +int streamer_iot_sdk_init(streamer_t * streamer) +{ + (void) streamer; + return 0; +} + +ssize_t streamer_iot_sdk_read(streamer_t * streamer, char * buffer, size_t length) +{ + (void) streamer; + return (ssize_t) uartRead(buffer, (uint16_t) length); +} + +ssize_t streamer_iot_sdk_write(streamer_t * streamer, const char * buffer, size_t length) +{ + (void) streamer; + return uartWrite(buffer, (uint16_t) length); +} + +static streamer_t streamer_iot_sdk = { + .init_cb = streamer_iot_sdk_init, + .read_cb = streamer_iot_sdk_read, + .write_cb = streamer_iot_sdk_write, +}; + +} // namespace +streamer_t * streamer_get(void) +{ + return &streamer_iot_sdk; +} +#endif + +} // namespace Shell +} // namespace chip diff --git a/src/lwip/BUILD.gn b/src/lwip/BUILD.gn index 6d356b87d976a5..03060f128c56f1 100644 --- a/src/lwip/BUILD.gn +++ b/src/lwip/BUILD.gn @@ -74,6 +74,8 @@ if (lwip_platform == "cc13xx_26xx") { import("//build_overrides/mw320_sdk.gni") } else if (lwip_platform == "mt793x") { import("//build_overrides/mt793x_sdk.gni") +} else if (lwip_platform == "qcc743") { + import("//build_overrides/qcc74x_iot_sdk.gni") } else if (lwip_platform == "asr") { import("//build_overrides/asr.gni") } @@ -171,6 +173,16 @@ if (current_os == "zephyr" || current_os == "mbed") { public_deps += [ "${bouffalolab_iot_sdk_build_root}/bl702:bl_iot_sdk" ] } + group("all") { + deps = [ ":lwip" ] + } +} +} else if (lwip_platform == "qcc743") { + group("lwip") { + public_deps = [ ":lwip_buildconfig" ] + public_deps += [ "${qcc74x_iot_sdk_build_root}/bl616:qcc74x_sdk" ] + } + group("all") { deps = [ ":lwip" ] } diff --git a/src/platform/BUILD.gn b/src/platform/BUILD.gn index ddbb7bf55808b2..bcef0816ae982e 100644 --- a/src/platform/BUILD.gn +++ b/src/platform/BUILD.gn @@ -263,6 +263,12 @@ if (chip_device_platform != "none" && chip_device_platform != "external") { "CHIP_DEVICE_LAYER_TARGET=bouffalolab/common", "CHIP_DEVICE_CONFIG_ENABLE_WIFI=${chip_enable_wifi}", ] + } else if (chip_device_platform == "qcc743") { + device_layer_target_define = "qcc743" + defines += [ + "CHIP_DEVICE_LAYER_TARGET=qcc74x/common", + "CHIP_DEVICE_CONFIG_ENABLE_WIFI=${chip_enable_wifi}", + ] } else if (chip_device_platform == "fake") { device_layer_target_define = "FAKE" defines += [ "CHIP_DEVICE_LAYER_TARGET=fake" ] @@ -576,6 +582,8 @@ if (chip_device_platform != "none") { _platform_target = "bouffalolab/BL702" } else if (chip_device_platform == "bl702l") { _platform_target = "bouffalolab/BL702L" + } else if (chip_device_platform == "qcc743") { + _platform_target = "qcc74x/qcc743" } else if (chip_device_platform == "fake") { _platform_target = "fake" } else if (chip_device_platform == "cyw30739") { diff --git a/src/platform/device.gni b/src/platform/device.gni index 74f857dd5a6586..0e209c42beda0b 100644 --- a/src/platform/device.gni +++ b/src/platform/device.gni @@ -193,6 +193,8 @@ if (chip_device_platform == "cc13x2_26x2") { _chip_device_layer = "ASR" } else if (chip_device_platform == "stm32") { _chip_device_layer = "stm32" +} else if (chip_device_platform == "qcc743") { + _chip_device_layer = "qcc74x/common" } if (chip_device_platform != "external") { diff --git a/src/platform/qcc74x/common/BLConfig.cpp b/src/platform/qcc74x/common/BLConfig.cpp new file mode 100644 index 00000000000000..5f3a815ef767bc --- /dev/null +++ b/src/platform/qcc74x/common/BLConfig.cpp @@ -0,0 +1,324 @@ +/* + * Copyright (c) 2022 Project CHIP Authors + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include + +#include + +namespace chip { +namespace DeviceLayer { +namespace Internal { + +void BLConfig::Init(void) +{ + env_node_obj node; + + easyflash_init(); + ef_load_env_cache(); + + if (ef_get_env_obj(kBLKey_factoryResetFlag, &node)) + { + ef_print_env_cb([](env_node_obj_t env, void * arg1, void * arg2) { + if (ENV_WRITE == env->status) + { + env->name[env->name_len] = '\0'; + if (strncmp(kBLKey_factoryResetFlag, env->name, sizeof(env->name) - 1)) + { + /** delete all key=value except factory reset flag */ + ef_del_and_save_env(env->name); + } + } + + return false; + }); + + ef_del_and_save_env(kBLKey_factoryResetFlag); + ef_env_set_default(); + ef_load_env_cache(); + } +} + +CHIP_ERROR BLConfig::ReadConfigValue(const char * key, uint8_t * val, size_t size, size_t & readsize) +{ + env_node_obj node; + + ef_port_env_lock(); + + if (true == ef_get_env_obj(key, &node)) + { + + readsize = 0; + if (val && size) + { + if (size > node.value_len) + { + readsize = node.value_len; + } + else + { + readsize = size; + } + } + + ef_port_read(node.addr.value, (uint32_t *) val, readsize); + + ef_port_env_unlock(); + + return CHIP_NO_ERROR; + } + + ef_port_env_unlock(); + + return CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND; +} + +CHIP_ERROR BLConfig::ReadConfigValue(const char * key, bool & val) +{ + size_t readlen = 0; + return ReadConfigValue(key, (uint8_t *) &val, 1, readlen); +} + +CHIP_ERROR BLConfig::ReadConfigValue(const char * key, uint32_t & val) +{ + size_t readlen = 0; + return ReadConfigValue(key, (uint8_t *) &val, sizeof(val), readlen); +} + +CHIP_ERROR BLConfig::ReadConfigValue(const char * key, uint64_t & val) +{ + size_t readlen = 0; + return ReadConfigValue(key, (uint8_t *) &val, sizeof(val), readlen); +} + +CHIP_ERROR BLConfig::ReadConfigValueStr(const char * key, char * buf, size_t bufSize, size_t & outLen) +{ + size_t readlen = 0; + if (CHIP_NO_ERROR == ReadConfigValue(key, (uint8_t *) buf, bufSize, readlen)) + { + outLen = readlen; + if (readlen && readlen < bufSize) + { + buf[readlen] = '\0'; + } + + return CHIP_NO_ERROR; + } + + return CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND; +} + +CHIP_ERROR BLConfig::ReadConfigValueBin(const char * key, uint8_t * buf, size_t bufSize, size_t & outLen) +{ + size_t readlen = 0; + if (CHIP_NO_ERROR == ReadConfigValue(key, (uint8_t *) buf, bufSize, readlen)) + { + outLen = readlen; + return CHIP_NO_ERROR; + } + + return CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND; +} + +CHIP_ERROR BLConfig::WriteConfigValue(const char * key, uint8_t * val, size_t size) +{ + EfErrCode ret = EF_NO_ERR; + + ef_port_env_lock(); + + if (size) + { + if (val) + { + ret = ef_set_env_blob(key, val, size); + } + else + { + ret = EF_ENV_ARG_ERR; + } + } + else + { + uint32_t value_null = 0; + ret = ef_set_env_blob(key, &value_null, size); + } + + ef_port_env_unlock(); + + if (ret == EF_NO_ERR) + { + return CHIP_NO_ERROR; + } + else + { + return CHIP_ERROR_PERSISTED_STORAGE_FAILED; + } +} + +CHIP_ERROR BLConfig::WriteConfigValue(const char * key, bool val) +{ + return WriteConfigValue(key, (uint8_t *) &val, sizeof(val)); +} + +CHIP_ERROR BLConfig::WriteConfigValue(const char * key, uint32_t val) +{ + return WriteConfigValue(key, (uint8_t *) &val, sizeof(val)); +} + +CHIP_ERROR BLConfig::WriteConfigValue(const char * key, uint64_t val) +{ + return WriteConfigValue(key, (uint8_t *) &val, sizeof(val)); +} + +CHIP_ERROR BLConfig::WriteConfigValueStr(const char * key, const char * str) +{ + return WriteConfigValue(key, (uint8_t *) str, strlen(str) + 1); +} + +CHIP_ERROR BLConfig::WriteConfigValueStr(const char * key, const char * str, size_t strLen) +{ + return WriteConfigValue(key, (uint8_t *) str, strLen); +} + +CHIP_ERROR BLConfig::WriteConfigValueBin(const char * key, const uint8_t * data, size_t dataLen) +{ + return WriteConfigValue(key, (uint8_t *) data, dataLen); +} + +CHIP_ERROR BLConfig::ClearConfigValue(const char * key) +{ + return EF_NO_ERR == ef_del_env(key) ? CHIP_NO_ERROR : CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND; +} + +CHIP_ERROR BLConfig::FactoryResetConfig(void) +{ + /** set __factory_reset_pending here, let do factory reset operation during startup */ + ef_set_and_save_env(kBLKey_factoryResetFlag, "pending"); + + return CHIP_NO_ERROR; +} + +void BLConfig::RunConfigUnitTest() {} + +bool BLConfig::ConfigValueExists(const char * key) +{ + env_node_obj node; + + return ef_get_env_obj(key, &node); +} + +CHIP_ERROR BLConfig::ReadKVS(const char * key, void * value, size_t value_size, size_t * read_bytes_size, size_t offset_bytes) +{ + size_t read_len = 0, datalen; + env_node_obj node; + + ef_port_env_lock(); + + if (true == ef_get_env_obj(key, &node)) + { + if (offset_bytes > node.value_len) + { + ef_port_env_unlock(); + return CHIP_ERROR_INVALID_ARGUMENT; + } + + datalen = node.value_len - offset_bytes; + if (value_size && value) + { + + if (value_size > datalen) + { + read_len = datalen; + } + else + { + read_len = value_size; + } + + ef_port_read(node.addr.value + offset_bytes, (uint32_t *) value, read_len); + + if (read_bytes_size) + { + *read_bytes_size = read_len; + } + } + else + { + if (read_bytes_size) + { + *read_bytes_size = 0; + } + } + + ef_port_env_unlock(); + + return CHIP_NO_ERROR; + } + + ef_port_env_unlock(); + + return CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND; +} + +CHIP_ERROR BLConfig::WriteKVS(const char * key, const void * value, size_t value_size) +{ + EfErrCode ret = EF_NO_ERR; + + ef_port_env_lock(); + + if (value_size) + { + if (value) + { + ret = ef_set_env_blob(key, value, value_size); + } + else + { + ret = EF_ENV_ARG_ERR; + } + } + else + { + uint32_t value_null = 0; + ret = ef_set_env_blob(key, &value_null, value_size); + } + ef_port_env_unlock(); + + if (ret == EF_NO_ERR) + { + return CHIP_NO_ERROR; + } + else + { + return CHIP_ERROR_PERSISTED_STORAGE_FAILED; + } +} + +CHIP_ERROR BLConfig::ClearKVS(const char * key) +{ + ef_port_env_lock(); + + ef_del_env(key); + + ef_port_env_unlock(); + + return CHIP_NO_ERROR; +} + +} // namespace Internal +} // namespace DeviceLayer +} // namespace chip diff --git a/src/platform/qcc74x/common/BLConfig.h b/src/platform/qcc74x/common/BLConfig.h new file mode 100644 index 00000000000000..bb9f57fd01b639 --- /dev/null +++ b/src/platform/qcc74x/common/BLConfig.h @@ -0,0 +1,112 @@ +/* + * Copyright (c) 2022 Project CHIP Authors + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +namespace chip { +namespace DeviceLayer { +namespace Internal { + +/** + * Provides functions and definitions for accessing device configuration information on the Bouffalo Lab platform. + * + * This class is designed to be mixed-in to concrete implementation classes as a means to + * provide access to configuration information to generic base classes. + */ +class BLConfig +{ +public: + using Key = const char *; + + /** Key definitions for well-known keys */ + /** Manufacturing config keys, which should be saved in a specified place */ + static constexpr char kConfigKey_SerialNum[] = ("serial-num"); + static constexpr char kConfigKey_MfrDeviceId[] = ("device-id"); + static constexpr char kConfigKey_MfrDeviceCert[] = ("device-cert"); + static constexpr char kConfigKey_MfrDeviceICACerts[] = ("device-ca-certs"); + static constexpr char kConfigKey_MfrDevicePrivateKey[] = ("device-key"); + static constexpr char kConfigKey_ManufacturingDate[] = ("mfg-date"); + static constexpr char kConfigKey_SetupPinCode[] = ("pin-code"); + static constexpr char kConfigKey_SetupDiscriminator[] = ("discriminator"); + static constexpr char kConfigKey_Spake2pIterationCount[] = ("iteration-count"); + static constexpr char kConfigKey_Spake2pSalt[] = ("salt"); + static constexpr char kConfigKey_Spake2pVerifier[] = ("verifier"); + static constexpr char kConfigKey_UniqueId[] = ("unique-id"); + + /** Config keys, which should be droped after a factory reset */ + static constexpr char kConfigKey_FabricId[] = ("fabric-id"); + static constexpr char kConfigKey_ServiceConfig[] = ("service-config"); + static constexpr char kConfigKey_PairedAccountId[] = ("account-id"); + static constexpr char kConfigKey_ServiceId[] = ("service-id"); + static constexpr char kConfigKey_FabricSecret[] = ("fabric-secret"); + static constexpr char kConfigKey_HardwareVersion[] = ("hardware-ver"); + static constexpr char kConfigKey_LastUsedEpochKeyId[] = ("last-ek-id"); + static constexpr char kConfigKey_FailSafeArmed[] = ("fail-safe-armed"); + static constexpr char kConfigKey_OperationalDeviceId[] = ("op-device-id"); + static constexpr char kConfigKey_OperationalDeviceCert[] = ("op-device-cert"); + static constexpr char kConfigKey_OperationalDeviceICACerts[] = ("op-device-ca-certs"); + static constexpr char kConfigKey_OperationalDevicePrivateKey[] = ("op-device-key"); + static constexpr char kConfigKey_RegulatoryLocation[] = ("regulatory-location"); + static constexpr char kConfigKey_CountryCode[] = ("country-code"); + static constexpr char kConfigKey_ActiveLocale[] = ("active-locale"); + static constexpr char kConfigKey_Breadcrumb[] = ("breadcrumb"); + static constexpr char kConfigKey_GroupKeyIndex[] = ("group-key-index"); + static constexpr char kConfigKey_LifeTimeCounter[] = ("life-time-counter"); + + static constexpr char kConfigKey_WiFiSSID[] = ("bl-wifi-ssid"); + static constexpr char kConfigKey_WiFiPassword[] = ("bl-wifi-pass"); + + /** Counter Keys, diagnostic information */ + static constexpr char kCounterKey_RebootCount[] = ("reboot-count"); + static constexpr char kCounterKey_TotalOperationalHours[] = ("total-hours"); + static constexpr char kCounterKey_UpTime[] = ("up-time"); + + static constexpr char kBLKey_factoryResetFlag[] = ("__factory_reset_pending"); + + static void Init(void); + + // Config value accessors. + static CHIP_ERROR ReadConfigValue(const char * key, uint8_t * val, size_t size, size_t & readsize); + static CHIP_ERROR ReadConfigValue(const char * key, bool & val); + static CHIP_ERROR ReadConfigValue(const char * key, uint32_t & val); + static CHIP_ERROR ReadConfigValue(const char * key, uint64_t & val); + static CHIP_ERROR ReadConfigValueStr(const char * key, char * buf, size_t bufSize, size_t & outLen); + static CHIP_ERROR ReadConfigValueBin(const char * key, uint8_t * buf, size_t bufSize, size_t & outLen); + + static CHIP_ERROR WriteConfigValue(const char * key, uint8_t * val, size_t size); + static CHIP_ERROR WriteConfigValue(const char * key, bool val); + static CHIP_ERROR WriteConfigValue(const char * key, uint32_t val); + static CHIP_ERROR WriteConfigValue(const char * key, uint64_t val); + static CHIP_ERROR WriteConfigValueStr(const char * key, const char * str); + static CHIP_ERROR WriteConfigValueStr(const char * key, const char * str, size_t strLen); + static CHIP_ERROR WriteConfigValueBin(const char * key, const uint8_t * data, size_t dataLen); + + static CHIP_ERROR ClearConfigValue(const char * key); + static bool ConfigValueExists(const char * key); + static CHIP_ERROR FactoryResetConfig(void); + + static void RunConfigUnitTest(void); + + // internal to the platform for KeyValueStoreManagerImpl.cpp + static CHIP_ERROR ReadKVS(const char * key, void * value, size_t value_size, size_t * read_bytes_size, size_t offset_bytes); + static CHIP_ERROR WriteKVS(const char * key, const void * value, size_t value_size); + static CHIP_ERROR ClearKVS(const char * key); +}; + +} // namespace Internal +} // namespace DeviceLayer +} // namespace chip diff --git a/src/platform/qcc74x/common/BLConfig_littlefs.cpp b/src/platform/qcc74x/common/BLConfig_littlefs.cpp new file mode 100644 index 00000000000000..f462f3fd00d955 --- /dev/null +++ b/src/platform/qcc74x/common/BLConfig_littlefs.cpp @@ -0,0 +1,345 @@ +/* + * Copyright (c) 2022 Project CHIP Authors + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include +#include + +#include +extern "C" { +#include +} + +#include +#include + +#ifndef BLCONFIG_LFS_NAMESPACE +#define BLCONFIG_LFS_NAMESPACE "/_blcfg_" +#endif + +#ifndef BLCONFIG_SLASH +#define BLCONFIG_SLASH "-" +#endif + +namespace chip { +namespace DeviceLayer { +namespace Internal { + +static lfs_t * blconfig_lfs = nullptr; + +static inline std::string blcfg_convert_key(std::string key, std::string lfs_ns = std::string("")) +{ + return lfs_ns + std::string("/") + regex_replace(key, std::regex("/"), std::string(BLCONFIG_SLASH)); +} + +static CHIP_ERROR blcfg_do_factory_reset(void) +{ + CHIP_ERROR err = CHIP_NO_ERROR; + int ret; + struct lfs_info stat; + lfs_file_t file; + lfs_dir_t dir = {}; + std::string factory_reset_key = blcfg_convert_key(std::string(BLConfig::kBLKey_factoryResetFlag)); + + blconfig_lfs->cfg->lock(blconfig_lfs->cfg); + + ret = lfs_stat(blconfig_lfs, const_cast(factory_reset_key.c_str()), &stat); + + if (LFS_ERR_OK == ret) { + err = CHIP_ERROR_PERSISTED_STORAGE_FAILED; + + do { + ret = lfs_file_open(blconfig_lfs, &file, const_cast(factory_reset_key.c_str()), LFS_O_RDONLY); + VerifyOrExit(ret == LFS_ERR_OK, err = CHIP_ERROR_PERSISTED_STORAGE_FAILED); + lfs_file_close(blconfig_lfs, &file); + + ret = lfs_dir_open(blconfig_lfs, &dir, BLCONFIG_LFS_NAMESPACE); + VerifyOrExit(ret == LFS_ERR_OK, err = CHIP_ERROR_PERSISTED_STORAGE_FAILED); + + while (1) { + ret = lfs_dir_read(blconfig_lfs, &dir, &stat); + if (ret <= 0) { + break; + } + + if (stat.type != LFS_TYPE_REG) { + continue; + } + std::string delete_key = blcfg_convert_key(std::string(stat.name), std::string(BLCONFIG_LFS_NAMESPACE)); + + ret = lfs_remove(blconfig_lfs, const_cast(delete_key.c_str())); + if (ret != LFS_ERR_OK) { + break; + } + } + + lfs_dir_close(blconfig_lfs, &dir); + + ret = lfs_remove(blconfig_lfs, const_cast(factory_reset_key.c_str())); + if (ret != LFS_ERR_OK) { + break; + } + + err = CHIP_NO_ERROR; + } while(0); + } + +exit: + blconfig_lfs->cfg->unlock(blconfig_lfs->cfg); + + return err; +} + +void BLConfig::Init(void) +{ + CHIP_ERROR err = CHIP_NO_ERROR; + int ret; + struct lfs_info stat; + + blconfig_lfs = lfs_xip_init(); + VerifyOrExit(blconfig_lfs != NULL, err = CHIP_ERROR_PERSISTED_STORAGE_FAILED); + + /* init namespace */ + ret = lfs_stat(blconfig_lfs, BLCONFIG_LFS_NAMESPACE, &stat); + if (ret != LFS_ERR_OK) { + ret = lfs_mkdir(blconfig_lfs, BLCONFIG_LFS_NAMESPACE); + VerifyOrExit(ret == LFS_ERR_OK, err = CHIP_ERROR_PERSISTED_STORAGE_FAILED); + + ret = lfs_stat(blconfig_lfs, BLCONFIG_LFS_NAMESPACE, &stat); + } + VerifyOrExit(ret == LFS_ERR_OK && stat.type == LFS_TYPE_DIR, err = CHIP_ERROR_PERSISTED_STORAGE_FAILED); + + err = blcfg_do_factory_reset(); +exit: + configASSERT(err == CHIP_NO_ERROR); +} + +CHIP_ERROR BLConfig::ReadConfigValue(const char * key, uint8_t * val, size_t size, size_t & readsize) +{ + CHIP_ERROR err = CHIP_NO_ERROR; + int ret = LFS_ERR_OK; + lfs_file_t file; + std::string read_key = blcfg_convert_key(std::string(key), std::string(BLCONFIG_LFS_NAMESPACE)); + + blconfig_lfs->cfg->lock(blconfig_lfs->cfg); + + ret = lfs_file_open(blconfig_lfs, &file, const_cast(read_key.c_str()), LFS_O_RDONLY); + VerifyOrExit(ret == LFS_ERR_OK, err = CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND); + + if (val && size) { + ret = lfs_file_read(blconfig_lfs, &file, val, size); + readsize = ret; + } + lfs_file_close(blconfig_lfs, &file); + +exit: + blconfig_lfs->cfg->unlock(blconfig_lfs->cfg); + + return err; +} + +CHIP_ERROR BLConfig::ReadConfigValue(const char * key, bool & val) +{ + size_t readlen = 0; + return ReadConfigValue(key, (uint8_t *) &val, 1, readlen); +} + +CHIP_ERROR BLConfig::ReadConfigValue(const char * key, uint32_t & val) +{ + size_t readlen = 0; + return ReadConfigValue(key, (uint8_t *) &val, sizeof(val), readlen); +} + +CHIP_ERROR BLConfig::ReadConfigValue(const char * key, uint64_t & val) +{ + size_t readlen = 0; + return ReadConfigValue(key, (uint8_t *) &val, sizeof(val), readlen); +} + +CHIP_ERROR BLConfig::ReadConfigValueStr(const char * key, char * buf, size_t bufSize, size_t & outLen) +{ + size_t readlen = 0; + if (CHIP_NO_ERROR == ReadConfigValue(key, (uint8_t *) buf, bufSize, readlen)) + { + outLen = readlen; + if (readlen && readlen < bufSize) + { + buf[readlen] = '\0'; + } + + return CHIP_NO_ERROR; + } + + return CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND; +} + +CHIP_ERROR BLConfig::ReadConfigValueBin(const char * key, uint8_t * buf, size_t bufSize, size_t & outLen) +{ + size_t readlen = 0; + if (CHIP_NO_ERROR == ReadConfigValue(key, (uint8_t *) buf, bufSize, readlen)) + { + outLen = readlen; + return CHIP_NO_ERROR; + } + + return CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND; +} + +CHIP_ERROR BLConfig::WriteConfigValue(const char * key, uint8_t * val, size_t size) +{ + int ret = LFS_ERR_OK; + CHIP_ERROR err = CHIP_NO_ERROR; + lfs_file_t file; + std::string write_key = blcfg_convert_key(std::string(key), std::string(BLCONFIG_LFS_NAMESPACE)); + + blconfig_lfs->cfg->lock(blconfig_lfs->cfg); + + ret = lfs_file_open(blconfig_lfs, &file, const_cast(write_key.c_str()), LFS_O_CREAT | LFS_O_RDWR); + VerifyOrExit(ret == LFS_ERR_OK, err = CHIP_ERROR_PERSISTED_STORAGE_FAILED); + + lfs_file_write(blconfig_lfs, &file, val, size); + lfs_file_close(blconfig_lfs, &file); + +exit: + blconfig_lfs->cfg->unlock(blconfig_lfs->cfg); + + return err; +} + +CHIP_ERROR BLConfig::WriteConfigValue(const char * key, bool val) +{ + return WriteConfigValue(key, (uint8_t *) &val, sizeof(val)); +} + +CHIP_ERROR BLConfig::WriteConfigValue(const char * key, uint32_t val) +{ + return WriteConfigValue(key, (uint8_t *) &val, sizeof(val)); +} + +CHIP_ERROR BLConfig::WriteConfigValue(const char * key, uint64_t val) +{ + return WriteConfigValue(key, (uint8_t *) &val, sizeof(val)); +} + +CHIP_ERROR BLConfig::WriteConfigValueStr(const char * key, const char * str) +{ + return WriteConfigValue(key, (uint8_t *) str, strlen(str) + 1); +} + +CHIP_ERROR BLConfig::WriteConfigValueStr(const char * key, const char * str, size_t strLen) +{ + return WriteConfigValue(key, (uint8_t *) str, strLen); +} + +CHIP_ERROR BLConfig::WriteConfigValueBin(const char * key, const uint8_t * data, size_t dataLen) +{ + return WriteConfigValue(key, (uint8_t *) data, dataLen); +} + +CHIP_ERROR BLConfig::ClearConfigValue(const char * key) +{ + std::string delete_key = blcfg_convert_key(std::string(key), std::string(BLCONFIG_LFS_NAMESPACE)); + + return lfs_remove(blconfig_lfs, const_cast(delete_key.c_str())) >= LFS_ERR_OK ? CHIP_NO_ERROR: CHIP_ERROR_PERSISTED_STORAGE_FAILED; +} + +CHIP_ERROR BLConfig::FactoryResetConfig(void) +{ + int ret = LFS_ERR_OK; + CHIP_ERROR err = CHIP_NO_ERROR; + lfs_file_t file; + std::string reset_key = blcfg_convert_key(std::string(kBLKey_factoryResetFlag)); + const char reset_key_value[] = "pending"; + + blconfig_lfs->cfg->lock(blconfig_lfs->cfg); + + ret = lfs_file_open(blconfig_lfs, &file, const_cast(reset_key.c_str()), LFS_O_CREAT | LFS_O_RDWR); + if (ret != LFS_ERR_OK) { + blconfig_lfs->cfg->unlock(blconfig_lfs->cfg); + return CHIP_ERROR_PERSISTED_STORAGE_FAILED; + } + + lfs_file_write(blconfig_lfs, &file, reset_key_value, sizeof(reset_key_value)); + lfs_file_close(blconfig_lfs, &file); + + blconfig_lfs->cfg->unlock(blconfig_lfs->cfg); + + return blcfg_do_factory_reset(); +} + +void BLConfig::RunConfigUnitTest() {} + +bool BLConfig::ConfigValueExists(const char * key) +{ + std::string exist_key = blcfg_convert_key(std::string(key), std::string(BLCONFIG_LFS_NAMESPACE)); + struct lfs_info stat; + + return lfs_stat(blconfig_lfs, const_cast(exist_key.c_str()), &stat) == LFS_ERR_OK; +} + +CHIP_ERROR BLConfig::ReadKVS(const char * key, void * value, size_t value_size, size_t * read_bytes_size, size_t offset_bytes) +{ + CHIP_ERROR err = CHIP_NO_ERROR; + int ret = LFS_ERR_OK; + lfs_file_t file; + std::string read_key = blcfg_convert_key(std::string(key), std::string(BLCONFIG_LFS_NAMESPACE)); + + if (read_bytes_size) { + * read_bytes_size = 0; + } + + blconfig_lfs->cfg->lock(blconfig_lfs->cfg); + + ret = lfs_file_open(blconfig_lfs, &file, const_cast(read_key.c_str()), LFS_O_RDONLY); + VerifyOrExit(ret == LFS_ERR_OK, err = CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND); + + if (value && value_size) { + do { + ret = 0; + if (offset_bytes > 0 && lfs_file_seek(blconfig_lfs, &file, offset_bytes, 0) < 0) { + err = CHIP_ERROR_PERSISTED_STORAGE_FAILED; + break; + } + ret = lfs_file_read(blconfig_lfs, &file, value, value_size); + if (ret > 0) { + * read_bytes_size = ret; + } + } while (0); + } + + lfs_file_close(blconfig_lfs, &file); +exit: + blconfig_lfs->cfg->unlock(blconfig_lfs->cfg); + + return err; +} + +CHIP_ERROR BLConfig::WriteKVS(const char * key, const void * value, size_t value_size) +{ + return WriteConfigValueBin(key, (const uint8_t *)value, value_size); +} + +CHIP_ERROR BLConfig::ClearKVS(const char * key) +{ + return ClearConfigValue(key); +} + +} // namespace Internal +} // namespace DeviceLayer +} // namespace chip diff --git a/src/platform/qcc74x/common/BLEManagerImpl.cpp b/src/platform/qcc74x/common/BLEManagerImpl.cpp new file mode 100644 index 00000000000000..c6bbc87ba5338d --- /dev/null +++ b/src/platform/qcc74x/common/BLEManagerImpl.cpp @@ -0,0 +1,860 @@ +/* + * + * Copyright (c) 2020-2022 Project CHIP Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#define __ZEPHYR__ 1 +#define CONFIG_EVENTFD 0 +#include + +#if CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE + +#include +#include +#include +#include +#if CHIP_ENABLE_ADDITIONAL_DATA_ADVERTISING +#include +#endif + +extern "C" { +#if CHIP_DEVICE_LAYER_TARGET_BLBL702L || CHIP_DEVICE_LAYER_TARGET_QCC743 +#include +#else +#include +#endif +} + +#include +#include + +#include "BLEManagerImpl.h" + +using namespace ::chip; +using namespace ::chip::Ble; +using namespace ::chip::System; + +namespace chip { +namespace DeviceLayer { +namespace Internal { + +const bt_uuid_128 UUID128_CHIPoBLEChar_RX = + BT_UUID_INIT_128(0x11, 0x9D, 0x9F, 0x42, 0x9C, 0x4F, 0x9F, 0x95, 0x59, 0x45, 0x3D, 0x26, 0xF5, 0x2E, 0xEE, 0x18); +const bt_uuid_128 UUID128_CHIPoBLEChar_TX = + BT_UUID_INIT_128(0x12, 0x9D, 0x9F, 0x42, 0x9C, 0x4F, 0x9F, 0x95, 0x59, 0x45, 0x3D, 0x26, 0xF5, 0x2E, 0xEE, 0x18); +bt_uuid_16 UUID16_CHIPoBLEService = BT_UUID_INIT_16(0xFFF6); + +const ChipBleUUID chipUUID_CHIPoBLEChar_RX = { { 0x18, 0xEE, 0x2E, 0xF5, 0x26, 0x3D, 0x45, 0x59, 0x95, 0x9F, 0x4F, 0x9C, 0x42, 0x9F, + 0x9D, 0x11 } }; + +const ChipBleUUID chipUUID_CHIPoBLEChar_TX = { { 0x18, 0xEE, 0x2E, 0xF5, 0x26, 0x3D, 0x45, 0x59, 0x95, 0x9F, 0x4F, 0x9C, 0x42, 0x9F, + 0x9D, 0x12 } }; +#if CHIP_ENABLE_ADDITIONAL_DATA_ADVERTISING +const bt_uuid_128 UUID128_CHIPoBLEChar_C3 = + BT_UUID_INIT_128(0x04, 0x8F, 0x21, 0x83, 0x8A, 0x74, 0x7D, 0xB8, 0xF2, 0x45, 0x72, 0x87, 0x38, 0x02, 0x63, 0x64); +#endif + +_bt_gatt_ccc CHIPoBLEChar_TX_CCC = BT_GATT_CCC_INITIALIZER(nullptr, BLEManagerImpl::HandleTXCCCWrite, nullptr); + +struct bt_gatt_attr sChipoBleAttributes[] = { + BT_GATT_PRIMARY_SERVICE(&UUID16_CHIPoBLEService.uuid), + BT_GATT_CHARACTERISTIC(&UUID128_CHIPoBLEChar_RX.uuid, BT_GATT_CHRC_WRITE | BT_GATT_CHRC_WRITE_WITHOUT_RESP, + BT_GATT_PERM_READ | BT_GATT_PERM_WRITE, nullptr, BLEManagerImpl::HandleRXWrite, nullptr), + BT_GATT_CHARACTERISTIC(&UUID128_CHIPoBLEChar_TX.uuid, BT_GATT_CHRC_INDICATE, BT_GATT_PERM_NONE, nullptr, nullptr, nullptr), + BT_GATT_CCC_MANAGED(&CHIPoBLEChar_TX_CCC, BT_GATT_PERM_READ | BT_GATT_PERM_WRITE), +#if CHIP_ENABLE_ADDITIONAL_DATA_ADVERTISING + BT_GATT_CHARACTERISTIC(&UUID128_CHIPoBLEChar_C3.uuid, BT_GATT_CHRC_READ, BT_GATT_PERM_READ, BLEManagerImpl::HandleC3Read, + nullptr, nullptr), +#endif +}; + +struct bt_gatt_service sChipoBleService = { + .attrs = sChipoBleAttributes, + .attr_count = sizeof(sChipoBleAttributes) / sizeof(sChipoBleAttributes[0]), +}; + +static const int kCHIPoBLE_CCC_AttributeIndex = 3; + +CHIP_ERROR InitRandomStaticAddress() +{ + // When the BT privacy feature is disabled, generate a random static address once per boot. + // This must be done before bt_enable() has been called. + bt_addr_le_t addr; + + int error = bt_addr_le_create_static(&addr); + if (error) + { + ChipLogError(DeviceLayer, "Failed to create BLE address: %d", error); + return System::MapErrorZephyr(error); + } + + error = bt_id_create(&addr, nullptr); + + if (error < 0) + { + ChipLogError(DeviceLayer, "Failed to create BLE identity: %d", error); + return System::MapErrorZephyr(error); + } + + ChipLogProgress(DeviceLayer, "BLE address: %02X:%02X:%02X:%02X:%02X:%02X", addr.a.val[5], addr.a.val[4], addr.a.val[3], + addr.a.val[2], addr.a.val[1], addr.a.val[0]); + return CHIP_NO_ERROR; +} + +BLEManagerImpl BLEManagerImpl::sInstance; + +CHIP_ERROR BLEManagerImpl::_Init() +{ + mServiceMode = ConnectivityManager::kCHIPoBLEServiceMode_Enabled; + mFlags.ClearAll().Set(Flags::kAdvertisingEnabled, CHIP_DEVICE_CONFIG_CHIPOBLE_ENABLE_ADVERTISING_AUTOSTART); + mFlags.Set(Flags::kFastAdvertisingEnabled, true); + mGAPConns = 0; + + memset(mSubscribedConns, 0, sizeof(mSubscribedConns)); + + ReturnErrorOnFailure(InitRandomStaticAddress()); +#if CHIP_DEVICE_LAYER_TARGET_BL702L || CHIP_DEVICE_LAYER_TARGET_QCC743 + btble_controller_init(configMAX_PRIORITIES - 1); +#else + ble_controller_init(configMAX_PRIORITIES - 1); +#endif + hci_driver_init(); + bt_enable(NULL); + + memset(&mConnCallbacks, 0, sizeof(mConnCallbacks)); + mConnCallbacks.connected = HandleConnect; + mConnCallbacks.disconnected = HandleDisconnect; + + bt_conn_cb_register(&mConnCallbacks); + + // Initialize the CHIP BleLayer. + ReturnErrorOnFailure(BleLayer::Init(this, this, &DeviceLayer::SystemLayer())); + + PlatformMgr().ScheduleWork(DriveBLEState, 0); + + return CHIP_NO_ERROR; +} + +void BLEManagerImpl::_Shutdown() +{ + // Release BLE Stack resources + mFlags.Set(Flags::kChipoBleShutDown); +} + +void BLEManagerImpl::DriveBLEState(intptr_t arg) +{ + BLEMgrImpl().DriveBLEState(); +} + +void BLEManagerImpl::DriveBLEState() +{ + CHIP_ERROR err = CHIP_NO_ERROR; + + // Perform any initialization actions that must occur after the CHIP task is running. + if (!mFlags.Has(Flags::kAsyncInitCompleted)) + { + mFlags.Set(Flags::kAsyncInitCompleted); + } + + // If the application has enabled CHIPoBLE and BLE advertising... + if (mServiceMode == ConnectivityManager::kCHIPoBLEServiceMode_Enabled && + mFlags.Has(Flags::kAdvertisingEnabled) +#if CHIP_DEVICE_CONFIG_CHIPOBLE_SINGLE_CONNECTION + // and no connections are active... + && (NumConnections() == 0) +#endif + ) + { + // Start/re-start advertising if not already advertising, or if the + // advertising state needs to be refreshed. + if (!mFlags.Has(Flags::kAdvertising) || mFlags.Has(Flags::kAdvertisingRefreshNeeded)) + { + mFlags.Clear(Flags::kAdvertisingRefreshNeeded); + err = StartAdvertising(); + SuccessOrExit(err); + } + } + else + { + if (mFlags.Has(Flags::kAdvertising)) + { + err = StopAdvertising(); + SuccessOrExit(err); + } + + // If no connections are active unregister also CHIPoBLE GATT service + if (NumConnections() == 0 && mFlags.Has(Flags::kChipoBleGattServiceRegister)) + { + // Unregister CHIPoBLE service to not allow discovering it when pairing is disabled. + if (bt_gatt_service_unregister(&sChipoBleService) != 0) + { + ChipLogError(DeviceLayer, "Failed to unregister CHIPoBLE GATT service"); + } + else + { + mFlags.Clear(Flags::kChipoBleGattServiceRegister); + } + } + } + +exit: + if (err != CHIP_NO_ERROR) + { + ChipLogError(DeviceLayer, "Disabling CHIPoBLE service due to error: %s", ErrorStr(err)); + mServiceMode = ConnectivityManager::kCHIPoBLEServiceMode_Disabled; + } +} + +struct BLEManagerImpl::ServiceData +{ + uint8_t uuid[2]; + ChipBLEDeviceIdentificationInfo deviceIdInfo; +} __attribute__((packed)); + +CHIP_ERROR BLEManagerImpl::StartAdvertising(void) +{ + int err = 0; + const bool isAdvertisingRerun = mFlags.Has(Flags::kAdvertising); + + // At first run always select fast advertising, on the next attempt slow down interval. + const uint32_t intervalMin = mFlags.Has(Flags::kFastAdvertisingEnabled) ? CHIP_DEVICE_CONFIG_BLE_FAST_ADVERTISING_INTERVAL_MIN + : CHIP_DEVICE_CONFIG_BLE_SLOW_ADVERTISING_INTERVAL_MIN; + const uint32_t intervalMax = mFlags.Has(Flags::kFastAdvertisingEnabled) ? CHIP_DEVICE_CONFIG_BLE_FAST_ADVERTISING_INTERVAL_MAX + : CHIP_DEVICE_CONFIG_BLE_SLOW_ADVERTISING_INTERVAL_MAX; + + bt_le_adv_param advParams; + advParams.id = BT_ID_DEFAULT; + advParams.options = BT_LE_ADV_OPT_CONNECTABLE | BT_LE_ADV_OPT_ONE_TIME; + advParams.interval_min = intervalMin; + advParams.interval_max = intervalMax; + + // Define advertising and, if BLE device name is set, scan response data + ServiceData serviceData; + const uint8_t advFlags = BT_LE_AD_GENERAL | BT_LE_AD_NO_BREDR; + const bt_data advertisingData[] = { BT_DATA(BT_DATA_FLAGS, &advFlags, sizeof(advFlags)), + BT_DATA(BT_DATA_SVC_DATA16, &serviceData, sizeof(serviceData)) }; + + const char * deviceName = bt_get_name(); + const uint8_t deviceNameSize = static_cast(strlen(deviceName)); + const bt_data scanResponseData[] = { BT_DATA(BT_DATA_NAME_COMPLETE, deviceName, deviceNameSize) }; + const bt_data * scanResponseDataPtr = deviceNameSize > 0 ? scanResponseData : nullptr; + const size_t scanResponseDataLen = deviceNameSize > 0 ? sizeof(scanResponseData) / sizeof(scanResponseData[0]) : 0u; + + // Register dynamically CHIPoBLE GATT service + if (!mFlags.Has(Flags::kChipoBleGattServiceRegister)) + { + err = bt_gatt_service_register(&sChipoBleService); + + if (err != 0) + ChipLogError(DeviceLayer, "Failed to register CHIPoBLE GATT service"); + + VerifyOrReturnError(err == 0, MapErrorZephyr(err)); + + mFlags.Set(Flags::kChipoBleGattServiceRegister); + } + + // Initialize service data + static_assert(sizeof(serviceData) == 10, "Size of BLE advertisement data changed! Was that intentional?"); + chip::Encoding::LittleEndian::Put16(serviceData.uuid, UUID16_CHIPoBLEService.val); + ReturnErrorOnFailure(ConfigurationMgr().GetBLEDeviceIdentificationInfo(serviceData.deviceIdInfo)); + +#if CHIP_ENABLE_ADDITIONAL_DATA_ADVERTISING + ReturnErrorOnFailure(PrepareC3CharData()); +#endif + + if (!isAdvertisingRerun) + { +#ifdef CONFIG_BT_PRIVACY + static_assert(CHIP_DEVICE_CONFIG_DISCOVERY_TIMEOUT_SECS <= CONFIG_BT_RPA_TIMEOUT, + "BLE advertising timeout is too long relative to RPA timeout"); + // Generate new private BLE address + bt_le_oob bleOobInfo; + err = bt_le_oob_get_local(advParams.id, &bleOobInfo); + VerifyOrReturnError(err == 0, MapErrorZephyr(err)); +#endif // CONFIG_BT_PRIVACY + } + + // Restart advertising + err = bt_le_adv_stop(); + VerifyOrReturnError(err == 0, MapErrorZephyr(err)); + + err = bt_le_adv_start(&advParams, advertisingData, sizeof(advertisingData) / sizeof(advertisingData[0]), scanResponseDataPtr, + scanResponseDataLen); + VerifyOrReturnError(err == 0, MapErrorZephyr(err)); + + // Transition to the Advertising state... + if (!mFlags.Has(Flags::kAdvertising)) + { + ChipLogProgress(DeviceLayer, "CHIPoBLE advertising started"); + + mFlags.Set(Flags::kAdvertising); + + // Post a CHIPoBLEAdvertisingChange(Started) event. + { + ChipDeviceEvent advChange; + advChange.Type = DeviceEventType::kCHIPoBLEAdvertisingChange; + advChange.CHIPoBLEAdvertisingChange.Result = kActivity_Started; + ReturnErrorOnFailure(PlatformMgr().PostEvent(&advChange)); + } + + if (mFlags.Has(Flags::kFastAdvertisingEnabled)) + { + // Start timer to change advertising interval. + DeviceLayer::SystemLayer().StartTimer( + System::Clock::Milliseconds32(CHIP_DEVICE_CONFIG_BLE_ADVERTISING_INTERVAL_CHANGE_TIME), + HandleBLEAdvertisementIntervalChange, this); + } + } + + return CHIP_NO_ERROR; +} + +CHIP_ERROR BLEManagerImpl::StopAdvertising(void) +{ + int err = bt_le_adv_stop(); + VerifyOrReturnError(err == 0, MapErrorZephyr(err)); + + // Transition to the not Advertising state... + if (mFlags.Has(Flags::kAdvertising)) + { + mFlags.Clear(Flags::kAdvertising); + mFlags.Set(Flags::kFastAdvertisingEnabled, true); + + ChipLogProgress(DeviceLayer, "CHIPoBLE advertising stopped"); + + // Post a CHIPoBLEAdvertisingChange(Stopped) event. + { + ChipDeviceEvent advChange; + advChange.Type = DeviceEventType::kCHIPoBLEAdvertisingChange; + advChange.CHIPoBLEAdvertisingChange.Result = kActivity_Stopped; + ReturnErrorOnFailure(PlatformMgr().PostEvent(&advChange)); + } + + // Cancel timer event changing CHIPoBLE advertisement interval + DeviceLayer::SystemLayer().CancelTimer(HandleBLEAdvertisementIntervalChange, this); + } + + return CHIP_NO_ERROR; +} + +CHIP_ERROR BLEManagerImpl::_SetAdvertisingEnabled(bool val) +{ + VerifyOrReturnError(mServiceMode != ConnectivityManager::kCHIPoBLEServiceMode_NotSupported, + CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE); + + if (mFlags.Has(Flags::kAdvertisingEnabled) != val) + { + ChipLogDetail(DeviceLayer, "CHIPoBLE advertising set to %s", val ? "on" : "off"); + + mFlags.Set(Flags::kAdvertisingEnabled, val); + PlatformMgr().ScheduleWork(DriveBLEState, 0); + } + + return CHIP_NO_ERROR; +} + +CHIP_ERROR BLEManagerImpl::_SetAdvertisingMode(BLEAdvertisingMode mode) +{ + switch (mode) + { + case BLEAdvertisingMode::kFastAdvertising: + mFlags.Set(Flags::kFastAdvertisingEnabled, true); + break; + case BLEAdvertisingMode::kSlowAdvertising: + mFlags.Set(Flags::kFastAdvertisingEnabled, false); + break; + default: + return CHIP_ERROR_INVALID_ARGUMENT; + } + mFlags.Set(Flags::kAdvertisingRefreshNeeded); + PlatformMgr().ScheduleWork(DriveBLEState, 0); + return CHIP_NO_ERROR; +} + +CHIP_ERROR BLEManagerImpl::_GetDeviceName(char * buf, size_t bufSize) +{ + Platform::CopyString(buf, bufSize, bt_get_name()); + + return CHIP_NO_ERROR; +} + +CHIP_ERROR BLEManagerImpl::_SetDeviceName(const char * deviceName) +{ + if (mServiceMode == ConnectivityManager::kCHIPoBLEServiceMode_NotSupported) + { + return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; + } + + ChipLogDetail(DeviceLayer, "Device name set to: %s", StringOrNullMarker(deviceName)); + return MapErrorZephyr(bt_set_name(deviceName)); +} + +CHIP_ERROR BLEManagerImpl::HandleGAPConnect(const ChipDeviceEvent * event) +{ + const BleConnEventType * connEvent = &event->Platform.BleConnEvent; + + if (connEvent->HciResult == BT_HCI_ERR_SUCCESS) + { + ChipLogProgress(DeviceLayer, "BLE connection established (ConnId: 0x%02x)", bt_conn_index(connEvent->BtConn)); + mGAPConns++; + } + else + { + ChipLogError(DeviceLayer, "BLE connection failed (reason: 0x%02x)", connEvent->HciResult); + } + + ChipLogProgress(DeviceLayer, "Current number of connections: %u/%u", NumConnections(), CONFIG_BT_MAX_CONN); + + mFlags.Set(Flags::kAdvertisingRefreshNeeded); + PlatformMgr().ScheduleWork(DriveBLEState, 0); + + bt_conn_unref(connEvent->BtConn); + + return CHIP_NO_ERROR; +} + +CHIP_ERROR BLEManagerImpl::HandleGAPDisconnect(const ChipDeviceEvent * event) +{ + const BleConnEventType * connEvent = &event->Platform.BleConnEvent; + + ChipLogProgress(DeviceLayer, "BLE GAP connection terminated (reason 0x%02x)", connEvent->HciResult); + + mGAPConns--; + + // If indications were enabled for this connection, record that they are now disabled and + // notify the BLE Layer of a disconnect. + if (UnsetSubscribed(connEvent->BtConn)) + { + CHIP_ERROR disconReason; + switch (connEvent->HciResult) + { + case BT_HCI_ERR_REMOTE_USER_TERM_CONN: + // Do not treat proper connection termination as an error and exit. + VerifyOrExit(!ConfigurationMgr().IsFullyProvisioned(), BLEMgrImpl()._Shutdown()); + disconReason = BLE_ERROR_REMOTE_DEVICE_DISCONNECTED; + break; + case BT_HCI_ERR_LOCALHOST_TERM_CONN: + disconReason = BLE_ERROR_APP_CLOSED_CONNECTION; + break; + default: + disconReason = BLE_ERROR_CHIPOBLE_PROTOCOL_ABORT; + break; + } + HandleConnectionError(connEvent->BtConn, disconReason); + } + +exit: + // Unref bt_conn before scheduling DriveBLEState. + bt_conn_unref(connEvent->BtConn); + + ChipLogProgress(DeviceLayer, "Current number of connections: %u/%u", NumConnections(), CONFIG_BT_MAX_CONN); + + ChipDeviceEvent disconnectEvent; + disconnectEvent.Type = DeviceEventType::kCHIPoBLEConnectionClosed; + ReturnErrorOnFailure(PlatformMgr().PostEvent(&disconnectEvent)); + if (mFlags.Has(Flags::kChipoBleShutDown)) + { + int ret = bt_disable(); + if (ret) + { + ChipLogError(DeviceLayer, "CHIPoBLE Shutdown faild =%d", ret); + } + else + { + mFlags.Clear(Flags::kChipoBleShutDown); + } + return CHIP_NO_ERROR; + } + // Force a reconfiguration of advertising in case we switched to non-connectable mode when + // the BLE connection was established. + mFlags.Set(Flags::kAdvertisingRefreshNeeded); + PlatformMgr().ScheduleWork(DriveBLEState, 0); + + return CHIP_NO_ERROR; +} + +CHIP_ERROR BLEManagerImpl::HandleTXCharCCCDWrite(const ChipDeviceEvent * event) +{ + const BleCCCWriteEventType * writeEvent = &event->Platform.BleCCCWriteEvent; + + ChipLogDetail(DeviceLayer, "ConnId: 0x%02x, New CCCD value: 0x%04x", bt_conn_index(writeEvent->BtConn), writeEvent->Value); + + // If the client has requested to enable indications and if it is not yet subscribed + if (writeEvent->Value == BT_GATT_CCC_INDICATE && SetSubscribed(writeEvent->BtConn)) + { + // Alert the BLE layer that CHIPoBLE "subscribe" has been received and increment the bt_conn reference counter. + HandleSubscribeReceived(writeEvent->BtConn, &CHIP_BLE_SVC_ID, &chipUUID_CHIPoBLEChar_TX); + + ChipLogProgress(DeviceLayer, "CHIPoBLE connection established (ConnId: 0x%02x, GATT MTU: %u)", + bt_conn_index(writeEvent->BtConn), GetMTU(writeEvent->BtConn)); + + // Post a CHIPoBLEConnectionEstablished event to the DeviceLayer and the application. + { + ChipDeviceEvent conEstEvent; + conEstEvent.Type = DeviceEventType::kCHIPoBLEConnectionEstablished; + ReturnErrorOnFailure(PlatformMgr().PostEvent(&conEstEvent)); + } + } + else + { + if (UnsetSubscribed(writeEvent->BtConn)) + { + HandleUnsubscribeReceived(writeEvent->BtConn, &CHIP_BLE_SVC_ID, &chipUUID_CHIPoBLEChar_TX); + } + } + + bt_conn_unref(writeEvent->BtConn); + + return CHIP_NO_ERROR; +} + +CHIP_ERROR BLEManagerImpl::HandleRXCharWrite(const ChipDeviceEvent * event) +{ + const BleC1WriteEventType * c1WriteEvent = &event->Platform.BleC1WriteEvent; + + ChipLogDetail(DeviceLayer, "Write request received for CHIPoBLE RX characteristic (ConnId 0x%02x)", + bt_conn_index(c1WriteEvent->BtConn)); + + HandleWriteReceived(c1WriteEvent->BtConn, &CHIP_BLE_SVC_ID, &chipUUID_CHIPoBLEChar_RX, + PacketBufferHandle::Adopt(c1WriteEvent->Data)); + bt_conn_unref(c1WriteEvent->BtConn); + + return CHIP_NO_ERROR; +} + +CHIP_ERROR BLEManagerImpl::HandleTXCharComplete(const ChipDeviceEvent * event) +{ + const BleC2IndDoneEventType * c2IndDoneEvent = &event->Platform.BleC2IndDoneEvent; + + ChipLogDetail(DeviceLayer, "Indication for CHIPoBLE TX characteristic done (ConnId 0x%02x, result 0x%02x)", + bt_conn_index(c2IndDoneEvent->BtConn), c2IndDoneEvent->Result); + + // Signal the BLE Layer that the outstanding indication is complete. + HandleIndicationConfirmation(c2IndDoneEvent->BtConn, &CHIP_BLE_SVC_ID, &chipUUID_CHIPoBLEChar_TX); + bt_conn_unref(c2IndDoneEvent->BtConn); + + return CHIP_NO_ERROR; +} + +#if CHIP_ENABLE_ADDITIONAL_DATA_ADVERTISING +CHIP_ERROR BLEManagerImpl::PrepareC3CharData() +{ + CHIP_ERROR err = CHIP_NO_ERROR; + BitFlags additionalDataFields; + AdditionalDataPayloadGeneratorParams additionalDataPayloadParams; + +#if CHIP_ENABLE_ROTATING_DEVICE_ID && defined(CHIP_DEVICE_CONFIG_ROTATING_DEVICE_ID_UNIQUE_ID) + uint8_t rotatingDeviceIdUniqueId[ConfigurationManager::kRotatingDeviceIDUniqueIDLength] = {}; + MutableByteSpan rotatingDeviceIdUniqueIdSpan(rotatingDeviceIdUniqueId); + + err = DeviceLayer::GetDeviceInstanceInfoProvider()->GetRotatingDeviceIdUniqueId(rotatingDeviceIdUniqueIdSpan); + SuccessOrExit(err); + err = ConfigurationMgr().GetLifetimeCounter(additionalDataPayloadParams.rotatingDeviceIdLifetimeCounter); + SuccessOrExit(err); + additionalDataPayloadParams.rotatingDeviceIdUniqueId = rotatingDeviceIdUniqueIdSpan; + additionalDataFields.Set(AdditionalDataFields::RotatingDeviceId); +#endif /* CHIP_ENABLE_ROTATING_DEVICE_ID && defined(CHIP_DEVICE_CONFIG_ROTATING_DEVICE_ID_UNIQUE_ID) */ + + err = AdditionalDataPayloadGenerator().generateAdditionalDataPayload(additionalDataPayloadParams, c3CharDataBufferHandle, + additionalDataFields); + +exit: + if (err != CHIP_NO_ERROR) + { + ChipLogError(DeviceLayer, "Failed to generate TLV encoded Additional Data (%s)", __func__); + } + + return err; +} +#endif + +void BLEManagerImpl::HandleBLEAdvertisementIntervalChange(System::Layer * layer, void * param) +{ + BLEMgr().SetAdvertisingMode(BLEAdvertisingMode::kSlowAdvertising); + ChipLogProgress(DeviceLayer, "CHIPoBLE advertising mode changed to slow"); +} + +void BLEManagerImpl::_OnPlatformEvent(const ChipDeviceEvent * event) +{ + CHIP_ERROR err = CHIP_NO_ERROR; + + switch (event->Type) + { + case DeviceEventType::kPlatformZephyrBleConnected: + err = HandleGAPConnect(event); + break; + + case DeviceEventType::kPlatformZephyrBleDisconnected: + err = HandleGAPDisconnect(event); + break; + + case DeviceEventType::kPlatformZephyrBleCCCWrite: + err = HandleTXCharCCCDWrite(event); + break; + + case DeviceEventType::kPlatformZephyrBleC1WriteEvent: + err = HandleRXCharWrite(event); + break; + + case DeviceEventType::kPlatformZephyrBleC2IndDoneEvent: + err = HandleTXCharComplete(event); + break; + + default: + break; + } + + if (err != CHIP_NO_ERROR) + { + ChipLogError(DeviceLayer, "Disabling CHIPoBLE service due to error: %" CHIP_ERROR_FORMAT, err.Format()); + mServiceMode = ConnectivityManager::kCHIPoBLEServiceMode_Disabled; + PlatformMgr().ScheduleWork(DriveBLEState, 0); + } +} + +uint16_t BLEManagerImpl::_NumConnections(void) +{ + return mGAPConns; +} + +bool BLEManagerImpl::CloseConnection(BLE_CONNECTION_OBJECT conId) +{ + ChipLogProgress(DeviceLayer, "Closing BLE GATT connection (ConnId %02x)", bt_conn_index((bt_conn *) conId)); + return bt_conn_disconnect((bt_conn *) conId, BT_HCI_ERR_REMOTE_USER_TERM_CONN) == 0; +} + +uint16_t BLEManagerImpl::GetMTU(BLE_CONNECTION_OBJECT conId) const +{ + return bt_gatt_get_mtu((bt_conn *) conId); +} + +bool BLEManagerImpl::SubscribeCharacteristic(BLE_CONNECTION_OBJECT conId, const ChipBleUUID * svcId, const ChipBleUUID * charId) +{ + ChipLogError(DeviceLayer, "%s: NOT IMPLEMENTED", __PRETTY_FUNCTION__); + return true; +} + +bool BLEManagerImpl::UnsubscribeCharacteristic(BLE_CONNECTION_OBJECT conId, const ChipBleUUID * svcId, const ChipBleUUID * charId) +{ + ChipLogError(DeviceLayer, "%s: NOT IMPLEMENTED", __PRETTY_FUNCTION__); + return true; +} + +bool BLEManagerImpl::SendIndication(BLE_CONNECTION_OBJECT conId, const ChipBleUUID * svcId, const ChipBleUUID * charId, + PacketBufferHandle pBuf) +{ + CHIP_ERROR err = CHIP_NO_ERROR; + int status = 0; + uint8_t index = bt_conn_index(conId); + bt_gatt_indicate_params * params = &mIndicateParams[index]; + + VerifyOrExit(IsSubscribed(conId) == true, err = CHIP_ERROR_INVALID_ARGUMENT); + + ChipLogDetail(DeviceLayer, "Sending indication for CHIPoBLE TX characteristic (ConnId %02x, len %u)", index, + pBuf->DataLength()); + + params->uuid = nullptr; + params->attr = &sChipoBleAttributes[kCHIPoBLE_CCC_AttributeIndex]; + params->func = HandleTXIndicated; + params->data = pBuf->Start(); + params->len = pBuf->DataLength(); + + status = bt_gatt_indicate(conId, params); + VerifyOrExit(status == 0, err = MapErrorZephyr(status)); + +exit: + if (err != CHIP_NO_ERROR) + { + ChipLogError(DeviceLayer, "BLEManagerImpl::SendIndication() failed: %." CHIP_ERROR_FORMAT, err.Format()); + ChipLogError(DeviceLayer, "BLEManagerImpl::SendIndication() failed: %d", status); + } + + return err == CHIP_NO_ERROR; +} + +bool BLEManagerImpl::SendWriteRequest(BLE_CONNECTION_OBJECT conId, const ChipBleUUID * svcId, const ChipBleUUID * charId, + PacketBufferHandle pBuf) +{ + ChipLogError(DeviceLayer, "%s: NOT IMPLEMENTED", __PRETTY_FUNCTION__); + return true; +} + +bool BLEManagerImpl::SendReadRequest(BLE_CONNECTION_OBJECT conId, const ChipBleUUID * svcId, const ChipBleUUID * charId, + PacketBufferHandle pBuf) +{ + ChipLogError(DeviceLayer, "%s: NOT IMPLEMENTED", __PRETTY_FUNCTION__); + return true; +} + +bool BLEManagerImpl::SendReadResponse(BLE_CONNECTION_OBJECT conId, BLE_READ_REQUEST_CONTEXT requestContext, + const ChipBleUUID * svcId, const ChipBleUUID * charId) +{ + ChipLogError(DeviceLayer, "%s: NOT IMPLEMENTED", __PRETTY_FUNCTION__); + return true; +} + +void BLEManagerImpl::NotifyChipConnectionClosed(BLE_CONNECTION_OBJECT conId) +{ + CloseConnection(conId); +} + +bool BLEManagerImpl::IsSubscribed(bt_conn * conn) +{ + return mSubscribedConns[bt_conn_index(conn)]; +} + +bool BLEManagerImpl::SetSubscribed(bt_conn * conn) +{ + uint8_t index = bt_conn_index(conn); + bool isSubscribed = mSubscribedConns[index]; + mSubscribedConns[index] = true; + + // If we were not subscribed previously, increment the reference counter of the connection. + if (!isSubscribed) + { + bt_conn_ref(conn); + } + + return !isSubscribed; +} + +bool BLEManagerImpl::UnsetSubscribed(bt_conn * conn) +{ + uint8_t index = bt_conn_index(conn); + bool isSubscribed = mSubscribedConns[index]; + mSubscribedConns[index] = false; + + // If we were subscribed previously, decrement the reference counter of the connection. + if (isSubscribed) + { + bt_conn_unref(conn); + } + + return isSubscribed; +} + +ssize_t BLEManagerImpl::HandleRXWrite(struct bt_conn * conId, const struct bt_gatt_attr * attr, const void * buf, uint16_t len, + uint16_t offset, uint8_t flags) +{ + ChipDeviceEvent event; + PacketBufferHandle packetBuf = PacketBufferHandle::NewWithData(buf, len); + + if (!packetBuf.IsNull()) + { + // Arrange to post a CHIPoBLERXWriteEvent event to the CHIP queue. + event.Type = DeviceEventType::kPlatformZephyrBleC1WriteEvent; + event.Platform.BleC1WriteEvent.BtConn = bt_conn_ref(conId); + event.Platform.BleC1WriteEvent.Data = std::move(packetBuf).UnsafeRelease(); + } + + // If we failed to allocate a buffer, post a kPlatformZephyrBleOutOfBuffersEvent event. + else + { + event.Type = DeviceEventType::kPlatformZephyrBleOutOfBuffersEvent; + } + + PlatformMgr().PostEventOrDie(&event); + + return len; +} + +bool BLEManagerImpl::HandleTXCCCWrite(struct bt_conn * conId, const struct bt_gatt_attr * attr, uint16_t value) +{ + ChipDeviceEvent event; + + if (value != BT_GATT_CCC_INDICATE && value != 0) + { + return BT_GATT_ERR(BT_ATT_ERR_VALUE_NOT_ALLOWED); + } + + event.Type = DeviceEventType::kPlatformZephyrBleCCCWrite; + event.Platform.BleCCCWriteEvent.BtConn = bt_conn_ref(conId); + event.Platform.BleCCCWriteEvent.Value = value; + + PlatformMgr().PostEventOrDie(&event); + + return sizeof(value); +} + +void BLEManagerImpl::HandleTXIndicated(struct bt_conn * conId, IndicationAttrType, uint8_t err) +{ + ChipDeviceEvent event; + + event.Type = DeviceEventType::kPlatformZephyrBleC2IndDoneEvent; + event.Platform.BleC2IndDoneEvent.BtConn = bt_conn_ref(conId); + event.Platform.BleC2IndDoneEvent.Result = err; + + PlatformMgr().PostEventOrDie(&event); +} + +void BLEManagerImpl::HandleConnect(struct bt_conn * conId, uint8_t err) +{ + ChipDeviceEvent event; + + PlatformMgr().LockChipStack(); + + // Don't handle BLE connecting events when it is not related to CHIPoBLE + VerifyOrExit(sInstance.mFlags.Has(Flags::kChipoBleGattServiceRegister), ); + + event.Type = DeviceEventType::kPlatformZephyrBleConnected; + event.Platform.BleConnEvent.BtConn = bt_conn_ref(conId); + event.Platform.BleConnEvent.HciResult = err; + + PlatformMgr().PostEventOrDie(&event); + +exit: + PlatformMgr().UnlockChipStack(); +} + +void BLEManagerImpl::HandleDisconnect(struct bt_conn * conId, uint8_t reason) +{ + ChipDeviceEvent event; + + PlatformMgr().LockChipStack(); + + // Don't handle BLE disconnecting events when it is not related to CHIPoBLE + VerifyOrExit(sInstance.mFlags.Has(Flags::kChipoBleGattServiceRegister), ); + + event.Type = DeviceEventType::kPlatformZephyrBleDisconnected; + event.Platform.BleConnEvent.BtConn = bt_conn_ref(conId); + event.Platform.BleConnEvent.HciResult = reason; + + PlatformMgr().PostEventOrDie(&event); + +exit: + PlatformMgr().UnlockChipStack(); +} + +#if CHIP_ENABLE_ADDITIONAL_DATA_ADVERTISING +ssize_t BLEManagerImpl::HandleC3Read(struct bt_conn * conId, const struct bt_gatt_attr * attr, void * buf, uint16_t len, + uint16_t offset) +{ + ChipLogDetail(DeviceLayer, "Read request received for CHIPoBLE C3 (ConnId 0x%02x)", bt_conn_index(conId)); + + if (sInstance.c3CharDataBufferHandle.IsNull()) + { + return 0; + } + + return bt_gatt_attr_read(conId, attr, buf, len, offset, sInstance.c3CharDataBufferHandle->Start(), + sInstance.c3CharDataBufferHandle->DataLength()); +} +#endif + +} // namespace Internal +} // namespace DeviceLayer +} // namespace chip + +#endif // CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE diff --git a/src/platform/qcc74x/common/BLEManagerImpl.h b/src/platform/qcc74x/common/BLEManagerImpl.h new file mode 100644 index 00000000000000..d5d571ef7949cd --- /dev/null +++ b/src/platform/qcc74x/common/BLEManagerImpl.h @@ -0,0 +1,187 @@ +/* + * Copyright (c) 2022 Project CHIP Authors + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#if CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE + +#include +#include +#include + +namespace chip { +namespace DeviceLayer { +namespace Internal { + +using namespace chip::Ble; + +/** + * Concrete implementation of the BLEManager singleton object for the Bouffalo Lab platform. + */ +class BLEManagerImpl final : public BLEManager, private BleLayer, private BlePlatformDelegate, private BleApplicationDelegate +{ + // Allow the BLEManager interface class to delegate method calls to + // the implementation methods provided by this class. + friend BLEManager; + +private: + // ===== Members that implement the BLEManager internal interface. + using IndicationAttrType = + std::conditional_t::value, + bt_gatt_indicate_params *, const bt_gatt_attr *>; + CHIP_ERROR _Init(void); + void _Shutdown(); + bool _IsAdvertisingEnabled(void); + CHIP_ERROR _SetAdvertisingEnabled(bool val); + bool _IsAdvertising(void); + CHIP_ERROR _SetAdvertisingMode(BLEAdvertisingMode mode); + CHIP_ERROR _GetDeviceName(char * buf, size_t bufSize); + CHIP_ERROR _SetDeviceName(const char * deviceName); + uint16_t _NumConnections(void); + void _OnPlatformEvent(const ChipDeviceEvent * event); + BleLayer * _GetBleLayer(void); + + // ===== Members that implement virtual methods on BlePlatformDelegate. + + bool SubscribeCharacteristic(BLE_CONNECTION_OBJECT conId, const ChipBleUUID * svcId, const ChipBleUUID * charId); + bool UnsubscribeCharacteristic(BLE_CONNECTION_OBJECT conId, const ChipBleUUID * svcId, const ChipBleUUID * charId); + bool CloseConnection(BLE_CONNECTION_OBJECT conId); + uint16_t GetMTU(BLE_CONNECTION_OBJECT conId) const; + bool SendIndication(BLE_CONNECTION_OBJECT conId, const ChipBleUUID * svcId, const ChipBleUUID * charId, + PacketBufferHandle pBuf); + bool SendWriteRequest(BLE_CONNECTION_OBJECT conId, const ChipBleUUID * svcId, const ChipBleUUID * charId, + PacketBufferHandle pBuf); + bool SendReadRequest(BLE_CONNECTION_OBJECT conId, const ChipBleUUID * svcId, const ChipBleUUID * charId, + PacketBufferHandle pBuf); + bool SendReadResponse(BLE_CONNECTION_OBJECT conId, BLE_READ_REQUEST_CONTEXT requestContext, const ChipBleUUID * svcId, + const ChipBleUUID * charId); + + // ===== Members that implement virtual methods on BleApplicationDelegate. + + void NotifyChipConnectionClosed(BLE_CONNECTION_OBJECT conId); + + // ===== Private members reserved for use by this class only. + + enum class Flags : uint8_t + { + kAsyncInitCompleted = 0x0001, /**< One-time asynchronous initialization actions have been performed. */ + kAdvertisingEnabled = 0x0002, /**< The application has enabled CHIPoBLE advertising. */ + kFastAdvertisingEnabled = 0x0004, /**< The application has enabled fast advertising. */ + kAdvertising = 0x0008, /**< The system is currently CHIPoBLE advertising. */ + kAdvertisingRefreshNeeded = + 0x0010, /**< The advertising state/configuration has changed, but the SoftDevice has yet to be updated. */ + kChipoBleGattServiceRegister = 0x0020, /**< The system has currently CHIPoBLE GATT service registered. */ + kChipoBleShutDown = 0x0040, /**< The system has disable ble stack. */ + }; + + struct ServiceData; + + BitFlags mFlags; + uint16_t mGAPConns; + CHIPoBLEServiceMode mServiceMode; + bool mSubscribedConns[CONFIG_BT_MAX_CONN]; + bt_gatt_indicate_params mIndicateParams[CONFIG_BT_MAX_CONN]; + bt_conn_cb mConnCallbacks; +#if CHIP_ENABLE_ADDITIONAL_DATA_ADVERTISING + PacketBufferHandle c3CharDataBufferHandle; +#endif + + void DriveBLEState(void); + CHIP_ERROR ConfigureAdvertising(void); + CHIP_ERROR StartAdvertising(void); + CHIP_ERROR StopAdvertising(void); + CHIP_ERROR HandleGAPConnect(const ChipDeviceEvent * event); + CHIP_ERROR HandleGAPDisconnect(const ChipDeviceEvent * event); + CHIP_ERROR HandleRXCharWrite(const ChipDeviceEvent * event); + CHIP_ERROR HandleTXCharCCCDWrite(const ChipDeviceEvent * event); + CHIP_ERROR HandleTXCharComplete(const ChipDeviceEvent * event); +#if CHIP_ENABLE_ADDITIONAL_DATA_ADVERTISING + CHIP_ERROR PrepareC3CharData(); +#endif + bool IsSubscribed(bt_conn * conn); + bool SetSubscribed(bt_conn * conn); + bool UnsetSubscribed(bt_conn * conn); + uint32_t GetAdvertisingInterval(); + + static void DriveBLEState(intptr_t arg); + + // Below callbacks run from the system workqueue context and have a limited stack capacity. + static void HandleTXIndicated(bt_conn * conn, IndicationAttrType attr, uint8_t err); + static void HandleConnect(bt_conn * conn, uint8_t err); + static void HandleDisconnect(bt_conn * conn, uint8_t reason); + static void HandleBLEAdvertisementIntervalChange(System::Layer * layer, void * param); + + // ===== Members for internal use by the following friends. + + friend BLEManager & BLEMgr(void); + friend BLEManagerImpl & BLEMgrImpl(void); + + static BLEManagerImpl sInstance; + +public: + // Below callbacks are public in order to be visible from the global scope. + static ssize_t HandleRXWrite(bt_conn * conn, const bt_gatt_attr * attr, const void * buf, uint16_t len, uint16_t offset, + uint8_t flags); + static bool HandleTXCCCWrite(bt_conn * conn, const bt_gatt_attr * attr, uint16_t value); + +#if CHIP_ENABLE_ADDITIONAL_DATA_ADVERTISING + static ssize_t HandleC3Read(struct bt_conn * conn, const struct bt_gatt_attr * attr, void * buf, uint16_t len, uint16_t offset); +#endif +}; + +/** + * Returns a reference to the public interface of the BLEManager singleton object. + * + * Internal components should use this to access features of the BLEManager object + * that are common to all platforms. + */ +inline BLEManager & BLEMgr(void) +{ + return BLEManagerImpl::sInstance; +} + +/** + * Returns the platform-specific implementation of the BLEManager singleton object. + * + * Internal components can use this to gain access to features of the BLEManager + * that are specific to the Bouffalo Lab platform. + */ +inline BLEManagerImpl & BLEMgrImpl(void) +{ + return BLEManagerImpl::sInstance; +} + +inline BleLayer * BLEManagerImpl::_GetBleLayer() +{ + return this; +} + +inline bool BLEManagerImpl::_IsAdvertisingEnabled(void) +{ + return mFlags.Has(Flags::kAdvertisingEnabled); +} + +inline bool BLEManagerImpl::_IsAdvertising(void) +{ + return mFlags.Has(Flags::kAdvertising); +} + +} // namespace Internal +} // namespace DeviceLayer +} // namespace chip + +#endif // CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE diff --git a/src/platform/qcc74x/common/BlePlatformConfig.h b/src/platform/qcc74x/common/BlePlatformConfig.h new file mode 100644 index 00000000000000..8579667417a7c9 --- /dev/null +++ b/src/platform/qcc74x/common/BlePlatformConfig.h @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2022 Project CHIP Authors + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +// ==================== Platform Adaptations ==================== + +struct bt_conn; +#define BLE_CONNECTION_OBJECT bt_conn * +#define BLE_CONNECTION_UNINITIALIZED nullptr +#define BLE_MAX_RECEIVE_WINDOW_SIZE 5 diff --git a/src/platform/qcc74x/common/CHIPDevicePlatformConfig.h b/src/platform/qcc74x/common/CHIPDevicePlatformConfig.h new file mode 100644 index 00000000000000..bc34d9124b6d92 --- /dev/null +++ b/src/platform/qcc74x/common/CHIPDevicePlatformConfig.h @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2022 Project CHIP Authors + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#if CHIP_DEVICE_CONFIG_ENABLE_WIFI +#define CHIP_DEVICE_CONFIG_ENABLE_WIFI_STATION 1 +#define CHIP_DEVICE_CONFIG_ENABLE_WIFI_AP 0 +#else +#define CHIP_DEVICE_CONFIG_ENABLE_WIFI_STATION 0 +#define CHIP_DEVICE_CONFIG_ENABLE_WIFI_AP 0 +#endif + +#ifndef CHIP_DEVICE_CONFIG_ENABLE_ETHERNET +#define CHIP_DEVICE_CONFIG_ENABLE_ETHERNET 0 +#endif + +#if CHIP_ENABLE_OPENTHREAD +#define CHIP_DEVICE_CONFIG_ENABLE_THREAD 1 +#define CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT 1 +#define CHIP_DEVICE_CONFIG_ENABLE_THREAD_DNS_CLIENT 1 +#else +#define CHIP_DEVICE_CONFIG_ENABLE_THREAD 0 +#define CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT 0 +#define CHIP_DEVICE_CONFIG_ENABLE_THREAD_DNS_CLIENT 0 +#endif + +#define CHIP_DEVICE_CONFIG_ENABLE_EXTENDED_DISCOVERY 1 + +#define CHIP_DEVICE_CONFIG_ENABLE_WIFI_TELEMETRY 0 +#define CHIP_DEVICE_CONFIG_ENABLE_THREAD_TELEMETRY 0 +#define CHIP_DEVICE_CONFIG_ENABLE_THREAD_TELEMETRY_FULL 0 + +#define CHIP_DEVICE_CONFIG_CHIP_TASK_STACK_SIZE (8 * 1024) +#define CHIP_DEVICE_CONFIG_MAX_EVENT_QUEUE_SIZE 50 + +#ifndef CONFIG_BOUFFALOLAB_FACTORY_DATA_ENABLE +#define CONFIG_BOUFFALOLAB_FACTORY_DATA_ENABLE 0 +#endif + +#if CHIP_DEVICE_LAYER_TARGET_BL602 +#define CHIP_CONFIG_FREERTOS_USE_STATIC_TASK 1 +#define CHIP_CONFIG_FREERTOS_USE_STATIC_SEMAPHORE 1 +#define CHIP_CONFIG_FREERTOS_USE_STATIC_QUEUE 1 +#elif CHIP_DEVICE_LAYER_TARGET_BL702 +#define CHIP_CONFIG_FREERTOS_USE_STATIC_TASK 1 +#endif diff --git a/src/platform/qcc74x/common/CHIPDevicePlatformEvent.h b/src/platform/qcc74x/common/CHIPDevicePlatformEvent.h new file mode 100644 index 00000000000000..c41a791fec4099 --- /dev/null +++ b/src/platform/qcc74x/common/CHIPDevicePlatformEvent.h @@ -0,0 +1,102 @@ +/* + * Copyright (c) 2022 Project CHIP Authors + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include +#include + +#if CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE +#include +#include +#endif + +namespace chip { +namespace DeviceLayer { + +namespace DeviceEventType { + +/** + * Enumerates Bouffalo Lab platforms event types that are visible to the application. + */ +enum PublicPlatformSpecificEventTypes +{ + /* None currently defined */ +}; + +/** + * Enumerates Bouffalo Lab platforms event types that are internal to the chip Device Layer. + */ +enum InternalPlatformSpecificEventTypes +{ + kPlatformZephyrEvent = kRange_InternalPlatformSpecific, + kPlatformZephyrBleConnected, + kPlatformZephyrBleDisconnected, + kPlatformZephyrBleCCCWrite, + kPlatformZephyrBleC1WriteEvent, + kPlatformZephyrBleC2IndDoneEvent, + kPlatformZephyrBleOutOfBuffersEvent, +}; + +} // namespace DeviceEventType + +#if CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE +struct BleConnEventType +{ + bt_conn * BtConn; + uint8_t HciResult; +}; + +struct BleCCCWriteEventType +{ + bt_conn * BtConn; + uint16_t Value; +}; + +struct BleC1WriteEventType +{ + bt_conn * BtConn; + ::chip::System::PacketBuffer * Data; +}; + +struct BleC2IndDoneEventType +{ + bt_conn * BtConn; + uint8_t Result; +}; + +/** + * Represents platform-specific event information for Bouffalo Lab platforms. + */ +struct ChipDevicePlatformEvent final +{ + union + { + BleConnEventType BleConnEvent; + BleCCCWriteEventType BleCCCWriteEvent; + BleC1WriteEventType BleC1WriteEvent; + BleC2IndDoneEventType BleC2IndDoneEvent; + }; +}; +#else +struct ChipDevicePlatformEvent final +{ +}; +#endif + +} // namespace DeviceLayer +} // namespace chip diff --git a/src/platform/qcc74x/common/CHIPPlatformConfig.h b/src/platform/qcc74x/common/CHIPPlatformConfig.h new file mode 100644 index 00000000000000..94fe3e715580c8 --- /dev/null +++ b/src/platform/qcc74x/common/CHIPPlatformConfig.h @@ -0,0 +1,90 @@ +/* + * Copyright (c) 2022 Project CHIP Authors + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include + +extern "C" void bflb_assert(void); +#define CHIP_CONFIG_ABORT() bflb_assert() + +// ==================== General Platform Adaptations ==================== +#define CHIP_CONFIG_PERSISTED_STORAGE_KEY_TYPE const char * +#define CHIP_CONFIG_PERSISTED_STORAGE_ENC_MSG_CNTR_ID 1 +#define CHIP_CONFIG_PERSISTED_STORAGE_MAX_KEY_LENGTH 2 + +#define CHIP_CONFIG_LIFETIIME_PERSISTED_COUNTER_KEY BLConfig::kConfigKey_LifeTimeCounter + +// ==================== Security Adaptations ==================== +#define CHIP_CONFIG_AES_IMPLEMENTATION_OPENSSL 0 +#define CHIP_CONFIG_AES_IMPLEMENTATION_AESNI 0 +#define CHIP_CONFIG_AES_IMPLEMENTATION_MBEDTLS 1 +#define CHIP_CONFIG_AES_IMPLEMENTATION_PLATFORM 0 + +#define CHIP_CONFIG_RNG_IMPLEMENTATION_OPENSSL 0 +#define CHIP_CONFIG_RNG_IMPLEMENTATION_CHIPDRBG 1 +#define CHIP_CONFIG_RNG_IMPLEMENTATION_PLATFORM 0 + +#define CHIP_CONFIG_ENABLE_PASE_INITIATOR 0 +#define CHIP_CONFIG_ENABLE_PASE_RESPONDER 1 +#define CHIP_CONFIG_ENABLE_CASE_INITIATOR 1 + +#define CHIP_CONFIG_SUPPORT_PASE_CONFIG0 0 +#define CHIP_CONFIG_SUPPORT_PASE_CONFIG1 0 +#define CHIP_CONFIG_SUPPORT_PASE_CONFIG2 0 +#define CHIP_CONFIG_SUPPORT_PASE_CONFIG3 0 +#define CHIP_CONFIG_SUPPORT_PASE_CONFIG4 1 + +#define CHIP_CONFIG_ENABLE_KEY_EXPORT_INITIATOR 0 + +#define CHIP_CONFIG_ENABLE_PROVISIONING_BUNDLE_SUPPORT 0 + +// ==================== General Configuration Overrides ==================== + +#ifndef CHIP_CONFIG_MAX_UNSOLICITED_MESSAGE_HANDLERS +#define CHIP_CONFIG_MAX_UNSOLICITED_MESSAGE_HANDLERS 8 +#endif // CHIP_CONFIG_MAX_UNSOLICITED_MESSAGE_HANDLERS + +#ifndef CHIP_CONFIG_MAX_EXCHANGE_CONTEXTS +#define CHIP_CONFIG_MAX_EXCHANGE_CONTEXTS 8 +#endif // CHIP_CONFIG_MAX_EXCHANGE_CONTEXTS + +#ifndef CHIP_CONFIG_RMP_TIMER_DEFAULT_PERIOD_SHIFT +#define CHIP_CONFIG_RMP_TIMER_DEFAULT_PERIOD_SHIFT 6 +#endif // CHIP_CONFIG_RMP_TIMER_DEFAULT_PERIOD_SHIFT + +#ifndef CHIP_LOG_FILTERING +#define CHIP_LOG_FILTERING 0 +#endif // CHIP_LOG_FILTERING + +#ifndef CHIP_CONFIG_MAX_INTERFACES +#define CHIP_CONFIG_MAX_INTERFACES 4 +#endif // CHIP_CONFIG_MAX_INTERFACES + +#ifndef CHIP_CONFIG_MAX_LOCAL_ADDR_UDP_ENDPOINTS +#define CHIP_CONFIG_MAX_LOCAL_ADDR_UDP_ENDPOINTS 4 +#endif // CHIP_CONFIG_MAX_LOCAL_ADDR_UDP_ENDPOINTS + +#ifndef CHIP_CONFIG_MAX_FABRICS +#define CHIP_CONFIG_MAX_FABRICS 6 // 5 fabrics + 1 for rotation slack +#endif + +// ==================== Security Configuration Overrides ==================== + +#ifndef CHIP_CONFIG_DEBUG_CERT_VALIDATION +#define CHIP_CONFIG_DEBUG_CERT_VALIDATION 0 +#endif // CHIP_CONFIG_DEBUG_CERT_VALIDATION diff --git a/src/platform/qcc74x/common/ConfigurationManagerImpl.cpp b/src/platform/qcc74x/common/ConfigurationManagerImpl.cpp new file mode 100644 index 00000000000000..4495a7a08ade1b --- /dev/null +++ b/src/platform/qcc74x/common/ConfigurationManagerImpl.cpp @@ -0,0 +1,210 @@ +/* + * Copyright (c) 2022 Project CHIP Authors + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#include + +#include + +extern "C" void hal_reboot(void); + +namespace chip { +namespace DeviceLayer { + +using namespace ::chip::DeviceLayer::Internal; +ConfigurationManagerImpl & ConfigurationManagerImpl::GetDefaultInstance() +{ + static ConfigurationManagerImpl sInstance; + return sInstance; +} +bool ConfigurationManagerImpl::IsFullyProvisioned() +{ + return +#if CHIP_DEVICE_CONFIG_ENABLE_WIFI_STATION + ConnectivityMgr().IsWiFiStationProvisioned() && +#endif +#if CHIP_DEVICE_CONFIG_ENABLE_THREAD + ConnectivityMgr().IsThreadProvisioned() && +#endif + true; +} +CHIP_ERROR ConfigurationManagerImpl::Init() +{ + CHIP_ERROR err; + uint32_t rebootCount = 0; + + err = Internal::GenericConfigurationManagerImpl::Init(); + SuccessOrExit(err); + + if (BLConfig::ConfigValueExists(BLConfig::kCounterKey_RebootCount)) + { + err = GetRebootCount(rebootCount); + SuccessOrExit(err); + } + else + { + rebootCount = 0; + } + err = StoreRebootCount(rebootCount + 1); + SuccessOrExit(err); + + if (!BLConfig::ConfigValueExists(BLConfig::kCounterKey_TotalOperationalHours)) + { + err = StoreTotalOperationalHours(0); + SuccessOrExit(err); + } + + err = CHIP_NO_ERROR; + +exit: + return err; +} + +bool ConfigurationManagerImpl::CanFactoryReset() +{ + // TODO: query the application to determine if factory reset is allowed. + return true; +} + +void ConfigurationManagerImpl::InitiateFactoryReset() +{ + PlatformMgr().ScheduleWork(DoFactoryReset); +} + +CHIP_ERROR ConfigurationManagerImpl::GetRebootCount(uint32_t & rebootCount) +{ + return BLConfig::ReadConfigValue(BLConfig::kCounterKey_RebootCount, rebootCount); +} + +CHIP_ERROR ConfigurationManagerImpl::StoreRebootCount(uint32_t rebootCount) +{ + return BLConfig::WriteConfigValue(BLConfig::kCounterKey_RebootCount, rebootCount); +} + +CHIP_ERROR ConfigurationManagerImpl::GetTotalOperationalHours(uint32_t & totalOperationalHours) +{ + return ReadConfigValue(BLConfig::kCounterKey_TotalOperationalHours, totalOperationalHours); +} + +CHIP_ERROR ConfigurationManagerImpl::StoreTotalOperationalHours(uint32_t totalOperationalHours) +{ + return WriteConfigValue(BLConfig::kCounterKey_TotalOperationalHours, totalOperationalHours); +} + +CHIP_ERROR ConfigurationManagerImpl::ReadPersistedStorageValue(::chip::Platform::PersistedStorage::Key key, uint32_t & value) +{ + BLConfig::Key configKey{ key }; + + CHIP_ERROR err = ReadConfigValue(configKey, value); + if (err == CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND) + { + err = CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND; + } + return err; +} + +CHIP_ERROR ConfigurationManagerImpl::WritePersistedStorageValue(::chip::Platform::PersistedStorage::Key key, uint32_t value) +{ + BLConfig::Key configKey{ key }; + return WriteConfigValue(configKey, value); +} + +CHIP_ERROR ConfigurationManagerImpl::ReadConfigValue(Key key, bool & val) +{ + return BLConfig::ReadConfigValue(key, val); +} + +CHIP_ERROR ConfigurationManagerImpl::ReadConfigValue(Key key, uint32_t & val) +{ + return BLConfig::ReadConfigValue(key, val); +} + +CHIP_ERROR ConfigurationManagerImpl::ReadConfigValue(Key key, uint64_t & val) +{ + return BLConfig::ReadConfigValue(key, val); +} + +CHIP_ERROR ConfigurationManagerImpl::ReadConfigValueStr(Key key, char * buf, size_t bufSize, size_t & outLen) +{ + return BLConfig::ReadConfigValueStr(key, buf, bufSize, outLen); +} + +CHIP_ERROR ConfigurationManagerImpl::ReadConfigValueBin(Key key, uint8_t * buf, size_t bufSize, size_t & outLen) +{ + return BLConfig::ReadConfigValueBin(key, buf, bufSize, outLen); +} + +CHIP_ERROR ConfigurationManagerImpl::WriteConfigValue(Key key, bool val) +{ + return BLConfig::WriteConfigValue(key, val); +} + +CHIP_ERROR ConfigurationManagerImpl::WriteConfigValue(Key key, uint32_t val) +{ + return BLConfig::WriteConfigValue(key, val); +} + +CHIP_ERROR ConfigurationManagerImpl::WriteConfigValue(Key key, uint64_t val) +{ + return BLConfig::WriteConfigValue(key, val); +} + +CHIP_ERROR ConfigurationManagerImpl::WriteConfigValueStr(Key key, const char * str) +{ + return BLConfig::WriteConfigValueStr(key, str); +} + +CHIP_ERROR ConfigurationManagerImpl::WriteConfigValueStr(Key key, const char * str, size_t strLen) +{ + return BLConfig::WriteConfigValueStr(key, str, strLen); +} + +CHIP_ERROR ConfigurationManagerImpl::WriteConfigValueBin(Key key, const uint8_t * data, size_t dataLen) +{ + return BLConfig::WriteConfigValueBin(key, data, dataLen); +} + +void ConfigurationManagerImpl::RunConfigUnitTest(void) +{ + BLConfig::RunConfigUnitTest(); +} + +void ConfigurationManagerImpl::DoFactoryReset(intptr_t arg) +{ + CHIP_ERROR err; + + ChipLogProgress(DeviceLayer, "Performing factory reset"); + + err = BLConfig::FactoryResetConfig(); + if (err != CHIP_NO_ERROR) + { + ChipLogError(DeviceLayer, "FactoryResetConfig() failed: %s", ErrorStr(err)); + } + + // Restart the system. + ChipLogProgress(DeviceLayer, "System restarting"); + + hal_reboot(); +} + +ConfigurationManager & ConfigurationMgrImpl() +{ + return ConfigurationManagerImpl::GetDefaultInstance(); +} +} // namespace DeviceLayer +} // namespace chip diff --git a/src/platform/qcc74x/common/ConfigurationManagerImpl.h b/src/platform/qcc74x/common/ConfigurationManagerImpl.h new file mode 100644 index 00000000000000..02716d565dcefa --- /dev/null +++ b/src/platform/qcc74x/common/ConfigurationManagerImpl.h @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2022 Project CHIP Authors + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include + +#include + +namespace chip { +namespace DeviceLayer { + +/** + * Concrete implementation of the ConfigurationManager singleton object for the Bouffalo Lab platform. + */ +class ConfigurationManagerImpl : public Internal::GenericConfigurationManagerImpl +{ +public: + static ConfigurationManagerImpl & GetDefaultInstance(); + + CHIP_ERROR GetRebootCount(uint32_t & rebootCount); + CHIP_ERROR StoreRebootCount(uint32_t rebootCount); + CHIP_ERROR GetTotalOperationalHours(uint32_t & totalOperationalHours); + CHIP_ERROR StoreTotalOperationalHours(uint32_t totalOperationalHours); + bool IsFullyProvisioned(); + +private: + // ===== Members that implement the ConfigurationManager private interface. + + CHIP_ERROR Init(void) override; + + bool CanFactoryReset(void) override; + void InitiateFactoryReset(void) override; + CHIP_ERROR ReadPersistedStorageValue(::chip::Platform::PersistedStorage::Key key, uint32_t & value) override; + CHIP_ERROR WritePersistedStorageValue(::chip::Platform::PersistedStorage::Key key, uint32_t value) override; + + CHIP_ERROR ReadConfigValue(Key key, bool & val) override; + CHIP_ERROR ReadConfigValue(Key key, uint32_t & val) override; + CHIP_ERROR ReadConfigValue(Key key, uint64_t & val) override; + CHIP_ERROR ReadConfigValueStr(Key key, char * buf, size_t bufSize, size_t & outLen) override; + CHIP_ERROR ReadConfigValueBin(Key key, uint8_t * buf, size_t bufSize, size_t & outLen) override; + CHIP_ERROR WriteConfigValue(Key key, bool val) override; + CHIP_ERROR WriteConfigValue(Key key, uint32_t val) override; + CHIP_ERROR WriteConfigValue(Key key, uint64_t val) override; + CHIP_ERROR WriteConfigValueStr(Key key, const char * str) override; + CHIP_ERROR WriteConfigValueStr(Key key, const char * str, size_t strLen) override; + CHIP_ERROR WriteConfigValueBin(Key key, const uint8_t * data, size_t dataLen) override; + void RunConfigUnitTest(void) override; + +#if CHIP_DEVICE_CONFIG_ENABLE_WIFI + CHIP_ERROR GetPrimaryWiFiMACAddress(uint8_t * buf) override; +#endif + +#if CHIP_DEVICE_CONFIG_ENABLE_ETHERNET + CHIP_ERROR GetPrimaryMACAddress(MutableByteSpan buf) override; +#endif + + static void DoFactoryReset(intptr_t arg); +}; + +} // namespace DeviceLayer +} // namespace chip diff --git a/src/platform/qcc74x/common/ConnectivityManagerImpl.cpp b/src/platform/qcc74x/common/ConnectivityManagerImpl.cpp new file mode 100644 index 00000000000000..ff8f238a5af291 --- /dev/null +++ b/src/platform/qcc74x/common/ConnectivityManagerImpl.cpp @@ -0,0 +1,347 @@ +/* + * Copyright (c) 2022 Project CHIP Authors + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#include +#include +#include +#include +#include +#include +#include + +#include + +#if INET_CONFIG_ENABLE_TCP_ENDPOINT +#include +#endif + +#if CHIP_DEVICE_CONFIG_ENABLE_WIFI +#include +#if CHIP_DEVICE_LAYER_TARGET_BL602 +#include +#endif +#if CHIP_DEVICE_LAYER_TARGET_BL702 +#include +#endif +#if CHIP_DEVICE_LAYER_TARGET_QCC743 +#include +#endif +#endif + +#if CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE +#include +#include +#endif + +#if CHIP_DEVICE_CONFIG_ENABLE_THREAD +#include +#endif + +using namespace ::chip; +using namespace ::chip::Inet; +using namespace ::chip::System; +using namespace ::chip::TLV; +using namespace ::chip::DeviceLayer::Internal; + +namespace chip { +namespace DeviceLayer { + +ConnectivityManagerImpl ConnectivityManagerImpl::sInstance; + +CHIP_ERROR ConnectivityManagerImpl::_Init() +{ + // Initialize the generic base classes that require it. +#if CHIP_DEVICE_CONFIG_ENABLE_THREAD + GenericConnectivityManagerImpl_Thread::_Init(); +#endif + +#if CHIP_DEVICE_CONFIG_ENABLE_WIFI + mWiFiStationState = ConnectivityManager::kWiFiStationState_NotConnected; + ReturnErrorOnFailure(SetWiFiStationMode(kWiFiStationMode_Enabled)); + + PlatformMgr().AddEventHandler(NetworkCommissioning::NetworkEventHandler, 0); +#endif + + return CHIP_NO_ERROR; +} + +void ConnectivityManagerImpl::_OnPlatformEvent(const ChipDeviceEvent * event) +{ + // Forward the event to the generic base classes as needed. +#if CHIP_DEVICE_CONFIG_ENABLE_THREAD + GenericConnectivityManagerImpl_Thread::_OnPlatformEvent(event); +#endif +} + +#if CHIP_DEVICE_CONFIG_ENABLE_WIFI +bool ConnectivityManagerImpl::_IsWiFiStationEnabled(void) +{ + return GetWiFiStationMode() == kWiFiStationMode_Enabled; +} + +bool ConnectivityManagerImpl::_IsWiFiStationProvisioned(void) +{ + CHIP_ERROR err = CHIP_NO_ERROR; + char ssid[64] = { 0 }; + char psk[64] = { 0 }; + size_t ssidLen = 0; + size_t pskLen = 0; + + err = PersistedStorage::KeyValueStoreMgr().Get(BLConfig::kConfigKey_WiFiSSID, (void *) ssid, 64, &ssidLen, 0); + SuccessOrExit(err); + + err = PersistedStorage::KeyValueStoreMgr().Get(BLConfig::kConfigKey_WiFiPassword, (void *) psk, 64, &pskLen, 0); + SuccessOrExit(err); + + return (ssidLen != 0); +exit: + return false; +} + +CHIP_ERROR ConnectivityManagerImpl::_SetWiFiStationMode(WiFiStationMode val) +{ + CHIP_ERROR err = CHIP_NO_ERROR; + + VerifyOrExit(val != kWiFiStationMode_NotSupported, err = CHIP_ERROR_INVALID_ARGUMENT); + + if (val != kWiFiStationMode_ApplicationControlled) + { + DeviceLayer::SystemLayer().ScheduleWork(DriveStationState, NULL); + } + + if (mWiFiStationMode != val) + { + ChipLogProgress(DeviceLayer, "WiFi station mode change: %s -> %s", WiFiStationModeToStr(mWiFiStationMode), + WiFiStationModeToStr(val)); + } + + mWiFiStationMode = val; + +exit: + return err; +} + +void ConnectivityManagerImpl::ChangeWiFiStationState(WiFiStationState newState) +{ + if (mWiFiStationState != newState) + { + ChipLogProgress(DeviceLayer, "WiFi station state change: %s -> %s", WiFiStationStateToStr(mWiFiStationState), + WiFiStationStateToStr(newState)); + mWiFiStationState = newState; + ConnectivityMgrImpl().DriveStationState(); + SystemLayer().ScheduleLambda([]() { NetworkCommissioning::BLWiFiDriver::GetInstance().OnNetworkStatusChange(); }); + } +} + +void ConnectivityManagerImpl::_ClearWiFiStationProvision(void) +{ + CHIP_ERROR err = CHIP_NO_ERROR; + + err = PersistedStorage::KeyValueStoreMgr().Delete(BLConfig::kConfigKey_WiFiSSID); + SuccessOrExit(err); + + err = PersistedStorage::KeyValueStoreMgr().Delete(BLConfig::kConfigKey_WiFiPassword); + SuccessOrExit(err); + +exit: + return; +} + +void ConnectivityManagerImpl::_OnWiFiStationProvisionChange(void) +{ + DeviceLayer::SystemLayer().ScheduleWork(DriveStationState, NULL); +} + +CHIP_ERROR ConnectivityManagerImpl::ConnectProvisionedWiFiNetwork(void) +{ + char ssid[64] = { 0 }; + char psk[64] = { 0 }; + size_t ssidLen = 0; + size_t pskLen = 0; + + ReturnErrorOnFailure(PersistedStorage::KeyValueStoreMgr().Get(BLConfig::kConfigKey_WiFiSSID, (void *) ssid, 64, &ssidLen, 0)); + ReturnErrorOnFailure(PersistedStorage::KeyValueStoreMgr().Get(BLConfig::kConfigKey_WiFiPassword, (void *) psk, 64, &pskLen, 0)); + + NetworkCommissioning::BLWiFiDriver::GetInstance().ConnectWiFiNetwork(ssid, ssidLen, psk, pskLen); + + return CHIP_NO_ERROR; +} + +void ConnectivityManagerImpl::OnWiFiStationConnected() +{ + ChipDeviceEvent event; + event.Type = DeviceEventType::kWiFiConnectivityChange; + event.WiFiConnectivityChange.Result = kConnectivity_Established; + PlatformMgr().PostEventOrDie(&event); + + WiFiDiagnosticsDelegate * delegate = GetDiagnosticDataProvider().GetWiFiDiagnosticsDelegate(); + if (delegate) + { + delegate->OnConnectionStatusChanged( + chip::to_underlying(chip::app::Clusters::WiFiNetworkDiagnostics::ConnectionStatusEnum::kConnected)); + } +} + +void ConnectivityManagerImpl::DriveStationState() +{ + ChipLogProgress(DeviceLayer, "DriveStationState: mWiFiStationState=%s", WiFiStationStateToStr(mWiFiStationState)); + switch (mWiFiStationState) + { + case ConnectivityManager::kWiFiStationState_NotConnected: { + if (GetWiFiStationMode() == ConnectivityManager::kWiFiStationMode_Enabled && IsWiFiStationProvisioned()) + { + ConnectProvisionedWiFiNetwork(); + } + } + break; + case ConnectivityManager::kWiFiStationState_Connecting: { + ChipLogProgress(DeviceLayer, "Wi-Fi station is connecting to AP"); + } + break; + case ConnectivityManager::kWiFiStationState_Connecting_Succeeded: { + ChipLogProgress(DeviceLayer, "Wi-Fi station successfully connects to AP"); + mConnectivityFlag.ClearAll(); + mConnectivityFlag.Set(ConnectivityFlags::kAwaitingConnectivity); + } + break; + case ConnectivityManager::kWiFiStationState_Connecting_Failed: { + ChipLogProgress(DeviceLayer, "Wi-Fi station connecting failed"); + mConnectivityFlag.ClearAll(); + OnWiFiStationDisconnected(); + if (ConnectivityManager::kWiFiStationState_Connecting == mWiFiStationState) + { + SystemLayer().ScheduleLambda([]() { NetworkCommissioning::BLWiFiDriver::GetInstance().OnConnectWiFiNetwork(false); }); + } + } + break; + case ConnectivityManager::kWiFiStationState_Connected: { + ChipLogProgress(DeviceLayer, "Wi-Fi station connected."); + OnWiFiStationConnected(); + SystemLayer().ScheduleLambda([]() { NetworkCommissioning::BLWiFiDriver::GetInstance().OnConnectWiFiNetwork(true); }); + } + break; + case ConnectivityManager::kWiFiStationState_Disconnecting: { + ChipLogProgress(DeviceLayer, "Wi-Fi station is disconnecting to AP"); + mConnectivityFlag.ClearAll(); + } + break; + default: + break; + } +} + +void ConnectivityManagerImpl::DriveStationState(::chip::System::Layer * aLayer, void * aAppState) +{ + ConnectivityMgrImpl().DriveStationState(); +} +#endif + +#if CHIP_DEVICE_CONFIG_ENABLE_ETHERNET || CHIP_DEVICE_CONFIG_ENABLE_WIFI +void ConnectivityManagerImpl::OnConnectivityChanged(struct netif * interface) +{ + bool haveIPv4Conn = false; + bool haveIPv6Conn = false; + const bool hadIPv4Conn = mConnectivityFlag.Has(ConnectivityFlags::kHaveIPv4InternetConnectivity); + const bool hadIPv6Conn = mConnectivityFlag.Has(ConnectivityFlags::kHaveIPv6InternetConnectivity); + IPAddress addr; + + if (interface != NULL && netif_is_up(interface) && netif_is_link_up(interface)) + { + mConnectivityFlag.Clear(ConnectivityFlags::kAwaitingConnectivity); + + if (!ip4_addr_isany(netif_ip4_addr(interface)) && !ip4_addr_isany(netif_ip4_gw(interface))) + { + haveIPv4Conn = true; + char addrStr[INET_ADDRSTRLEN]; + ip4addr_ntoa_r(netif_ip4_addr(interface), addrStr, sizeof(addrStr)); + IPAddress::FromString(addrStr, addr); + if (0 != memcmp(netif_ip4_addr(interface), &m_ip4addr, sizeof(ip4_addr_t))) + { + ChipLogProgress(DeviceLayer, "IPv4 Address Assigned, %s", ip4addr_ntoa(netif_ip4_addr(interface))); + memcpy(&m_ip4addr, netif_ip4_addr(interface), sizeof(ip4_addr_t)); + ConnectivityMgrImpl().OnIPv4AddressAvailable(); + } + } + + // Search among the IPv6 addresses assigned to the interface for a Global Unicast + // address (2000::/3) that is in the valid state. If such an address is found... + for (uint32_t i = 0; i < LWIP_IPV6_NUM_ADDRESSES; i++) + { + if (!ip6_addr_islinklocal(netif_ip6_addr(interface, i)) && ip6_addr_isvalid(netif_ip6_addr_state(interface, i))) + { + haveIPv6Conn = true; + if (0 != memcmp(netif_ip6_addr(interface, i), m_ip6addr + i, sizeof(ip6_addr_t))) + { + ChipLogProgress(DeviceLayer, "IPv6 Address Assigned, %s", ip6addr_ntoa(netif_ip6_addr(interface, i))); + memcpy(m_ip6addr + i, netif_ip6_addr(interface, i), sizeof(ip6_addr_t)); + ConnectivityMgrImpl().OnIPv6AddressAvailable(); + } + } + } + } + + // If the internet connectivity state has changed... + if (haveIPv4Conn != hadIPv4Conn || haveIPv6Conn != hadIPv6Conn) + { + // Update the current state. + mConnectivityFlag.Set(ConnectivityFlags::kHaveIPv4InternetConnectivity, haveIPv4Conn); + mConnectivityFlag.Set(ConnectivityFlags::kHaveIPv6InternetConnectivity, haveIPv6Conn); + + // Alert other components of the state change. + ChipDeviceEvent event; + event.Type = DeviceEventType::kInternetConnectivityChange; + event.InternetConnectivityChange.IPv4 = GetConnectivityChange(hadIPv4Conn, haveIPv4Conn); + event.InternetConnectivityChange.IPv6 = GetConnectivityChange(hadIPv6Conn, haveIPv6Conn); + event.InternetConnectivityChange.ipAddress = addr; + PlatformMgr().PostEventOrDie(&event); + + if (haveIPv4Conn != hadIPv4Conn) + { + memset(&m_ip4addr, 0, sizeof(ip4_addr_t)); + ChipLogProgress(DeviceLayer, "%s Internet connectivity %s", "IPv4", (haveIPv4Conn) ? "ESTABLISHED" : "LOST"); + } + + if (haveIPv6Conn != hadIPv6Conn) + { + memset(&m_ip6addr, 0, sizeof(ip6_addr_t) * LWIP_IPV6_NUM_ADDRESSES); + ChipLogProgress(DeviceLayer, "%s Internet connectivity %s", "IPv6", (haveIPv6Conn) ? "ESTABLISHED" : "LOST"); + } + } +} + +void ConnectivityManagerImpl::OnIPv4AddressAvailable() +{ + ChipDeviceEvent event; + event.Type = DeviceEventType::kInterfaceIpAddressChanged; + event.InterfaceIpAddressChanged.Type = InterfaceIpChangeType::kIpV4_Assigned; + PlatformMgr().PostEventOrDie(&event); +} + +void ConnectivityManagerImpl::OnIPv6AddressAvailable() +{ + ChipDeviceEvent event; + event.Type = DeviceEventType::kInterfaceIpAddressChanged; + event.InterfaceIpAddressChanged.Type = InterfaceIpChangeType::kIpV6_Assigned; + PlatformMgr().PostEventOrDie(&event); +} + +#endif + +} // namespace DeviceLayer +} // namespace chip diff --git a/src/platform/qcc74x/common/ConnectivityManagerImpl.h b/src/platform/qcc74x/common/ConnectivityManagerImpl.h new file mode 100644 index 00000000000000..80b1d980d4f9d1 --- /dev/null +++ b/src/platform/qcc74x/common/ConnectivityManagerImpl.h @@ -0,0 +1,181 @@ +/* + * Copyright (c) 2022 Project CHIP Authors + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include +#include +#include +#if INET_CONFIG_ENABLE_TCP_ENDPOINT +#include +#endif +#if CHIP_DEVICE_CONFIG_ENABLE_WIFI +#include +#else +#include +#endif +#if CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE +#include +#else +#include +#endif +#if CHIP_DEVICE_CONFIG_ENABLE_THREAD +#include +#else +#include +#endif + +namespace chip { +namespace DeviceLayer { + +enum +{ + kWiFiOnInitDone = DeviceEventType::kRange_PublicPlatformSpecific, + kWiFiOnScanDone, + kWiFiOnConnected, + kGotIpAddress, + kGotIpv6Address, + kWiFiOnDisconnected, +}; + +class ConnectivityManagerImpl final : public ConnectivityManager, + public Internal::GenericConnectivityManagerImpl, + public Internal::GenericConnectivityManagerImpl_UDP, +#if INET_CONFIG_ENABLE_TCP_ENDPOINT + public Internal::GenericConnectivityManagerImpl_TCP, +#endif +#if CHIP_DEVICE_CONFIG_ENABLE_WIFI + public Internal::GenericConnectivityManagerImpl_WiFi, +#else + public Internal::GenericConnectivityManagerImpl_NoWiFi, +#endif +#if CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE + public Internal::GenericConnectivityManagerImpl_BLE, +#else + public Internal::GenericConnectivityManagerImpl_NoBLE, +#endif +#if CHIP_DEVICE_CONFIG_ENABLE_THREAD + public Internal::GenericConnectivityManagerImpl_Thread +#else + public Internal::GenericConnectivityManagerImpl_NoThread +#endif +{ + // Allow the ConnectivityManager interface class to delegate method calls to + // the implementation methods provided by this class. + friend class ConnectivityManager; + friend void netif_status_callback(struct netif * netif); + +public: +#if CHIP_DEVICE_CONFIG_ENABLE_WIFI + bool _IsWiFiStationConnected(void); + WiFiStationState GetWiFiStationState(void); + void ChangeWiFiStationState(WiFiStationState newState); + void OnWiFiStationStateChanged(void); + void OnWiFiStationConnected(void); + void OnWiFiStationDisconnected(void); +#endif + +#if CHIP_DEVICE_CONFIG_ENABLE_WIFI || CHIP_DEVICE_CONFIG_ENABLE_ETHERNET + void OnConnectivityChanged(struct netif * interface); + void OnIPv4AddressAvailable(); + void OnIPv6AddressAvailable(); +#endif + +private: + // ===== Members that implement the ConnectivityManager abstract interface. +#if CHIP_DEVICE_CONFIG_ENABLE_WIFI + WiFiStationMode mWiFiStationMode; + WiFiStationState mWiFiStationState; + + BitFlags mConnectivityFlag; + + bool _IsWiFiStationEnabled(void); + ConnectivityManager::WiFiStationMode _GetWiFiStationMode(); + CHIP_ERROR _SetWiFiStationMode(WiFiStationMode val); + bool _IsWiFiStationProvisioned(void); + void _ClearWiFiStationProvision(); + void _OnWiFiStationProvisionChange(); + CHIP_ERROR ConnectProvisionedWiFiNetwork(); +#endif + +#if CHIP_DEVICE_CONFIG_ENABLE_ETHERNET + enum class ConnectivityFlags : uint16_t{ + kHaveIPv4InternetConnectivity = 0x0001, + kHaveIPv6InternetConnectivity = 0x0002, + kAwaitingConnectivity = 0x0010, + }; + BitFlags mConnectivityFlag; +#endif + +#if CHIP_DEVICE_CONFIG_ENABLE_WIFI || CHIP_DEVICE_CONFIG_ENABLE_ETHERNET + ip4_addr_t m_ip4addr; + ip6_addr_t m_ip6addr[LWIP_IPV6_NUM_ADDRESSES]; +#endif + + void DriveStationState(void); + static void DriveStationState(::chip::System::Layer * aLayer, void * aAppState); + CHIP_ERROR _Init(void); + void _OnPlatformEvent(const ChipDeviceEvent * event); + + // ===== Members for internal use by the following friends. + friend ConnectivityManager & ConnectivityMgr(void); + friend ConnectivityManagerImpl & ConnectivityMgrImpl(void); + + static ConnectivityManagerImpl sInstance; +}; + +#if CHIP_DEVICE_CONFIG_ENABLE_WIFI +inline ConnectivityManager::WiFiStationState ConnectivityManagerImpl::GetWiFiStationState(void) +{ + return mWiFiStationState; +} + +inline bool ConnectivityManagerImpl::_IsWiFiStationConnected(void) +{ + return mWiFiStationState == kWiFiStationState_Connected; +} + +inline ConnectivityManager::WiFiStationMode ConnectivityManagerImpl::_GetWiFiStationMode(void) +{ + return kWiFiStationMode_Enabled; +} +#endif + +/** + * Returns the public interface of the ConnectivityManager singleton object. + * + * Chip applications should use this to access features of the ConnectivityManager object + * that are common to all platforms. + */ +inline ConnectivityManager & ConnectivityMgr(void) +{ + return ConnectivityManagerImpl::sInstance; +} + +/** + * Returns the platform-specific implementation of the ConnectivityManager singleton object. + * + * Chip applications can use this to gain access to features of the ConnectivityManager + * that are specific to the Bouffalo Lab platform. + */ +inline ConnectivityManagerImpl & ConnectivityMgrImpl(void) +{ + return ConnectivityManagerImpl::sInstance; +} + +} // namespace DeviceLayer +} // namespace chip diff --git a/src/platform/qcc74x/common/DiagnosticDataProviderImpl.cpp b/src/platform/qcc74x/common/DiagnosticDataProviderImpl.cpp new file mode 100644 index 00000000000000..3efce0117f95a3 --- /dev/null +++ b/src/platform/qcc74x/common/DiagnosticDataProviderImpl.cpp @@ -0,0 +1,297 @@ +/* + * Copyright (c) 2022 Project CHIP Authors + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#include + +#include +#include + +#include +#if CHIP_DEVICE_LAYER_TARGET_QCC743 +#include +#endif +namespace chip { +namespace DeviceLayer { + +extern "C" size_t get_heap_size(void); +#ifdef CFG_USE_PSRAM +extern "C" size_t get_heap3_size(void); +#endif +extern "C" struct netif * deviceInterface_getNetif(void); + +DiagnosticDataProviderImpl & DiagnosticDataProviderImpl::GetDefaultInstance() +{ + static DiagnosticDataProviderImpl sInstance; + return sInstance; +} + +CHIP_ERROR DiagnosticDataProviderImpl::GetCurrentHeapFree(uint64_t & currentHeapFree) +{ +#if CHIP_DEVICE_LAYER_TARGET_QCC743 + struct meminfo info; + bflb_mem_usage(KMEM_HEAP, &info); + currentHeapFree = info.free_size; +#else +#ifdef CFG_USE_PSRAM + currentHeapFree = xPortGetFreeHeapSize() + xPortGetFreeHeapSizePsram(); +#else + currentHeapFree = xPortGetFreeHeapSize(); +#endif +#endif + + return CHIP_NO_ERROR; +} + +CHIP_ERROR DiagnosticDataProviderImpl::GetCurrentHeapUsed(uint64_t & currentHeapUsed) +{ +#if CHIP_DEVICE_LAYER_TARGET_QCC743 + struct meminfo info; + bflb_mem_usage(KMEM_HEAP, &info); + currentHeapUsed = info.total_size - info.free_size; +#else +#ifdef CFG_USE_PSRAM + currentHeapUsed = (get_heap_size() + get_heap3_size() - xPortGetFreeHeapSize() - xPortGetFreeHeapSizePsram()); +#else + currentHeapUsed = (get_heap_size() - xPortGetFreeHeapSize()); +#endif +#endif + + return CHIP_NO_ERROR; +} + +CHIP_ERROR DiagnosticDataProviderImpl::GetCurrentHeapHighWatermark(uint64_t & currentHeapHighWatermark) +{ +#if CHIP_DEVICE_LAYER_TARGET_QCC743 + return CHIP_ERROR_NOT_IMPLEMENTED; +#else +#ifdef CFG_USE_PSRAM + currentHeapHighWatermark = + get_heap_size() + get_heap3_size() - xPortGetMinimumEverFreeHeapSize() - xPortGetMinimumEverFreeHeapSizePsram(); +#else + currentHeapHighWatermark = get_heap_size() - xPortGetMinimumEverFreeHeapSize(); +#endif + return CHIP_NO_ERROR; +#endif +} + +CHIP_ERROR DiagnosticDataProviderImpl::GetThreadMetrics(ThreadMetrics ** threadMetricsOut) +{ + /* Obtain all available task information */ + TaskStatus_t * taskStatusArray; + ThreadMetrics * head = nullptr; + uint32_t arraySize, x, dummy; + + arraySize = uxTaskGetNumberOfTasks(); + + taskStatusArray = static_cast(chip::Platform::MemoryCalloc(arraySize, sizeof(TaskStatus_t))); + + if (taskStatusArray != NULL) + { + /* Generate raw status information about each task. */ + arraySize = uxTaskGetSystemState(taskStatusArray, arraySize, &dummy); + /* For each populated position in the taskStatusArray array, + format the raw data as human readable ASCII data. */ + + for (x = 0; x < arraySize; x++) + { + ThreadMetrics * thread = new ThreadMetrics(); + if (thread) + { + Platform::CopyString(thread->NameBuf, taskStatusArray[x].pcTaskName); + thread->name.Emplace(CharSpan::fromCharString(thread->NameBuf)); + thread->id = taskStatusArray[x].xTaskNumber; + thread->stackFreeMinimum.Emplace(taskStatusArray[x].usStackHighWaterMark); + + /* Unsupported metrics */ + // thread->stackSize + // thread->stackFreeCurrent + + thread->Next = head; + head = thread; + } + } + + *threadMetricsOut = head; + /* The array is no longer needed, free the memory it consumes. */ + chip::Platform::MemoryFree(taskStatusArray); + } + + return CHIP_NO_ERROR; +} + +void DiagnosticDataProviderImpl::ReleaseThreadMetrics(ThreadMetrics * threadMetrics) +{ + while (threadMetrics) + { + ThreadMetrics * del = threadMetrics; + threadMetrics = threadMetrics->Next; + delete del; + } +} + +CHIP_ERROR DiagnosticDataProviderImpl::GetRebootCount(uint16_t & rebootCount) +{ + uint32_t count = 0; + + CHIP_ERROR err = ConfigurationMgr().GetRebootCount(count); + + if (err == CHIP_NO_ERROR) + { + VerifyOrReturnError(count <= UINT16_MAX, CHIP_ERROR_INVALID_INTEGER_VALUE); + rebootCount = static_cast(count); + } + + return err; +} + +CHIP_ERROR DiagnosticDataProviderImpl::GetUpTime(uint64_t & upTime) +{ + System::Clock::Timestamp currentTime = System::SystemClock().GetMonotonicTimestamp(); + System::Clock::Timestamp startTime = PlatformMgrImpl().GetStartTime(); + + if (currentTime >= startTime) + { + upTime = std::chrono::duration_cast(currentTime - startTime).count(); + return CHIP_NO_ERROR; + } + + return CHIP_ERROR_INVALID_TIME; +} + +CHIP_ERROR DiagnosticDataProviderImpl::GetTotalOperationalHours(uint32_t & totalOperationalHours) +{ + uint64_t upTime = 0; + + if (GetUpTime(upTime) == CHIP_NO_ERROR) + { + uint32_t totalHours = 0; + if (ConfigurationMgr().GetTotalOperationalHours(totalHours) == CHIP_NO_ERROR) + { + VerifyOrReturnError(upTime / 3600 <= UINT32_MAX, CHIP_ERROR_INVALID_INTEGER_VALUE); + totalOperationalHours = totalHours + static_cast(upTime / 3600); + return CHIP_NO_ERROR; + } + } + + return CHIP_ERROR_INVALID_TIME; +} + +CHIP_ERROR DiagnosticDataProviderImpl::GetActiveHardwareFaults(GeneralFaults & hardwareFaults) +{ +#if CHIP_CONFIG_TEST + ReturnErrorOnFailure(hardwareFaults.add(to_underlying(HardwareFaultEnum::kRadio))); + ReturnErrorOnFailure(hardwareFaults.add(to_underlying(HardwareFaultEnum::kSensor))); + ReturnErrorOnFailure(hardwareFaults.add(to_underlying(HardwareFaultEnum::kPowerSource))); + ReturnErrorOnFailure(hardwareFaults.add(to_underlying(HardwareFaultEnum::kUserInterfaceFault))); +#endif + + return CHIP_NO_ERROR; +} + +CHIP_ERROR DiagnosticDataProviderImpl::GetActiveRadioFaults(GeneralFaults & radioFaults) +{ +#if CHIP_CONFIG_TEST + ReturnErrorOnFailure(radioFaults.add(to_underlying(RadioFaultEnum::kThreadFault))); + ReturnErrorOnFailure(radioFaults.add(to_underlying(RadioFaultEnum::kBLEFault))); +#endif + + return CHIP_NO_ERROR; +} + +CHIP_ERROR DiagnosticDataProviderImpl::GetActiveNetworkFaults(GeneralFaults & networkFaults) +{ +#if CHIP_CONFIG_TEST + ReturnErrorOnFailure(networkFaults.add(to_underlying(NetworkFaultEnum::kHardwareFailure))); + ReturnErrorOnFailure(networkFaults.add(to_underlying(NetworkFaultEnum::kNetworkJammed))); + ReturnErrorOnFailure(networkFaults.add(to_underlying(NetworkFaultEnum::kConnectionFailed))); +#endif + + return CHIP_NO_ERROR; +} + +CHIP_ERROR DiagnosticDataProviderImpl::GetNetworkInterfaces(NetworkInterface ** netifpp) +{ + NetworkInterface * ifp = new NetworkInterface(); + +#if CHIP_DEVICE_CONFIG_ENABLE_THREAD + const char * threadNetworkName = otThreadGetNetworkName(ThreadStackMgrImpl().OTInstance()); + ifp->name = Span(threadNetworkName, strlen(threadNetworkName)); + ifp->isOperational = true; + ifp->offPremiseServicesReachableIPv4.SetNull(); + ifp->offPremiseServicesReachableIPv6.SetNull(); + ifp->type = app::Clusters::GeneralDiagnostics::InterfaceTypeEnum::kThread; + uint8_t macBuffer[ConfigurationManager::kPrimaryMACAddressLength]; + ConfigurationMgr().GetPrimary802154MACAddress(macBuffer); + ifp->hardwareAddress = ByteSpan(macBuffer, ConfigurationManager::kPrimaryMACAddressLength); +#else + + struct netif * netif = deviceInterface_getNetif(); + + Platform::CopyString(ifp->Name, netif->name); + ifp->name = CharSpan::fromCharString(ifp->Name); + ifp->isOperational = true; +#if CHIP_DEVICE_CONFIG_ENABLE_WIFI + ifp->type = app::Clusters::GeneralDiagnostics::InterfaceTypeEnum::kWiFi; +#else + ifp->type = app::Clusters::GeneralDiagnostics::InterfaceTypeEnum::kEthernet; +#endif + ifp->offPremiseServicesReachableIPv4.SetNull(); + ifp->offPremiseServicesReachableIPv6.SetNull(); + + memcpy(ifp->MacAddress, netif->hwaddr, sizeof(netif->hwaddr)); + ifp->hardwareAddress = ByteSpan(ifp->MacAddress, sizeof(netif->hwaddr)); + + memcpy(ifp->Ipv4AddressesBuffer[0], netif_ip_addr4(netif), kMaxIPv4AddrSize); + ifp->Ipv4AddressSpans[0] = ByteSpan(ifp->Ipv4AddressesBuffer[0], kMaxIPv4AddrSize); + ifp->IPv4Addresses = chip::app::DataModel::List(ifp->Ipv4AddressSpans, 1); + + int addr_count = 0; + for (size_t i = 0; (i < LWIP_IPV6_NUM_ADDRESSES) && (i < kMaxIPv6AddrCount); i++) + { + if (!ip6_addr_isany(&(netif->ip6_addr[i].u_addr.ip6))) + { + memcpy(ifp->Ipv6AddressesBuffer[addr_count], &(netif->ip6_addr[i].u_addr.ip6), sizeof(ip6_addr_t)); + ifp->Ipv6AddressSpans[addr_count] = ByteSpan(ifp->Ipv6AddressesBuffer[addr_count], kMaxIPv6AddrSize); + } + } + ifp->IPv6Addresses = chip::app::DataModel::List(ifp->Ipv6AddressSpans, addr_count); +#endif + + *netifpp = ifp; + + return CHIP_NO_ERROR; +} + +void DiagnosticDataProviderImpl::ReleaseNetworkInterfaces(NetworkInterface * netifp) +{ + while (netifp) + { + NetworkInterface * del = netifp; + netifp = netifp->Next; + delete del; + } +} + +DiagnosticDataProvider & GetDiagnosticDataProviderImpl() +{ + return DiagnosticDataProviderImpl::GetDefaultInstance(); +} + +} // namespace DeviceLayer +} // namespace chip diff --git a/src/platform/qcc74x/common/DiagnosticDataProviderImpl.h b/src/platform/qcc74x/common/DiagnosticDataProviderImpl.h new file mode 100644 index 00000000000000..8001afb0544cb3 --- /dev/null +++ b/src/platform/qcc74x/common/DiagnosticDataProviderImpl.h @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2021 Project CHIP Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include + +#include + +namespace chip { +namespace DeviceLayer { + +/** + * Concrete implementation of the PlatformManager singleton object for Linux platforms. + */ +class DiagnosticDataProviderImpl : public DiagnosticDataProvider +{ +public: + static DiagnosticDataProviderImpl & GetDefaultInstance(); + + // ===== Methods that implement the PlatformManager abstract interface. + + CHIP_ERROR GetCurrentHeapFree(uint64_t & currentHeapFree) override; + CHIP_ERROR GetCurrentHeapUsed(uint64_t & currentHeapUsed) override; + CHIP_ERROR GetCurrentHeapHighWatermark(uint64_t & currentHeapHighWatermark) override; + CHIP_ERROR GetThreadMetrics(ThreadMetrics ** threadMetricsOut) override; + void ReleaseThreadMetrics(ThreadMetrics * threadMetrics) override; + CHIP_ERROR GetRebootCount(uint16_t & rebootCount) override; + CHIP_ERROR GetBootReason(BootReasonType & bootReason) override; + CHIP_ERROR GetUpTime(uint64_t & upTime) override; + CHIP_ERROR GetTotalOperationalHours(uint32_t & totalOperationalHours) override; + CHIP_ERROR GetActiveHardwareFaults(GeneralFaults & hardwareFaults) override; + CHIP_ERROR GetActiveRadioFaults(GeneralFaults & radioFaults) override; + CHIP_ERROR GetActiveNetworkFaults(GeneralFaults & networkFaults) override; + CHIP_ERROR GetNetworkInterfaces(NetworkInterface ** netifpp) override; + void ReleaseNetworkInterfaces(NetworkInterface * netifp) override; +#if CHIP_DEVICE_CONFIG_ENABLE_WIFI + CHIP_ERROR GetWiFiBssId(MutableByteSpan & BssId) override; + CHIP_ERROR GetWiFiSecurityType(app::Clusters::WiFiNetworkDiagnostics::SecurityTypeEnum & securityType) override; + CHIP_ERROR GetWiFiVersion(app::Clusters::WiFiNetworkDiagnostics::WiFiVersionEnum & wifiVersion) override; + CHIP_ERROR GetWiFiChannelNumber(uint16_t & channelNumber) override; + CHIP_ERROR GetWiFiRssi(int8_t & rssi) override; + CHIP_ERROR GetWiFiBeaconLostCount(uint32_t & beaconLostCount) override; + CHIP_ERROR GetWiFiBeaconRxCount(uint32_t & beaconRxCount) override; + CHIP_ERROR GetWiFiPacketMulticastRxCount(uint32_t & packetMulticastRxCount) override; + CHIP_ERROR GetWiFiPacketMulticastTxCount(uint32_t & packetMulticastTxCount) override; + CHIP_ERROR GetWiFiPacketUnicastRxCount(uint32_t & packetUnicastRxCount) override; + CHIP_ERROR GetWiFiPacketUnicastTxCount(uint32_t & packetUnicastTxCount) override; + CHIP_ERROR GetWiFiCurrentMaxRate(uint64_t & currentMaxRate) override; + CHIP_ERROR GetWiFiOverrunCount(uint64_t & overrunCount) override; + CHIP_ERROR ResetWiFiNetworkDiagnosticsCounts() override; +#endif +}; + +} // namespace DeviceLayer +} // namespace chip diff --git a/src/platform/qcc74x/common/FactoryDataProvider.cpp b/src/platform/qcc74x/common/FactoryDataProvider.cpp new file mode 100644 index 00000000000000..056b4da903ef55 --- /dev/null +++ b/src/platform/qcc74x/common/FactoryDataProvider.cpp @@ -0,0 +1,694 @@ +/* + * + * Copyright (c) 2022 Project CHIP Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include +#include + +#include + +#if CONFIG_BOUFFALOLAB_FACTORY_DATA_ENABLE +#include +#else +extern "C" { +#include +} +#endif + +#include "FactoryDataProvider.h" + +namespace chip { +namespace DeviceLayer { + +CHIP_ERROR LoadKeypairFromRaw(ByteSpan privateKey, ByteSpan publicKey, Crypto::P256Keypair & keypair) +{ + Crypto::P256SerializedKeypair serializedKeypair; + ReturnErrorOnFailure(serializedKeypair.SetLength(privateKey.size() + publicKey.size())); + memcpy(serializedKeypair.Bytes(), publicKey.data(), publicKey.size()); + memcpy(serializedKeypair.Bytes() + publicKey.size(), privateKey.data(), privateKey.size()); + return keypair.Deserialize(serializedKeypair); +} + +CHIP_ERROR FactoryDataProvider::Init() +{ +#if CONFIG_BOUFFALOLAB_FACTORY_DATA_ENABLE + if (false == mfd_init()) + { + return CHIP_ERROR_PERSISTED_STORAGE_FAILED; + } +#endif + return CHIP_NO_ERROR; +} + +CHIP_ERROR FactoryDataProvider::GetCertificationDeclaration(MutableByteSpan & outBuffer) +{ +#if CONFIG_BOUFFALOLAB_FACTORY_DATA_ENABLE + int len = 0; + + len = mfd_getCd(outBuffer.data(), outBuffer.size()); + if (len > 0) + { + outBuffer.reduce_size(len); + return CHIP_NO_ERROR; + } + else if (0 == len) + { + return CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND; + } + + return CHIP_ERROR_BUFFER_TOO_SMALL; +#else + + static const unsigned char Chip_Test_CD_130D_f001_der[] = { + 0x30, 0x81, 0xe9, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x07, 0x02, 0xa0, 0x81, 0xdb, 0x30, 0x81, 0xd8, + 0x02, 0x01, 0x03, 0x31, 0x0d, 0x30, 0x0b, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x01, 0x30, 0x45, + 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x07, 0x01, 0xa0, 0x38, 0x04, 0x36, 0x15, 0x24, 0x00, 0x01, 0x25, + 0x01, 0x0d, 0x13, 0x36, 0x02, 0x05, 0x01, 0xf0, 0x18, 0x25, 0x03, 0x34, 0x12, 0x2c, 0x04, 0x13, 0x5a, 0x49, 0x47, 0x32, + 0x30, 0x31, 0x34, 0x31, 0x5a, 0x42, 0x33, 0x33, 0x30, 0x30, 0x30, 0x31, 0x2d, 0x32, 0x34, 0x24, 0x05, 0x00, 0x24, 0x06, + 0x00, 0x25, 0x07, 0x76, 0x98, 0x24, 0x08, 0x00, 0x18, 0x31, 0x7d, 0x30, 0x7b, 0x02, 0x01, 0x03, 0x80, 0x14, 0x62, 0xfa, + 0x82, 0x33, 0x59, 0xac, 0xfa, 0xa9, 0x96, 0x3e, 0x1c, 0xfa, 0x14, 0x0a, 0xdd, 0xf5, 0x04, 0xf3, 0x71, 0x60, 0x30, 0x0b, + 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x01, 0x30, 0x0a, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, + 0x04, 0x03, 0x02, 0x04, 0x47, 0x30, 0x45, 0x02, 0x21, 0x00, 0xd9, 0x91, 0xc9, 0xce, 0xaf, 0x8e, 0x81, 0x56, 0x10, 0x63, + 0x1d, 0x1d, 0x69, 0x3d, 0x0c, 0xbb, 0xb6, 0x17, 0x6e, 0x0b, 0x91, 0xba, 0x7b, 0x23, 0x57, 0xdc, 0x50, 0x80, 0x23, 0xc9, + 0x8e, 0xd0, 0x02, 0x20, 0x34, 0x5d, 0xeb, 0xd7, 0x38, 0xca, 0x8f, 0xfb, 0xa8, 0x4e, 0x8b, 0xe9, 0x5b, 0x66, 0x8b, 0x15, + 0xb9, 0x0a, 0x9a, 0xf2, 0x11, 0x82, 0x0a, 0x7a, 0xf2, 0x9f, 0x3b, 0xdd, 0xd8, 0x15, 0x51, 0x07 + }; + + ReturnErrorOnFailure(CopySpanToMutableSpan(ByteSpan(Chip_Test_CD_130D_f001_der), outBuffer)); + + return CHIP_NO_ERROR; +#endif +} + +CHIP_ERROR FactoryDataProvider::GetFirmwareInformation(MutableByteSpan & out_firmware_info_buffer) +{ + out_firmware_info_buffer.reduce_size(0); + + return CHIP_NO_ERROR; +} + +CHIP_ERROR FactoryDataProvider::GetDeviceAttestationCert(MutableByteSpan & outBuffer) +{ +#if CONFIG_BOUFFALOLAB_FACTORY_DATA_ENABLE + int len = 0; + + len = mfd_getDacCert(outBuffer.data(), outBuffer.size()); + if (len > 0) + { + outBuffer.reduce_size(len); + return CHIP_NO_ERROR; + } + else if (0 == len) + { + return CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND; + } + + return CHIP_ERROR_BUFFER_TOO_SMALL; +#else + static const uint8_t Dac_Cert_Array[] = { + 0x30, 0x82, 0x01, 0xd0, 0x30, 0x82, 0x01, 0x76, 0xa0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x08, 0x68, 0xa3, 0xb6, 0x6e, 0x27, + 0x6b, 0x5b, 0x29, 0x30, 0x0a, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x04, 0x03, 0x02, 0x30, 0x30, 0x31, 0x18, 0x30, + 0x16, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, 0x0f, 0x4d, 0x61, 0x74, 0x74, 0x65, 0x72, 0x20, 0x54, 0x65, 0x73, 0x74, 0x20, + 0x50, 0x41, 0x49, 0x31, 0x14, 0x30, 0x12, 0x06, 0x0a, 0x2b, 0x06, 0x01, 0x04, 0x01, 0x82, 0xa2, 0x7c, 0x02, 0x01, 0x0c, + 0x04, 0x31, 0x33, 0x30, 0x44, 0x30, 0x20, 0x17, 0x0d, 0x32, 0x31, 0x30, 0x36, 0x32, 0x38, 0x31, 0x34, 0x32, 0x33, 0x34, + 0x33, 0x5a, 0x18, 0x0f, 0x39, 0x39, 0x39, 0x39, 0x31, 0x32, 0x33, 0x31, 0x32, 0x33, 0x35, 0x39, 0x35, 0x39, 0x5a, 0x30, + 0x48, 0x31, 0x1a, 0x30, 0x18, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, 0x11, 0x4d, 0x61, 0x74, 0x74, 0x65, 0x72, 0x20, 0x54, + 0x65, 0x73, 0x74, 0x20, 0x44, 0x41, 0x43, 0x20, 0x30, 0x31, 0x14, 0x30, 0x12, 0x06, 0x0a, 0x2b, 0x06, 0x01, 0x04, 0x01, + 0x82, 0xa2, 0x7c, 0x02, 0x01, 0x0c, 0x04, 0x31, 0x33, 0x30, 0x44, 0x31, 0x14, 0x30, 0x12, 0x06, 0x0a, 0x2b, 0x06, 0x01, + 0x04, 0x01, 0x82, 0xa2, 0x7c, 0x02, 0x02, 0x0c, 0x04, 0x46, 0x30, 0x30, 0x31, 0x30, 0x59, 0x30, 0x13, 0x06, 0x07, 0x2a, + 0x86, 0x48, 0xce, 0x3d, 0x02, 0x01, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x03, 0x01, 0x07, 0x03, 0x42, 0x00, 0x04, + 0xd8, 0x19, 0x93, 0xac, 0xf1, 0xc8, 0x63, 0xbb, 0x04, 0x2b, 0x8c, 0x2e, 0x4d, 0xe4, 0x08, 0x39, 0x4f, 0xf9, 0x3e, 0xa3, + 0x89, 0x19, 0x96, 0x8c, 0x22, 0xa1, 0x0f, 0xeb, 0x4c, 0x20, 0x2a, 0x8a, 0x12, 0xff, 0xe4, 0xe6, 0x09, 0x4f, 0x13, 0x4b, + 0xa8, 0x35, 0x53, 0x2f, 0xa4, 0x9d, 0x8e, 0x79, 0x8c, 0x07, 0x01, 0x5c, 0x73, 0xff, 0x0d, 0x1c, 0x34, 0xfe, 0x14, 0x7f, + 0xbe, 0xc6, 0x70, 0xf8, 0xa3, 0x60, 0x30, 0x5e, 0x30, 0x0c, 0x06, 0x03, 0x55, 0x1d, 0x13, 0x01, 0x01, 0xff, 0x04, 0x02, + 0x30, 0x00, 0x30, 0x0e, 0x06, 0x03, 0x55, 0x1d, 0x0f, 0x01, 0x01, 0xff, 0x04, 0x04, 0x03, 0x02, 0x07, 0x80, 0x30, 0x1d, + 0x06, 0x03, 0x55, 0x1d, 0x0e, 0x04, 0x16, 0x04, 0x14, 0x63, 0x9f, 0xbd, 0x91, 0x8c, 0x90, 0xed, 0x7a, 0xbf, 0x64, 0xcd, + 0xe8, 0x2e, 0x13, 0x10, 0x8e, 0xee, 0x5d, 0x6f, 0x8e, 0x30, 0x1f, 0x06, 0x03, 0x55, 0x1d, 0x23, 0x04, 0x18, 0x30, 0x16, + 0x80, 0x14, 0x3a, 0xb2, 0xfa, 0x06, 0x27, 0xcc, 0x4a, 0xdc, 0x84, 0xac, 0x9c, 0x95, 0x1e, 0x8c, 0x8f, 0xdc, 0x4c, 0x0d, + 0xec, 0x01, 0x30, 0x0a, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x04, 0x03, 0x02, 0x03, 0x48, 0x00, 0x30, 0x45, 0x02, + 0x21, 0x00, 0xd6, 0xc3, 0xab, 0x6d, 0xbd, 0xd0, 0xa2, 0x45, 0xbc, 0xcf, 0xb7, 0x2d, 0x6f, 0x5e, 0xd1, 0xbe, 0xd7, 0xd4, + 0xea, 0xca, 0x9e, 0xf2, 0xa1, 0x09, 0x77, 0xc3, 0x43, 0xa2, 0x29, 0x67, 0x63, 0x3d, 0x02, 0x20, 0x2b, 0xb8, 0x39, 0xf8, + 0x31, 0xeb, 0x83, 0x31, 0xe2, 0x31, 0xeb, 0xd2, 0x5c, 0x82, 0xe4, 0xb7, 0x14, 0xfd, 0x62, 0x97, 0x1f, 0x64, 0xff, 0x51, + 0x43, 0x83, 0xb4, 0xa9, 0x19, 0x6f, 0x96, 0xcf + }; + + ReturnErrorOnFailure(CopySpanToMutableSpan(ByteSpan(Dac_Cert_Array), outBuffer)); + + return CHIP_NO_ERROR; +#endif +} + +CHIP_ERROR FactoryDataProvider::GetProductAttestationIntermediateCert(MutableByteSpan & outBuffer) +{ +#if CONFIG_BOUFFALOLAB_FACTORY_DATA_ENABLE + int len = 0; + + len = mfd_getPaiCert(outBuffer.data(), outBuffer.size()); + if (len > 0) + { + outBuffer.reduce_size(len); + return CHIP_NO_ERROR; + } + else if (0 == len) + { + return CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND; + } + + return CHIP_ERROR_BUFFER_TOO_SMALL; +#else + static const uint8_t Pai_Cert_Array[] = { + 0x30, 0x82, 0x01, 0xa7, 0x30, 0x82, 0x01, 0x4e, 0xa0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x08, 0x01, 0x0f, 0x96, 0xa1, 0x42, + 0x5c, 0xe7, 0x0c, 0x30, 0x0a, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x04, 0x03, 0x02, 0x30, 0x1a, 0x31, 0x18, 0x30, + 0x16, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, 0x0f, 0x4d, 0x61, 0x74, 0x74, 0x65, 0x72, 0x20, 0x54, 0x65, 0x73, 0x74, 0x20, + 0x50, 0x41, 0x41, 0x30, 0x20, 0x17, 0x0d, 0x32, 0x31, 0x30, 0x36, 0x32, 0x38, 0x31, 0x34, 0x32, 0x33, 0x34, 0x33, 0x5a, + 0x18, 0x0f, 0x39, 0x39, 0x39, 0x39, 0x31, 0x32, 0x33, 0x31, 0x32, 0x33, 0x35, 0x39, 0x35, 0x39, 0x5a, 0x30, 0x30, 0x31, + 0x18, 0x30, 0x16, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, 0x0f, 0x4d, 0x61, 0x74, 0x74, 0x65, 0x72, 0x20, 0x54, 0x65, 0x73, + 0x74, 0x20, 0x50, 0x41, 0x49, 0x31, 0x14, 0x30, 0x12, 0x06, 0x0a, 0x2b, 0x06, 0x01, 0x04, 0x01, 0x82, 0xa2, 0x7c, 0x02, + 0x01, 0x0c, 0x04, 0x31, 0x33, 0x30, 0x44, 0x30, 0x59, 0x30, 0x13, 0x06, 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x02, 0x01, + 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x03, 0x01, 0x07, 0x03, 0x42, 0x00, 0x04, 0xdb, 0xbe, 0xac, 0xd5, 0xf3, 0xd6, + 0x32, 0x36, 0x04, 0x00, 0xe0, 0xa1, 0x16, 0x8d, 0xbf, 0x0c, 0x74, 0x8f, 0xdb, 0xd7, 0x03, 0x7f, 0x8c, 0x4e, 0x65, 0x58, + 0x27, 0x2f, 0xfa, 0x2d, 0x64, 0x61, 0x4e, 0xe5, 0x72, 0xb8, 0xa5, 0x87, 0x8c, 0x15, 0xc7, 0x25, 0x55, 0x47, 0xc4, 0xc9, + 0x62, 0xda, 0xd7, 0x02, 0x64, 0xd2, 0x84, 0x2d, 0xe8, 0x2d, 0xf1, 0x69, 0xcb, 0x56, 0x42, 0x86, 0xf8, 0x55, 0xa3, 0x66, + 0x30, 0x64, 0x30, 0x12, 0x06, 0x03, 0x55, 0x1d, 0x13, 0x01, 0x01, 0xff, 0x04, 0x08, 0x30, 0x06, 0x01, 0x01, 0xff, 0x02, + 0x01, 0x00, 0x30, 0x0e, 0x06, 0x03, 0x55, 0x1d, 0x0f, 0x01, 0x01, 0xff, 0x04, 0x04, 0x03, 0x02, 0x01, 0x06, 0x30, 0x1d, + 0x06, 0x03, 0x55, 0x1d, 0x0e, 0x04, 0x16, 0x04, 0x14, 0x3a, 0xb2, 0xfa, 0x06, 0x27, 0xcc, 0x4a, 0xdc, 0x84, 0xac, 0x9c, + 0x95, 0x1e, 0x8c, 0x8f, 0xdc, 0x4c, 0x0d, 0xec, 0x01, 0x30, 0x1f, 0x06, 0x03, 0x55, 0x1d, 0x23, 0x04, 0x18, 0x30, 0x16, + 0x80, 0x14, 0x78, 0x5c, 0xe7, 0x05, 0xb8, 0x6b, 0x8f, 0x4e, 0x6f, 0xc7, 0x93, 0xaa, 0x60, 0xcb, 0x43, 0xea, 0x69, 0x68, + 0x82, 0xd5, 0x30, 0x0a, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x04, 0x03, 0x02, 0x03, 0x47, 0x00, 0x30, 0x44, 0x02, + 0x20, 0x0f, 0x12, 0x2f, 0x8c, 0x83, 0xab, 0xdd, 0x35, 0x53, 0xbc, 0xcd, 0xe5, 0xec, 0x2d, 0x84, 0x99, 0x24, 0xb5, 0xe0, + 0x1a, 0x54, 0x45, 0x37, 0x78, 0xba, 0x88, 0xa8, 0x51, 0x18, 0xf8, 0x0e, 0x05, 0x02, 0x20, 0x59, 0x84, 0x16, 0xe1, 0xd1, + 0xee, 0x5e, 0xc6, 0x50, 0xcd, 0x5d, 0x58, 0x47, 0xb8, 0x10, 0x82, 0xa9, 0xa2, 0x2f, 0x4f, 0x31, 0x7e, 0xc7, 0x5d, 0xb6, + 0x6c, 0xc9, 0xc5, 0x70, 0xb8, 0x1e, 0xd8 + }; + + ReturnErrorOnFailure(CopySpanToMutableSpan(ByteSpan(Pai_Cert_Array), outBuffer)); + + return CHIP_NO_ERROR; +#endif +} + +CHIP_ERROR FactoryDataProvider::SignWithDeviceAttestationKey(const ByteSpan & messageToSign, MutableByteSpan & outSignBuffer) +{ + Crypto::P256ECDSASignature signature; + Crypto::P256Keypair keypair; + chip::Crypto::P256PublicKey dacPublicKey; + + if (outSignBuffer.size() < signature.Capacity()) + { + return CHIP_ERROR_BUFFER_TOO_SMALL; + } + +#if CONFIG_BOUFFALOLAB_FACTORY_DATA_ENABLE + + uint32_t dacCertSize = 0, dacPrivateKeySize = 0; + uint8_t * pDacCertPtr = mfd_getDacCertPtr(&dacCertSize); + uint8_t * pDacPrivateKeyPtr = mfd_getDacPrivateKeyPtr(&dacPrivateKeySize); + + if (NULL == pDacCertPtr || 0 == dacCertSize || NULL == pDacPrivateKeyPtr || 0 == dacPrivateKeySize) + { + outSignBuffer.reduce_size(0); + return CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND; + } + + ByteSpan dacCert(pDacCertPtr, dacCertSize); + ByteSpan dacPrivateKey(pDacPrivateKeyPtr, dacPrivateKeySize); + +#else + static const uint8_t Dac_PrivateKey_Array[] = { 0x65, 0x11, 0x78, 0x2e, 0xf7, 0xcd, 0x30, 0x59, 0xbd, 0x3a, 0xdd, + 0x44, 0x6f, 0xc5, 0xdd, 0x92, 0xe5, 0xd8, 0x3c, 0x56, 0x9d, 0x67, + 0x7a, 0x29, 0xc7, 0xe9, 0xa7, 0x8f, 0x67, 0xc5, 0x5f, 0xf2 }; + + uint8_t dac_cert_array[Credentials::kMaxDERCertLength]; + uint8_t dac_cert_private_key_array[sizeof(Dac_PrivateKey_Array)]; + MutableByteSpan dacCert(dac_cert_array, Credentials::kMaxDERCertLength), + dacPrivateKey(dac_cert_private_key_array, sizeof(dac_cert_private_key_array)); + + ReturnErrorOnFailure(CopySpanToMutableSpan(ByteSpan(Dac_PrivateKey_Array), dacPrivateKey)); + ReturnErrorOnFailure(GetDeviceAttestationCert(dacCert)); + +#endif + + ReturnErrorOnFailure(chip::Crypto::ExtractPubkeyFromX509Cert(dacCert, dacPublicKey)); + + ReturnErrorOnFailure(LoadKeypairFromRaw(dacPrivateKey, ByteSpan(dacPublicKey.Bytes(), dacPublicKey.Length()), keypair)); + ReturnErrorOnFailure(keypair.ECDSA_sign_msg(messageToSign.data(), messageToSign.size(), signature)); + + ReturnErrorOnFailure(CopySpanToMutableSpan(ByteSpan(signature.Bytes(), signature.Length()), outSignBuffer)); + + return CHIP_NO_ERROR; +} + +CHIP_ERROR FactoryDataProvider::GetSetupDiscriminator(uint16_t & setupDiscriminator) +{ +#if CONFIG_BOUFFALOLAB_FACTORY_DATA_ENABLE + int len = 0; + + len = mfd_getDiscriminator((uint8_t *) &setupDiscriminator, sizeof(setupDiscriminator)); + if (len > 0) + { + setupDiscriminator = 0xfff & setupDiscriminator; + return CHIP_NO_ERROR; + } + else if (0 == len) + { + return CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND; + } + + return CHIP_ERROR_BUFFER_TOO_SMALL; +#else + setupDiscriminator = 3840; + + return CHIP_NO_ERROR; +#endif +} + +CHIP_ERROR FactoryDataProvider::SetSetupDiscriminator(uint16_t setupDiscriminator) +{ + return CHIP_ERROR_NOT_IMPLEMENTED; +} + +CHIP_ERROR FactoryDataProvider::GetSpake2pIterationCount(uint32_t & iterationCount) +{ +#if CONFIG_BOUFFALOLAB_FACTORY_DATA_ENABLE + int len = 0; + + len = mfd_getSapke2It((uint8_t *) &iterationCount, sizeof(iterationCount)); + if (len > 0) + { + return CHIP_NO_ERROR; + } + else if (0 == len) + { + return CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND; + } + + return CHIP_ERROR_BUFFER_TOO_SMALL; +#else + iterationCount = 1000; + + return CHIP_NO_ERROR; +#endif +} + +CHIP_ERROR FactoryDataProvider::GetSpake2pSalt(MutableByteSpan & saltBuf) +{ +#if CONFIG_BOUFFALOLAB_FACTORY_DATA_ENABLE + int len = 0; + + len = mfd_getSapke2Salt(saltBuf.data(), saltBuf.size()); + if (len > 0) + { + saltBuf.reduce_size(len); + return CHIP_NO_ERROR; + } + else if (0 == len) + { + return CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND; + } + + return CHIP_ERROR_BUFFER_TOO_SMALL; +#else + static const char spake2pSalt[] = "U1BBS0UyUCBLZXkgU2FsdA=="; + uint32_t aSpake2pSaltLen; + + if (!utils_base64decode((const uint8_t *) spake2pSalt, sizeof(spake2pSalt) - 1, saltBuf.size(), saltBuf.data(), + &aSpake2pSaltLen)) + { + return CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND; + } + + saltBuf = MutableByteSpan(saltBuf.data(), aSpake2pSaltLen); + + return CHIP_NO_ERROR; +#endif +} + +CHIP_ERROR FactoryDataProvider::GetSpake2pVerifier(MutableByteSpan & verifierBuf, size_t & verifierLen) +{ +#if CONFIG_BOUFFALOLAB_FACTORY_DATA_ENABLE + int len = 0; + + len = mfd_getSapke2Verifier(verifierBuf.data(), verifierBuf.size()); + if (len > 0) + { + verifierLen = len; + verifierBuf.reduce_size(len); + return CHIP_NO_ERROR; + } + else if (0 == len) + { + return CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND; + } + + return CHIP_ERROR_BUFFER_TOO_SMALL; +#else + static const char spake2pVerifier[] = "jdf0KbjmAwujViR8WckvvklJzE0UL+uIOiIjTtb3a5kE/" + "WdbVWhmDFSSjLqFhiiCILxXQ4NVO3YBWTdkERnTlXbFmx+T/32FMRpZLPz8yqFXyALytJW7ZJfArBz0/CP9hA=="; + uint32_t aSpake2pVerifierLen; + + if (!utils_base64decode((const uint8_t *) spake2pVerifier, sizeof(spake2pVerifier) - 1, verifierBuf.size(), verifierBuf.data(), + &aSpake2pVerifierLen)) + { + return CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND; + } + + verifierBuf = MutableByteSpan(verifierBuf.data(), aSpake2pVerifierLen); + verifierLen = aSpake2pVerifierLen; + + return CHIP_NO_ERROR; +#endif +} + +CHIP_ERROR FactoryDataProvider::GetSetupPasscode(uint32_t & setupPasscode) +{ +#if CONFIG_BOUFFALOLAB_FACTORY_DATA_ENABLE + int len = 0; + + len = mfd_getPasscode((uint8_t *) &setupPasscode, sizeof(setupPasscode)); + if (len > 0) + { + return CHIP_NO_ERROR; + } + else if (0 == len) + { + return CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND; + } + + return CHIP_ERROR_BUFFER_TOO_SMALL; +#else + setupPasscode = 49808401; + return CHIP_NO_ERROR; +#endif +} + +CHIP_ERROR FactoryDataProvider::SetSetupPasscode(uint32_t setupPasscode) +{ + return CHIP_ERROR_NOT_IMPLEMENTED; +} + +CHIP_ERROR FactoryDataProvider::GetVendorName(char * buf, size_t bufSize) +{ +#if CONFIG_BOUFFALOLAB_FACTORY_DATA_ENABLE + int len = 0; + + len = mfd_getVendorName(buf, bufSize); + if (len > 0) + { + buf[len] = 0; + return CHIP_NO_ERROR; + } + else if (0 == len) + { + return CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND; + } + + return CHIP_ERROR_BUFFER_TOO_SMALL; +#else + static const char vendorName[] = "Bouffalo Lab"; + strncpy(buf, vendorName, bufSize); + + return CHIP_NO_ERROR; +#endif +} + +CHIP_ERROR FactoryDataProvider::GetVendorId(uint16_t & vendorId) +{ +#if CONFIG_BOUFFALOLAB_FACTORY_DATA_ENABLE + int len = 0; + + len = mfd_getVendorId((uint8_t *) &vendorId, sizeof(vendorId)); + if (len > 0) + { + return CHIP_NO_ERROR; + } + else if (0 == len) + { + return CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND; + } + + return CHIP_ERROR_BUFFER_TOO_SMALL; +#else + vendorId = 0x130D; + return CHIP_NO_ERROR; +#endif +} + +CHIP_ERROR FactoryDataProvider::GetProductName(char * buf, size_t bufSize) +{ +#if CONFIG_BOUFFALOLAB_FACTORY_DATA_ENABLE + int len = 0; + + len = mfd_getProductName(buf, bufSize); + if (len > 0) + { + buf[len] = 0; + return CHIP_NO_ERROR; + } + else if (0 == len) + { + return CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND; + } + + return CHIP_ERROR_BUFFER_TOO_SMALL; +#else + strncpy(buf, CHIP_BLE_DEVICE_NAME, bufSize); + + return CHIP_NO_ERROR; +#endif +} + +CHIP_ERROR FactoryDataProvider::GetProductId(uint16_t & productId) +{ +#if CONFIG_BOUFFALOLAB_FACTORY_DATA_ENABLE + int len = 0; + + len = mfd_getProductId((uint8_t *) &productId, sizeof(productId)); + if (len > 0) + { + return CHIP_NO_ERROR; + } + else if (0 == len) + { + return CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND; + } + + return CHIP_ERROR_BUFFER_TOO_SMALL; +#else + productId = 0xf001; + + return CHIP_NO_ERROR; +#endif +} + +CHIP_ERROR FactoryDataProvider::GetPartNumber(char * buf, size_t bufSize) +{ +#if CONFIG_BOUFFALOLAB_FACTORY_DATA_ENABLE + int len = 0; + + len = mfd_getPartNumber(buf, bufSize); + if (len > 0) + { + buf[len] = 0; + return CHIP_NO_ERROR; + } + else if (0 == len) + { + return CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND; + } + + return CHIP_ERROR_BUFFER_TOO_SMALL; +#else + return CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND; +#endif +} + +CHIP_ERROR FactoryDataProvider::GetProductURL(char * buf, size_t bufSize) +{ +#if CONFIG_BOUFFALOLAB_FACTORY_DATA_ENABLE + int len = 0; + + len = mfd_getProductUrl(buf, bufSize); + if (len > 0) + { + buf[len] = 0; + return CHIP_NO_ERROR; + } + else if (0 == len) + { + return CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND; + } + + return CHIP_ERROR_BUFFER_TOO_SMALL; +#else + return CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND; +#endif +} + +CHIP_ERROR FactoryDataProvider::GetProductLabel(char * buf, size_t bufSize) +{ +#if CONFIG_BOUFFALOLAB_FACTORY_DATA_ENABLE + int len = 0; + + len = mfd_getProductLabel(buf, bufSize); + if (len > 0) + { + buf[len] = 0; + return CHIP_NO_ERROR; + } + else if (0 == len) + { + return CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND; + } + + return CHIP_ERROR_BUFFER_TOO_SMALL; +#else + return CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND; +#endif +} + +CHIP_ERROR FactoryDataProvider::GetSerialNumber(char * buf, size_t bufSize) +{ +#if CONFIG_BOUFFALOLAB_FACTORY_DATA_ENABLE + int len = 0; + + len = mfd_getSerialNumber(buf, bufSize); + if (len > 0) + { + buf[len] = 0; + return CHIP_NO_ERROR; + } + else if (0 == len) + { + return CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND; + } + + return CHIP_ERROR_BUFFER_TOO_SMALL; +#else + strncpy(buf, CHIP_DEVICE_CONFIG_TEST_SERIAL_NUMBER, bufSize); + + return CHIP_NO_ERROR; +#endif +} + +CHIP_ERROR FactoryDataProvider::GetManufacturingDate(uint16_t & year, uint8_t & month, uint8_t & day) +{ +#define OS_YEAR \ + ((((int) (__DATE__[7] - '0') * 10 + (int) (__DATE__[8] - '0')) * 10 + (int) (__DATE__[9] - '0')) * 10 + \ + (int) (__DATE__[10] - '0')) + +#define OS_MONTH \ + (__DATE__[2] == 'n' ? (__DATE__[1] == 'a' ? 1 : 6) \ + : __DATE__[2] == 'b' ? 2 \ + : __DATE__[2] == 'r' ? (__DATE__[0] == 'M' ? 3 : 4) \ + : __DATE__[2] == 'y' ? 5 \ + : __DATE__[2] == 'l' ? 7 \ + : __DATE__[2] == 'g' ? 8 \ + : __DATE__[2] == 'p' ? 9 \ + : __DATE__[2] == 't' ? 10 \ + : __DATE__[2] == 'v' ? 11 \ + : 12) + +#define OS_DAY ((__DATE__[4] == ' ' ? 0 : __DATE__[4] - '0') * 10 + (__DATE__[5] - '0')) + +#if CONFIG_BOUFFALOLAB_FACTORY_DATA_ENABLE + if (mfd_getManufacturingDate(&year, &month, &day)) + { + return CHIP_NO_ERROR; + } +#endif + + year = (uint16_t) OS_YEAR; + month = (uint8_t) OS_MONTH; + day = (uint8_t) OS_DAY; + + return CHIP_NO_ERROR; +} + +CHIP_ERROR FactoryDataProvider::GetHardwareVersion(uint16_t & hardwareVersion) +{ +#if CONFIG_BOUFFALOLAB_FACTORY_DATA_ENABLE + int len = 0; + + len = mfd_getHardwareVersion((uint8_t *) &hardwareVersion, sizeof(hardwareVersion)); + if (len > 0) + { + return CHIP_NO_ERROR; + } + else if (0 == len) + { + return CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND; + } + + return CHIP_ERROR_BUFFER_TOO_SMALL; +#else + hardwareVersion = CHIP_DEVICE_CONFIG_DEFAULT_DEVICE_HARDWARE_VERSION; + + return CHIP_NO_ERROR; +#endif +} + +CHIP_ERROR FactoryDataProvider::GetHardwareVersionString(char * buf, size_t bufSize) +{ +#if CONFIG_BOUFFALOLAB_FACTORY_DATA_ENABLE + int len = 0; + len = mfd_getHardwareVersionString(buf, bufSize); + if (len > 0) + { + buf[len] = 0; + return CHIP_NO_ERROR; + } + else if (0 == len) + { + return CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND; + } + + return CHIP_ERROR_BUFFER_TOO_SMALL; +#else + strncpy(buf, CHIP_DEVICE_CONFIG_DEFAULT_DEVICE_HARDWARE_VERSION_STRING, bufSize); + + return CHIP_NO_ERROR; +#endif +} + +CHIP_ERROR FactoryDataProvider::GetRotatingDeviceIdUniqueId(MutableByteSpan & uniqueIdSpan) +{ +#if CONFIG_BOUFFALOLAB_FACTORY_DATA_ENABLE + int len = 0; + + len = mfd_getRotatingDeviceIdUniqueId(uniqueIdSpan.data(), uniqueIdSpan.size()); + if (len > 0) + { + return CHIP_NO_ERROR; + } + else if (0 == len) + { + return CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND; + } + + return CHIP_ERROR_BUFFER_TOO_SMALL; +#else + constexpr uint8_t uniqueId[] = CHIP_DEVICE_CONFIG_ROTATING_DEVICE_ID_UNIQUE_ID; + + VerifyOrReturnValue(uniqueIdSpan.size() >= sizeof(uniqueId), CHIP_ERROR_INVALID_ARGUMENT); + + memcpy(uniqueIdSpan.data(), uniqueId, sizeof(uniqueId)); + uniqueIdSpan.reduce_size(sizeof(uniqueId)); + + return CHIP_NO_ERROR; +#endif +} + +} // namespace DeviceLayer +} // namespace chip diff --git a/src/platform/qcc74x/common/FactoryDataProvider.h b/src/platform/qcc74x/common/FactoryDataProvider.h new file mode 100644 index 00000000000000..80cc166034e7f3 --- /dev/null +++ b/src/platform/qcc74x/common/FactoryDataProvider.h @@ -0,0 +1,68 @@ +/* + * + * Copyright (c) 2022 Project CHIP Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include +#include +#include + +#include + +namespace chip { +namespace DeviceLayer { + +class FactoryDataProvider : public chip::Credentials::DeviceAttestationCredentialsProvider, + public CommissionableDataProvider, + public DeviceInstanceInfoProvider +{ +public: + CHIP_ERROR Init(); + + // ===== Members functions that implement the DeviceAttestationCredentialsProvider + CHIP_ERROR GetCertificationDeclaration(MutableByteSpan & outBuffer) override; + CHIP_ERROR GetFirmwareInformation(MutableByteSpan & out_firmware_info_buffer) override; + CHIP_ERROR GetDeviceAttestationCert(MutableByteSpan & outBuffer) override; + CHIP_ERROR GetProductAttestationIntermediateCert(MutableByteSpan & outBuffer) override; + CHIP_ERROR SignWithDeviceAttestationKey(const ByteSpan & messageToSign, MutableByteSpan & outSignBuffer) override; + + // ===== Members functions that implement the CommissionableDataProvider + CHIP_ERROR GetSetupDiscriminator(uint16_t & setupDiscriminator) override; + CHIP_ERROR SetSetupDiscriminator(uint16_t setupDiscriminator) override; + CHIP_ERROR GetSpake2pIterationCount(uint32_t & iterationCount) override; + CHIP_ERROR GetSpake2pSalt(MutableByteSpan & saltBuf) override; + CHIP_ERROR GetSpake2pVerifier(MutableByteSpan & verifierBuf, size_t & verifierLen) override; + CHIP_ERROR GetSetupPasscode(uint32_t & setupPasscode) override; + CHIP_ERROR SetSetupPasscode(uint32_t setupPasscode) override; + + // ===== Members functions that implement the DeviceInstanceInfoProvider + CHIP_ERROR GetVendorName(char * buf, size_t bufSize) override; + CHIP_ERROR GetVendorId(uint16_t & vendorId) override; + CHIP_ERROR GetProductName(char * buf, size_t bufSize) override; + CHIP_ERROR GetProductId(uint16_t & productId) override; + CHIP_ERROR GetPartNumber(char * buf, size_t bufSize) override; + CHIP_ERROR GetProductURL(char * buf, size_t bufSize) override; + CHIP_ERROR GetProductLabel(char * buf, size_t bufSize) override; + CHIP_ERROR GetSerialNumber(char * buf, size_t bufSize) override; + CHIP_ERROR GetManufacturingDate(uint16_t & year, uint8_t & month, uint8_t & day) override; + CHIP_ERROR GetHardwareVersion(uint16_t & hardwareVersion) override; + CHIP_ERROR GetHardwareVersionString(char * buf, size_t bufSize) override; + CHIP_ERROR GetRotatingDeviceIdUniqueId(MutableByteSpan & uniqueIdSpan) override; +}; + +} // namespace DeviceLayer +} // namespace chip diff --git a/src/platform/qcc74x/common/InetPlatformConfig.h b/src/platform/qcc74x/common/InetPlatformConfig.h new file mode 100644 index 00000000000000..d4552c22c81d5a --- /dev/null +++ b/src/platform/qcc74x/common/InetPlatformConfig.h @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2022 Project CHIP Authors + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +// ==================== Platform Adaptations ==================== + +#ifndef INET_CONFIG_ENABLE_IPV4 +#error Inet IPv4 configuration should be configured at build generation time +#endif + +// ========== Platform-specific Configuration Overrides ========= + +#ifndef INET_CONFIG_NUM_TCP_ENDPOINTS +#define INET_CONFIG_NUM_TCP_ENDPOINTS 4 +#endif // INET_CONFIG_NUM_TCP_ENDPOINTS + +#ifndef INET_CONFIG_NUM_UDP_ENDPOINTS +#define INET_CONFIG_NUM_UDP_ENDPOINTS 6 +#endif // INET_CONFIG_NUM_UDP_ENDPOINTS diff --git a/src/platform/qcc74x/common/KeyValueStoreManagerImpl.cpp b/src/platform/qcc74x/common/KeyValueStoreManagerImpl.cpp new file mode 100644 index 00000000000000..d12cefe439ac74 --- /dev/null +++ b/src/platform/qcc74x/common/KeyValueStoreManagerImpl.cpp @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2022 Project CHIP Authors + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* this file behaves like a config.h, comes first */ +#include + +#include + +#include + +#include + +namespace chip { +namespace DeviceLayer { +namespace PersistedStorage { + +using namespace ::chip::DeviceLayer::Internal; + +KeyValueStoreManagerImpl KeyValueStoreManagerImpl::sInstance; + +CHIP_ERROR KeyValueStoreManagerImpl::_Get(const char * key, void * value, size_t value_size, size_t * read_bytes_size, + size_t offset_bytes) const +{ + VerifyOrReturnError(key, CHIP_ERROR_INVALID_ARGUMENT); + + CHIP_ERROR err = BLConfig::ReadKVS(key, value, value_size, read_bytes_size, offset_bytes); + if (err == CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND) + { + err = CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND; + } + return err; +} + +CHIP_ERROR KeyValueStoreManagerImpl::_Put(const char * key, const void * value, size_t value_size) +{ + VerifyOrReturnError(key, CHIP_ERROR_INVALID_ARGUMENT); + + return BLConfig::WriteKVS(key, value, value_size); +} + +CHIP_ERROR KeyValueStoreManagerImpl::_Delete(const char * key) +{ + return BLConfig::ClearKVS((char *) key); +} + +} // namespace PersistedStorage +} // namespace DeviceLayer +} // namespace chip diff --git a/src/platform/qcc74x/common/KeyValueStoreManagerImpl.h b/src/platform/qcc74x/common/KeyValueStoreManagerImpl.h new file mode 100644 index 00000000000000..65a9bfde758766 --- /dev/null +++ b/src/platform/qcc74x/common/KeyValueStoreManagerImpl.h @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2022 Project CHIP Authors + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +namespace chip { +namespace DeviceLayer { +namespace PersistedStorage { + +class KeyValueStoreManagerImpl final : public KeyValueStoreManager +{ + // Allow the KeyValueStoreManager interface class to delegate method calls to + // the implementation methods provided by this class. + friend class KeyValueStoreManager; + +public: + CHIP_ERROR _Get(const char * key, void * value, size_t value_size, size_t * read_bytes_size = nullptr, size_t offset = 0) const; + + CHIP_ERROR _Delete(const char * key); + + CHIP_ERROR _Put(const char * key, const void * value, size_t value_size); + +private: + // ===== Members for internal use by the following friends. + friend KeyValueStoreManager & KeyValueStoreMgr(); + friend KeyValueStoreManagerImpl & KeyValueStoreMgrImpl(); + + static KeyValueStoreManagerImpl sInstance; +}; + +/** + * Returns the public interface of the KeyValueStoreManager singleton object. + * + */ +inline KeyValueStoreManager & KeyValueStoreMgr(void) +{ + return KeyValueStoreManagerImpl::sInstance; +} + +/** + * Returns the platform-specific implementation of the KeyValueStoreManager singleton object. + */ +inline KeyValueStoreManagerImpl & KeyValueStoreMgrImpl(void) +{ + return KeyValueStoreManagerImpl::sInstance; +} + +} // namespace PersistedStorage +} // namespace DeviceLayer +} // namespace chip diff --git a/src/platform/qcc74x/common/Logging.cpp b/src/platform/qcc74x/common/Logging.cpp new file mode 100644 index 00000000000000..edfdb62fec287e --- /dev/null +++ b/src/platform/qcc74x/common/Logging.cpp @@ -0,0 +1,160 @@ +/* + * Copyright (c) 2022 Project CHIP Authors + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include +#include +#include +#include + +#include +#include +#include + +#if PW_RPC_ENABLED +#include "PigweedLogger.h" +#endif + +#include +#include +#if CHIP_DEVICE_LAYER_TARGET_BL602 || CHIP_DEVICE_LAYER_TARGET_BL702 || CHIP_DEVICE_LAYER_TARGET_BL702L +#include +#endif + +namespace chip { +namespace Logging { +namespace Platform { + +static char formattedMsg[CHIP_CONFIG_LOG_MESSAGE_MAX_SIZE]; +void LogV(const char * module, uint8_t category, const char * msg, va_list v) +{ +#if !PW_RPC_ENABLED + int lmsg = 0; + + vsnprintf(formattedMsg, sizeof(formattedMsg), msg, v); + + lmsg = strlen(formattedMsg); + if (lmsg) + { + /** remove duplicate \r\n */ + if (lmsg >= 2 && formattedMsg[lmsg - 2] == '\r' && formattedMsg[lmsg - 1] == '\n') + { + lmsg -= 2; + } + else if (lmsg >= 1 && formattedMsg[lmsg - 1] == '\n') + { + lmsg -= 1; + } + + formattedMsg[lmsg] = '\0'; + } + + switch (category) + { + case kLogCategory_Error: +#if CHIP_DEVICE_LAYER_TARGET_BL602 || CHIP_DEVICE_LAYER_TARGET_BL702 || CHIP_DEVICE_LAYER_TARGET_BL702L + __utils_printf("[%10lu][%s][ERROR] %s\r\n", xTaskGetTickCount(), module, formattedMsg); +#else + printf("[%10lu][%s][ERROR] %s\r\n", xTaskGetTickCount(), module, formattedMsg); +#endif + break; + case kLogCategory_Progress: +#if CHIP_DEVICE_LAYER_TARGET_BL602 || CHIP_DEVICE_LAYER_TARGET_BL702 || CHIP_DEVICE_LAYER_TARGET_BL702L + __utils_printf("[%10lu][%s][PROGR] %s\r\n", xTaskGetTickCount(), module, formattedMsg); +#else + printf("[%10lu][%s][PROGR] %s\r\n", xTaskGetTickCount(), module, formattedMsg); +#endif + break; + case kLogCategory_Detail: +#if CHIP_DEVICE_LAYER_TARGET_BL602 || CHIP_DEVICE_LAYER_TARGET_BL702 || CHIP_DEVICE_LAYER_TARGET_BL702L + __utils_printf("[%10lu][%s][DETAIL] %s\r\n", xTaskGetTickCount(), module, formattedMsg); +#else + printf("[%10lu][%s][DETAIL] %s\r\n", xTaskGetTickCount(), module, formattedMsg); +#endif + break; + } +#else + size_t prefixLen = 0; + + switch (category) + { + case kLogCategory_Error: + strcpy(formattedMsg, "[ERROR] "); + break; + case kLogCategory_Progress: + default: + strcpy(formattedMsg, "[INFO] "); + break; + case kLogCategory_Detail: + strcpy(formattedMsg, "[TRACE] "); + break; + } + + prefixLen = strlen(formattedMsg); + snprintf(formattedMsg + prefixLen, sizeof(formattedMsg) - prefixLen, "[%s] ", module); + prefixLen = strlen(formattedMsg); + vsnprintf(formattedMsg + prefixLen, sizeof(formattedMsg) - prefixLen, msg, v); + + PigweedLogger::putString(formattedMsg, strlen(formattedMsg)); + const char * newline = "\r\n"; + PigweedLogger::putString(newline, strlen(newline)); +#endif +} + +} // namespace Platform +} // namespace Logging +} // namespace chip + +#if CHIP_DEVICE_CONFIG_ENABLE_THREAD +extern "C" void otPlatLog(int aLogLevel, int aLogRegion, const char * aFormat, ...) +{ + va_list v; + uint8_t category = chip::Logging::kLogCategory_Error; + + (void) aLogRegion; + + if (aLogLevel == 1 && aLogLevel == 2) + { + category = chip::Logging::kLogCategory_Error; + } + else + { + category = chip::Logging::kLogCategory_Progress; + } + + va_start(v, aFormat); + + chip::Logging::Platform::LogV("OTBR", category, aFormat, v); + + va_end(v); +} +#endif + +#if CHIP_SYSTEM_CONFIG_USE_LWIP +/** + * LwIP log output function. + */ +extern "C" void LwIPLog(const char * msg, ...) +{ + va_list v; + uint8_t category = chip::Logging::kLogCategory_Error; + + va_start(v, msg); + + chip::Logging::Platform::LogV("LWIP", category, msg, v); + + va_end(v); +} +#endif // #if CHIP_SYSTEM_CONFIG_USE_LWIP diff --git a/src/platform/qcc74x/common/OTAImageProcessorImpl.cpp b/src/platform/qcc74x/common/OTAImageProcessorImpl.cpp new file mode 100644 index 00000000000000..4cc843f5848e29 --- /dev/null +++ b/src/platform/qcc74x/common/OTAImageProcessorImpl.cpp @@ -0,0 +1,309 @@ +/* + * Copyright (c) 2022 Project CHIP Authors + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include + +extern "C" { +#if CHIP_DEVICE_LAYER_TARGET_QCC743 +#include +#else +#include +#include +#endif +} +#include "OTAImageProcessorImpl.h" + +extern "C" void hal_reboot(void); + +using namespace chip::System; + +namespace chip { + +bool OTAImageProcessorImpl::IsFirstImageRun() +{ + OTARequestorInterface * requestor = chip::GetRequestorInstance(); + if (requestor == nullptr) + { + return false; + } + + return requestor->GetCurrentUpdateState() == OTARequestorInterface::OTAUpdateStateEnum::kApplying; +} + +CHIP_ERROR OTAImageProcessorImpl::ConfirmCurrentImage() +{ + OTARequestorInterface * requestor = chip::GetRequestorInstance(); + if (requestor == nullptr) + { + return CHIP_ERROR_INTERNAL; + } + + uint32_t currentVersion; + uint32_t targetVersion = requestor->GetTargetVersion(); + ReturnErrorOnFailure(DeviceLayer::ConfigurationMgr().GetSoftwareVersion(currentVersion)); + if (currentVersion != targetVersion) + { + ChipLogError(SoftwareUpdate, "Current software version = %" PRIu32 ", expected software version = %" PRIu32, currentVersion, + targetVersion); + return CHIP_ERROR_INCORRECT_STATE; + } + + return CHIP_NO_ERROR; +} + +CHIP_ERROR OTAImageProcessorImpl::PrepareDownload() +{ + DeviceLayer::PlatformMgr().ScheduleWork(HandlePrepareDownload, reinterpret_cast(this)); + return CHIP_NO_ERROR; +} + +CHIP_ERROR OTAImageProcessorImpl::Finalize() +{ + DeviceLayer::PlatformMgr().ScheduleWork(HandleFinalize, reinterpret_cast(this)); + return CHIP_NO_ERROR; +} + +CHIP_ERROR OTAImageProcessorImpl::Apply() +{ + DeviceLayer::PlatformMgr().ScheduleWork(HandleApply, reinterpret_cast(this)); + return CHIP_NO_ERROR; +} + +CHIP_ERROR OTAImageProcessorImpl::Abort() +{ + DeviceLayer::PlatformMgr().ScheduleWork(HandleAbort, reinterpret_cast(this)); + return CHIP_NO_ERROR; +} + +CHIP_ERROR OTAImageProcessorImpl::ProcessBlock(ByteSpan & block) +{ + if ((nullptr == block.data()) || block.empty()) + { + return CHIP_ERROR_INVALID_ARGUMENT; + } + + // Store block data for HandleProcessBlock to access + CHIP_ERROR err = SetBlock(block); + if (err != CHIP_NO_ERROR) + { + ChipLogError(SoftwareUpdate, "Cannot set block data: %" CHIP_ERROR_FORMAT, err.Format()); + } + + DeviceLayer::PlatformMgr().ScheduleWork(HandleProcessBlock, reinterpret_cast(this)); + return CHIP_NO_ERROR; +} + +void OTAImageProcessorImpl::HandlePrepareDownload(intptr_t context) +{ + auto * imageProcessor = reinterpret_cast(context); + + if (imageProcessor == nullptr) + { + ChipLogError(SoftwareUpdate, "ImageProcessor context is null"); + return; + } + else if (imageProcessor->mDownloader == nullptr) + { + ChipLogError(SoftwareUpdate, "mDownloader is null"); + return; + } + + imageProcessor->mParams.downloadedBytes = 0; + imageProcessor->mParams.totalFileBytes = 0; + imageProcessor->mHeaderParser.Init(); + + imageProcessor->mDownloader->OnPreparedForDownload(CHIP_NO_ERROR); +} + +void OTAImageProcessorImpl::HandleFinalize(intptr_t context) +{ + auto * imageProcessor = reinterpret_cast(context); + + if (imageProcessor == nullptr) + { + return; + } + +#if CHIP_DEVICE_LAYER_TARGET_QCC743 + if (bflb_ota_check() < 0) +#else + if (hosal_ota_check() < 0) +#endif + { + imageProcessor->mDownloader->EndDownload(CHIP_ERROR_WRITE_FAILED); + ChipLogProgress(SoftwareUpdate, "OTA image verification error"); + } + else + { + ChipLogProgress(SoftwareUpdate, "OTA image downloaded"); + } + + imageProcessor->ReleaseBlock(); +} + +void OTAImageProcessorImpl::HandleApply(intptr_t context) +{ + auto * imageProcessor = reinterpret_cast(context); + + if (imageProcessor == nullptr) + { + return; + } + +#if CHIP_DEVICE_LAYER_TARGET_QCC743 + bflb_ota_apply(); +#else + hosal_ota_apply(0); +#endif + DeviceLayer::SystemLayer().StartTimer( + System::Clock::Seconds32(OTA_AUTO_REBOOT_DELAY), + [](Layer *, void *) { + ChipLogProgress(SoftwareUpdate, "Rebooting..."); + hal_reboot(); + }, + nullptr); +} + +void OTAImageProcessorImpl::HandleAbort(intptr_t context) +{ + auto * imageProcessor = reinterpret_cast(context); + if (imageProcessor == nullptr) + { + return; + } + +#if CHIP_DEVICE_LAYER_TARGET_QCC743 + bflb_ota_abort(); +#else + hosal_ota_abort(); +#endif + + imageProcessor->ReleaseBlock(); +} + +void OTAImageProcessorImpl::HandleProcessBlock(intptr_t context) +{ + OTAImageHeader header; + CHIP_ERROR error; + auto * imageProcessor = reinterpret_cast(context); + + if (imageProcessor == nullptr) + { + ChipLogError(SoftwareUpdate, "ImageProcessor context is null"); + return; + } + else if (imageProcessor->mDownloader == nullptr) + { + ChipLogError(SoftwareUpdate, "mDownloader is null"); + return; + } + + ByteSpan block = imageProcessor->mBlock; + if (imageProcessor->mHeaderParser.IsInitialized()) + { + error = imageProcessor->mHeaderParser.AccumulateAndDecode(block, header); + if (CHIP_ERROR_BUFFER_TOO_SMALL == error) + { + return; + } + else if (CHIP_NO_ERROR != error) + { + ChipLogError(SoftwareUpdate, "Matter image header parser error %s", chip::ErrorStr(error)); + imageProcessor->mDownloader->EndDownload(CHIP_ERROR_INVALID_FILE_IDENTIFIER); + imageProcessor->mHeaderParser.Clear(); + return; + } + + ChipLogProgress(SoftwareUpdate, "Image Header software version: %ld payload size: %lu", header.mSoftwareVersion, + (long unsigned int) header.mPayloadSize); + imageProcessor->mParams.totalFileBytes = header.mPayloadSize; + imageProcessor->mHeaderParser.Clear(); + +#if CHIP_DEVICE_LAYER_TARGET_QCC743 + if (bflb_ota_start(header.mPayloadSize) < 0) +#else + if (hosal_ota_start(header.mPayloadSize) < 0) +#endif + { + imageProcessor->mDownloader->EndDownload(CHIP_ERROR_OPEN_FAILED); + return; + } + } + + if (imageProcessor->mParams.totalFileBytes) + { +#if CHIP_DEVICE_LAYER_TARGET_QCC743 + if (bflb_ota_update(imageProcessor->mParams.totalFileBytes, imageProcessor->mParams.downloadedBytes, + (uint8_t *) block.data(), block.size()) < 0) +#else + if (hosal_ota_update(imageProcessor->mParams.totalFileBytes, imageProcessor->mParams.downloadedBytes, + (uint8_t *) block.data(), block.size()) < 0) +#endif + { + imageProcessor->mDownloader->EndDownload(CHIP_ERROR_WRITE_FAILED); + return; + } + imageProcessor->mParams.downloadedBytes += block.size(); + } + + imageProcessor->mDownloader->FetchNextData(); +} + +// Store block data for HandleProcessBlock to access +CHIP_ERROR OTAImageProcessorImpl::SetBlock(ByteSpan & block) +{ + if ((block.data() == nullptr) || block.empty()) + { + return CHIP_NO_ERROR; + } + + // Allocate memory for block data if we don't have enough already + if (mBlock.size() < block.size()) + { + ReleaseBlock(); + + mBlock = MutableByteSpan(static_cast(chip::Platform::MemoryAlloc(block.size())), block.size()); + if (mBlock.data() == nullptr) + { + return CHIP_ERROR_NO_MEMORY; + } + } + + // Store the actual block data + CHIP_ERROR err = CopySpanToMutableSpan(block, mBlock); + if (err != CHIP_NO_ERROR) + { + ChipLogError(SoftwareUpdate, "Cannot copy block data: %" CHIP_ERROR_FORMAT, err.Format()); + return err; + } + + return CHIP_NO_ERROR; +} + +CHIP_ERROR OTAImageProcessorImpl::ReleaseBlock() +{ + if (mBlock.data() != nullptr) + { + chip::Platform::MemoryFree(mBlock.data()); + } + + mBlock = MutableByteSpan(); + return CHIP_NO_ERROR; +} + +} // namespace chip diff --git a/src/platform/qcc74x/common/OTAImageProcessorImpl.h b/src/platform/qcc74x/common/OTAImageProcessorImpl.h new file mode 100644 index 00000000000000..3e68f3c59d329a --- /dev/null +++ b/src/platform/qcc74x/common/OTAImageProcessorImpl.h @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2022 Project CHIP Authors + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include +#include +#include +#include + +namespace chip { + +class OTAImageProcessorImpl : public OTAImageProcessorInterface +{ +public: + //////////// OTAImageProcessorInterface Implementation /////////////// + CHIP_ERROR PrepareDownload() override; + CHIP_ERROR Finalize() override; + CHIP_ERROR Apply() override; + CHIP_ERROR Abort() override; + CHIP_ERROR ProcessBlock(ByteSpan & block) override; + bool IsFirstImageRun() override; + CHIP_ERROR ConfirmCurrentImage() override; + + void SetOTADownloader(OTADownloader * downloader) { mDownloader = downloader; } + +private: + //////////// Actual handlers for the OTAImageProcessorInterface /////////////// + static void HandlePrepareDownload(intptr_t context); + static void HandleFinalize(intptr_t context); + static void HandleApply(intptr_t context); + static void HandleAbort(intptr_t context); + static void HandleProcessBlock(intptr_t context); + + /** + * Called to allocate memory for mBlock if necessary and set it to block + */ + CHIP_ERROR SetBlock(ByteSpan & block); + + /** + * Called to release allocated memory for mBlock + */ + CHIP_ERROR ReleaseBlock(); + + MutableByteSpan mBlock; + OTADownloader * mDownloader; + OTAImageHeaderParser mHeaderParser; +}; + +} // namespace chip diff --git a/src/platform/qcc74x/common/PlatformManagerImpl.cpp b/src/platform/qcc74x/common/PlatformManagerImpl.cpp new file mode 100644 index 00000000000000..a346a1bbd7e1b8 --- /dev/null +++ b/src/platform/qcc74x/common/PlatformManagerImpl.cpp @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2022 Project CHIP Authors + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#include +#include +#include + +namespace chip { +namespace DeviceLayer { + +PlatformManagerImpl PlatformManagerImpl::sInstance; + +void PlatformManagerImpl::_Shutdown() +{ + uint64_t upTime = 0; + + if (GetDiagnosticDataProvider().GetUpTime(upTime) == CHIP_NO_ERROR) + { + uint32_t totalOperationalHours = 0; + + if (ConfigurationMgr().GetTotalOperationalHours(totalOperationalHours) == CHIP_NO_ERROR) + { + ConfigurationMgr().StoreTotalOperationalHours(totalOperationalHours + static_cast(upTime / 3600)); + } + else + { + ChipLogError(DeviceLayer, "Failed to get total operational hours of the Node"); + } + } + else + { + ChipLogError(DeviceLayer, "Failed to get current uptime since the Node’s last reboot"); + } + + Internal::GenericPlatformManagerImpl_FreeRTOS::_Shutdown(); +} + +CHIP_ERROR PlatformManagerImpl::_PostEvent(const ChipDeviceEvent * event) +{ + if (mChipEventQueue == NULL) + { + return CHIP_ERROR_INTERNAL; + } + BaseType_t status = xQueueSend(mChipEventQueue, event, 0); + if (status != pdTRUE) + { + ChipLogError(DeviceLayer, "Failed to post event to CHIP Platform event queue"); + return CHIP_ERROR(chip::ChipError::Range::kOS, status); + } + + return CHIP_NO_ERROR; +} +} // namespace DeviceLayer +} // namespace chip diff --git a/src/platform/qcc74x/common/PlatformManagerImpl.h b/src/platform/qcc74x/common/PlatformManagerImpl.h new file mode 100644 index 00000000000000..59cc45848e2323 --- /dev/null +++ b/src/platform/qcc74x/common/PlatformManagerImpl.h @@ -0,0 +1,105 @@ +/* + * + * Copyright (c) 2021 Project CHIP Authors + * Copyright (c) 2019 Nest Labs, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include + +#if CHIP_DEVICE_LAYER_TARGET_BL602 +#include +#endif + +namespace chip { +namespace DeviceLayer { + +/** + * Concrete implementation of the PlatformManager singleton object for the Bouffalo Lab platform. + */ +class PlatformManagerImpl final : public PlatformManager, public Internal::GenericPlatformManagerImpl_FreeRTOS +{ + // Allow the PlatformManager interface class to delegate method calls to + // the implementation methods provided by this class. + friend PlatformManager; + + // Allow the generic implementation base class to call helper methods on + // this class. +#ifndef DOXYGEN_SHOULD_SKIP_THIS + friend Internal::GenericPlatformManagerImpl_FreeRTOS; +#endif + +protected: + void _RunEventLoop(void); + +public: + // ===== Platform-specific members that may be accessed directly by the application. + System::Clock::Timestamp GetStartTime() { return mStartTime; } + +private: + // ===== Methods that implement the PlatformManager abstract interface. + CHIP_ERROR _InitChipStack(void); + void _Shutdown(); + + // ===== Members for internal use by the following friends. + + friend PlatformManager & PlatformMgr(void); + friend PlatformManagerImpl & PlatformMgrImpl(void); + friend class Internal::BLEManagerImpl; +#if CHIP_DEVICE_LAYER_TARGET_BL602 && CHIP_DEVICE_CONFIG_ENABLE_WIFI + friend void OnWiFiPlatformEvent(input_event_t * event, void * private_data); +#endif + + CHIP_ERROR _PostEvent(const ChipDeviceEvent * event); + System::Clock::Timestamp mStartTime = System::Clock::kZero; + + static PlatformManagerImpl sInstance; + + using Internal::GenericPlatformManagerImpl_FreeRTOS::PostEventFromISR; + + CHIP_ERROR PlatformInit(void); +}; + +/** + * Returns the public interface of the PlatformManager singleton object. + * + * Chip applications should use this to access features of the PlatformManager object + * that are common to all platforms. + */ +inline PlatformManager & PlatformMgr(void) +{ + return PlatformManagerImpl::sInstance; +} + +/** + * Returns the platform-specific implementation of the PlatformManager singleton object. + * + * Chip applications can use this to gain access to features of the PlatformManager + * that are specific to the Bouffalo Lab platform. + */ +inline PlatformManagerImpl & PlatformMgrImpl(void) +{ + return PlatformManagerImpl::sInstance; +} + +inline void PlatformManagerImpl::_RunEventLoop(void) +{ + PlatformInit(); + Internal::GenericPlatformManagerImpl_FreeRTOS::_RunEventLoop(); +} + +} // namespace DeviceLayer +} // namespace chip diff --git a/src/platform/qcc74x/common/SystemPlatformConfig.h b/src/platform/qcc74x/common/SystemPlatformConfig.h new file mode 100644 index 00000000000000..f16397c18a0773 --- /dev/null +++ b/src/platform/qcc74x/common/SystemPlatformConfig.h @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2022 Project CHIP Authors + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include + +namespace chip { +namespace DeviceLayer { +struct ChipDeviceEvent; +} // namespace DeviceLayer +} // namespace chip + +// ==================== Platform Adaptations ==================== +#define CHIP_SYSTEM_CONFIG_PLATFORM_PROVIDES_EVENT_FUNCTIONS 1 +#define CHIP_SYSTEM_CONFIG_PLATFORM_PROVIDES_TIME 1 +#define CHIP_SYSTEM_CONFIG_EVENT_OBJECT_TYPE const struct ::chip::DeviceLayer::ChipDeviceEvent * + +#if CHIP_ENABLE_OPENTHREAD +#define CHIP_SYSTEM_CONFIG_PACKETBUFFER_POOL_SIZE 8 +#endif + +#if CHIP_DEVICE_LAYER_TARGET_QCC743 +// #define CHIP_CONFIG_SHA256_CONTEXT_SIZE sizeof(mbedtls_sha256_context) in hw_acc/sha256_alt.h +#define CHIP_CONFIG_SHA256_CONTEXT_SIZE (32 + 64 + 64 + 19 * 32) +#define CHIP_CONFIG_SHA256_CONTEXT_ALIGN 32 +#define CHIP_SYSTEM_CRYPTO_HEADER_RESERVE_SIZE (388) +#else + +// #define CHIP_CONFIG_SHA256_CONTEXT_SIZE sizeof(bl_sha_ctx_t) +#define CHIP_CONFIG_SHA256_CONTEXT_SIZE ((7 + 1 + 5 + 18 + 16 + 16 + 7) * sizeof(unsigned int)) +#endif diff --git a/src/platform/qcc74x/common/ThreadStackManagerImpl.h b/src/platform/qcc74x/common/ThreadStackManagerImpl.h new file mode 100644 index 00000000000000..462d2de76ac32d --- /dev/null +++ b/src/platform/qcc74x/common/ThreadStackManagerImpl.h @@ -0,0 +1,111 @@ +/* + * Copyright (c) 2022 Project CHIP Authors + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include +#include +#include +#include + +extern "C" void otSysEventSignalPending(void); +extern "C" void otrLock(void); +extern "C" void otrUnlock(void); +extern "C" otInstance * otrGetInstance(); + +namespace chip { +namespace DeviceLayer { + +class ThreadStackManager; +class ThreadStackManagerImpl; + +/** + * Concrete implementation of the ThreadStackManager singleton object for Bouffalo Lab platforms + * using the Bouffalolab SDK and the OpenThread stack. + */ +class ThreadStackManagerImpl final : public ThreadStackManager, + public Internal::GenericThreadStackManagerImpl_OpenThread, + public Internal::GenericThreadStackManagerImpl_FreeRTOS +{ + // Allow the ThreadStackManager interface class to delegate method calls to + // the implementation methods provided by this class. + friend class ThreadStackManager; + + // Allow the generic implementation base classes to call helper methods on + // this class. +#ifndef DOXYGEN_SHOULD_SKIP_THIS + friend Internal::GenericThreadStackManagerImpl_OpenThread; + friend Internal::GenericThreadStackManagerImpl_OpenThread_LwIP; + friend Internal::GenericThreadStackManagerImpl_FreeRTOS; +#endif + + // // Allow glue functions called by OpenThread to call helper methods on this + // // class. + friend void ::otSysEventSignalPending(void); + friend void ::otrLock(void); + friend void ::otrUnlock(void); + friend void ::otTaskletsSignalPending(otInstance * otInst); + +public: + // ===== Platform-specific members that may be accessed directly by the application. + + using ThreadStackManager::InitThreadStack; + CHIP_ERROR InitThreadStack(otInstance * otInst); + +private: + // ===== Methods that implement the ThreadStackManager abstract interface. + + CHIP_ERROR _InitThreadStack(void); + + // ===== Members for internal use by the following friends. + + friend ThreadStackManager & ::chip::DeviceLayer::ThreadStackMgr(void); + friend ThreadStackManagerImpl & ::chip::DeviceLayer::ThreadStackMgrImpl(void); + + static ThreadStackManagerImpl sInstance; + + static bool IsInitialized(); + + // ===== Private members for use by this class only. + + ThreadStackManagerImpl() = default; +}; + +/** + * Returns the public interface of the ThreadStackManager singleton object. + * + * Chip applications should use this to access features of the ThreadStackManager object + * that are common to all platforms. + */ +inline ThreadStackManager & ThreadStackMgr(void) +{ + return ThreadStackManagerImpl::sInstance; +} + +/** + * Returns the platform-specific implementation of the ThreadStackManager singleton object. + * + * Chip applications can use this to gain access to features of the ThreadStackManager + * that are specific to Bouffalo Lab platforms. + */ +inline ThreadStackManagerImpl & ThreadStackMgrImpl(void) +{ + return ThreadStackManagerImpl::sInstance; +} + +} // namespace DeviceLayer +} // namespace chip diff --git a/src/platform/qcc74x/common/args.gni b/src/platform/qcc74x/common/args.gni new file mode 100644 index 00000000000000..15c7b10dba8a01 --- /dev/null +++ b/src/platform/qcc74x/common/args.gni @@ -0,0 +1,22 @@ +# Copyright (c) 2020 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +declare_args() { + chip_enable_factory_data = false + chip_enable_factory_data_test = false + + chip_enable_ethernet = false + + qcc74x_sdk_component_easyflash_enabled = false +} diff --git a/src/platform/qcc74x/qcc743/BUILD.gn b/src/platform/qcc74x/qcc743/BUILD.gn new file mode 100644 index 00000000000000..a87abdfdd7a0b9 --- /dev/null +++ b/src/platform/qcc74x/qcc743/BUILD.gn @@ -0,0 +1,81 @@ +# Copyright (c) 2022 Project CHIP Authors +# All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build_overrides/chip.gni") + +import("${chip_root}/src/platform/device.gni") + +import("${chip_root}/src/platform/qcc74x/common/args.gni") + +assert(chip_device_platform == "qcc743") + +static_library("qcc743") { + sources = [ + "ConfigurationManagerImpl.cpp", + "ConnectivityManagerImpl.cpp", + "DiagnosticDataProviderImpl.cpp", + "NetworkCommissioningDriver.cpp", + "PlatformManagerImpl.cpp", + "wifi_mgmr_portable.c", + ] + + sources += [ + "../../FreeRTOS/SystemTimeSupport.cpp", + "../../SingletonConfigurationManager.cpp", + "../common/ConfigurationManagerImpl.cpp", + "../common/ConnectivityManagerImpl.cpp", + "../common/DiagnosticDataProviderImpl.cpp", + "../common/KeyValueStoreManagerImpl.cpp", + "../common/Logging.cpp", + "../common/PlatformManagerImpl.cpp", + ] + + if (chip_enable_ota_requestor) { + sources += [ + "../common/OTAImageProcessorImpl.cpp", + "../common/OTAImageProcessorImpl.h", + ] + } + + if (chip_enable_ble) { + sources += [ + "../common/BLEManagerImpl.cpp", + "../common/BLEManagerImpl.h", + ] + } + + defines = + [ "CONFIG_BOUFFALOLAB_FACTORY_DATA_ENABLE=${chip_enable_factory_data}" ] + if (chip_enable_factory_data || chip_enable_factory_data_test) { + sources += [ + "../common/FactoryDataProvider.cpp", + "../common/FactoryDataProvider.h", + ] + } + + if (qcc74x_sdk_component_easyflash_enabled) { + sources += [ "../common/BLConfig.cpp"] + } + else { + sources += [ "../common/BLConfig_littlefs.cpp"] + } + + deps = [ + "${chip_root}/src/credentials:credentials_header", + "${chip_root}/src/lib/dnssd:platform_header", + "${chip_root}/src/platform/logging:headers", + ] + public_deps = [ "${chip_root}/src/platform:platform_base" ] +} diff --git a/src/platform/qcc74x/qcc743/CHIPMem-Platform.cpp b/src/platform/qcc74x/qcc743/CHIPMem-Platform.cpp new file mode 100644 index 00000000000000..34e336d8a6d7c9 --- /dev/null +++ b/src/platform/qcc74x/qcc743/CHIPMem-Platform.cpp @@ -0,0 +1,89 @@ +/* + * + * Copyright (c) 2020 Project CHIP Authors + * Copyright (c) 2019 Nest Labs, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * + * Copyright (c) 2020-2021 Project CHIP Authors + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @file + * This file implements heap memory allocation APIs for CHIP. These functions are platform + * specific and might be C Standard Library heap functions re-direction in most of cases. + * + */ + +#include + +#include + +#if CHIP_CONFIG_MEMORY_MGMT_PLATFORM +namespace chip { +namespace Platform { + +CHIP_ERROR MemoryAllocatorInit(void * buf, size_t bufSize) +{ + return CHIP_NO_ERROR; +} + +void MemoryAllocatorShutdown() +{ +} + +void * MemoryAlloc(size_t size) +{ + return kmalloc(size); +} + +void * MemoryCalloc(size_t num, size_t size) +{ + return kcalloc(size, num); +} + +void * MemoryRealloc(void * p, size_t size) +{ + return realloc(p, size); +} + +void MemoryFree(void * p) +{ + kfree(p); +} + +bool MemoryInternalCheckPointer(const void * p, size_t min_size) +{ + return (p != nullptr); +} + +} // namespace Platform +} // namespace chip + +#endif // CHIP_CONFIG_MEMORY_MGMT_PLATFORM diff --git a/src/platform/qcc74x/qcc743/ConfigurationManagerImpl.cpp b/src/platform/qcc74x/qcc743/ConfigurationManagerImpl.cpp new file mode 100644 index 00000000000000..f0b65b34bd896b --- /dev/null +++ b/src/platform/qcc74x/qcc743/ConfigurationManagerImpl.cpp @@ -0,0 +1,46 @@ +/* + * + * Copyright (c) 2022 Project CHIP Authors + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#include + +#include + +#include +#include + +#include +#include + +extern "C" { +#include +} + +namespace chip { +namespace DeviceLayer { + +CHIP_ERROR ConfigurationManagerImpl::GetPrimaryWiFiMACAddress(uint8_t * buf) +{ + bflb_efuse_read_mac_address_opt(0, buf, 1); + + return CHIP_NO_ERROR; +} + +} // namespace DeviceLayer +} // namespace chip diff --git a/src/platform/qcc74x/qcc743/ConnectivityManagerImpl.cpp b/src/platform/qcc74x/qcc743/ConnectivityManagerImpl.cpp new file mode 100644 index 00000000000000..673c9b7d49c5e7 --- /dev/null +++ b/src/platform/qcc74x/qcc743/ConnectivityManagerImpl.cpp @@ -0,0 +1,103 @@ +/* + * Copyright (c) 2022 Project CHIP Authors + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#include + +#include +#include + +#include + +using namespace ::chip; + +namespace chip { +namespace DeviceLayer { + +void ConnectivityManagerImpl::OnWiFiStationDisconnected() +{ + NetworkCommissioning::BLWiFiDriver::GetInstance().SetLastDisconnectReason(NULL); + uint16_t reason = NetworkCommissioning::BLWiFiDriver::GetInstance().GetLastDisconnectReason(); + uint8_t associationFailureCause = + chip::to_underlying(chip::app::Clusters::WiFiNetworkDiagnostics::AssociationFailureCauseEnum::kUnknown); + WiFiDiagnosticsDelegate * delegate = GetDiagnosticDataProvider().GetWiFiDiagnosticsDelegate(); + + ChipLogError(DeviceLayer, "WiFi station disconnect, reason %d.", reason); + + switch (reason) + { + case WLAN_FW_TX_ASSOC_FRAME_ALLOCATE_FAIILURE: + case WLAN_FW_ASSOCIATE_FAIILURE: + case WLAN_FW_4WAY_HANDSHAKE_ERROR_PSK_TIMEOUT_FAILURE: + associationFailureCause = + chip::to_underlying(chip::app::Clusters::WiFiNetworkDiagnostics::AssociationFailureCauseEnum::kAssociationFailed); + if (delegate) + { + delegate->OnAssociationFailureDetected(associationFailureCause, reason); + } + break; + case WLAN_FW_TX_AUTH_FRAME_ALLOCATE_FAIILURE: + case WLAN_FW_AUTHENTICATION_FAIILURE: + case WLAN_FW_AUTH_ALGO_FAIILURE: + case WLAN_FW_DEAUTH_BY_AP_WHEN_NOT_CONNECTION: + case WLAN_FW_DEAUTH_BY_AP_WHEN_CONNECTION: + case WLAN_FW_4WAY_HANDSHAKE_TX_DEAUTH_FRAME_TRANSMIT_FAILURE: + case WLAN_FW_4WAY_HANDSHAKE_TX_DEAUTH_FRAME_ALLOCATE_FAIILURE: + case WLAN_FW_AUTH_OR_ASSOC_RESPONSE_TIMEOUT_FAILURE: + case WLAN_FW_DISCONNECT_BY_USER_WITH_DEAUTH: + case WLAN_FW_DISCONNECT_BY_USER_NO_DEAUTH: + associationFailureCause = + chip::to_underlying(chip::app::Clusters::WiFiNetworkDiagnostics::AssociationFailureCauseEnum::kAuthenticationFailed); + if (delegate) + { + delegate->OnAssociationFailureDetected(associationFailureCause, reason); + } + break; + case WLAN_FW_SCAN_NO_BSSID_AND_CHANNEL: + associationFailureCause = + chip::to_underlying(chip::app::Clusters::WiFiNetworkDiagnostics::AssociationFailureCauseEnum::kSsidNotFound); + if (delegate) + { + delegate->OnAssociationFailureDetected(associationFailureCause, reason); + } + break; + case WLAN_FW_BEACON_LOSS: + case WLAN_FW_DISCONNECT_BY_FW_PS_TX_NULLFRAME_FAILURE: + case WLAN_FW_CREATE_CHANNEL_CTX_FAILURE_WHEN_JOIN_NETWORK: + case WLAN_FW_ADD_STA_FAILURE: + case WLAN_FW_JOIN_NETWORK_FAILURE: + break; + + default: + if (delegate) + { + delegate->OnAssociationFailureDetected(associationFailureCause, reason); + } + break; + } + + if (delegate) + { + delegate->OnDisconnectionDetected(reason); + delegate->OnConnectionStatusChanged( + chip::to_underlying(chip::app::Clusters::WiFiNetworkDiagnostics::ConnectionStatusEnum::kNotConnected)); + } +} + +} // namespace DeviceLayer +} // namespace chip diff --git a/src/platform/qcc74x/qcc743/DiagnosticDataProviderImpl.cpp b/src/platform/qcc74x/qcc743/DiagnosticDataProviderImpl.cpp new file mode 100644 index 00000000000000..eb83db36ac824e --- /dev/null +++ b/src/platform/qcc74x/qcc743/DiagnosticDataProviderImpl.cpp @@ -0,0 +1,135 @@ +/* + * + * Copyright (c) 2022 Project CHIP Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include + +#include + +extern "C" { +#include +} +#include + +namespace chip { +namespace DeviceLayer { + +CHIP_ERROR DiagnosticDataProviderImpl::GetBootReason(BootReasonType & bootReason) +{ + bootReason = BootReasonType::kUnspecified; + return CHIP_NO_ERROR; +} + +CHIP_ERROR DiagnosticDataProviderImpl::GetWiFiBssId(MutableByteSpan & BssId) +{ + wifi_mgmr_connect_ind_stat_info_t statInfo; + + memset(&statInfo, 0, sizeof(wifi_mgmr_connect_ind_stat_info_t)); + if (ConnectivityMgrImpl()._IsWiFiStationConnected() && 0 == wifi_mgmr_sta_connect_ind_stat_get(&statInfo)) + { + return CopySpanToMutableSpan(ByteSpan(statInfo.bssid), BssId); + } + + return CHIP_ERROR_READ_FAILED; +} + +CHIP_ERROR DiagnosticDataProviderImpl::GetWiFiSecurityType(app::Clusters::WiFiNetworkDiagnostics::SecurityTypeEnum & securityType) +{ + return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; +} + +CHIP_ERROR DiagnosticDataProviderImpl::GetWiFiVersion(app::Clusters::WiFiNetworkDiagnostics::WiFiVersionEnum & wifiVersion) +{ + return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; +} + +CHIP_ERROR DiagnosticDataProviderImpl::GetWiFiChannelNumber(uint16_t & channelNumber) +{ + wifi_mgmr_connect_ind_stat_info_t statInfo; + + memset(&statInfo, 0, sizeof(wifi_mgmr_connect_ind_stat_info_t)); + if (ConnectivityMgrImpl()._IsWiFiStationConnected() && 0 == wifi_mgmr_sta_connect_ind_stat_get(&statInfo)) + { + channelNumber = statInfo.channel; + return CHIP_NO_ERROR; + } + + return CHIP_ERROR_READ_FAILED; +} + +CHIP_ERROR DiagnosticDataProviderImpl::GetWiFiRssi(int8_t & rssi) +{ + int tmp_rssi; + if (ConnectivityMgrImpl()._IsWiFiStationConnected()) + { + wifi_mgmr_sta_rssi_get(&tmp_rssi); + rssi = (int8_t)tmp_rssi; + return CHIP_NO_ERROR; + } + + return CHIP_ERROR_READ_FAILED; +} + +CHIP_ERROR DiagnosticDataProviderImpl::GetWiFiBeaconLostCount(uint32_t & beaconLostCount) +{ + return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; +} + +CHIP_ERROR DiagnosticDataProviderImpl::GetWiFiCurrentMaxRate(uint64_t & currentMaxRate) +{ + return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; +} + +CHIP_ERROR DiagnosticDataProviderImpl::GetWiFiPacketMulticastRxCount(uint32_t & packetMulticastRxCount) +{ + return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; +} + +CHIP_ERROR DiagnosticDataProviderImpl::GetWiFiPacketMulticastTxCount(uint32_t & packetMulticastTxCount) +{ + return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; +} + +CHIP_ERROR DiagnosticDataProviderImpl::GetWiFiPacketUnicastRxCount(uint32_t & packetUnicastRxCount) +{ + return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; +} + +CHIP_ERROR DiagnosticDataProviderImpl::GetWiFiPacketUnicastTxCount(uint32_t & packetUnicastTxCount) +{ + return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; +} + +CHIP_ERROR DiagnosticDataProviderImpl::GetWiFiOverrunCount(uint64_t & overrunCount) +{ + return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; +} + +CHIP_ERROR DiagnosticDataProviderImpl::ResetWiFiNetworkDiagnosticsCounts() +{ + return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; +} + +CHIP_ERROR DiagnosticDataProviderImpl::GetWiFiBeaconRxCount(uint32_t & beaconRxCount) +{ + return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; +} + +} // namespace DeviceLayer +} // namespace chip diff --git a/src/platform/qcc74x/qcc743/NetworkCommissioningDriver.cpp b/src/platform/qcc74x/qcc743/NetworkCommissioningDriver.cpp new file mode 100644 index 00000000000000..5a375e73127e23 --- /dev/null +++ b/src/platform/qcc74x/qcc743/NetworkCommissioningDriver.cpp @@ -0,0 +1,432 @@ +/* + * + * Copyright (c) 2021 Project CHIP Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include +#include + +#include +#include +#include +#include +extern "C" { +#include +} +#include + +using namespace ::chip; +using namespace ::chip::DeviceLayer::Internal; +using namespace ::chip::Platform; + +namespace chip { +namespace DeviceLayer { +namespace NetworkCommissioning { + +CHIP_ERROR BLWiFiDriver::Init(NetworkStatusChangeCallback * networkStatusChangeCallback) +{ + CHIP_ERROR err; + size_t ssidLen = 0; + size_t credentialsLen = 0; + + err = PersistedStorage::KeyValueStoreMgr().Get(BLConfig::kConfigKey_WiFiPassword, mSavedNetwork.credentials, + sizeof(mSavedNetwork.credentials), &credentialsLen); + SuccessOrExit(err); + err = PersistedStorage::KeyValueStoreMgr().Get(BLConfig::kConfigKey_WiFiSSID, mSavedNetwork.ssid, sizeof(mSavedNetwork.ssid), + &ssidLen); + SuccessOrExit(err); + mSavedNetwork.credentialsLen = credentialsLen; + mSavedNetwork.ssidLen = ssidLen; + + mStagingNetwork = mSavedNetwork; + mpScanCallback = nullptr; + mpConnectCallback = nullptr; + mpStatusChangeCallback = networkStatusChangeCallback; + +exit: + if (err == CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND) + { + /** Not commissioned, SSID and Network Password not found. */ + return CHIP_NO_ERROR; + } + + return err; +} + +void BLWiFiDriver::Shutdown() +{ + mpStatusChangeCallback = nullptr; +} + +CHIP_ERROR BLWiFiDriver::CommitConfiguration() +{ + ChipLogProgress(NetworkProvisioning, "BLWiFiDriver::CommitConfiguration"); + ReturnErrorOnFailure( + PersistedStorage::KeyValueStoreMgr().Put(BLConfig::kConfigKey_WiFiSSID, mStagingNetwork.ssid, mStagingNetwork.ssidLen)); + ReturnErrorOnFailure(PersistedStorage::KeyValueStoreMgr().Put(BLConfig::kConfigKey_WiFiPassword, mStagingNetwork.credentials, + mStagingNetwork.credentialsLen)); + mSavedNetwork = mStagingNetwork; + return CHIP_NO_ERROR; +} + +CHIP_ERROR BLWiFiDriver::RevertConfiguration() +{ + mStagingNetwork = mSavedNetwork; + return CHIP_NO_ERROR; +} + +bool BLWiFiDriver::NetworkMatch(const WiFiNetwork & network, ByteSpan networkId) +{ + return networkId.size() == network.ssidLen && memcmp(networkId.data(), network.ssid, network.ssidLen) == 0; +} + +Status BLWiFiDriver::AddOrUpdateNetwork(ByteSpan ssid, ByteSpan credentials, MutableCharSpan & outDebugText, + uint8_t & outNetworkIndex) +{ + outDebugText.reduce_size(0); + outNetworkIndex = 0; + + VerifyOrReturnError(mStagingNetwork.ssidLen == 0 || NetworkMatch(mStagingNetwork, ssid), Status::kBoundsExceeded); + VerifyOrReturnError(credentials.size() <= sizeof(mStagingNetwork.credentials), Status::kOutOfRange); + VerifyOrReturnError(ssid.size() <= sizeof(mStagingNetwork.ssid), Status::kOutOfRange); + + memcpy(mStagingNetwork.credentials, credentials.data(), credentials.size()); + mStagingNetwork.credentialsLen = static_cast(credentials.size()); + + memcpy(mStagingNetwork.ssid, ssid.data(), ssid.size()); + mStagingNetwork.ssidLen = static_cast(ssid.size()); + + return Status::kSuccess; +} + +Status BLWiFiDriver::RemoveNetwork(ByteSpan networkId, MutableCharSpan & outDebugText, uint8_t & outNetworkIndex) +{ + outDebugText.reduce_size(0); + outNetworkIndex = 0; + + VerifyOrReturnError(NetworkMatch(mStagingNetwork, networkId), Status::kNetworkIDNotFound); + + // Use empty ssid for representing invalid network + mStagingNetwork.ssidLen = 0; + return Status::kSuccess; +} + +Status BLWiFiDriver::ReorderNetwork(ByteSpan networkId, uint8_t index, MutableCharSpan & outDebugText) +{ + outDebugText.reduce_size(0); + + // Only one network is supported now + VerifyOrReturnError(index == 0, Status::kOutOfRange); + VerifyOrReturnError(NetworkMatch(mStagingNetwork, networkId), Status::kNetworkIDNotFound); + return Status::kSuccess; +} + +CHIP_ERROR BLWiFiDriver::ConnectWiFiNetwork(const char * ssid, uint8_t ssidLen, const char * key, uint8_t keyLen) +{ + wifi_mgmr_sta_connect_params_t conn_param = {0}; + + ConnectivityMgrImpl().ChangeWiFiStationState(ConnectivityManager::kWiFiStationState_Connecting); + + strncpy((char *)conn_param.ssid, ssid, ssidLen); + conn_param.ssid_len = ssidLen; + + if (keyLen) { + strncpy((char *)conn_param.key, key, keyLen); + conn_param.key_len = keyLen; + } + conn_param.freq1 = 0; + conn_param.freq2 = 0; + conn_param.use_dhcp = 1; + conn_param.pmf_cfg = 1; + conn_param.quick_connect = 1; + conn_param.timeout_ms = -1; + + wifi_mgmr_sta_connect(&conn_param); + + return CHIP_NO_ERROR; +} + +void BLWiFiDriver::OnConnectWiFiNetwork(bool isConnected) +{ + if (mpConnectCallback) + { + if (isConnected) + { + mpConnectCallback->OnResult(Status::kSuccess, CharSpan(), 0); + } + else + { + mpConnectCallback->OnResult(Status::kUnknownError, CharSpan(), 0); + } + mpConnectCallback = nullptr; + } +} + +void BLWiFiDriver::ConnectNetwork(ByteSpan networkId, ConnectCallback * callback) +{ + CHIP_ERROR err = CHIP_NO_ERROR; + Status networkingStatus = Status::kSuccess; + + VerifyOrExit(NetworkMatch(mStagingNetwork, networkId), networkingStatus = Status::kNetworkIDNotFound); + VerifyOrExit(mpConnectCallback == nullptr, networkingStatus = Status::kUnknownError); + ChipLogProgress(NetworkProvisioning, "BL NetworkCommissioningDelegate: SSID: %.*s", static_cast(networkId.size()), + networkId.data()); + + err = ConnectWiFiNetwork(reinterpret_cast(mStagingNetwork.ssid), mStagingNetwork.ssidLen, + reinterpret_cast(mStagingNetwork.credentials), mStagingNetwork.credentialsLen); + mpConnectCallback = callback; + +exit: + if (err != CHIP_NO_ERROR) + { + networkingStatus = Status::kUnknownError; + } + if (networkingStatus != Status::kSuccess) + { + ChipLogError(NetworkProvisioning, "Failed to connect to WiFi network:%s", chip::ErrorStr(err)); + mpConnectCallback = nullptr; + callback->OnResult(networkingStatus, CharSpan(), 0); + } +} + +void BLWiFiDriver::ScanNetworks(ByteSpan ssid, WiFiDriver::ScanCallback * callback) +{ + if (callback != nullptr) + { + mpScanCallback = nullptr; + if (0 == wifi_start_scan(ssid.data(), ssid.size())) + { + mpScanCallback = callback; + } + else { + callback->OnFinished(Status::kUnknownError, CharSpan(), nullptr); + } + } +} + +void BLWiFiDriver::OnScanWiFiNetworkDone() +{ + uint32_t nums = wifi_mgmr_sta_scanlist_nums_get(); + if (nums) { + wifi_mgmr_scan_item_t * pScanList = (wifi_mgmr_scan_item_t*)MemoryAlloc(nums * sizeof(wifi_mgmr_scan_item_t)); + + if (NULL == pScanList || 0 == wifi_mgmr_sta_scanlist_dump(pScanList, nums)) { + mpScanCallback->OnFinished(Status::kUnknownError, CharSpan(), nullptr); + mpScanCallback = nullptr; + } + else { + + if (CHIP_NO_ERROR == DeviceLayer::SystemLayer().ScheduleLambda([nums, pScanList]() { + BLScanResponseIterator iter(nums, pScanList); + if (GetInstance().mpScanCallback) + { + GetInstance().mpScanCallback->OnFinished(Status::kSuccess, CharSpan(), &iter); + GetInstance().mpScanCallback = nullptr; + } + else + { + ChipLogError(DeviceLayer, "can't find the ScanCallback function"); + } + })) + { + MemoryFree(pScanList); + } + } + } + else { + ChipLogProgress(DeviceLayer, "No AP found"); + if (mpScanCallback != nullptr) + { + mpScanCallback->OnFinished(Status::kNetworkNotFound, CharSpan(), nullptr); + mpScanCallback = nullptr; + } + } +} + +CHIP_ERROR GetConfiguredNetwork(Network & network) +{ + wifi_mgmr_connect_ind_stat_info_t statInfo; + + memset(&statInfo, 0, sizeof(wifi_mgmr_connect_ind_stat_info_t)); + if (0 == wifi_mgmr_sta_connect_ind_stat_get(&statInfo)) { + memcpy(network.networkID, statInfo.ssid, strlen(statInfo.ssid)); + network.networkIDLen = strlen(statInfo.ssid); + return CHIP_NO_ERROR; + } + + return CHIP_ERROR_INTERNAL; +} + +void BLWiFiDriver::OnNetworkStatusChange() +{ + Network configuredNetwork; + + VerifyOrReturn(mpStatusChangeCallback != nullptr); + if (GetConfiguredNetwork(configuredNetwork) != CHIP_NO_ERROR) + { + return; + } + + if (ConnectivityManagerImpl().GetWiFiStationState() == ConnectivityManager::kWiFiStationState_Connected) + { + mpStatusChangeCallback->OnNetworkingStatusChange( + Status::kSuccess, MakeOptional(ByteSpan(configuredNetwork.networkID, configuredNetwork.networkIDLen)), NullOptional); + } + else { + mpStatusChangeCallback->OnNetworkingStatusChange( + Status::kUnknownError, MakeOptional(ByteSpan(configuredNetwork.networkID, configuredNetwork.networkIDLen)), + MakeOptional(GetLastDisconnectReason())); + } +} + +CHIP_ERROR BLWiFiDriver::SetLastDisconnectReason(const ChipDeviceEvent * event) +{ + mLastDisconnectedReason = wifi_mgmr_sta_info_status_code_get(); + + return CHIP_NO_ERROR; +} + +int32_t BLWiFiDriver::GetLastDisconnectReason() +{ + return mLastDisconnectedReason; +} + +size_t BLWiFiDriver::WiFiNetworkIterator::Count() +{ + return mDriver->mStagingNetwork.ssidLen == 0 ? 0 : 1; +} + +bool BLWiFiDriver::WiFiNetworkIterator::Next(Network & item) +{ + if (mExhausted || mDriver->mStagingNetwork.ssidLen == 0) + { + return false; + } + memcpy(item.networkID, mDriver->mStagingNetwork.ssid, mDriver->mStagingNetwork.ssidLen); + item.networkIDLen = mDriver->mStagingNetwork.ssidLen; + item.connected = false; + mExhausted = true; + + Network connectedNetwork; + CHIP_ERROR err = GetConfiguredNetwork(connectedNetwork); + if (err == CHIP_NO_ERROR) + { + if (connectedNetwork.networkIDLen == item.networkIDLen && + memcmp(connectedNetwork.networkID, item.networkID, item.networkIDLen) == 0) + { + item.connected = true; + } + } + return true; +} + +void NetworkEventHandler(const ChipDeviceEvent * event, intptr_t arg) +{ + if (!(DeviceEventType::IsPlatformSpecific(event->Type) && DeviceEventType::IsPublic(event->Type))) { + return; + } + + switch (event->Type) { + case kWiFiOnInitDone: + break; + case kWiFiOnScanDone: + BLWiFiDriver::GetInstance().OnScanWiFiNetworkDone(); + break; + case kWiFiOnConnected: + BLWiFiDriver::GetInstance().OnNetworkStatusChange(); + break; + case kGotIpAddress: + ConnectivityMgrImpl().ChangeWiFiStationState(ConnectivityManagerImpl::kWiFiStationState_Connected); + ConnectivityMgrImpl().OnConnectivityChanged(deviceInterface_getNetif()); + break; + case kGotIpv6Address: + ConnectivityMgrImpl().ChangeWiFiStationState(ConnectivityManagerImpl::kWiFiStationState_Connected); + ConnectivityMgrImpl().OnConnectivityChanged(deviceInterface_getNetif()); + break; + case kWiFiOnDisconnected: + if (ConnectivityManager::kWiFiStationState_Connecting == ConnectivityMgrImpl().GetWiFiStationState()) + { + ConnectivityMgrImpl().ChangeWiFiStationState(ConnectivityManager::kWiFiStationState_Connecting_Failed); + } + break; + default: + ChipLogProgress(DeviceLayer, "Undefined network commission event type %x.\r\n", event->Type); + break; + } +} + +static wifi_conf_t conf = { + .country_code = "CN", +}; + +extern "C" void wifi_event_handler(uint32_t code) +{ + ChipDeviceEvent event; + + memset(&event, 0, sizeof(ChipDeviceEvent)); + + switch (code) { + case CODE_WIFI_ON_INIT_DONE: + wifi_mgmr_init(&conf); + break; + case CODE_WIFI_ON_MGMR_DONE: + wifi_mgmr_sta_autoconnect_enable(); + break; + case CODE_WIFI_ON_SCAN_DONE: + event.Type = kWiFiOnScanDone; + PlatformMgr().PostEventOrDie(&event); + break; + case CODE_WIFI_ON_CONNECTED: + event.Type = kWiFiOnConnected; + PlatformMgr().PostEventOrDie(&event); + break; + case CODE_WIFI_ON_GOT_IP: + event.Type = kGotIpAddress; + PlatformMgr().PostEventOrDie(&event); + break; + case CODE_WIFI_ON_DISCONNECT: + event.Type = kWiFiOnDisconnected; + PlatformMgr().PostEventOrDie(&event); + break; + default: { + ChipLogProgress(DeviceLayer, "[APP] [EVT] Unknown code %lu \r\n", code); + } + } +} + +extern "C" void network_netif_ext_callback(struct netif* nif, netif_nsc_reason_t reason, const netif_ext_callback_args_t* args) +{ + ChipDeviceEvent event; + + memset(&event, 0, sizeof(ChipDeviceEvent)); + + if (((LWIP_NSC_IPV6_ADDR_STATE_CHANGED | LWIP_NSC_IPV6_SET) & reason) && args) { + + if (args->ipv6_addr_state_changed.addr_index >= LWIP_IPV6_NUM_ADDRESSES || + ip6_addr_islinklocal(netif_ip6_addr(nif, args->ipv6_addr_state_changed.addr_index))) { + return; + } + + if (netif_ip6_addr_state(nif, args->ipv6_addr_state_changed.addr_index) != args->ipv6_addr_state_changed.old_state && + ip6_addr_ispreferred(netif_ip6_addr_state(nif, args->ipv6_addr_state_changed.addr_index))) { + event.Type = kGotIpv6Address; + PlatformMgr().PostEventOrDie(&event); + } + } +} + +} // namespace NetworkCommissioning +} // namespace DeviceLayer +} // namespace chip +//#endif // CHIP_DEVICE_CONFIG_ENABLE_WIFI diff --git a/src/platform/qcc74x/qcc743/NetworkCommissioningDriver.h b/src/platform/qcc74x/qcc743/NetworkCommissioningDriver.h new file mode 100644 index 00000000000000..e28c2ddfe61569 --- /dev/null +++ b/src/platform/qcc74x/qcc743/NetworkCommissioningDriver.h @@ -0,0 +1,150 @@ +/* + * + * Copyright (c) 2021 Project CHIP Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#if CHIP_DEVICE_CONFIG_ENABLE_WIFI + +#pragma once +extern "C" { +#include +} +#include + +namespace chip { +namespace DeviceLayer { +namespace NetworkCommissioning { + +void NetworkEventHandler(const ChipDeviceEvent * event, intptr_t arg); + +namespace { +constexpr uint8_t kMaxWiFiNetworks = 1; +constexpr uint8_t kWiFiScanNetworksTimeOutSeconds = 10; +constexpr uint8_t kWiFiConnectNetworkTimeoutSeconds = 20; +} // namespace + +class BLScanResponseIterator : public Iterator +{ +public: + BLScanResponseIterator(const size_t size, const wifi_mgmr_scan_item_t * scanResults) : mSize(size), mpScanResults(scanResults) {} + size_t Count() override { return mSize; } + bool Next(WiFiScanResponse & item) override + { + if (mIternum >= mSize) + { + return false; + } + + item.security.SetRaw(mpScanResults[mIternum].auth); + item.ssidLen = (uint32_t)(mpScanResults[mIternum].ssid_len) < chip::DeviceLayer::Internal::kMaxWiFiSSIDLength + ? mpScanResults[mIternum].ssid_len + : chip::DeviceLayer::Internal::kMaxWiFiSSIDLength; + item.channel = mpScanResults[mIternum].channel; + item.wiFiBand = chip::DeviceLayer::NetworkCommissioning::WiFiBand::k2g4; + item.rssi = mpScanResults[mIternum].rssi; + memcpy(item.ssid, mpScanResults[mIternum].ssid, item.ssidLen); + memcpy(item.bssid, mpScanResults[mIternum].bssid, 6); + + mIternum++; + return true; + } + void Release() override {} + +private: + const size_t mSize; + const wifi_mgmr_scan_item_t * mpScanResults; + size_t mIternum = 0; +}; + +class BLWiFiDriver final : public WiFiDriver +{ +public: + class WiFiNetworkIterator final : public NetworkIterator + { + public: + WiFiNetworkIterator(BLWiFiDriver * aDriver) : mDriver(aDriver) {} + size_t Count() override; + bool Next(Network & item) override; + void Release() override { delete this; } + ~WiFiNetworkIterator() = default; + + private: + BLWiFiDriver * mDriver; + bool mExhausted = false; + }; + + struct WiFiNetwork + { + char ssid[DeviceLayer::Internal::kMaxWiFiSSIDLength]; + uint8_t ssidLen = 0; + char credentials[DeviceLayer::Internal::kMaxWiFiKeyLength]; + uint8_t credentialsLen = 0; + }; + + // BaseDriver + NetworkIterator * GetNetworks() override { return new WiFiNetworkIterator(this); } + CHIP_ERROR Init(NetworkStatusChangeCallback * networkStatusChangeCallback) override; + void Shutdown(); + + // WirelessDriver + uint8_t GetMaxNetworks() override { return kMaxWiFiNetworks; } + uint8_t GetScanNetworkTimeoutSeconds() override { return kWiFiScanNetworksTimeOutSeconds; } + uint8_t GetConnectNetworkTimeoutSeconds() override { return kWiFiConnectNetworkTimeoutSeconds; } + + CHIP_ERROR CommitConfiguration() override; + CHIP_ERROR SaveConfiguration(); + CHIP_ERROR RevertConfiguration() override; + + Status RemoveNetwork(ByteSpan networkId, MutableCharSpan & outDebugText, uint8_t & outNetworkIndex) override; + Status ReorderNetwork(ByteSpan networkId, uint8_t index, MutableCharSpan & outDebugText) override; + void ConnectNetwork(ByteSpan networkId, ConnectCallback * callback) override; + + // WiFiDriver + Status AddOrUpdateNetwork(ByteSpan ssid, ByteSpan credentials, MutableCharSpan & outDebugText, + uint8_t & outNetworkIndex) override; + void ScanNetworks(ByteSpan ssid, ScanCallback * callback) override; + + CHIP_ERROR ConnectWiFiNetwork(const char * ssid, uint8_t ssidLen, const char * key, uint8_t keyLen); + CHIP_ERROR ReConnectWiFiNetwork(void); + void OnConnectWiFiNetwork(bool isConnected); + void OnScanWiFiNetworkDone(); + void OnNetworkStatusChange(); + + CHIP_ERROR SetLastDisconnectReason(const ChipDeviceEvent * event); + int32_t GetLastDisconnectReason(); + + static BLWiFiDriver & GetInstance() + { + static BLWiFiDriver instance; + return instance; + } + +private: + bool NetworkMatch(const WiFiNetwork & network, ByteSpan networkId); + + WiFiNetwork mSavedNetwork; + WiFiNetwork mStagingNetwork; + ScanCallback * mpScanCallback; + ConnectCallback * mpConnectCallback; + NetworkStatusChangeCallback * mpStatusChangeCallback = nullptr; + int32_t mLastDisconnectedReason; +}; + + +} // namespace NetworkCommissioning +} // namespace DeviceLayer +} // namespace chip + +#endif // CHIP_DEVICE_CONFIG_ENABLE_WIFI \ No newline at end of file diff --git a/src/platform/qcc74x/qcc743/PlatformManagerImpl.cpp b/src/platform/qcc74x/qcc743/PlatformManagerImpl.cpp new file mode 100644 index 00000000000000..6f3f010c3eda3d --- /dev/null +++ b/src/platform/qcc74x/qcc743/PlatformManagerImpl.cpp @@ -0,0 +1,76 @@ +/* + * + * Copyright (c) 2021 Project CHIP Authors + * Copyright (c) 2019 Nest Labs, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include + +#include +#include +#include +#include +#include + +#include + +#include +extern "C" { +#include +} +#include "wifi_mgmr_portable.h" + + +namespace chip { +namespace DeviceLayer { + +static int app_entropy_source(void * data, unsigned char * output, size_t len, size_t * olen) +{ + bflb_trng_readlen(reinterpret_cast(output), static_cast(len)); + *olen = len; + return 0; +} + +CHIP_ERROR PlatformManagerImpl::_InitChipStack(void) +{ + CHIP_ERROR err = CHIP_NO_ERROR; + TaskHandle_t backup_eventLoopTask; + int iret_rfInit = -1; + + VerifyOrDieWithMsg(0 == (iret_rfInit = rfparam_init(0, NULL, 0)), DeviceLayer, "rfparam_init failed with %d", iret_rfInit); + + // Initialize LwIP. + tcpip_init(NULL, NULL); + + wifi_start_firmware_task(); + err = chip::Crypto::add_entropy_source(app_entropy_source, NULL, 16); + SuccessOrExit(err); + + // Call _InitChipStack() on the generic implementation base class + // to finish the initialization process. + /** weiyin, backup mEventLoopTask which is reset in _InitChipStack */ + backup_eventLoopTask = Internal::GenericPlatformManagerImpl_FreeRTOS::mEventLoopTask; + err = Internal::GenericPlatformManagerImpl_FreeRTOS::_InitChipStack(); + SuccessOrExit(err); + Internal::GenericPlatformManagerImpl_FreeRTOS::mEventLoopTask = backup_eventLoopTask; + +exit: + return err; +} + +} // namespace DeviceLayer +} // namespace chip diff --git a/src/platform/qcc74x/qcc743/args.gni b/src/platform/qcc74x/qcc743/args.gni new file mode 100644 index 00000000000000..9303fa1d8d439b --- /dev/null +++ b/src/platform/qcc74x/qcc743/args.gni @@ -0,0 +1,40 @@ +# Copyright (c) 2021 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build_overrides/qcc74x_iot_sdk.gni") +import("//build_overrides/chip.gni") +import("${chip_root}/examples/platform/qcc74x/qcc743/args.gni") + +riscv_platform_config = "${qcc74x_iot_sdk_build_root}/common/rsicv.gni" + +mbedtls_target = "${qcc74x_iot_sdk_build_root}/qcc743:qcc74x_sdk" + +chip_device_platform = "qcc743" + +chip_enable_ota_requestor = true + +lwip_platform = "qcc743" + +chip_inet_config_enable_ipv4 = true + +chip_enable_rotating_device_id = false + +#chip_with_lwip = false +#chip_system_config_use_sockets = true + +chip_build_tests = false +chip_inet_config_enable_dns_resolver = false +chip_inet_config_enable_tun_endpoint = false +chip_inet_config_enable_tcp_endpoint = true +chip_inet_config_enable_udp_endpoint = true diff --git a/src/platform/qcc74x/qcc743/bl616-chip-mbedtls-config.h b/src/platform/qcc74x/qcc743/bl616-chip-mbedtls-config.h new file mode 100644 index 00000000000000..7d676a27868aea --- /dev/null +++ b/src/platform/qcc74x/qcc743/bl616-chip-mbedtls-config.h @@ -0,0 +1,173 @@ +/* + * Copyright (c) 2021, The OpenThread Authors. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the copyright holder nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#pragma once + +#ifndef MBEDTLS_CONFIG_H +#define MBEDTLS_CONFIG_H +#include +#include +#include + +/** + * Enable FreeRTOS threading support + */ +#define MBEDTLS_FREERTOS +//#define MBEDTLS_THREADING_C + +/** + * Enable H Crypto and Entropy modules + */ +#define MBEDTLS_AES_C +#define MBEDTLS_ECP_C +#define MBEDTLS_ECDH_C +#define MBEDTLS_ENTROPY_C +#define MBEDTLS_SHA256_C +#define MBEDTLS_CIPHER_MODE_CTR +#define MBEDTLS_TRNG_C + +#if defined(MBEDTLS_ECP_ALT) && !defined(MBEDTLS_ECP_RESTARTABLE) +typedef void mbedtls_ecp_restart_ctx; +#endif + +#if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE) +#define _CRT_SECURE_NO_DEPRECATE 1 +#endif + +#define MBEDTLS_PLATFORM_MEMORY + + +#define MBEDTLS_CIPHER_PADDING_PKCS7 +#define MBEDTLS_CIPHER_PADDING_ZEROS +#define MBEDTLS_REMOVE_ARC4_CIPHERSUITES +#define MBEDTLS_REMOVE_3DES_CIPHERSUITES + +#define MBEDTLS_AES_ROM_TABLES +#define MBEDTLS_ASN1_PARSE_C +#define MBEDTLS_ASN1_WRITE_C +#define MBEDTLS_BASE64_C +#define MBEDTLS_BIGNUM_C +#define MBEDTLS_CCM_C +#define MBEDTLS_CIPHER_C +#define MBEDTLS_CIPHER_MODE_CBC +#define MBEDTLS_CIPHER_MODE_CFB +#define MBEDTLS_CMAC_C +#define MBEDTLS_CTR_DRBG_C +#define MBEDTLS_DEBUG_C +#define MBEDTLS_ECDH_LEGACY_CONTEXT +#define MBEDTLS_ECDSA_C +#define MBEDTLS_ECDSA_DETERMINISTIC +#define MBEDTLS_ECJPAKE_C +#define MBEDTLS_ECP_DP_SECP256R1_ENABLED +#define MBEDTLS_ECP_NIST_OPTIM +#define MBEDTLS_ENTROPY_FORCE_SHA256 + +#define MBEDTLS_ERROR_C +#define MBEDTLS_GCM_C +#define MBEDTLS_ERROR_STRERROR_DUMMY +#define MBEDTLS_HAVE_ASM +#define MBEDTLS_HKDF_C +#define MBEDTLS_HMAC_DRBG_C +#define MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED +#define MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED +#define MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED +#define MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED +#define MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED +#define MBEDTLS_KEY_EXCHANGE_PSK_ENABLED +#define MBEDTLS_KEY_EXCHANGE_RSA_ENABLED +#define MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED + +#define MBEDTLS_MD_C +#define MBEDTLS_MD5_C +#define MBEDTLS_OID_C +#define MBEDTLS_PEM_PARSE_C +#define MBEDTLS_PEM_WRITE_C +#define MBEDTLS_PK_C +#define MBEDTLS_PK_PARSE_C +#define MBEDTLS_PK_WRITE_C +#define MBEDTLS_PKCS5_C +#define MBEDTLS_PKCS1_V15 +#define MBEDTLS_PKCS1_V21 + +#define MBEDTLS_PLATFORM_C +#define MBEDTLS_GENPRIME +#define MBEDTLS_RSA_C +#define MBEDTLS_DHM_C + +#define MBEDTLS_PLATFORM_NO_STD_FUNCTIONS +#define MBEDTLS_PSA_CRYPTO_C +#define MBEDTLS_PSA_CRYPTO_CONFIG +#define MBEDTLS_PSA_CRYPTO_DRIVERS +#define MBEDTLS_PSA_CRYPTO_BUILTIN_KEYS +#define MBEDTLS_PSA_CRYPTO_STORAGE_C + +#define MBEDTLS_SHA1_C +#define MBEDTLS_SHA256_SMALLER +#define MBEDTLS_SHA512_C + +#define MBEDTLS_SSL_CLI_C +#define MBEDTLS_SSL_COOKIE_C +#define MBEDTLS_SSL_DTLS_ANTI_REPLAY +#define MBEDTLS_SSL_DTLS_HELLO_VERIFY +#define MBEDTLS_SSL_EXPORT_KEYS +#define MBEDTLS_SSL_KEEP_PEER_CERTIFICATE +#define MBEDTLS_SSL_MAX_FRAGMENT_LENGTH +#define MBEDTLS_SSL_PROTO_TLS1_2 +#define MBEDTLS_SSL_ALPN +#define MBEDTLS_SSL_SESSION_TICKETS +#define MBEDTLS_SSL_PROTO_DTLS +#define MBEDTLS_SSL_SRV_C +#define MBEDTLS_SSL_TLS_C +#define MBEDTLS_SSL_SERVER_NAME_INDICATION +#define MBEDTLS_X509_CREATE_C +#define MBEDTLS_X509_CSR_WRITE_C +#define MBEDTLS_X509_CRL_PARSE_C +#define MBEDTLS_X509_CRT_PARSE_C +#define MBEDTLS_X509_CSR_PARSE_C +#define MBEDTLS_X509_USE_C +#define MBEDTLS_X509_CHECK_KEY_USAGE +#define MBEDTLS_X509_CHECK_EXTENDED_KEY_USAGE + +#define MBEDTLS_NO_PLATFORM_ENTROPY +#define MBEDTLS_ENTROPY_HARDWARE_ALT + +#define MBEDTLS_PLATFORM_STD_MEM_HDR "mbedtls_port_qcc74x_sdk.h" + +#define MBEDTLS_SHA1_ALT +#define MBEDTLS_SHA256_ALT +#define MBEDTLS_SHA512_ALT +#define MBEDTLS_AES_ALT +#define MBEDTLS_ECP_ALT + +#if defined(CONFIG_MBEDTLS_ECC_USE_HW) && defined(MBEDTLS_ECP_RESTARTABLE) +#error "ECP Restartable is not implemented with ECP HW acceleration!" +#endif + +#include "mbedtls/check_config.h" + +#endif /* MBEDTLS_CONFIG_H */ diff --git a/src/platform/qcc74x/qcc743/wifi_mgmr_portable.c b/src/platform/qcc74x/qcc743/wifi_mgmr_portable.c new file mode 100644 index 00000000000000..c5df8fe666b5f2 --- /dev/null +++ b/src/platform/qcc74x/qcc743/wifi_mgmr_portable.c @@ -0,0 +1,64 @@ +#include +#include + +#include +#include + +#include +#undef __INLINE +#undef __PACKED +#include + +#include + +#define WIFI_STACK_SIZE (1536) +#define TASK_PRIORITY_FW (16) + +static TaskHandle_t wifi_fw_task; +static netif_ext_callback_t netifExtCallback; + +struct netif * deviceInterface_getNetif(void) +{ + LOCK_TCPIP_CORE(); + struct netif *net_if = netif_find("wl1"); + UNLOCK_TCPIP_CORE(); + + return net_if; +} + +void hal_reboot (void) +{ + taskDISABLE_INTERRUPTS(); + GLB_SW_POR_Reset(); +} + +int wifi_start_scan(const uint8_t * ssid, uint32_t length) +{ + wifi_mgmr_scan_params_t config; + + memset(&config, 0, sizeof(wifi_mgmr_scan_params_t)); + if (length && length <= MGMR_SSID_LEN) { + memcpy(config.ssid_array, ssid, length); + config.ssid_length = length; + } + + return wifi_mgmr_sta_scan(&config); +} + +void wifi_start_firmware_task(void) +{ + memset(&netifExtCallback, 0, sizeof(netifExtCallback)); + + GLB_PER_Clock_UnGate(GLB_AHB_CLOCK_IP_WIFI_PHY | GLB_AHB_CLOCK_IP_WIFI_MAC_PHY | GLB_AHB_CLOCK_IP_WIFI_PLATFORM); + GLB_AHB_MCU_Software_Reset(GLB_AHB_MCU_SW_WIFI); + + extern void interrupt0_handler(void); + bflb_irq_attach(WIFI_IRQn, (irq_callback)interrupt0_handler, NULL); + bflb_irq_enable(WIFI_IRQn); + + LOCK_TCPIP_CORE(); + netif_add_ext_callback(&netifExtCallback, network_netif_ext_callback); + UNLOCK_TCPIP_CORE(); + + xTaskCreate(wifi_main, (char *)"fw", WIFI_STACK_SIZE, NULL, TASK_PRIORITY_FW, &wifi_fw_task); +} diff --git a/src/platform/qcc74x/qcc743/wifi_mgmr_portable.h b/src/platform/qcc74x/qcc743/wifi_mgmr_portable.h new file mode 100644 index 00000000000000..faf61325a50df0 --- /dev/null +++ b/src/platform/qcc74x/qcc743/wifi_mgmr_portable.h @@ -0,0 +1,18 @@ +#ifndef __WIFI_MGMR_POARABLE_H__ +#define __WIFI_MGMR_POARABLE_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +int wifi_start_scan(const uint8_t * ssid, uint32_t length); +void network_netif_ext_callback(struct netif* netif, netif_nsc_reason_t reason, const netif_ext_callback_args_t* args); +void wifi_start_firmware_task(void); + +struct netif * deviceInterface_getNetif(void); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/system/BUILD.gn b/src/system/BUILD.gn index 776b141c357ba1..95be8e20955a93 100644 --- a/src/system/BUILD.gn +++ b/src/system/BUILD.gn @@ -76,6 +76,8 @@ if (chip_device_platform == "cc13x2_26x2") { import("//build_overrides/bouffalolab_iot_sdk.gni") } else if (chip_device_platform == "bl616") { import("//build_overrides/bouffalolab_iot_sdk.gni") +} else if (chip_device_platform == "qcc743") { + import("//build_overrides/qcc74x_iot_sdk.gni") } buildconfig_header("system_buildconfig") { diff --git a/third_party/qcc74x/common/bouffalolab_board.gni b/third_party/qcc74x/common/bouffalolab_board.gni new file mode 100644 index 00000000000000..c21e839dbfe372 --- /dev/null +++ b/third_party/qcc74x/common/bouffalolab_board.gni @@ -0,0 +1,25 @@ +# Copyright (c) 2021 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +declare_args() { + bouffalolab_bard = "BL-IOT-DVK" +} + +if (bouffalolab_bard == "") { + bouffalolab_bard = "BL-IOT-DVK" +} + +assert(bouffalolab_bard != "", "bouffalolab_bard must be specified") + +board_defines = [] diff --git a/third_party/qcc74x/common/bouffalolab_executable.gni b/third_party/qcc74x/common/bouffalolab_executable.gni new file mode 100644 index 00000000000000..066bea84562a46 --- /dev/null +++ b/third_party/qcc74x/common/bouffalolab_executable.gni @@ -0,0 +1,101 @@ +# Copyright (c) 2021 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build_overrides/build.gni") +import("//build_overrides/chip.gni") + +import("//build_overrides/bouffalolab_iot_sdk.gni") +import("${build_root}/toolchain/flashable_executable.gni") + +template("bouffalolab_executable") { + output_base_name = get_path_info(invoker.output_name, "name") + + objcopy_image_name = output_base_name + ".bin" + objcopy_image_format = "binary" + + objcopy = "riscv64-unknown-elf-objcopy" + if ("linux" == host_os) { + if (invoker.bl_plat_name == "bl616") { + objcopy = "${bouffalolab_sdk_root}/toolchain/t-head-riscv/gcc_t-head_v2.6.1/bin/riscv64-unknown-elf-objcopy" + } else { + objcopy = "${bouffalolab_sdk_root}/toolchain/riscv/Linux/bin/riscv64-unknown-elf-objcopy" + } + } else if ("mac" == host_os || "darwin" == host_os) { + objcopy = "${bouffalolab_sdk_root}/toolchain/riscv/Darwin/bin/riscv64-unknown-elf-objcopy" + } + + # Copy flashing dependencies to the output directory so that the output + # is collectively self-contained; this allows flashing to work reliably + # even if the build and flashing steps take place on different machines + # or in different containers. + flashing_runtime_target = target_name + ".flashing_runtime" + flashing_script_inputs = [ + "${chip_root}/scripts/flashing/bouffalolab_firmware_utils.py", + "${chip_root}/scripts/flashing/firmware_utils.py", + ] + + if (invoker.bl_plat_name == "bl602" || invoker.bl_plat_name == "bl616") { + flashing_script_inputs += [ "${chip_root}/examples/platform/bouffalolab/${invoker.bl_plat_name}/flash_config/partition_cfg_4M.toml" ] + } else { + flashing_script_inputs += [ "${chip_root}/examples/platform/bouffalolab/${invoker.bl_plat_name}/flash_config/partition_cfg_2M.toml" ] + } + + copy(flashing_runtime_target) { + sources = flashing_script_inputs + outputs = [ "${root_out_dir}/{{source_file_part}}" ] + } + + flashing_script_generator = + "${chip_root}/scripts/flashing/gen_flashing_script.py" + flashing_script_name = output_base_name + ".flash.py" + flashing_options = [ "bouffalolab" ] + flashing_options += [ "--chipname" ] + flashing_options += [ "${invoker.bl_plat_name}" ] + flashing_options += [ "--xtal" ] + if (invoker.bl_plat_name == "bl602") { + flashing_options += [ "40M" ] + } else if (invoker.bl_plat_name == "bl702") { + flashing_options += [ "32M" ] + } else if (invoker.bl_plat_name == "bl702l") { + flashing_options += [ "32M" ] + } else if (invoker.bl_plat_name == "bl616") { + flashing_options += [ "40M" ] + } + + flashing_options += [ "--pt" ] + if (invoker.bl_plat_name == "bl602" || invoker.bl_plat_name == "bl616") { + flashing_options += + [ rebase_path("partition_cfg_4M.toml", root_out_dir, root_out_dir) ] + } else if (defined(invoker.enable_openthread_border_router) && + invoker.enable_openthread_border_router) { + flashing_options += [ rebase_path("partition_cfg_2M_noOTA.toml", + root_out_dir, + root_out_dir) ] + } else { + flashing_options += + [ rebase_path("partition_cfg_2M.toml", root_out_dir, root_out_dir) ] + } + + flashing_options += [ "--ota" ] + flashing_options += [ "ota_images/" ] + + # set 2000000 baudrate for image download by default + flashing_options += [ "--baudrate" ] + flashing_options += [ "2000000" ] + + flashable_executable(target_name) { + forward_variables_from(invoker, "*") + data_deps = [ ":${flashing_runtime_target}" ] + } +} diff --git a/third_party/qcc74x/common/rsicv.gni b/third_party/qcc74x/common/rsicv.gni new file mode 100644 index 00000000000000..25b5c78bc99f1e --- /dev/null +++ b/third_party/qcc74x/common/rsicv.gni @@ -0,0 +1,26 @@ +# Copyright (c) 2020 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build_overrides/chip.gni") + +import("${chip_root}/src/platform/device.gni") + +import("${chip_root}/src/platform/device.gni") +if (chip_device_platform == "bl616") { + riscv_arch = "rv32imafcpzpsfoperand_xtheade" +} else { + riscv_arch = "rv32imfc" +} + +riscv_abi = "ilp32f" diff --git a/third_party/qcc74x/env-setup.sh b/third_party/qcc74x/env-setup.sh new file mode 100755 index 00000000000000..d384753728dbe9 --- /dev/null +++ b/third_party/qcc74x/env-setup.sh @@ -0,0 +1,86 @@ +#!/usr/bin/env bash + +set -x +CURRENT_DIR=$( + cd "$(dirname "$0")" + pwd +) + +user=`stat -c %U $0` + +SDK_ROOT=/opt/bouffalolab_sdk + +echo "Please input path to install toolchain, or type Enter to install under ${SDK_ROOT}" +read TOOLCHAIN_SETUP_ROOT +if [[ ${TOOLCHAIN_SETUP_ROOT} == "" ]]; then + TOOLCHAIN_SETUP_ROOT=$SDK_ROOT +fi +echo "Toolchain will install under ${TOOLCHAIN_SETUP_ROOT}" +flash_tool_postfix= + +flash_tool=BouffaloLabDevCube-v1.8.9 +flash_tool_url=https://dev.bouffalolab.com/media/upload/download/${flash_tool}.zip +thead_toolchain=gcc_t-head_v2.6.1 +thead_toolchain_url=https://codeload.github.com/bouffalolab/toolchain_gcc_t-head_linux/zip/c4afe91cbd01bf7dce525e0d23b4219c8691e8f0 +thead_toolchain_unzip=toolchain_gcc_t-head_linux-c4afe91cbd01bf7dce525e0d23b4219c8691e8f0 + +if [[ "$OSTYPE" == "linux-gnu"* ]]; then + toolchains_url=( + "toolchain/riscv" "https://dev.bouffalolab.com/media/upload/download/toolchain_riscv_sifive_linux64.zip" Linux toolchain_riscv_sifive_linux + "toolchain/t-head-riscv" ${thead_toolchain_url} ${thead_toolchain} ${thead_toolchain_unzip} + "flashtool" ${flash_tool_url} ${flash_tool} "" + ) + flash_tool_postfix=ubuntu +elif [[ "$OSTYPE" == "darwin"* ]]; then + toolchains_url=( + "toolchain/riscv/Darwin" "https://dev.bouffalolab.com/media/upload/download/toolchain_riscv_sifive_macos.zip" + ) + flash_tool_postfix=macos +else + echo "Not support for ""$OSTYPE" +fi + +if [ ! -d "$TOOLCHAIN_SETUP_ROOT" ]; then + mkdir -p "$TOOLCHAIN_SETUP_ROOT" +fi +rm -rf "$TOOLCHAIN_SETUP_ROOT"/*.zip + +for ((i = 0; i < ${#toolchains_url[@]}; i += 4)); do + path=${toolchains_url[i]} + url=${toolchains_url[i + 1]} + out=${toolchains_url[i + 2]} + unzip_name=${toolchains_url[i + 3]} + + if [ -d "$TOOLCHAIN_SETUP_ROOT/$path/$out" ]; then + continue + fi + rm -rf "$TOOLCHAIN_SETUP_ROOT/$path" + mkdir -p "$TOOLCHAIN_SETUP_ROOT/$path" + + wget -P "$TOOLCHAIN_SETUP_ROOT"/ "$url" + toolchain_zip=$(basename "$url") + toolchain_zip=`find $TOOLCHAIN_SETUP_ROOT -maxdepth 1 -name *${toolchain_zip}*` + toolchain_zip=$(basename "$toolchain_zip") + if [ ! -f "$TOOLCHAIN_SETUP_ROOT/$toolchain_zip" ]; then + exit 1 + fi + + unzip -q "$TOOLCHAIN_SETUP_ROOT/$toolchain_zip" -d "$TOOLCHAIN_SETUP_ROOT/$path/tmp" + mv $TOOLCHAIN_SETUP_ROOT/$path/tmp/$unzip_name $TOOLCHAIN_SETUP_ROOT/$path/$out + + rm -rf $TOOLCHAIN_SETUP_ROOT/$path/tmp + rm -rf $TOOLCHAIN_SETUP_ROOT/$toolchain_zip + + if [ -f "$TOOLCHAIN_SETUP_ROOT/$path"/$out/chmod755.sh ]; then + cd "$TOOLCHAIN_SETUP_ROOT/$path"/$out + bash chmod755.sh + cd "$CURRENT_DIR" + fi +done + +chmod +x ${TOOLCHAIN_SETUP_ROOT}/flashtool/${flash_tool}/BLDevCube-${flash_tool_postfix} +chmod +x ${TOOLCHAIN_SETUP_ROOT}/flashtool/${flash_tool}/bflb_iot_tool-${flash_tool_postfix} + +if [[ "$user" != "root" ]]; then + chown $user ${TOOLCHAIN_SETUP_ROOT}/flashtool/${flash_tool}/ -R +fi diff --git a/third_party/qcc74x/qcc743/BUILD.gn b/third_party/qcc74x/qcc743/BUILD.gn new file mode 100644 index 00000000000000..15335a44f9354a --- /dev/null +++ b/third_party/qcc74x/qcc743/BUILD.gn @@ -0,0 +1,27 @@ +# Copyright (c) 2020 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build_overrides/bouffalolab_iot_sdk.gni") +import("${bouffalolab_iot_sdk_build_root}/bl616/bouffalo_sdk.gni") + +declare_args() { + # Build target to use for Bouffalo Lab SDK. Use this to set global SDK defines. + bouffalo_sdk_target = "" +} + +assert(bouffalo_sdk_target != "", "bl_iot_sdk_target must be specified") + +group("bouffalo_sdk") { + public_deps = [ bouffalo_sdk_target ] +} diff --git a/third_party/qcc74x/qcc743/bouffalo_sdk.gni b/third_party/qcc74x/qcc743/bouffalo_sdk.gni new file mode 100644 index 00000000000000..43d65a68b0b32e --- /dev/null +++ b/third_party/qcc74x/qcc743/bouffalo_sdk.gni @@ -0,0 +1,1207 @@ +# Copyright (c) 2021 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +import("//args.gni") +import("//build_overrides/bouffalolab_iot_sdk.gni") +import("//build_overrides/chip.gni") +import("//build_overrides/mbedtls.gni") +import("${chip_root}/src/lib/lib.gni") + +declare_args() { + # Location of the bl616 SDK. + bouffalo_sdk_root = "${chip_root}/third_party/bouffalolab/bouffalo_sdk" + + enable_debug_frame_ptr = true +} + +assert(bouffalo_sdk_root != "", "bouffalo_sdk_root must be specified") + +# Defines an bl616 SDK build target. +# +# Parameters: +# bouffalo_sdk_root - The location of the bl616 SDK. +# sources - The sources files to build. +template("bouffalo_sdk") { + if (defined(invoker.bouffalo_sdk_root)) { + bouffalo_sdk_root = invoker.bouffalo_sdk_root + } + + assert(bouffalo_sdk_root != "", "bouffalo_sdk_root must be specified") + + sdk_target_name = target_name + + config("${sdk_target_name}_config") { + + defines = [ + "BL616=BL616", + "ARCH_RISCV", + "__STARTUP_CLEAR_BSS", + + "CONFIG_COMPONENT_BUGKILLER_ENABLE=1", + ] + + include_dirs = [] + if (defined(invoker.include_dirs)) { + include_dirs += invoker.include_dirs + } + + if (defined(invoker.defines)) { + defines += invoker.defines + } + + cflags_c = [ + "-fno-jump-tables", + "-fstrict-volatile-bitfields", + + "-ffunction-sections", + "-fdata-sections", + "-Wl,--cref", + "-Wl,--gc-sections", + "-nostartfiles", + + "--specs=nano.specs", + "-fshort-enums", + ] + cflags = [ "-Wno-unused-but-set-variable", "-Wno-conversion", "-fstack-usage" ] + + if (defined(invoker.enable_debug_frame_ptr) && invoker.enable_debug_frame_ptr) { + cflags += [ "-fno-omit-frame-pointer" ] + } + + if (defined(invoker.defines)) { + defines += invoker.defines + } + } + + config("${sdk_target_name}_config_startup") { + include_dirs = [ + "${bouffalo_sdk_root}/drivers/soc/bl616/std/startup", + ] + } + + source_set("${sdk_target_name}_startup") { + defines = [ + "ARCH_RISCV", + "BFLB_USE_HAL_DRIVER", + "CONFIG_IRQ_NUM=80", + ] + + include_dirs = [ + #bl616 startup + "${bouffalo_sdk_root}/drivers/soc/bl616/std/startup", + ] + + sources = [ + "${bouffalo_sdk_root}/drivers/soc/bl616/std/startup/start.S", + "${bouffalo_sdk_root}/drivers/soc/bl616/std/startup/vector.S", + "${bouffalo_sdk_root}/drivers/soc/bl616/std/startup/riscv_fpu.S", + "${bouffalo_sdk_root}/drivers/soc/bl616/std/startup/interrupt.c", + "${bouffalo_sdk_root}/drivers/soc/bl616/std/startup/start_load.c", + "${bouffalo_sdk_root}/drivers/soc/bl616/std/startup/system_bl616.c", + ] + + if (defined(invoker.enable_debug_frame_ptr) && invoker.enable_debug_frame_ptr) { + defines += [ "CONF_ENABLE_FRAME_PTR" ] + } + + configs += [ + ":${sdk_target_name}_config_freertos", + ":${sdk_target_name}_config_std_drv", + ":${sdk_target_name}_config_lhal", + ":${sdk_target_name}_config_utils", + ] + + public_configs = [ + ":${sdk_target_name}_config_startup", + ":${sdk_target_name}_config", + ] + } + + config("${sdk_target_name}_config_std_drv") { + include_dirs = [ + "${bouffalo_sdk_root}/drivers/soc/bl616/std/include", + "${bouffalo_sdk_root}/drivers/soc/bl616/std/include/hardware", + ] + + defines = [ + "ARCH_RISCV", + "BFLB_USE_HAL_DRIVER", + ] + + cflags = ["-Wsign-compare"] + } + + source_set("${sdk_target_name}_std_drv") { + defines = [ + "ARCH_RISCV", + "BFLB_USE_HAL_DRIVER", + "BFLB_USE_ROM_DRIVER", + ] + + include_dirs = [ + #bl616 startup + "${bouffalo_sdk_root}/drivers/soc/bl616/std/include", + "${bouffalo_sdk_root}/drivers/soc/bl616/std/include/hardware", + ] + + sources = [ + "${bouffalo_sdk_root}/drivers/soc/bl616/std/port/bl616_clock.c", + "${bouffalo_sdk_root}/drivers/soc/bl616/std/port/bl616_gpio.c", + ] + + sources += [ + #use rom api default + "${bouffalo_sdk_root}/drivers/soc/bl616/std/src/bl616_romapi_e907.c", + "${bouffalo_sdk_root}/drivers/soc/bl616/std/src/bl616_romapi_patch.c", + "${bouffalo_sdk_root}/drivers/soc/bl616/std/src/bl616_clock.c", + "${bouffalo_sdk_root}/drivers/soc/bl616/std/src/bl616_common.c", + "${bouffalo_sdk_root}/drivers/soc/bl616/std/src/bl616_ef_cfg.c", + "${bouffalo_sdk_root}/drivers/soc/bl616/std/src/bl616_sdh.c", + "${bouffalo_sdk_root}/drivers/soc/bl616/std/src/bl616_tzc_sec.c", + "${bouffalo_sdk_root}/drivers/soc/bl616/std/src/bl616_psram.c", + "${bouffalo_sdk_root}/drivers/soc/bl616/std/src/bl616_pm.c", + "${bouffalo_sdk_root}/drivers/soc/bl616/std/src/bl616_mfg_efuse.c", + "${bouffalo_sdk_root}/drivers/soc/bl616/std/src/bl616_mfg_flash.c", + "${bouffalo_sdk_root}/drivers/soc/bl616/std/src/bl616_mfg_media.c", + ] + + cflags_c = [ + "-Wno-sign-compare", + "-Wno-enum-conversion", + "-Wno-type-limits" + ] + + configs += [ + ":${sdk_target_name}_config_startup", + ":${sdk_target_name}_config_lhal", + ":${sdk_target_name}_config_freertos", + ] + public_configs = [ + ":${sdk_target_name}_config_std_drv", + ":${sdk_target_name}_config", + ] + } + + config("${sdk_target_name}_config_lhal") { + + include_dirs = [ + #bl616 lhal + "${bouffalo_sdk_root}/drivers/lhal/include", + "${bouffalo_sdk_root}/drivers/lhal/include/arch", + "${bouffalo_sdk_root}/drivers/lhal/include/arch/risc-v/t-head", + "${bouffalo_sdk_root}/drivers/lhal/include/arch/risc-v/t-head/Core/Include", + "${bouffalo_sdk_root}/drivers/lhal/include/arch/risc-v/t-head/csi_dsp/include", + "${bouffalo_sdk_root}/drivers/lhal/src/flash", + "${bouffalo_sdk_root}/drivers/lhal/config/bl616", + ] + } + + source_set("${sdk_target_name}_lhal") { + defines = [ + "CPU_M0", + "CONFIG_IRQ_NUM=80", + ] + + sources = [ + "${bouffalo_sdk_root}/drivers/lhal/src/bflb_common.c", + "${bouffalo_sdk_root}/drivers/lhal/src/bflb_adc.c", + "${bouffalo_sdk_root}/drivers/lhal/src/bflb_acomp.c", + "${bouffalo_sdk_root}/drivers/lhal/src/bflb_cks.c", + "${bouffalo_sdk_root}/drivers/lhal/src/bflb_ef_ctrl.c", + "${bouffalo_sdk_root}/drivers/lhal/src/bflb_gpio.c", + "${bouffalo_sdk_root}/drivers/lhal/src/bflb_i2c.c", + "${bouffalo_sdk_root}/drivers/lhal/src/bflb_dma.c", + "${bouffalo_sdk_root}/drivers/lhal/src/bflb_rtc.c", + "${bouffalo_sdk_root}/drivers/lhal/src/bflb_sec_aes.c", + "${bouffalo_sdk_root}/drivers/lhal/src/bflb_sec_sha.c", + "${bouffalo_sdk_root}/drivers/lhal/src/bflb_sec_trng.c", + "${bouffalo_sdk_root}/drivers/lhal/src/bflb_spi.c", + "${bouffalo_sdk_root}/drivers/lhal/src/bflb_timer.c", + "${bouffalo_sdk_root}/drivers/lhal/src/bflb_uart.c", + "${bouffalo_sdk_root}/drivers/lhal/src/bflb_wdg.c", + "${bouffalo_sdk_root}/drivers/lhal/src/bflb_flash.c", + "${bouffalo_sdk_root}/drivers/lhal/src/flash/bflb_sf_cfg.c", + "${bouffalo_sdk_root}/drivers/lhal/src/flash/bflb_xip_sflash.c", + "${bouffalo_sdk_root}/drivers/lhal/src/flash/bflb_sflash.c", + "${bouffalo_sdk_root}/drivers/lhal/src/flash/bflb_sf_ctrl.c", + "${bouffalo_sdk_root}/drivers/lhal/src/bflb_dac.c", + "${bouffalo_sdk_root}/drivers/lhal/src/bflb_emac.c", + "${bouffalo_sdk_root}/drivers/lhal/src/bflb_ir.c", + "${bouffalo_sdk_root}/drivers/lhal/src/bflb_mjpeg.c", + "${bouffalo_sdk_root}/drivers/lhal/src/bflb_pwm_v2.c", + "${bouffalo_sdk_root}/drivers/lhal/src/bflb_cam.c", + "${bouffalo_sdk_root}/drivers/lhal/src/bflb_i2s.c", + "${bouffalo_sdk_root}/drivers/lhal/src/bflb_sdio2.c", + "${bouffalo_sdk_root}/drivers/lhal/src/bflb_dbi.c", + "${bouffalo_sdk_root}/drivers/lhal/src/bflb_audac.c", + "${bouffalo_sdk_root}/drivers/lhal/src/bflb_auadc.c", + #"${bouffalo_sdk_root}/drivers/lhal/src/bflb_platform_dma.c", + #"${bouffalo_sdk_root}/drivers/lhal/src/bflb_usb_v2.c", + "${bouffalo_sdk_root}/drivers/lhal/src/bflb_irq.c", + "${bouffalo_sdk_root}/drivers/lhal/src/bflb_l1c.c", + "${bouffalo_sdk_root}/drivers/lhal/src/bflb_mtimer.c", + "${bouffalo_sdk_root}/drivers/lhal/include/arch/risc-v/t-head/rv_hart.c", + "${bouffalo_sdk_root}/drivers/lhal/include/arch/risc-v/t-head/rv_pmp.c", + "${bouffalo_sdk_root}/drivers/lhal/config/bl616/device_table.c", + ] + + libs = [ + "${bouffalo_sdk_root}/drivers/lhal/src/pka/libpka.a", + ] + + cflags_c = [ + "-Wno-shadow", + "-Wno-sign-compare", + "-Wno-implicit-fallthrough", + ] + + configs += [ + ":${sdk_target_name}_config_startup", + ":${sdk_target_name}_config_freertos", + ] + + public_configs = [ + ":${sdk_target_name}_config_lhal", + ":${sdk_target_name}_config_std_drv", + ":${sdk_target_name}_config", + ] + } + + config("${sdk_target_name}_config_board") { + include_dirs = [ + "${bouffalo_sdk_root}/bsp/board", + ] + } + + source_set("${sdk_target_name}_board") { + defines = [ + "CONFIG_MBEDTLS", + "CONFIG_BFLOG", + "BL616" + ] + + include_dirs = [ + "${bouffalo_sdk_root}/bsp/board/bl616dk", + ] + + sources = [ + "${bouffalo_sdk_root}/bsp/board/bl616dk/board.c", + "${bouffalo_sdk_root}/bsp/board/bl616dk/board_rf.c", + ] + + cflags_c = [ + "-Wno-shadow", + "-Wno-enum-conversion", + "-Wno-format", + "-Wno-format-nonliteral", + "-Wno-format-security" + ] + + configs += [ + ":${sdk_target_name}_config_lhal", + ":${sdk_target_name}_config_std_drv", + ":${sdk_target_name}_config_startup", + ":${sdk_target_name}_config_freertos", + ":${sdk_target_name}_config_mm", + ":${sdk_target_name}_config_rf", + ] + + public_configs = [ + ":${sdk_target_name}_config_board", + ] + } + + config("${sdk_target_name}_config_shell") { + include_dirs = [ + "${bouffalo_sdk_root}/components/shell", + ] + } + + source_set("${sdk_target_name}_shell") { + defines = [ + #"CONFIG_PSRAM", + "BL616" + ] + + include_dirs = [ + "${bouffalo_sdk_root}/bsp/board/bl616dk", + ] + + sources = [ + "${bouffalo_sdk_root}/components/shell/shell.c", + "${bouffalo_sdk_root}/components/shell/shell_freertos.c", + ] + + cflags_c = [ + "-Wno-shadow", + "-Wno-enum-conversion", + "-Wno-format-security", + "-Wno-format-truncation", + "-Wno-format-nonliteral", + "-Wno-sign-compare" + ] + + configs += [ + ":${sdk_target_name}_config_lhal", + ":${sdk_target_name}_config_utils", + ":${sdk_target_name}_config_board", + ":${sdk_target_name}_config_freertos", + ":${sdk_target_name}_config_mm", + ] + public_configs = [ + ":${sdk_target_name}_config_shell", + ] + } + + config("${sdk_target_name}_config_rf") { + include_dirs = [ + "${bouffalo_sdk_root}/drivers/soc/bl616/phyrf/include", + "${bouffalo_sdk_root}/drivers/rfparam/Inc", + ] + + defines = [ + "WL_BL616=1" + ] + } + + source_set("${sdk_target_name}_rf") { + defines = [ + "RFPARAM_BL616", + ] + + include_dirs = [ + "${bouffalo_sdk_root}/drivers/rfparam/Inc", + ] + + sources = [ + "${bouffalo_sdk_root}/drivers/rfparam/Src/rfparam_adapter.c", + "${bouffalo_sdk_root}/drivers/rfparam/Src/rfparam_rftlv.c", + ] + + libs = [ + "${bouffalo_sdk_root}/drivers/soc/bl616/phyrf/lib-gcc_10.2.0-toolchain_V2.6.1/libbl616_phyrf.a", + ] + + cflags_c = [ + "-Wno-shadow", + "-Wno-sign-compare" + ] + + configs += [ + ":${sdk_target_name}_config_std_drv", + ":${sdk_target_name}_config_lhal", + ":${sdk_target_name}_config_utils", + ] + public_configs = [ + ":${sdk_target_name}_config_rf", + ":${sdk_target_name}_config", + ] + } + + source_set("${sdk_target_name}_libc") { + + include_dirs = [ + "${bouffalo_sdk_root}/components/libc", + ] + + sources = [ + "${bouffalo_sdk_root}/components/libc/newlib/port_init_fini.c", + "${bouffalo_sdk_root}/components/libc/newlib/port_memory.c", + "${bouffalo_sdk_root}/components/libc/newlib/syscalls_nosys.c", + "${bouffalo_sdk_root}/components/libc/nuttx/libc/stdlib/lib_abs.c", + "${bouffalo_sdk_root}/components/libc/nuttx/libc/stdlib/lib_atof.c", + "${bouffalo_sdk_root}/components/libc/nuttx/libc/stdlib/lib_atoi.c", + "${bouffalo_sdk_root}/components/libc/nuttx/libc/stdlib/lib_atol.c", + "${bouffalo_sdk_root}/components/libc/nuttx/libc/stdlib/lib_atoll.c", + "${bouffalo_sdk_root}/components/libc/nuttx/libc/stdlib/lib_bsearch.c", + "${bouffalo_sdk_root}/components/libc/nuttx/libc/stdlib/lib_checkbase.c", + "${bouffalo_sdk_root}/components/libc/nuttx/libc/stdlib/lib_itoa.c", + "${bouffalo_sdk_root}/components/libc/nuttx/libc/stdlib/lib_llabs.c", + "${bouffalo_sdk_root}/components/libc/nuttx/libc/stdlib/lib_lldiv.c", + "${bouffalo_sdk_root}/components/libc/nuttx/libc/stdlib/lib_qsort.c", + "${bouffalo_sdk_root}/components/libc/nuttx/libc/stdlib/lib_strtod.c", + "${bouffalo_sdk_root}/components/libc/nuttx/libc/string/lib_ffs.c", + "${bouffalo_sdk_root}/components/libc/nuttx/libc/string/lib_ffsl.c", + "${bouffalo_sdk_root}/components/libc/nuttx/libc/string/lib_ffsll.c", + "${bouffalo_sdk_root}/components/libc/nuttx/libc/string/lib_fls.c", + "${bouffalo_sdk_root}/components/libc/nuttx/libc/string/lib_flsl.c", + "${bouffalo_sdk_root}/components/libc/nuttx/libc/string/lib_flsll.c", + "${bouffalo_sdk_root}/components/libc/nuttx/libc/string/lib_index.c", + "${bouffalo_sdk_root}/components/libc/nuttx/libc/string/lib_memccpy.c", + "${bouffalo_sdk_root}/components/libc/nuttx/libc/string/lib_memchr.c", + "${bouffalo_sdk_root}/components/libc/nuttx/libc/string/lib_memcmp.c", + "${bouffalo_sdk_root}/components/libc/nuttx/libc/string/lib_memmove.c", + "${bouffalo_sdk_root}/components/libc/nuttx/libc/string/lib_memrchr.c", + "${bouffalo_sdk_root}/components/libc/nuttx/libc/string/lib_memset.c", + "${bouffalo_sdk_root}/components/libc/nuttx/libc/string/lib_stpcpy.c", + "${bouffalo_sdk_root}/components/libc/nuttx/libc/string/lib_stpncpy.c", + "${bouffalo_sdk_root}/components/libc/nuttx/libc/string/lib_strcasecmp.c", + "${bouffalo_sdk_root}/components/libc/nuttx/libc/string/lib_strcasestr.c", + "${bouffalo_sdk_root}/components/libc/nuttx/libc/string/lib_strcat.c", + "${bouffalo_sdk_root}/components/libc/nuttx/libc/string/lib_strchr.c", + "${bouffalo_sdk_root}/components/libc/nuttx/libc/string/lib_strcmp.c", + "${bouffalo_sdk_root}/components/libc/nuttx/libc/string/lib_strcspn.c", + "${bouffalo_sdk_root}/components/libc/nuttx/libc/string/lib_strdup.c", + "${bouffalo_sdk_root}/components/libc/nuttx/libc/string/lib_strnlen.c", + "${bouffalo_sdk_root}/components/libc/nuttx/libc/string/lib_strpbrk.c", + "${bouffalo_sdk_root}/components/libc/nuttx/libc/string/lib_strsep.c", + "${bouffalo_sdk_root}/components/libc/nuttx/libc/string/lib_strspn.c", + "${bouffalo_sdk_root}/components/libc/nuttx/libc/string/lib_strstr.c", + "${bouffalo_sdk_root}/components/libc/nuttx/libc/string/lib_strtok.c", + "${bouffalo_sdk_root}/components/libc/nuttx/libc/string/lib_strtokr.c", + "${bouffalo_sdk_root}/components/libc/nuttx/libc/string/lib_vikmemcpy.c", + "${bouffalo_sdk_root}/components/libc/vsnprintf.c", + "${bouffalo_sdk_root}/components/libc/snprintf.c", + "${bouffalo_sdk_root}/components/libc/sprintf.c", + "${bouffalo_sdk_root}/components/libc/vsprintf.c", + "${bouffalo_sdk_root}/components/libc/printf.c", + "${bouffalo_sdk_root}/components/libc/stdatomic.c", + ] + + cflags = [ + "-fno-builtin", + "-Wno-sign-compare", + "-Wno-implicit-fallthrough", + "-Wno-builtin-declaration-mismatch", + ] + configs += [ + ":${sdk_target_name}_config_mm", + ":${sdk_target_name}_config_lhal", + ] + public_configs = [ + ":${sdk_target_name}_config", + ] + } + + config("${sdk_target_name}_config_freertos") { + + defines = [ + "configSTACK_ALLOCATION_FROM_SEPARATE_HEAP=1", + ] + + include_dirs = [ + "${bouffalo_sdk_root}/components/os/freertos/include", + "${bouffalo_sdk_root}/components/os/freertos/portable/GCC/RISC-V/common", + "${bouffalo_sdk_root}/components/os/freertos/portable/GCC/RISC-V/common/chip_specific_extensions/RV32I_CLINT_no_extensions", + #"${bouffalo_sdk_root}/components/os/freertos/posix/include", + "${chip_root}/examples/platform/bouffalolab/bl616", + ] + } + + source_set("${sdk_target_name}_freertos") { + defines = [ + "CONFIG_FREERTOS", + "portasmHANDLE_INTERRUPT=interrupt_entry", + "default_interrupt_handler=freertos_risc_v_trap_handler", + #"CONFIG_POSIX", + ] + + include_dirs = [ + #memory heap + "${bouffalo_sdk_root}/components/os/freertos/include", + "${bouffalo_sdk_root}/components/os/freertos/portable/GCC/RISC-V/common", + "${bouffalo_sdk_root}/components/os/freertos/portable/GCC/RISC-V/common/chip_specific_extensions/RV32I_CLINT_no_extensions", + ] + + sources = [ + "${bouffalo_sdk_root}/components/os/freertos/croutine.c", + "${bouffalo_sdk_root}/components/os/freertos/event_groups.c", + "${bouffalo_sdk_root}/components/os/freertos/list.c", + "${bouffalo_sdk_root}/components/os/freertos/queue.c", + "${bouffalo_sdk_root}/components/os/freertos/tasks.c", + "${bouffalo_sdk_root}/components/os/freertos/timers.c", + "${bouffalo_sdk_root}/components/os/freertos/freertos_port.c", + "${bouffalo_sdk_root}/components/os/freertos/portable/MemMang/heap_3.c", + "${bouffalo_sdk_root}/components/os/freertos/portable/GCC/RISC-V/common/port.c", + "${bouffalo_sdk_root}/components/os/freertos/portable/GCC/RISC-V/common/portASM.S", + ] + + cflags_c = [] + + if (defined(invoker.enable_debug_frame_ptr) && invoker.enable_debug_frame_ptr) { + defines += [ "CONF_ENABLE_FRAME_PTR" ] + include_dirs += [ + "${bouffalo_sdk_root}/components/os/freertos/panic", + ] + sources += [ + "${bouffalo_sdk_root}/components/os/freertos/panic/panic_c.c", + ] + cflags_c += [ + "-Wno-int-conversion", + "-Wno-incompatible-pointer-types" + ] + } + + public_configs = [ + ":${sdk_target_name}_config_freertos", + ":${sdk_target_name}_config", + ] + } + + config("${sdk_target_name}_config_mm") { + include_dirs = [ + "${bouffalo_sdk_root}/components/mm", + "${bouffalo_sdk_root}/components/mm/tlsf", + ] + } + + source_set("${sdk_target_name}_mm") { + defines = [ + "configSTACK_ALLOCATION_FROM_SEPARATE_HEAP=1", + "CONFIG_TLSF", + ] + + include_dirs = [ + #memory heap + "${bouffalo_sdk_root}/components/mm", + "${bouffalo_sdk_root}/components/mm/tlsf", + ] + + sources = [ + "${bouffalo_sdk_root}/components/mm/mem.c", + "${bouffalo_sdk_root}/components/mm/tlsf/tlsf.c", + "${bouffalo_sdk_root}/components/mm/tlsf/bflb_tlsf.c", + ] + + cflags_c = [ + "-Wno-sign-compare", + "-Wno-format", + "-Wno-format-nonliteral", + "-Wno-format-security" + ] + + configs += [ + ":${sdk_target_name}_config_freertos", + ":${sdk_target_name}_config_lhal", + ] + + public_configs = [ + ":${sdk_target_name}_config_mm", + ":${sdk_target_name}_config", + ] + } + + config("${sdk_target_name}_config_easyflash4") { + include_dirs = [ + "${bouffalo_sdk_root}/components/easyflash4/inc", + ] + } + + source_set("${sdk_target_name}_easyflash4") { + defines = [ + "CONFIG_EASYFLASH4", + "BL616", + "EF_ENV_CACHE_TABLE_SIZE=100" + ] + + include_dirs = [ + "${bouffalo_sdk_root}/components/easyflash4/inc", + ] + + sources = [ + "${bouffalo_sdk_root}/components/easyflash4/src/easyflash.c", + "${bouffalo_sdk_root}/components/easyflash4/src/ef_env.c", + "${bouffalo_sdk_root}/components/easyflash4/src/ef_env_legacy_wl.c", + "${bouffalo_sdk_root}/components/easyflash4/src/ef_env_legacy.c", + "${bouffalo_sdk_root}/components/easyflash4/src/ef_port.c", + "${bouffalo_sdk_root}/components/easyflash4/src/ef_utils.c", + "${bouffalo_sdk_root}/components/easyflash4/src/easyflash_cli.c", + ] + + cflags_c = [ + "-Wno-sign-compare", + ] + + configs += [ + ":${sdk_target_name}_config_freertos", + ":${sdk_target_name}_config_utils", + ":${sdk_target_name}_config_lhal", + ] + + public_configs = [ + ":${sdk_target_name}_config_easyflash4", + ] + } + + config("${sdk_target_name}_config_littlefs") { + include_dirs = [ + "${bouffalo_sdk_root}/components/fs/littlefs/littlefs", + "${bouffalo_sdk_root}/components/fs/littlefs/port", + ] + + defines = [ "LFS_THREADSAFE" ] + } + + source_set("${sdk_target_name}_littlefs") { + defines = [ + "CONFIG_LITTLEFS", + "CONFIG_FREERTOS", + ] + + include_dirs = [ + "${bouffalo_sdk_root}/components/fs/littlefs/littlefs", + "${bouffalo_sdk_root}/components/fs/littlefs/port", + ] + + sources = [ + "${bouffalo_sdk_root}/components/fs/littlefs/easyflash_port/lfs_easyflash.c", + "${bouffalo_sdk_root}/components/fs/littlefs/littlefs/lfs_util.c", + "${bouffalo_sdk_root}/components/fs/littlefs/littlefs/lfs.c", + "${bouffalo_sdk_root}/components/fs/littlefs/port/lfs_xip_flash.c", + ] + + cflags_c = [ + "-Wno-sign-compare", + "-Wno-format", + "-Wno-format-nonliteral", + "-Wno-format-security", + "-Wno-shadow" + ] + + configs += [ + ":${sdk_target_name}_config", + ":${sdk_target_name}_config_freertos", + ":${sdk_target_name}_config_utils", + ":${sdk_target_name}_config_lhal", + ] + + public_configs = [ + ":${sdk_target_name}_config_littlefs", + ] + } + + config("${sdk_target_name}_config_utils") { + include_dirs = [ + "${bouffalo_sdk_root}/components/utils/log", + "${bouffalo_sdk_root}/components/utils/log/bflog", + "${bouffalo_sdk_root}/components/utils/bflb_mtd/include", + "${bouffalo_sdk_root}/components/utils/bflb_ota", + "${bouffalo_sdk_root}/components/utils/partition", + "${bouffalo_sdk_root}/components/utils/getopt", + "${bouffalo_sdk_root}/components/utils/ring_buffer", + "${bouffalo_sdk_root}/components/utils/coredump", + "${bouffalo_sdk_root}/components/utils/math/include", + ] +# "${bouffalo_sdk_root}/components/utils/matter_factory_data/include", + + defines = [ + "CONFIG_LOG_LEVEL=0", + "CONFIG_BFLOG", + "CONFIG_BFLOG_DEBUG", + "CONFIG_COREDUMP", + ] + } + + source_set("${sdk_target_name}_utils") { + defines = [ + "CONFIG_LOG_LEVEL=0", + "CONFIG_BFLOG", + "CONFIG_BFLOG_DEBUG", + "CONFIG_COREDUMP", + ] + + include_dirs = [ + "${bouffalo_sdk_root}/components/utils/log", + "${bouffalo_sdk_root}/components/utils/bflog", + "${bouffalo_sdk_root}/components/utils/bflb_mtd/include", + "${bouffalo_sdk_root}/components/utils/partition", + "${bouffalo_sdk_root}/components/utils/getopt", + "${bouffalo_sdk_root}/components/utils/ring_buffer", + "${bouffalo_sdk_root}/components/utils/coredump", + "${bouffalo_sdk_root}/components/utils/math/include", + ] + + sources = [ + "${bouffalo_sdk_root}/components/utils/log/log.c", + "${bouffalo_sdk_root}/components/utils/log/bflog/bflog.c", + "${bouffalo_sdk_root}/components/utils/log/log_freertos.c", + "${bouffalo_sdk_root}/components/utils/bflb_mtd/bflb_mtd.c", + "${bouffalo_sdk_root}/components/utils/bflb_mtd/bflb_boot2.c", + "${bouffalo_sdk_root}/components/utils/bflb_ota/bflb_ota.c", + "${bouffalo_sdk_root}/components/utils/bflb_ota/utils_sha256.c", + "${bouffalo_sdk_root}/components/utils/getopt/utils_getopt.c", + "${bouffalo_sdk_root}/components/utils/partition/partition.c", + "${bouffalo_sdk_root}/components/utils/ring_buffer/ring_buffer.c", + "${bouffalo_sdk_root}/components/utils/coredump/bflb_coredump.c", + "${bouffalo_sdk_root}/components/utils/math/src/utils_base64.c", + "${bouffalo_sdk_root}/components/utils/math/src/utils_crc.c", + "${bouffalo_sdk_root}/components/utils/math/src/utils_hex.c", + ] + +# "${bouffalo_sdk_root}/components/utils/matter_factory_data/efuse_slot.c", +# "${bouffalo_sdk_root}/components/utils/matter_factory_data/matter_factory_data.c", + + cflags_c = [ + "-Wno-sign-compare", + "-Wno-type-limits", + "-Wno-stringop-truncation", + "-Wno-format", + "-Wno-format-nonliteral", + "-Wno-format-security", + "-Wno-implicit-function-declaration" + ] + + configs += [ + ":${sdk_target_name}_config_lhal", + ":${sdk_target_name}_config_std_drv", + ":${sdk_target_name}_config_startup", + ":${sdk_target_name}_config_freertos", + ] + + public_configs = [ + ":${sdk_target_name}_config_utils", + ":${sdk_target_name}_config", + ] + } + + config("${sdk_target_name}_config_mbedtls") { + include_dirs = [ + "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/include", + "${bouffalo_sdk_root}/components/crypto/mbedtls/port/hw_acc", + ] + + defines = [ "MBEDTLS_CONFIG_FILE=\"bl616-chip-mbedtls-config.h\"" ] + } + + source_set("${sdk_target_name}_mbedtls") { + + defines = ["CONFIG_FREERTOS"] + + include_dirs = [ + "${bouffalo_sdk_root}/components/crypto/mbedtls/port", + "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library", + ] + + sources = [ + "${bouffalo_sdk_root}/components/crypto/mbedtls/port/hw_acc/aes_alt.c", + "${bouffalo_sdk_root}/components/crypto/mbedtls/port/hw_acc/bignum_alt.c", + "${bouffalo_sdk_root}/components/crypto/mbedtls/port/hw_acc/bignum_ext.c", + "${bouffalo_sdk_root}/components/crypto/mbedtls/port/hw_acc/ecp_alt.c", + "${bouffalo_sdk_root}/components/crypto/mbedtls/port/hw_acc/ecp_curves_alt.c", + "${bouffalo_sdk_root}/components/crypto/mbedtls/port/hw_acc/sha1_alt.c", + "${bouffalo_sdk_root}/components/crypto/mbedtls/port/hw_acc/sha256_alt.c", + "${bouffalo_sdk_root}/components/crypto/mbedtls/port/hw_acc/sha512_alt.c", + ] + + sources += [ + "${bouffalo_sdk_root}/components/crypto/mbedtls/port/bignum.c", + "${bouffalo_sdk_root}/components/crypto/mbedtls/port/entropy_poll_alt.c", + "${bouffalo_sdk_root}/components/crypto/mbedtls/port/net_sockets.c", + "${bouffalo_sdk_root}/components/crypto/mbedtls/port/sec_mutex.c", + ] + + sources += [ + "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/aes.c", + "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/aesni.c", + "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/arc4.c", + "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/aria.c", + "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/asn1parse.c", + "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/asn1write.c", + "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/base64.c", +# "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/bignum.c", + "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/blowfish.c", + "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/camellia.c", + "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/ccm.c", + "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/certs.c", + "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/chacha20.c", + "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/chachapoly.c", + "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/cipher.c", + "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/cipher_wrap.c", + "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/cmac.c", + "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/debug.c", + "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/des.c", + "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/dhm.c", + "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/constant_time.c", + "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/ctr_drbg.c", + "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/ecdh.c", + "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/ecdsa.c", + "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/ecjpake.c", + "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/ecp.c", + "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/ecp_curves.c", + "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/entropy.c", + "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/entropy_poll.c", + "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/error.c", + "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/gcm.c", + "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/padlock.c", + "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/mps_reader.c", + "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/mps_trace.c", + "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/nist_kw.c", + "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/memory_buffer_alloc.c", + "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/havege.c", + "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/hkdf.c", + "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/hmac_drbg.c", + "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/md.c", + "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/md2.c", + "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/md4.c", + "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/md5.c", + "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/oid.c", + "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/pem.c", + "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/pk.c", + "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/pk_wrap.c", + "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/pkparse.c", + "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/pkcs11.c", + "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/pkcs12.c", + "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/pkcs5.c", + "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/pkwrite.c", + "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/platform.c", + "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/platform_util.c", + "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls//library/poly1305.c", + "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls//library/ripemd160.c", + "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls//library/rsa.c", + "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls//library/rsa_internal.c", + "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/sha1.c", + "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/sha256.c", + "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/sha512.c", + "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/ssl_cache.c", + "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/ssl_ciphersuites.c", + "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/ssl_cli.c", + "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/ssl_cookie.c", + "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/ssl_msg.c", + "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/ssl_srv.c", + "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/ssl_ticket.c", + "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/ssl_tls13_keys.c", + "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/ssl_tls.c", + "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/threading.c", + "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/timing.c", + "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/version.c", + "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/version_features.c", + "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/x509.c", + "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/x509_create.c", + "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/x509_crt.c", + "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/x509_crl.c", + "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/x509write_csr.c", + "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/x509_csr.c", + "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/x509write_crt.c", + "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/xtea.c", + ] + + cflags_c = [ + "-Wno-sign-compare", + "-Wno-implicit-function-declaration", + "-Wno-format", + "-Wno-format-security", + "-Wno-format-nonliteral" + ] + + configs += [ + ":${sdk_target_name}_config", + ":${sdk_target_name}_config_lhal", + ":${sdk_target_name}_config_freertos", + ":${sdk_target_name}_config_mm", + ":${sdk_target_name}_config_lwip" + ] + + public_configs = [ + ":${sdk_target_name}_config_mbedtls", + ] + } + + config("${sdk_target_name}_config_lwip") { + include_dirs = [ + "${bouffalolab_iot_sdk_build_root}/bl616", + "${bouffalo_sdk_root}/components/net/lwip/lwip/system", + "${bouffalo_sdk_root}/components/net/lwip/lwip/src/include", + "${bouffalo_sdk_root}/components/net/lwip/lwip/src/compat/posix", + "${bouffalo_sdk_root}/components/net/lwip/lwip/src/include/compat/posix", + "${bouffalo_sdk_root}/components/net/lwip/lwip/lwip-port", + "${bouffalo_sdk_root}/components/net/lwip/lwip_apps/dhcpd", + ] + + defines = [ + "CONFIG_LWIP", + "CONFIG_MAC_TXQ_DEPTH=8", + "CONFIG_MAC_RXQ_DEPTH=8", + ] + } + + source_set("${sdk_target_name}_lwip") { + + sources = [ + "${bouffalo_sdk_root}/components/net/lwip/lwip/src/apps/lwiperf/lwiperf.c", + "${bouffalo_sdk_root}/components/net/lwip/lwip/src/apps/http/fs.c", + "${bouffalo_sdk_root}/components/net/lwip/lwip/src/api/api_msg.c", + "${bouffalo_sdk_root}/components/net/lwip/lwip/src/api/err.c", + "${bouffalo_sdk_root}/components/net/lwip/lwip/src/api/netbuf.c", + "${bouffalo_sdk_root}/components/net/lwip/lwip/src/api/netdb.c", + "${bouffalo_sdk_root}/components/net/lwip/lwip/src/api/netifapi.c", + "${bouffalo_sdk_root}/components/net/lwip/lwip/src/api/sockets.c", + "${bouffalo_sdk_root}/components/net/lwip/lwip/src/api/tcpip.c", + "${bouffalo_sdk_root}/components/net/lwip/lwip/src/api/api_lib.c", + "${bouffalo_sdk_root}/components/net/lwip/lwip/src/core/ipv4/autoip.c", + "${bouffalo_sdk_root}/components/net/lwip/lwip/src/core/ipv4/dhcp.c", + "${bouffalo_sdk_root}/components/net/lwip/lwip/src/core/ipv4/etharp.c", + "${bouffalo_sdk_root}/components/net/lwip/lwip/src/core/ipv4/icmp.c", + "${bouffalo_sdk_root}/components/net/lwip/lwip/src/core/ipv4/igmp.c", + "${bouffalo_sdk_root}/components/net/lwip/lwip/src/core/ipv4/ip4_addr.c", + "${bouffalo_sdk_root}/components/net/lwip/lwip/src/core/ipv4/ip4_frag.c", + "${bouffalo_sdk_root}/components/net/lwip/lwip/src/core/ipv4/ip4.c", + + "${bouffalo_sdk_root}/components/net/lwip/lwip/src/core/ipv6/dhcp6.c", + "${bouffalo_sdk_root}/components/net/lwip/lwip/src/core/ipv6/ethip6.c", + "${bouffalo_sdk_root}/components/net/lwip/lwip/src/core/ipv6/icmp6.c", + "${bouffalo_sdk_root}/components/net/lwip/lwip/src/core/ipv6/inet6.c", + "${bouffalo_sdk_root}/components/net/lwip/lwip/src/core/ipv6/ip6.c", + "${bouffalo_sdk_root}/components/net/lwip/lwip/src/core/ipv6/ip6_addr.c", + "${bouffalo_sdk_root}/components/net/lwip/lwip/src/core/ipv6/ip6_frag.c", + "${bouffalo_sdk_root}/components/net/lwip/lwip/src/core/ipv6/mld6.c", + "${bouffalo_sdk_root}/components/net/lwip/lwip/src/core/ipv6/nd6.c", + + "${bouffalo_sdk_root}/components/net/lwip/lwip/src/core/def.c", + "${bouffalo_sdk_root}/components/net/lwip/lwip/src/core/dns.c", + "${bouffalo_sdk_root}/components/net/lwip/lwip/src/core/inet_chksum.c", + "${bouffalo_sdk_root}/components/net/lwip/lwip/src/core/init.c", + "${bouffalo_sdk_root}/components/net/lwip/lwip/src/core/ip.c", + "${bouffalo_sdk_root}/components/net/lwip/lwip/src/core/mem.c", + "${bouffalo_sdk_root}/components/net/lwip/lwip/src/core/memp.c", + "${bouffalo_sdk_root}/components/net/lwip/lwip/src/core/netif.c", + "${bouffalo_sdk_root}/components/net/lwip/lwip/src/core/pbuf.c", + "${bouffalo_sdk_root}/components/net/lwip/lwip/src/core/raw.c", + "${bouffalo_sdk_root}/components/net/lwip/lwip/src/core/stats.c", + "${bouffalo_sdk_root}/components/net/lwip/lwip/src/core/sys.c", + "${bouffalo_sdk_root}/components/net/lwip/lwip/src/core/tcp_in.c", + "${bouffalo_sdk_root}/components/net/lwip/lwip/src/core/tcp_out.c", + "${bouffalo_sdk_root}/components/net/lwip/lwip/src/core/tcp.c", + "${bouffalo_sdk_root}/components/net/lwip/lwip/src/core/timeouts.c", + "${bouffalo_sdk_root}/components/net/lwip/lwip/src/core/udp.c", + "${bouffalo_sdk_root}/components/net/lwip/lwip/src/netif/ethernet.c", + "${bouffalo_sdk_root}/components/net/lwip/lwip/src/apps/mdns/mdns.c", + "${bouffalo_sdk_root}/components/net/lwip/lwip/lwip-port/FreeRTOS/sys_arch.c", + "${bouffalo_sdk_root}/components/net/lwip/lwip_apps/dhcpd/dhcp_server_raw.c", + #"${bouffalo_sdk_root}/components/net/lwip/lwip/system/os/sys_arch.c", + ] + + cflags_c = [ + "-Wno-sign-compare", + "-Wno-format", + "-Wno-format-nonliteral", + "-Wno-format-security", + "-Wno-unused-variable" + ] + + configs += [ + ":${sdk_target_name}_config_utils", + ":${sdk_target_name}_config_std_drv", + ":${sdk_target_name}_config_freertos", + ":${sdk_target_name}_config_lhal", + ":${sdk_target_name}_config_mm", + ":${sdk_target_name}_config_wifi", + ] + + public_configs = [ + ":${sdk_target_name}_config_lwip", + ":${sdk_target_name}_config", + ] + } + + config("${sdk_target_name}_config_wifi") { + + defines = [ + "CFG_VIF_MAX=2", + "CFG_STA_MAX=4", + "CFG_UMAC" + ] + + include_dirs = [ + "${bouffalo_sdk_root}/components/wireless/wifi6/include", + "${bouffalo_sdk_root}/components/wireless/wifi6/include/export", + "${bouffalo_sdk_root}/components/wireless/wifi6/bl6_os_adapter/include", + "${bouffalo_sdk_root}/components/wireless/wifi6/wifi6_lwip_adapter/include", + ] + } + + source_set("${sdk_target_name}_wifi") { + + defines = [ + "CFG_IPV6" + ] + + libs = [ + "${bouffalo_sdk_root}/components/wireless/wifi6/lib/libwifi6.a", + ] + + include_dirs = [ + "${bouffalo_sdk_root}/components/wireless/wifi6/wifi6_lwip_adapter", + ] + + sources = [ + "${bouffalo_sdk_root}/components/wireless/wifi6/bl6_os_adapter/src/rtos_al.c", + "${bouffalo_sdk_root}/components/wireless/wifi6/bl6_os_adapter/src/platform_bouffalo_sdk.c", + "${bouffalo_sdk_root}/components/wireless/wifi6/wifi6_lwip_adapter/cli_al.c", + "${bouffalo_sdk_root}/components/wireless/wifi6/wifi6_lwip_adapter/net_al.c", + "${bouffalo_sdk_root}/components/wireless/wifi6/wifi6_lwip_adapter/net_al_ext.c", + "${bouffalo_sdk_root}/components/wireless/wifi6/wifi6_lwip_adapter/net_tg_al.c", + "${bouffalo_sdk_root}/components/wireless/wifi6/wifi6_lwip_adapter/net_iperf_al.c", + "${bouffalo_sdk_root}/components/wireless/wifi6/wifi6_lwip_adapter/wifi_pkt_hooks.c", + ] + + cflags_c = [ + "-Wno-incompatible-pointer-types", + "-Wno-implicit-function-declaration", + "-Wno-format", + "-Wno-format-nonliteral", + "-Wno-discarded-qualifiers", + "-Wno-format-security" + ] + + configs += [ + ":${sdk_target_name}_config_lhal", + ":${sdk_target_name}_config_utils", + ":${sdk_target_name}_config_shell", + ":${sdk_target_name}_config_freertos", + ":${sdk_target_name}_config_lwip", + ] + public_configs = [ + ":${sdk_target_name}_config_wifi", + ":${sdk_target_name}_config", + ] + } + + config("${sdk_target_name}_config_ble") { + + defines = [ + "BFLB_BLE", + "CONFIG_BT_CONN=1", + + "CONFIG_SET_TX_PWR", + "CFG_CON=1", + "CFG_BLE", + "CFG_SLEEP", + "CFG_BT_RESET", + "CONFIG_BT_PERIPHERAL=1", + "CFG_BLE_TX_BUFF_DATA=2", + "CONFIG_BT_GATT_DYNAMIC_DB", + "CONFIG_BT_GATT_SERVICE_CHANGED", + "CONFIG_BT_SETTINGS_CCC_LAZY_LOADING", + "CONFIG_BT_KEYS_OVERWRITE_OLDEST", + "CONFIG_BT_GAP_PERIPHERAL_PREF_PARAMS", + "CONFIG_BT_BONDABLE", + "CONFIG_BT_ASSERT", + "CFG_BLE_STACK_DBG_PRINT", + ] + + include_dirs = [ + "${bouffalo_sdk_root}/components/wireless/bluetooth/btblecontroller/btble_inc", + "${bouffalo_sdk_root}/components/wireless/bluetooth/blestack/src/include", + "${bouffalo_sdk_root}/components/wireless/bluetooth/blestack/src/include/bluetooth", + "${bouffalo_sdk_root}/components/wireless/bluetooth/blestack/src", + "${bouffalo_sdk_root}/components/wireless/bluetooth/blestack/src/port/include", + "${bouffalo_sdk_root}/components/wireless/bluetooth/blestack/src/common/include/zephyr", + "${bouffalo_sdk_root}/components/wireless/bluetooth/blestack/src/host", + "${bouffalo_sdk_root}/components/wireless/bluetooth/blestack/src/common/include", + "${bouffalo_sdk_root}/components/wireless/bluetooth/blestack/src/include/drivers/bluetooth", + ] + } + + source_set("${sdk_target_name}_ble") { + defines = [ + "CONFIG_BT_L2CAP_DYNAMIC_CHANNEL", + "CONFIG_BT_GATT_CLIENT", + "CONFIG_BT_CONN=1", + "CONFIG_BT_GATT_DIS_PNP", + "CONFIG_BT_GATT_DIS_SERIAL_NUMBER", + "CONFIG_BT_GATT_DIS_FW_REV", + "CONFIG_BT_GATT_DIS_HW_REV", + "CONFIG_BT_GATT_DIS_SW_REV", + "CONFIG_BT_ECC", + "CONFIG_BT_KEYS_SAVE_AGING_COUNTER_ON_PAIRING", + "CONFIG_BT_HCI_VS_EVT_USER", + "CONFIG_BT_SETTINGS_USE_PRINTK", + "CONFIG_BLE_MULTI_ADV", + ] + + libs = [ "${bouffalo_sdk_root}/components/wireless/bluetooth/btblecontroller/lib/libbtblecontroller_bl616_ble1m0s1bredr0.a" ] + + include_dirs = [ + "${bouffalo_sdk_root}/components/wireless/bluetooth/blestack/src/bl_hci_wrapper", + "${bouffalo_sdk_root}/components/wireless/bluetooth/blestack/src/common", + "${bouffalo_sdk_root}/components/wireless/bluetooth/blestack/src/common/include", + "${bouffalo_sdk_root}/components/wireless/bluetooth/blestack/src/common/include/misc", + "${bouffalo_sdk_root}/components/wireless/bluetooth/blestack/src/common/tinycrypt/include/tinycrypt", + ] + + sources = [ + "${bouffalo_sdk_root}/components/wireless/bluetooth/blestack/src/bl_hci_wrapper/bl_hci_wrapper.c", + "${bouffalo_sdk_root}/components/wireless/bluetooth/blestack/src/common/atomic_c.c", + "${bouffalo_sdk_root}/components/wireless/bluetooth/blestack/src/common/buf.c", + "${bouffalo_sdk_root}/components/wireless/bluetooth/blestack/src/common/dec.c", + "${bouffalo_sdk_root}/components/wireless/bluetooth/blestack/src/common/log.c", + "${bouffalo_sdk_root}/components/wireless/bluetooth/blestack/src/common/poll.c", + "${bouffalo_sdk_root}/components/wireless/bluetooth/blestack/src/common/work_q.c", + "${bouffalo_sdk_root}/components/wireless/bluetooth/blestack/src/hci_onchip/hci_driver.c", + "${bouffalo_sdk_root}/components/wireless/bluetooth/blestack/src/host/att.c", + "${bouffalo_sdk_root}/components/wireless/bluetooth/blestack/src/host/bl_host_assist.c", + "${bouffalo_sdk_root}/components/wireless/bluetooth/blestack/src/host/conn.c", + "${bouffalo_sdk_root}/components/wireless/bluetooth/blestack/src/host/crypto.c", + "${bouffalo_sdk_root}/components/wireless/bluetooth/blestack/src/host/gatt.c", + "${bouffalo_sdk_root}/components/wireless/bluetooth/blestack/src/host/hci_core.c", + "${bouffalo_sdk_root}/components/wireless/bluetooth/blestack/src/host/l2cap.c", + "${bouffalo_sdk_root}/components/wireless/bluetooth/blestack/src/host/settings.c", + "${bouffalo_sdk_root}/components/wireless/bluetooth/blestack/src/host/uuid.c", + "${bouffalo_sdk_root}/components/wireless/bluetooth/blestack/src/port/bl_port.c", + "${bouffalo_sdk_root}/components/wireless/bluetooth/blestack/src/host/multi_adv.c" + + ] + + cflags_c = [ + "-Wno-sign-compare", + "-Wno-implicit-function-declaration", + "-Wno-format", + "-Wno-format-nonliteral", + "-Wno-format-security", + "-Wno-discarded-qualifiers", + "-Wno-misleading-indentation" + ] + + configs += [ + ":${sdk_target_name}_config", + ":${sdk_target_name}_config_utils", + ":${sdk_target_name}_config_freertos" + ] + public_configs = [ + ":${sdk_target_name}_config", + ":${sdk_target_name}_config_ble", + ] + } + + group(sdk_target_name) { + public_deps = [ + ":${sdk_target_name}_startup", + ":${sdk_target_name}_std_drv", + ":${sdk_target_name}_lhal", + ":${sdk_target_name}_board", + ":${sdk_target_name}_shell", + ":${sdk_target_name}_rf", + ":${sdk_target_name}_libc", + ":${sdk_target_name}_mm", + ":${sdk_target_name}_freertos", + + ":${sdk_target_name}_mbedtls", + ":${sdk_target_name}_utils", + ":${sdk_target_name}_lwip", + ":${sdk_target_name}_wifi", + ] + + if (defined(invoker.bouffalo_sdk_component_easyflash_enabled) && invoker.bouffalo_sdk_component_easyflash_enabled) { + public_deps += [ ":${sdk_target_name}_easyflash4" ] + } + else { + public_deps += [ ":${sdk_target_name}_littlefs" ] + } + + if (defined(invoker.chip_config_network_layer_ble) && invoker.chip_config_network_layer_ble) { + public_deps += [ + ":${sdk_target_name}_ble", + ] + } + } +} diff --git a/third_party/qcc74x/qcc74x_sdk b/third_party/qcc74x/qcc74x_sdk new file mode 160000 index 00000000000000..3d5ebb92397f59 --- /dev/null +++ b/third_party/qcc74x/qcc74x_sdk @@ -0,0 +1 @@ +Subproject commit 3d5ebb92397f598ae908178eadcc613573da0277 diff --git a/third_party/qcc74x/repo b/third_party/qcc74x/repo new file mode 160000 index 00000000000000..07ac148f70e1e3 --- /dev/null +++ b/third_party/qcc74x/repo @@ -0,0 +1 @@ +Subproject commit 07ac148f70e1e3773f0ba0fa5ccad00bdf40e4d9