NRF52840: Handling Matter calls ZCL

Hello everybody,

i am currently working on my bachelor thesis and could need some guidance.

I have the NRF52840 Development Kit and i am trying to develop a matter device, that can be integrated into Home Assistant.

I started with the "nrf/samples/matter/template" example and enhanced it to a generic light switch with help of this this guide: (4) Developing Matter 1.0 products with nRF Connect SDK - YouTube

I have a HomeAssistant installation running, that contains a OpenThreadBorderRouter on a Raspberry PI. These things are all working.

Also commissioning the device into HomeAssistant works. 

For HomeAssistant to be abe to communicate with the matter device, i added another endpoint to the template.zap with the Device ID 0x0100, that is HomeAssistant specific (HA On(Off Light).

The On/Off switch is successfully showing in the HomeAssistant web interface.

When pressed, the matter message reaches the NRF device.

My problem now is that i cant seem to find the possibility in the code to process this message.
I am stuck on trying to handle the message.

One approach is to implement a function "MatterPostAttributeChangeCallback(const chip::app::ConcreteAttributePath & attributePath, uint8_t mask, uint8_t type,
uint16_t size, uint8_t * value)" in the zcl_callbacks.cpp (allthough i dont think the file name matters) as seen in this guide: 
Creating Matter accessory device — nRF Connect SDK 1.9.2-dev1 documentation (nordicsemi.com)

In my other approach i had a look at the working ESP32 matter lighting example and implemented the callback simultaneous:
In the class "AppDeviceCallBacks" that is extending the "CommonDeviceCallbacks.h" (from the connectedhomeip CHIP repo) i implemented a function "virtual void PostAttributeChangeCallback(chip::EndpointId endpointId, chip::ClusterId clusterId, chip::AttributeId attributeId, uint8_t type, uint16_t size, uint8_t * value)"

All of these new files are of course added to the CMakeLists.txt in target_sources section, so they will be included / compiled.

Compiling and flashing works, but HA On/Off message arent triggering my functions.

Can anybody please help me "connectring" the incomming call to my code?

I am not completely sure, if its the right place to post this problem here, but i dont know, where else to go.

If you need more information, i will gladly provide it .

Thanks

Marvin 

Parents
  • Hi,

    I am not completely sure, if its the right place to post this problem here, but i dont know, where else to go.

    This is the correct place to put this yes.
    We are a team of Technical Support engineers working at Nordic Semiconductor who operate this forum, and help our users for free.
    Other users can also answer public cases, and you can see the difference if you hover our profile pictures and see the Nordic Logo achievement tag.
    I will help you figure this out in the case. Welcome to DevZone!

    First, can you say which version of the nRF Connect SDK you use?

    Maybe a bit lazy of an answer, but have you had a look at how our light bulb sample handles its callbacks at https://github.com/nrfconnect/sdk-nrf/blob/e8f2b391003391d95e4e6ae0edbdd98224eb8d0a/samples/matter/light_bulb/src/zcl_callbacks.cpp#L20?

    Regards,
    Sigurd Hellesvik

  • Hi Sigurd,

    I am using the SDK 2.3.0.

    I did implement it in the same way as the example you provided.

    I can see my print and log (debugging) messages, that are in the initializatin method "void emberAfOnOffClusterInitCallback(EndpointId endpoint)" that i have overriden.

    But the method "void MatterPostAttributeChangeCallback(const chip::app::ConcreteAttributePath &attributePath, uint8_t type,
    uint16_t size, uint8_t *value)" is never called.

    Keep in mind, that what makes the difference between my code and the nordic example, is that I use the endpoint 

    while the nordic light bulb example uses 

    This ZAP Configuration also generates the same case and init method

    But somehow the callback function (supposedly "MatterPostAttributeChangeCallback") is never reached.

    I cant find, from where the method is referenced to, propably from somewhere deep int the CHIP code or only the compiler knows that :) 

    Thank you very much!

    Marvin

  • Do you get the callback in the light_bulb sample?

    Can you zip and upload your project using Insert-> File?
    Then I can have a look and see if everything looks as expected.

    Regards,
    Sigurd Hellesvik

Reply Children
Related