[Matter] Changing or adding Endpoints/Clusters to Matter-Template example with the zap tool leads to compiling errors

Hi Nordic Guys,

hope you can help following issue (I think the issue is still mentioned in Ticket https://devzone.nordicsemi.com/f/nordic-q-a/87410/corrupt-matter-zcl-file-generation-matter-template-project, Case ID: 288305).

I try to extend the matter-template example from the nRF SDK. Out off the box the example compiles, build and links The application can be copied to the nRF5340DK board and works.

If I add a new endpoint, like it is described in https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/ug_matter_gs_adding_clusters.html#ug-matter-creating-accessory and let the generator.py script do its work, the result is an unbuild-able application.

See the following build-output:

/Users/bennynestler/workspaces/matter/nRFConnect/matter-template/src/zap-generated/endpoint_config.h:570:3: error: conversion from '<brace-enclosed initializer list>' to 'EmberAfDefaultOrMinMaxAttributeValue' is ambiguous
  570 |   }
      |   ^
/opt/nordic/ncs/v2.0.2/modules/lib/matter/src/app/util/attribute-storage.cpp:102:71: note: in expansion of macro 'GENERATED_ATTRIBUTES'
  102 | constexpr const EmberAfAttributeMetadata generatedAttributes[]      = GENERATED_ATTRIBUTES;
      |                                                                       ^~~~~~~~~~~~~~~~~~~~
In file included from /opt/nordic/ncs/v2.0.2/modules/lib/matter/src/app/util/af-types.h:58,
                 from /opt/nordic/ncs/v2.0.2/modules/lib/matter/src/app/util/af.h:69,
                 from /opt/nordic/ncs/v2.0.2/modules/lib/matter/src/app/util/common.h:45,
                 from /opt/nordic/ncs/v2.0.2/modules/lib/matter/src/app/util/attribute-storage.cpp:42:
/opt/nordic/ncs/v2.0.2/modules/lib/matter/src/app/util/attribute-metadata.h:104:15: note: candidate: 'constexpr EmberAfDefaultOrMinMaxAttributeValue::EmberAfDefaultOrMinMaxAttributeValue(const EmberAfAttributeMinMaxValue*)'
  104 |     constexpr EmberAfDefaultOrMinMaxAttributeValue(const EmberAfAttributeMinMaxValue * ptr) : ptrToMinMaxValue(ptr) {}
      |               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/opt/nordic/ncs/v2.0.2/modules/lib/matter/src/app/util/attribute-metadata.h:103:15: note: candidate: 'constexpr EmberAfDefaultOrMinMaxAttributeValue::EmberAfDefaultOrMinMaxAttributeValue(uint16_t)'
  103 |     constexpr EmberAfDefaultOrMinMaxAttributeValue(uint16_t val) : defaultValue(val) {}
      |               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/opt/nordic/ncs/v2.0.2/modules/lib/matter/src/app/util/attribute-metadata.h:102:15: note: candidate: 'constexpr EmberAfDefaultOrMinMaxAttributeValue::EmberAfDefaultOrMinMaxAttributeValue(const uint8_t*)'
  102 |     constexpr EmberAfDefaultOrMinMaxAttributeValue(const uint8_t * ptr) : ptrToDefaultValue(ptr) {}
      |               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/opt/nordic/ncs/v2.0.2/modules/lib/matter/src/app/util/attribute-metadata.h:100:7: note: candidate: 'constexpr EmberAfDefaultOrMinMaxAttributeValue::EmberAfDefaultOrMinMaxAttributeValue(const EmberAfDefaultOrMinMaxAttributeValue&)'
  100 | union EmberAfDefaultOrMinMaxAttributeValue
      |       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/opt/nordic/ncs/v2.0.2/modules/lib/matter/src/app/util/attribute-metadata.h:100:7: note: candidate: 'constexpr EmberAfDefaultOrMinMaxAttributeValue::EmberAfDefaultOrMinMaxAttributeValue(EmberAfDefaultOrMinMaxAttributeValue&&)'
In file included from /opt/nordic/ncs/v2.0.2/modules/lib/matter/src/app/util/config.h:83,
                 from /opt/nordic/ncs/v2.0.2/modules/lib/matter/src/app/util/af.h:56,
                 from /opt/nordic/ncs/v2.0.2/modules/lib/matter/src/app/util/common.h:45,
                 from /opt/nordic/ncs/v2.0.2/modules/lib/matter/src/app/util/attribute-storage.cpp:42:

The error repeats several times as result of the inclusion of header files.

  • Hi,

    Did you add any other endpoints, clusters, and/or attributes than the ones in the guide? Did you follow all the steps in the guide, that is, editing the main loop, creating a callback, and adding source files to CMakeLists.txt as well? If so, make sure that you are looking at the correct version of the documentation. The version you are linking to is the latest version, which is documentation for the main branch, and these steps differ between the main branch and v2.0.2.

    I am not able to reproduce your issue when testing with nRF Connect SDK v2.1.0. Can you test with v2.1.0 and see if you get the same issue there?

    Best regards,

    Marte

  • I have seen the same errors, though my issues originated using a wrong ZAP-file with the generated files. Maybe this is causing the problem?

  • I think I use the correct zap-file (src/template.zap).

  • I try this today without success.

    The problem today is to (run and) build the zap-tool.

    Uncaught Exception:
    Error: Cannot find module '/opt/nordic/ncs/v2.1.0/modules/lib/matter/third_party/zap/repo/node_modules/sqlite3/lib/binding/napi-v6-darwin-unknown-arm64/node_sqlite3.node'
    Require stack:
    - /opt/nordic/ncs/v2.1.0/modules/lib/matter/third_party/zap/repo/node_modules/sqlite3/lib/sqlite3-binding.js
    - /opt/nordic/ncs/v2.1.0/modules/lib/matter/third_party/zap/repo/node_modules/sqlite3/lib/sqlite3.js
    - /opt/nordic/ncs/v2.1.0/modules/lib/matter/third_party/zap/repo/dist/src-electron/db/db-api.js
    - /opt/nordic/ncs/v2.1.0/modules/lib/matter/third_party/zap/repo/dist/src-electron/db/query-package.js
    - /opt/nordic/ncs/v2.1.0/modules/lib/matter/third_party/zap/repo/dist/src-electron/util/util.js
    - /opt/nordic/ncs/v2.1.0/modules/lib/matter/third_party/zap/repo/dist/src-electron/ui/ui-util.js
    - /opt/nordic/ncs/v2.1.0/modules/lib/matter/third_party/zap/repo/dist/src-electron/ui/menu.js
    - /opt/nordic/ncs/v2.1.0/modules/lib/matter/third_party/zap/repo/dist/src-electron/ui/window.js
    - /opt/nordic/ncs/v2.1.0/modules/lib/matter/third_party/zap/repo/dist/src-electron/ui/main-ui.js
    - /opt/nordic/ncs/v2.1.0/modules/lib/matter/third_party/zap/repo/node_modules/electron/dist/Electron.app/Contents/Resources/default_app.asar/main.js
    - 
    at Module._resolveFilename (node:internal/modules/cjs/loader:940:15)
    at Function.n._resolveFilename (node:electron/js2c/browser_init:249:1105)
    at Module._load (node:internal/modules/cjs/loader:785:27)
    at Function.c._load (node:electron/js2c/asar_bundle:5:13331)
    at Module.require (node:internal/modules/cjs/loader:1012:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/opt/nordic/ncs/v2.1.0/modules/lib/matter/third_party/zap/repo/node_modules/sqlite3/lib/sqlite3-binding.js:4:15)
    at Module._compile (node:internal/modules/cjs/loader:1116:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1169:10)
    at Module.load (node:internal/modules/cjs/loader:988:32)

  • Hi,

    Which version of node and npm are you using? I get errors when using a version that is too new.

    Can you try the following:

    1. Go to ncs-dir/modules/lib/matter/third_party/zap/repo
    2. Run git clean -fdx to remove all local file changes in the repo
    3. Run zap-tool as described in the instruction again.

    Best regards,

    Marte

Related