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 

  • Hi Sigurd,

    i have finished my exams and am ready to dive into this topic 100%

    I did your proposal with both the 2.3.0 (again) aswell as the 2.4.0.

    As expected, the documentation didnt really vary greatly and so did the results.

    Its still not working, i see the calls in the log messages of the arriving packets but none in the "MatterPostAttributeChangeCallback" method .

    I cant even see where this method is referred to or what function it is supposed to overwrite.

    I believe this is more of an theoretical topic, not one of trial and error, as i am not even sure of the correct way to to it in the first place.

    Maybe you could have a chat with one of your colleagues that possibly had some expereince with matter?

    I would really like to know where these ZAP configured calls have their entry in the code.

    Thank you very much in advance.

    Best wishes

    Marvin

  • Hi Marvin,

    I hope your exams went well Slight smile

    HA devices are not Home Assistant devices, but Zigbee Home Automation devices. Therefore, when you are creating a HA On/Off Light device on the endpoint, you are actually creating a device following the Home Automation profile (0x0103) from the Zigbee specification. This explains why MatterPostAttributeChangeCallback() is not called, as the attribute that is changed is not a Matter attribute.

    If you want to use Matter you should use one of the Matter device types.

    Best regards,
    Marte

  • Hi Marte,

    thank you for your answer!
    You are correct, i messed up the endpoints.
    I still had problems afterwards, but as it have already been 2 months i cant remember anymore which exactly.
    If somebody has similar problems, just use the example provided by CHIP:

    connectedhomeip/examples/lighting-app/nrfconnect at master · project-chip/connectedhomeip · GitHub

    It is a long and hard way to get it to compiling / building, but it works perfectly for me!

    Thank you Nordic!

    Best Wishes

    Marvin

Related