project-chip / connectedhomeip

Matter (formerly Project CHIP) creates more connections between more objects, simplifying development for manufacturers and increasing compatibility for consumers, guided by the Connectivity Standards Alliance.
https://buildwithmatter.com
Apache License 2.0
7.45k stars 1.99k forks source link

[1.2]After adding a fan to the bridge device, the write callback cannot be triggered. #35211

Closed wolen666 closed 2 months ago

wolen666 commented 2 months ago

Reproduction steps

1 Prerequisites 1.1. sdk matter-1.2-branch 1.2. esp-idf 5.1 1.3. bridge-app 2.Using the ZAP tool, add a fan device to Endpoint 3 in the bridge-app.zap as shown in the image below. image image

  1. The fan code under the bridge-app example 3.1 Fan atrribute declare DECLARE_DYNAMIC_ATTRIBUTE_LIST_BEGIN(FanAttrs) DECLARE_DYNAMIC_ATTRIBUTE(FanControl::Attributes::FanMode::Id, ENUM8,1,0), DECLARE_DYNAMIC_ATTRIBUTE(FanControl::Attributes::FanModeSequence::Id, ENUM8,1,0), DECLARE_DYNAMIC_ATTRIBUTE(FanControl::Attributes::PercentSetting::Id, PERCENT,2,0), DECLARE_DYNAMIC_ATTRIBUTE(FanControl::Attributes::PercentCurrent::Id, PERCENT,2,0), DECLARE_DYNAMIC_ATTRIBUTE(FanControl::Attributes::SpeedMax::Id, INT8U,1,0), DECLARE_DYNAMIC_ATTRIBUTE(FanControl::Attributes::SpeedSetting::Id, INT8U,1,0), DECLARE_DYNAMIC_ATTRIBUTE(FanControl::Attributes::SpeedCurrent::Id, INT8U,1,0), DECLARE_DYNAMIC_ATTRIBUTE(FanControl::Attributes::FeatureMap::Id, BITMAP32,4,0), DECLARE_DYNAMIC_ATTRIBUTE_LIST_END(); constexpr CommandId fanIncomingCommands[] = { app::Clusters::FanControl::Commands::Step::Id, kInvalidCommandId, }; 3.2 Fan cluster declare

    DECLARE_DYNAMIC_CLUSTER_LIST_BEGIN(bridgedFanClusters) DECLARE_DYNAMIC_CLUSTER(FanControl::Id, FanAttrs, nullptr, nullptr), DECLARE_DYNAMIC_CLUSTER(Descriptor::Id, descriptorAttrs, nullptr, nullptr), DECLARE_DYNAMIC_CLUSTER(BridgedDeviceBasicInformation::Id, bridgedDeviceBasicAttrs, nullptr,nullptr) DECLARE_DYNAMIC_CLUSTER_LIST_END;

    3.3 Fan Endpoint declare

    DECLARE_DYNAMIC_ENDPOINT(bridgedFanEndpoint, bridgedFanClusters);

    3.4 Fan Write and Read Handlde image

image

  1. Device add to Apple Home

img_v3_02e5_321ea414-ff37-413c-93b6-7e2ac9bf6d3g

  1. devoce Log not found emberAfExternalAttributeWriteCallback log image When I control it, I can receive IM:WriteRequest information. According to the code, it should trigger the emberAfExternalAttributeWriteCallback callback. I have tried adding curtain equipment and switching the equipment on and off. There is no problem, but there is an error in the fan.

This question has been bothering me for a long time. Please help me answer it when you have time.Thank you!

Bug prevalence

1-2 times week

GitHub hash of the SDK that was being used

commit 13028cf6bf21f211215ed513e5e03d78b46418eb

Platform

esp32

Platform Version(s)

1.2

Type

Platform Issue

Anything else?

No response

bzbarsky-apple commented 2 months ago

DECLARE_DYNAMIC_ATTRIBUTE(FanControl::Attributes::FanMode::Id, ENUM8,1,0),

That 0 at the end says "no attribute flags". In particular, since it's not setting ATTRIBUTE_MASK_WRITABLE there, the attribute is not treated as writable.

You need to use ATTRIBUTE_MASK_WRITABLE instead of 0 as the last arg to the macro for attributes that should be writable.

bzbarsky-apple commented 2 months ago

Also, you would need PercentSetting to have ATTRIBUTE_MASK_NULLABLE, etc....

bzbarsky-apple commented 2 months ago

https://github.com/project-chip/connectedhomeip/pull/35228 to hopefully improve the documentation here.

wolen666 commented 2 months ago

Thank you, my problem has been solved, mainly because I referred to the example of bridge-app so I didn't consider that the problem appeared here.