ESP-Matter SDK 软件开发框架及目录结构介绍

ESP-Matter SDK 软件开发框架及目录结构介绍

ESP_Matter_SDK_directory struct

1. esp-matter/compoents

该目录为ESP-Matter 的核心功能组件,定义了相应基本matter 的数据模型。

esp-matter/components/
├── esp_matter
├── esp_matter_bridge
├── esp_matter_console
├── esp_matter_identify
├── esp_matter_openthread
├── esp_matter_ota
├── esp_matter_rainmaker
└── route_hook

1.1 components/esp_matter 组件

esp_matter 组件主要针对基本matter 设备类型的数据模型定义

esp-matter/components/esp_matter/
├── CMakeLists.txt
├── esp_matter_attribute.cpp
├── esp_matter_attribute.h
├── esp_matter_attribute_utils.cpp
├── esp_matter_attribute_utils.h
├── esp_matter_client.cpp
├── esp_matter_client.h
├── esp_matter_cluster.cpp
├── esp_matter_cluster.h
├── esp_matter_command.cpp
├── esp_matter_command.h
├── esp_matter_core.cpp
├── esp_matter_core.h
├── esp_matter_endpoint.cpp
├── esp_matter_endpoint.h
├── esp_matter_event.cpp
├── esp_matter_event.h
├── esp_matter_feature.cpp
├── esp_matter_feature.h
├── esp_matter.h
└── zap_common
  • esp_matter_core 定义

    esp_matter_core.cpp 中详细的定义了 node 数据模型的构建过程,如下图所示该文件提供了 node、endpoint、commd、attribute 等数据结构的定义。以及展示了如何创建一个原始的 node,在此文件中有详细的说明。
    esp_matter_data_model
    esp_matter_core.cpp 还定义了matter 协议栈的运行入口和初始化接口以及恢复出长重置接口等

    esp_err_t start(event_callback_t callback)
    {
        esp_err_t err = chip_init(callback);
        if (err != ESP_OK) {
            ESP_LOGE(TAG, "Error initializing matter");
        }
        return err;
    }
    
    esp_err_t factory_reset()
    {
        esp_err_t err = ESP_OK;
        node_t *node = node::get();
        if (node) {
            /* ESP Matter data model is used. Erase all the data that we have added in nvs. */
            endpoint_t *endpoint = endpoint::get_first(node);
            while (endpoint) {
                uint16_t endpoint_id = endpoint::get_id(endpoint);
                char nvs_namespace[16] = {0};
                snprintf(nvs_namespace, 16, "endpoint_%X", endpoint_id); /* endpoint_id */
    
                nvs_handle_t handle;
                err = nvs_open_from_partition(ESP_MATTER_NVS_PART_NAME, nvs_namespace, NVS_READWRITE, &handle);
                if (err != ESP_OK) {
                    ESP_LOGE(TAG, "Error opening partition: %s, %d", nvs_namespace, err);
                    continue;
                }
                err = nvs_erase_all(handle);
                if (err != ESP_OK) {
                    ESP_LOGE(TAG, "Error erasing partition: %s, %d", nvs_namespace, err);
                    continue;
                }
                endpoint = endpoint::get_next(endpoint);
            }
            if (err == ESP_OK) {
                ESP_LOGI(TAG, "Erasing attribute data completed");
            }
        }
    
        /* Submodule factory reset. This also restarts after completion. */
        ConfigurationMgr().InitiateFactoryReset();
        return err;
    }
    
  • esp_matter_endpoint 定义

    esp_matter_endpoint.h 文件中有不同设备类型的配置以及相应的 creat 函数,不同设备类型 endpiontcreat 函数要求传入node 指针,creat 函数会创建出一个 endpiont , 并且将该 endpiont 添加到 node 的数据结构当中,最终被esp_matter 的SDK 管理起来。

    namespace color_temperature_light {
    typedef struct config {
        cluster::identify::config_t identify;
        cluster::groups::config_t groups;
        cluster::scenes::config_t scenes;
        cluster::on_off::config_t on_off;
        cluster::level_control::config_t level_control;
        cluster::color_control::config_t color_control; //色温灯相关的功能簇
    } config_t;
    
    uint32_t get_device_type_id();
    endpoint_t *create(node_t *node, config_t *config, uint8_t flags);
    } /* color_temperature_light */
    

esp_matter_endpoint

  • esp_matter_cluster定义

    esp_matter_cluster.c/esp_matter_cluster.c 文件定义了 不同功能类型的cluster 的定义,不同设备类型 clustercreat 函数要求传入endpoint 指针,creat 函数会创建出一个 cluster , 并且将该 cluster 添加到 endpoint 的数据结构当中,最终被esp_matter 的SDK 管理起来。

    namespace level_control {
    typedef struct config {
        uint16_t cluster_revision;
        uint8_t current_level;
        uint8_t on_level;
        uint8_t options;
        feature::lighting::config_t lighting;
        config() : cluster_revision(5), current_level(0), on_level(1), options(0) {}
    } config_t;
    
    cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags, uint32_t features);
    } /* level_control */
    
    namespace color_control {
    typedef struct config {
        uint16_t cluster_revision; 
        uint8_t color_mode; //基本功能点
        uint8_t color_control_options;
        uint8_t enhanced_color_mode;
        uint16_t color_capabilities;
        feature::hue_saturation::config_t hue_saturation; //若需附加的功能,可选择此处的可选feature进行添加
        feature::color_temperature::config_t color_temperature;
        feature::xy::config_t xy;
        feature::enhanced_hue::config_t enhanced_hue;
        feature::color_loop::config_t color_loop;
        config() : cluster_revision(5), color_mode(1), color_control_options(0), enhanced_color_mode(1),
                   color_capabilities(0) {} //结构体构造初始化赋值
    } config_t;
    
    cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags, uint32_t features);
    } /* color_control */
    
  • attribute、feature/command

    每个Cluster 内都有自己的 Attribute 和 Command, Attribute表示可以读取或写入的内容, Command 代表触发 Cluster进行某种行为的能力, feature 代表某些cluster的附加功能,attribute、feature/command 等数据模型的定义和 endpoint和 cluster机制类似。

  • esp_matter_attribute_utils定义

    esp_matter_attribute_utils 文件定义了 esp_matter SDK中经常使用到的 结构体的数据类型

1.2 components/esp_matter_bridge 组件

esp-matter/components/esp_matter_bridge/
├── CMakeLists.txt
├── esp_matter_bridge.cpp
└── esp_matter_bridge.h

esp_matter_bridge 组件主要针对 bridge 设备类型提供相关API 去创建桥接节点。

1.3 components/esp_matter_console 组件

esp-matter/components/esp_matter_console/
├── CMakeLists.txt
├── esp_matter_console.cpp
├── esp_matter_console_diagnostics.cpp
├── esp_matter_console.h
└── Kconfig

esp_matter_console 组件提供初始化 matter console (通过串口进行相关的命令交互)

2. esp-matter/connectedhomeip

esp-matter/connectedhomeip/
└── connectedhomeip
    ├── build
    ├── BUILD.gn
    ├── build_overrides
    ├── CODE_OF_CONDUCT.md
    ├── config
    ├── CONTRIBUTING.md
    ├── credentials
    ├── docs
    ├── examples
    ├── gn_build.sh
    ├── integrations
    ├── lgtm.yml
    ├── LICENSE
    ├── README.md
    ├── REVIEWERS.md
    ├── scripts
    ├── src
    ├── third_party
    └── zzz_generated

该文件夹为 chip sdk 源目录,之前讲过esp-matter 是在 chip sdk 的基础上来完成数据模型的封装,因此在esp-matter sdk 中将 chip sdk 作为一个submodule 包含进来。

开发过程中侧重关注以下几个目录文件:

  • esp-matter/connectedhomeip/connectedhomeip/docs/guides/

    该目录文件为chip sdk 相关操作文档指南

    esp-matter/connectedhomeip/connectedhomeip/docs/guides/
    ├── access-control-guide.md
    ├── android_building.md
    ├── BUILDING.md
    ├── chip_tool_guide.md //chip_tool操作文档
    ├── images
    ├── infineon_p6_software_update.md
    ├── ip_commissioning.md
    ├── matter-repl.md
    ├── mbedos_add_new_target.md
    ├── mbedos_commissioning.md
    ├── mbedos_platform_overview.md
    ├── nrfconnect_android_commissioning.md
    ├── nrfconnect_examples_cli.md
    ├── nrfconnect_examples_configuration.md
    ├── nrfconnect_examples_software_update.md
    ├── nrfconnect_factory_data_configuration.md
    ├── nrfconnect_platform_overview.md
    ├── nxp_imx8m_linux_examples.md
    ├── nxp_k32w_android_commissioning.md
    ├── openthread_border_router_pi.md
    ├── openthread_rcp_nrf_dongle.md
    ├── python_chip_controller_advanced_usage.md
    ├── python_chip_controller_building.md
    ├── repl
    ├── silabs_efr32_building.md
    ├── silabs_efr32_software_update.md
    ├── simulated_device_linux.md
    ├── ti_platform_overview.md
    └── troubleshooting_avahi.md
    
    2 directories, 27 files
    
  • esp-matter/connectedhomeip/connectedhomeip/config/esp32/

    该目录文件为乐鑫平台为适配 chip sdk 所开发的配置相关文件。

    esp-matter/connectedhomeip/connectedhomeip/config/esp32/
    ├── args.gni
    ├── build -> third_party/connectedhomeip/build
    ├── BUILD.gn
    ├── build_overrides -> ../../examples/build_overrides
    ├── components
    ├── firmware_rom
    ├── lib
    ├── mbedtls
    ├── third_party
    └── toolchain
    
    8 directories, 2 files
    
  • esp-matter/connectedhomeip/connectedhomeip/src/platform/ESP32/

    该目录为 ESP32 芯片平台的支持和相关初始化适配工作,包含 WiFi、ble的初始化和WiFi的连接、ble广播如何工作等相关操作由 chip sdk 统一管理调度。

    esp-matter/connectedhomeip/connectedhomeip/src/platform/ESP32/
    ├── BLEManagerImpl.h
    ├── BlePlatformConfig.h
    ├── bluedroid
    ├── BUILD.gn
    ├── CHIPDevicePlatformConfig.h
    ├── CHIPDevicePlatformEvent.h
    ├── CHIPPlatformConfig.h
    ├── ConfigurationManagerImpl.cpp
    ├── ConfigurationManagerImpl.h
    ├── ConnectivityManagerImpl.cpp
    ├── ConnectivityManagerImpl.h
    ├── ConnectivityManagerImpl_WiFi.cpp
    ├── DeviceInfoProviderImpl.cpp
    ├── DeviceInfoProviderImpl.h
    ├── DeviceNetworkProvisioningDelegateImpl.cpp
    ├── DeviceNetworkProvisioningDelegateImpl.h
    ├── DiagnosticDataProviderImpl.cpp
    ├── DiagnosticDataProviderImpl.h
    ├── DnssdImpl.cpp
    ├── DnssdImpl.h
    ├── ESP32Config.cpp
    ├── ESP32Config.h
    ├── ESP32FactoryDataProvider.cpp
    ├── ESP32FactoryDataProvider.h
    ├── ESP32Utils.cpp
    ├── ESP32Utils.h
    ├── InetPlatformConfig.h
    ├── KeyValueStoreManagerImpl.cpp
    ├── KeyValueStoreManagerImpl.h
    ├── Logging.cpp
    ├── LwIPCoreLock.cpp
    ├── NetworkCommissioningDriver.cpp
    ├── NetworkCommissioningDriver.h
    ├── nimble
    ├── OpenthreadConfig.h
    ├── OpenthreadLauncher.c
    ├── OpenthreadLauncher.h
    ├── OTAImageProcessorImpl.cpp
    ├── OTAImageProcessorImpl.h
    ├── PlatformManagerImpl.cpp
    ├── PlatformManagerImpl.h
    ├── ScopedNvsHandle.h
    ├── SystemPlatformConfig.h
    ├── SystemTimeSupport.cpp
    ├── SystemTimeSupport.h
    ├── ThreadStackManagerImpl.cpp
    ├── ThreadStackManagerImpl.h
    └── WarmPlatformConfig.h
    
    2 directories, 46 files
    

3. esp-matter/device_hal

该文件夹包含乐鑫提供的部分设备外设驱动。

4. esp-matter/example

该文件夹为乐鑫matter 相关demo 程序,可用于快速构建相关示例功能。

esp-matter/examples/
├── blemesh_bridge
├── common
├── light
├── light_switch
├── rainmaker_light
├── zap_light
└── zigbee_bridge

7 directories, 0 files

5. esp-matter/tools

该目录为量产工具相关配置文件,量产工具可以生成烧录所需的固件、matter的设备证书以及一些应用的配置。

esp-matter/tools
├── ci
│   └── format_all.sh
└── mfg_tool
    ├── chip_nvs_keys.py
    ├── mfg_tool.py
    ├── README.md
    └── requirements.txt

2 directories, 5 files
  • 2
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
ESP-C3 SDK 4.3 是新型的ESP- C3 软件开发工具包。这种软件开发工具包和以前的版本有很大的不同。本次发行的ESP-C3 SDK 4.3 包含了很多全新的特性。所以,对于想要进行网联设备开发的用户和开发者来说,ESP-C3 SDK 4.3 资料是非常重要的。以下是对这个资料的解释和分析: 首先,ESP- C3 背后的团队为此版本的 SDK 带来了许多改进。这些改进一部分都是和行业趋势和市场需求有关的。比如,SDK 4.3 增加了LLMNR 广播查询支持。除此之外,SDK 4.3 中还增加了SNTP 客户端库和Eventloop 改进以及BLE Mesh 组网的全新支持等等。这些改进都给开发者带来了更好的体验和更加充足的工具。 其次,ESP-C3 SDK 4.3 在安全方面也有所提升。通过支持TLS 1.3,可以提高安全性。此外,ESP-C3 SDK 4.3 还支持在TLS 栈中添加自定义 CA 和 client certificate。这为开发者提供了更加精细的控制和配置。 最后,新的开发人员进入行业,希望能够更快、更准确地学习和应用 IoT 技术,因此,SDK 4.3 的资料不仅涵盖了示例代码和代码文档,还增加了更多视频教程和实例应用程序,这更进一步增强了开发者对这个 SDK 4.3 资料的认知度和学习难度。 综上所述,ESP-C3 SDK 4.3 资料对于开发人员来说是一个非常有价值的开发工具集。它不仅支持开发工具包和多种联网协议,而且在改进功能和提升安全性方面都进行了不断的更新和完善,使得开发人员在开发 IoT 设备时拥有更加自由、安全和高效的开发环境和工具。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Engineer-Jaylen_Sun

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值