Build Matter Light Bulb using ZAP auto generated files dynamically

  

        Sorry for the inconvenience!

        I have downloaded V2.8.0 nRF SDK, and I use this command to build light bulb project:

        west build -p always --build-dir nrf/samples/matter/light_bulb/build -b nrf52840dk_nrf52840 nrf/samples/matter/light_bulb

        It can build pass! But I noticed that bulb project used zap generated files, I want to auto generate zap files in the build flow(that means generating code files by light_bulb.zap dynamically), could you tell me how can I do?

        Furthermore, I have noticed the macro("BYPASS_IDL") in cmake file is TRUE, so it skip auto generate flow, how can I set it to FALSE?

        chip_configure_data_model(app
               INCLUDE_SERVER
               BYPASS_IDL
               GEN_DIR ${CONFIG_NCS_SAMPLE_MATTER_ZAP_FILES_PATH}/zap-generated
               ZAP_FILE ${CMAKE_CURRENT_SOURCE_DIR}/${CONFIG_NCS_SAMPLE_MATTER_ZAP_FILES_PATH}/light_bulb.zap
        )

BR

Chuan

        

Parents
  • Hi Chuan,

    When you remove BYPASS_IDL, the chip_configure_data_model() function tries to generate source files from a .matter IDL file, but it cannot find the .matter file. You must provide it using the IDL option, for example:

    chip_configure_data_model(app
        INCLUDE_SERVER
        GEN_DIR ${CONFIG_NCS_SAMPLE_MATTER_ZAP_FILES_PATH}/zap-generated
        ZAP_FILE ${CMAKE_CURRENT_SOURCE_DIR}/${CONFIG_NCS_SAMPLE_MATTER_ZAP_FILES_PATH}/light_bulb.zap
        IDL ${CMAKE_CURRENT_SOURCE_DIR}/src/light_bulb.matter
    )

    Please note that you need to have zap-cli installed, and the installed version must match the version used in the SDK you are using. If not, you will get an error when it tries to generate the zap files.
    You can install it by running the following in modules/lib/matter:

    python3 scripts/setup/nrfconnect/get_zap.py -l <location_path> -o

    Best regards,
    Marte

  •  

            What is '<location_path>' ?

            When I run this command, there's no result output, is it reasonable?

            

    @PC21040223 MINGW64 /c/ncs/v2.8.0
    $ cd modules/lib/matter/

    @PC21040223 MINGW64 /c/ncs/v2.8.0/modules/lib/matter ((v2.8.0))
    $ python3 scripts/setup/nrfconnect/get_zap.py -l zap_path -o

    @PC21040223 MINGW64 /c/ncs/v2.8.0/modules/lib/matter ((v2.8.0))
    $

  • Hi Chuan,

    It can work by following the steps in one of my previous replies. I got it to work on both Windows and Linux.

    For installing zap-cli, you might have to use python instead of python3:

    python scripts/setup/nrfconnect/get_zap.py -l <location_path> -o

    However, the recommended method is to generate the ZAP tools manually using the west zap generate command.

    Best regards,
    Marte

  •   

            Great!

            I'll have a try to use 'python' instead of 'python3'.

            Besides, can you build light bulb pass even though omit 'BYPASS_IDL'?

    BR

    Chuan

  • Hi Chuan,

    Yes, I was able to build the light bulb sample on both Windows and Linux when omitting BYPASS_IDL by including the path to the light_bulb.matter IDL file in chip_configure_data_model():

    IDL ${CMAKE_CURRENT_SOURCE_DIR}/src/light_bulb.matter

    Please note that I have not thoroughly tested the sample, only that it builds.

    Best regards,
    Marte

  •   

            Thanks for your solution, it work well!

            Finally, I have another question:

            I see there are 9 files in the zap-generated folder, namely: 

                    -> access.h

                    -> callback-stub.cpp

                    -> CHIPClientCallbacks.h

                    -> CHIPClusters.h

                    -> endpoint_config.h

                    -> gen_config.h

                    -> gen_tokens.h

                    -> IMClusterCommandHandler.cpp

                    -> PluginApplicationCallbacks.h

             But when I use ZCL tool to generate files, only 4 files generate, namely:

                    -> access.h

                    -> endpoint_config.h

                    -> gen_config.h

                    -> IMClusterCommandHandler.cpp

            Can you tell me why cause this difference?

            Besides, how can I generate other 5 files?

    BR

    Chuan

  • Hi Chuan,

    I asked the developers about this, and it looks like the files you mentioned were generated with an older version of the ZAP tool and are no longer used. The developers will remove the old files from the SDK.

    The developers have also added a --clear argument to zap-generate that removes old files: https://github.com/nrfconnect/sdk-connectedhomeip/pull/599.

    Best regards,
    Marte

Reply Children
No Data
Related