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 Reply Children
  • 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

  • Yes, the function in the example works / is called.

    I have also tried it with the endpoint 0x0103, which also works (in the code ill upload, but with another zap configuration).

    I will attach my code here.

    Nordic52840MatterDev-HA-LightBulb.zip

  • While I have not been able to test your code, the way you set up the callback looks like the right way to do it.

    I realize that the documentation you link to says 1.9.2.

    Maybe not the answer you are looking for, but sometimes the solution is to try again.
    I suggest that you update the nRC Connect SDK to v2.4.0, and then follow v2.4.0 documentaiton for setting up the Matter device:
    https://developer.nordicsemi.com/nRF_Connect_SDK/doc/2.4.0/nrf/protocols/matter/getting_started/index.html

    Maybe some of the steps from the old docs along the way was wrong, and this way you will get them right.

    Regards,
    Sigurd Hellesvik

  • 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

Related