It failed to run attributes set function in the timer callback handler.

Software version: nRF CONNECT SDK v2.4.2.  Project: Matter light bulb

I have created a soft timer, and defined a function named "autoAdjustPWMLevel" as callback handler, like the pic shows.

Everything is fine but when I want to set the attribute value and call this "Set" function, it run wrong even if it compile and build normally.

Fullscreen
1
chip::app::Clusters::IlluminanceMeasurement::Attributes::MeasuredValue::Set()
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Parents
  • Hi Barry,

    Before I try to test this sample, Can you please explain what you mean by " it run wrong even if it compile and build normally.".

    Do you mean that it does not set the attribute to the given value? How are you testing that?

  • It can not set the attribute rightly, and it can not be commissioned into Matter Network normally. The most obvious phenomenon is that the LED0(which indicates the Thread network status) no longer blink. It looks like that the main program isn't normal, but it doesn't crash. 

  • Just focus on the Line 106 ~ 108 in gl-inet/gl_app.cpp( github.com/.../gl_app.cpp ). When I uncomment these three lines, it will cause some problems like what I said before.

  • I am not able to compile your project when I try to compile it similar to the light_bulb. 

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    === child image mcuboot - begin ===
    loading initial cache file E:/ncs/v2.4.2/nrf/samples/matter/Light_bulb-main/build/mcuboot/child_image_preload.cmake
    -- Application: E:/ncs/v2.4.2/bootloader/mcuboot/boot/zephyr
    -- CMake version: 3.20.5
    Loading Zephyr default modules (Zephyr base).
    -- Found Python3: E:/ncs/toolchains/v2.3.0/opt/bin/python.exe (found suitable exact version "3.8.2") found components: Interpreter
    -- Cache files will be written to: E:/ncs/v2.4.2/zephyr/.cache
    -- Zephyr version: 3.3.99 (E:/ncs/v2.4.2/zephyr)
    -- Found west (found suitable version "0.14.0", minimum required is "0.7.1")
    -- Board: nrf52840dk_nrf52840
    -- Found host-tools: zephyr 0.15.2 (E:/ncs/toolchains/v2.3.0/opt/zephyr-sdk)
    -- Found toolchain: zephyr 0.15.2 (E:/ncs/toolchains/v2.3.0/opt/zephyr-sdk)
    -- Found Dtc: E:/ncs/toolchains/v2.3.0/opt/bin/dtc.exe (found suitable version "1.4.7", minimum required is "1.4.6")
    -- Found BOARD.dts: E:/ncs/v2.4.2/zephyr/boards/arm/nrf52840dk_nrf52840/nrf52840dk_nrf52840.dts
    -- Found devicetree overlay: E:/ncs/v2.4.2/nrf/samples/matter/Light_bulb-main/child_image/mcuboot/boards/nrf52840dk_nrf52840.overlay
    -- Generated zephyr.dts: E:/ncs/v2.4.2/nrf/samples/matter/Light_bulb-main/build/mcuboot/zephyr/zephyr.dts
    -- Generated devicetree_generated.h: E:/ncs/v2.4.2/nrf/samples/matter/Light_bulb-main/build/mcuboot/zephyr/include/generated/devicetree_generated.h
    -- Including generated dts.cmake file: E:/ncs/v2.4.2/nrf/samples/matter/Light_bulb-main/build/mcuboot/zephyr/dts.cmake
    Parsing E:/ncs/v2.4.2/modules/lib/matter/config/nrfconnect/chip-module/Kconfig.mcuboot.root
    Loaded configuration 'E:/ncs/v2.4.2/zephyr/boards/arm/nrf52840dk_nrf52840/nrf52840dk_nrf52840_defconfig'
    Merged configuration 'E:/ncs/v2.4.2/nrf/samples/matter/Light_bulb-main/child_image/mcuboot/prj.conf'
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

  • Thank you for your answer!

    I can compile normally. It said "cannot find source file: callback-stub.cpp" in your logs.

    OK, let's forget my project. Maybe I didn't describe my problem very well. There is one thing I want to verify is that can the "Set()" function be used in a timer callback function like the pic shows? It seems not.

    7180.light_bulb.zip

  • The documentation does not specify that you cannot use it. If you are able to start your application in the debugger and step into this function, you can verify yourself if it goes low level in actually calling the protocol stack API to set the attribute. If there is no errors returned, then I do not know why the set function is not working as it should.

  • Thanks for your help all the time. I have figured out some problems, but therer are still some problems remaining.

    Now the situation is: I put the function chip::app::Clusters::IlluminanceMeasurement::Attributes::MeasuredValue::Set into a timer,which would update illuminance measurement's measured value per second, it seems to run normally. But when if I want to use the command chip-tool illuminancemeasurement read measured-value 2332 1 to read this attribute, its Matter progress seems to collapse totally.And the same problem will occur when I want to "ble-thread" pair the device to OTBR while this "Set Attribute" timer running.

Reply
  • Thanks for your help all the time. I have figured out some problems, but therer are still some problems remaining.

    Now the situation is: I put the function chip::app::Clusters::IlluminanceMeasurement::Attributes::MeasuredValue::Set into a timer,which would update illuminance measurement's measured value per second, it seems to run normally. But when if I want to use the command chip-tool illuminancemeasurement read measured-value 2332 1 to read this attribute, its Matter progress seems to collapse totally.And the same problem will occur when I want to "ble-thread" pair the device to OTBR while this "Set Attribute" timer running.

Children
No Data