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.56k stars 2.04k forks source link

[1.1] Error Deprecated40 When use Bridge Matter with Cluster ColorControl #33131

Open ngocuong86 opened 7 months ago

ngocuong86 commented 7 months ago

Reproduction steps

I want to use Bridge Matter to use for device nonMatter. When I fake a device with cluster ColorControl to connect to Google Home and chip_tool but don't control device. The device can be uploaded to Google but cannot control LevelControl and ColorControl functions. Still use the On/Off feature. When I put it into chip_tool I see the Attribute data has an error Deprecated40 in all Attribute of ColorControl and Attribute ClusterRevision and FeatureMap of LevelControl. I define ATTRIBUTE: `DECLARE_DYNAMIC_ATTRIBUTE_LIST_BEGIN(colorExtendAttrs) DECLARE_DYNAMIC_ATTRIBUTE(ColorControl::Attributes::CurrentHue::Id, INT8U, 1, 0), / Current Hue / DECLARE_DYNAMIC_ATTRIBUTE(ColorControl::Attributes::CurrentSaturation::Id, INT8U, 1, 0), / Current Saturation / DECLARE_DYNAMIC_ATTRIBUTE(ColorControl::Attributes::RemainingTime::Id, INT16U, 2, 0), / Remaining Time / DECLARE_DYNAMIC_ATTRIBUTE(ColorControl::Attributes::CurrentX::Id, INT16U, 2, 0), / Current X / DECLARE_DYNAMIC_ATTRIBUTE(ColorControl::Attributes::CurrentY::Id, INT16U, 2, 0), / Current Y / DECLARE_DYNAMIC_ATTRIBUTE(ColorControl::Attributes::ColorTemperatureMireds::Id, INT16U, 2, 0), / Color Temperature / DECLARE_DYNAMIC_ATTRIBUTE(ColorControl::Attributes::ColorMode::Id, ENUM8, 1, 0), / Color Mode / DECLARE_DYNAMIC_ATTRIBUTE(ColorControl::Attributes::Options::Id, BITMAP8, 1, 0), / Options / DECLARE_DYNAMIC_ATTRIBUTE(ColorControl::Attributes::NumberOfPrimaries::Id, INT8U, 1, 0), / Number Of Primaries / DECLARE_DYNAMIC_ATTRIBUTE(ColorControl::Attributes::EnhancedCurrentHue::Id, INT16U, 2, 0), / Enhanced Current Hue / DECLARE_DYNAMIC_ATTRIBUTE(ColorControl::Attributes::EnhancedColorMode::Id, ENUM8, 1, 0), / Enhanced Color Mode / DECLARE_DYNAMIC_ATTRIBUTE(ColorControl::Attributes::ColorLoopActive::Id, INT8U, 1, 0), / Color Loop Active / DECLARE_DYNAMIC_ATTRIBUTE(ColorControl::Attributes::ColorLoopDirection::Id, INT8U, 1, 0), / Color Loop Direction / DECLARE_DYNAMIC_ATTRIBUTE(ColorControl::Attributes::ColorLoopTime::Id, INT16U, 2, 0), / Color Loop Time / DECLARE_DYNAMIC_ATTRIBUTE(ColorControl::Attributes::ColorCapabilities::Id, BITMAP16, 2, 0), / Color Capabilities / DECLARE_DYNAMIC_ATTRIBUTE(ColorControl::Attributes::ColorTempPhysicalMinMireds::Id, INT16U, 2, 0), / Color Temp Physical Min / DECLARE_DYNAMIC_ATTRIBUTE(ColorControl::Attributes::ColorTempPhysicalMaxMireds::Id, INT16U, 2, 0), / Color Temp Physical Max / DECLARE_DYNAMIC_ATTRIBUTE(ColorControl::Attributes::CoupleColorTempToLevelMinMireds::Id, INT16U, 2, 0), / Couple Color Temp To Level Min Mireds / DECLARE_DYNAMIC_ATTRIBUTE(ColorControl::Attributes::StartUpColorTemperatureMireds::Id, INT16U, 2, 0), / Start Up Color Temperature / DECLARE_DYNAMIC_ATTRIBUTE(ColorControl::Attributes::ClusterRevision::Id, INT16U, 2, 0), / Cluster Revision / DECLARE_DYNAMIC_ATTRIBUTE(ColorControl::Attributes::FeatureMap::Id, BITMAP32, 4, 0), / Feature Map / DECLARE_DYNAMIC_ATTRIBUTE_LIST_END(); DECLARE_DYNAMIC_ATTRIBUTE_LIST_BEGIN(levelControlAttrs) DECLARE_DYNAMIC_ATTRIBUTE(LevelControl::Attributes::CurrentLevel::Id, INT8U, 1, 0), / Current Level / DECLARE_DYNAMIC_ATTRIBUTE(LevelControl::Attributes::RemainingTime::Id, INT16U, 2, 0), / Remaining Time / DECLARE_DYNAMIC_ATTRIBUTE(LevelControl::Attributes::MinLevel::Id, INT8U, 1, 0), / Min Level / DECLARE_DYNAMIC_ATTRIBUTE(LevelControl::Attributes::Options::Id, BITMAP8, 1, 0), / Options / DECLARE_DYNAMIC_ATTRIBUTE(LevelControl::Attributes::StartUpCurrentLevel::Id, INT8U, 1, 0), / Start Up Current Level / DECLARE_DYNAMIC_ATTRIBUTE(LevelControl::Attributes::CurrentFrequency::Id, INT16U, 2, 0), / Current Frequency / DECLARE_DYNAMIC_ATTRIBUTE(LevelControl::Attributes::MinFrequency::Id, INT16U, 2, 0), / Min Frequency / DECLARE_DYNAMIC_ATTRIBUTE(LevelControl::Attributes::MaxFrequency::Id, INT16U, 2, 0), / Max Frequency / DECLARE_DYNAMIC_ATTRIBUTE(LevelControl::Attributes::OnOffTransitionTime::Id, INT16U, 2, 0), / On/Off Transition Time / DECLARE_DYNAMIC_ATTRIBUTE(LevelControl::Attributes::OnLevel::Id, INT8U, 1, 0), / On Level / DECLARE_DYNAMIC_ATTRIBUTE(LevelControl::Attributes::OnTransitionTime::Id, INT16U, 2, 0), / On Transition Time / DECLARE_DYNAMIC_ATTRIBUTE(LevelControl::Attributes::OffTransitionTime::Id, INT16U, 2, 0), / Off Transition Time / DECLARE_DYNAMIC_ATTRIBUTE(LevelControl::Attributes::DefaultMoveRate::Id, INT16U, 2, 0), / Default Move Rate / DECLARE_DYNAMIC_ATTRIBUTE(LevelControl::Attributes::ClusterRevision::Id, INT16U, 2, 0), / Cluster Revision / DECLARE_DYNAMIC_ATTRIBUTE(LevelControl::Attributes::FeatureMap::Id, BITMAP32, 4, 0), / Feature Map / DECLARE_DYNAMIC_ATTRIBUTE_LIST_END();

DECLARE_DYNAMIC_ATTRIBUTE_LIST_BEGIN(scenesManagerAttrs) DECLARE_DYNAMIC_ATTRIBUTE(Scenes::Attributes::SceneCount::Id, INT16U, 2, 0), / Scene Table Size / DECLARE_DYNAMIC_ATTRIBUTE(Scenes::Attributes::FeatureMap::Id, BITMAP32, 4, 0), / Feature Map / DECLARE_DYNAMIC_ATTRIBUTE(Scenes::Attributes::ClusterRevision::Id, INT16U, 2, 0), / Cluster Revision / DECLARE_DYNAMIC_ATTRIBUTE_LIST_END();

DECLARE_DYNAMIC_ATTRIBUTE_LIST_BEGIN(groupsManagerAttrs) DECLARE_DYNAMIC_ATTRIBUTE(Groups::Attributes::NameSupport::Id, BITMAP8, 1, 0), / Name Support / DECLARE_DYNAMIC_ATTRIBUTE(Groups::Attributes::ClusterRevision::Id, INT16U, 2, 0), / Cluster Revision / DECLARE_DYNAMIC_ATTRIBUTE(Groups::Attributes::FeatureMap::Id, BITMAP32, 4, 0), / Feature Map / DECLARE_DYNAMIC_ATTRIBUTE_LIST_END();

DECLARE_DYNAMIC_ATTRIBUTE_LIST_BEGIN(IdentifyAttrs) DECLARE_DYNAMIC_ATTRIBUTE(Identify::Attributes::IdentifyTime::Id, INT16U, 2, 0), / Identify Time / DECLARE_DYNAMIC_ATTRIBUTE(Identify::Attributes::IdentifyType::Id, ENUM8, 1, 0), / Identify Type / DECLARE_DYNAMIC_ATTRIBUTE(Identify::Attributes::FeatureMap::Id, BITMAP32, 4, 0), / Feature Map / DECLARE_DYNAMIC_ATTRIBUTE(Identify::Attributes::ClusterRevision::Id, INT16U, 2, 0), / Cluster Revision / DECLARE_DYNAMIC_ATTRIBUTE_LIST_END();`

I define Command: `constexpr CommandId onOffIncomingCommands[] = { app::Clusters::OnOff::Commands::Off::Id, app::Clusters::OnOff::Commands::On::Id, app::Clusters::OnOff::Commands::Toggle::Id, app::Clusters::OnOff::Commands::OffWithEffect::Id, app::Clusters::OnOff::Commands::OnWithRecallGlobalScene::Id, app::Clusters::OnOff::Commands::OnWithTimedOff::Id, kInvalidCommandId, }; constexpr CommandId levelControlIncomingCommands[] = { app::Clusters::LevelControl::Commands::Move::Id, app::Clusters::LevelControl::Commands::MoveToLevel::Id, app::Clusters::LevelControl::Commands::MoveToLevelWithOnOff::Id, app::Clusters::LevelControl::Commands::MoveWithOnOff::Id, app::Clusters::LevelControl::Commands::Step::Id, app::Clusters::LevelControl::Commands::StepWithOnOff::Id, app::Clusters::LevelControl::Commands::Stop::Id, app::Clusters::LevelControl::Commands::StopWithOnOff::Id, kInvalidCommandId, }; constexpr CommandId colorExtendIncomingCommands[] { app::Clusters::ColorControl::Commands::MoveToHue::Id, app::Clusters::ColorControl::Commands::MoveHue::Id, app::Clusters::ColorControl::Commands::StepHue::Id, app::Clusters::ColorControl::Commands::MoveToSaturation::Id, app::Clusters::ColorControl::Commands::MoveSaturation::Id, app::Clusters::ColorControl::Commands::StepSaturation::Id, app::Clusters::ColorControl::Commands::MoveToHueAndSaturation::Id, app::Clusters::ColorControl::Commands::MoveToColor::Id, app::Clusters::ColorControl::Commands::MoveColor::Id, app::Clusters::ColorControl::Commands::StepColor::Id, app::Clusters::ColorControl::Commands::MoveToColorTemperature::Id, app::Clusters::ColorControl::Commands::MoveColorTemperature::Id, app::Clusters::ColorControl::Commands::StepColorTemperature::Id, kInvalidCommandId, }; constexpr CommandId groupIncommingCommands[]{ app::Clusters::Groups::Commands::AddGroup::Id, app::Clusters::Groups::Commands::AddGroupIfIdentifying::Id, app::Clusters::Groups::Commands::GetGroupMembership::Id, app::Clusters::Groups::Commands::RemoveGroup::Id, app::Clusters::Groups::Commands::RemoveAllGroups::Id, app::Clusters::Groups::Commands::AddGroupResponse::Id, app::Clusters::Groups::Commands::ViewGroup::Id, app::Clusters::Groups::Commands::GetGroupMembershipResponse::Id, app::Clusters::Groups::Commands::RemoveGroupResponse::Id, kInvalidCommandId, };

constexpr CommandId identityIncomingCommands[]{ app::Clusters::Identify::Commands::Identify::Id, app::Clusters::Identify::Commands::TriggerEffect::Id, kInvalidCommandId, };

constexpr CommandId scenceIncommingCommands[]{ app::Clusters::Scenes::Commands::AddScene::Id, app::Clusters::Scenes::Commands::ViewScene::Id, app::Clusters::Scenes::Commands::CopyScene::Id, kInvalidCommandId, };`

I define Cluster and Endpoint: `DECLARE_DYNAMIC_CLUSTER_LIST_BEGIN(bridgedColorExtendClusters) DECLARE_DYNAMIC_CLUSTER(ColorControl::Id, colorExtendAttrs, colorExtendIncomingCommands, nullptr), DECLARE_DYNAMIC_CLUSTER(OnOff::Id, onOffAttrs, onOffIncomingCommands, nullptr), DECLARE_DYNAMIC_CLUSTER(LevelControl::Id, levelControlAttrs,levelControlIncomingCommands, nullptr), DECLARE_DYNAMIC_CLUSTER(Identify::Id, IdentifyAttrs,identityIncomingCommands, nullptr), DECLARE_DYNAMIC_CLUSTER(Scenes::Id, scenesManagerAttrs,scenceIncommingCommands, nullptr), DECLARE_DYNAMIC_CLUSTER(Groups::Id, groupsManagerAttrs,groupIncommingCommands, nullptr), DECLARE_DYNAMIC_CLUSTER(Descriptor::Id, descriptorAttrs,nullptr, nullptr), DECLARE_DYNAMIC_CLUSTER(BridgedDeviceBasicInformation::Id, bridgedDeviceBasicAttrs,nullptr, nullptr) DECLARE_DYNAMIC_CLUSTER_LIST_END; DECLARE_DYNAMIC_ENDPOINT(bridgedColorExtendEndpoint, bridgedColorExtendClusters); DataVersion gColorExtendDataVersions[ArraySize(bridgedColorExtendClusters)]; DeviceColorControl ColorExtend1("Color Extend 1", "Room 1", 0,0,0);

define ZCL_COLOR_CONTROL_CLUSTER_REVISION (5u)

define ZCL_LEVEL_CONTROL_CLUSTER_REVISION (5u)

define ZCL_ON_OFF_CLUSTER_REVISION (4u)

const EmberAfDeviceType gColorExtendDeviceTypes[] = { { DEVICE_TYPE_COLOR_EXTEND_LIGHT, DEVICE_VERSION_DEFAULT }, { DEVICE_TYPE_BRIDGED_NODE, DEVICE_VERSION_DEFAULT} }; **And I AddDeviceEnpoint: ** AddDeviceEndpoint(&ColorExtend1, &bridgedColorExtendEndpoint,Span(gColorExtendDeviceTypes), Span(gColorExtendDataVersions),1);`

Function ReadAttribute of Color: EmberAfStatus HandleReadColorControlAttribute(DeviceColorControl * dev, chip::AttributeId attributeId, uint8_t *buffer , uint16_t maxReadLength){ ChipLogProgress(DeviceLayer, "HandleReadColorControlAttribute: attrId=%d, maxReadLength=%d", attributeId, maxReadLength); if((attributeId == ColorControl::Attributes::FeatureMap::Id) && (maxReadLength == 4)) { ChipLogProgress(DeviceLayer, "HandleReadColorControlAttribute: FeatureMap"); uint32_t featureMap = 0x1F; memcpy(buffer, &featureMap, sizeof(featureMap)); } if((attributeId == ColorControl::Attributes::CurrentHue::Id) && (maxReadLength == 1)) { uint8_t hue = dev->GetCurrentHue(); ChipLogAutomation("HandleReadColorControlAttribute: CurrentHue: %d", hue); memcpy(buffer, &hue, sizeof(hue)); }else if((attributeId == ColorControl::Attributes::CurrentSaturation::Id) && (maxReadLength == 1)) { uint8_t saturation = dev->GetCurrentSaturation(); ChipLogAutomation("HandleReadColorControlAttribute: CurrentSaturation: %d", saturation); memcpy(buffer, &saturation, sizeof(saturation)); }else if((attributeId == ColorControl::Attributes::ColorTemperatureMireds::Id) && (maxReadLength == 2)) { uint16_t temperature = dev->GetCurrentTemperatureMireds(); ChipLogAutomation("HandleReadColorControlAttribute: ColorTemperatureMireds: %d", temperature); memcpy(buffer, &temperature, sizeof(temperature)); } else if((attributeId == ColorControl::Attributes::CurrentX::Id) && (maxReadLength==2)){ uint16_t currentX = dev->GetCurrentX(); ChipLogAutomation("HandleReadColorControlAttribute: CurrentX: %d", currentX); memcpy(buffer, &currentX, sizeof(currentX)); } else if((attributeId == ColorControl::Attributes::CurrentY::Id) && (maxReadLength==2)){ uint16_t currentY = dev->GetCurrentY(); ChipLogAutomation("HandleReadColorControlAttribute: CurrentY: %d", currentY); memcpy(buffer, &currentY, sizeof(currentY)); } else if((attributeId == ColorControl ::Attributes::ColorMode::Id) && (maxReadLength = 1)){ uint8_t colorMode = dev->GetColorMode(); ChipLogAutomation("HandleReadColorControlAttribute: ColorMode: %d", colorMode); memcpy(buffer, &colorMode, sizeof(colorMode)); } else if((attributeId == ColorControl::Attributes::EnhancedCurrentHue::Id) && (maxReadLength == 2)) { uint16_t hue = 0; ChipLogAutomation("HandleReadColorControlAttribute: EnhancedCurrentHue: %d", hue); memcpy(buffer, &hue, sizeof(hue)); } else if((attributeId == ColorControl::Attributes::EnhancedColorMode::Id) && (maxReadLength == 1)) { uint8_t colorMode = 0x01; ChipLogAutomation("HandleReadColorControlAttribute: EnhancedColorMode: %d", colorMode); memcpy(buffer, &colorMode, sizeof(colorMode)); } else if((attributeId == ColorControl::Attributes::ColorLoopActive::Id) && (maxReadLength == 1)) { uint8_t active = 0x00; ChipLogAutomation("HandleReadColorControlAttribute: ColorLoopActive: %d", active); memcpy(buffer, &active, sizeof(active)); } else if((attributeId == ColorControl::Attributes::ColorLoopDirection::Id) && (maxReadLength == 1)) { uint8_t direction = 0x00; ChipLogAutomation("HandleReadColorControlAttribute: ColorLoopDirection: %d", direction); memcpy(buffer, &direction, sizeof(direction)); } else if((attributeId == ColorControl::Attributes::ColorLoopTime::Id) && (maxReadLength == 2)) { uint16_t time = 0x0019; ChipLogAutomation("HandleReadColorControlAttribute: ColorLoopTime: %d", time); memcpy(buffer, &time, sizeof(time)); } else if((attributeId == ColorControl::Attributes::ColorLoopStartEnhancedHue::Id) && (maxReadLength == 2)){ uint16_t hue = 0x2300; ChipLogAutomation("HandleReadColorControlAttribute: ColorLoopStartEnhancedHue: %d", hue); memcpy(buffer, &hue, sizeof(hue)); } else if((attributeId == ColorControl::Attributes::ColorLoopStoredEnhancedHue::Id) && (maxReadLength == 2)){ uint16_t hue = 0x0000; ChipLogAutomation("HandleReadColorControlAttribute: ColorLoopStoredEnhancedHue: %d", hue); memcpy(buffer, &hue, sizeof(hue)); } else if((attributeId == ColorControl::Attributes::RemainingTime::Id) && (maxReadLength == 2)) { uint16_t time = 0; ChipLogAutomation("HandleReadColorControlAttribute: RemainingTime: %d", time); memcpy(buffer, &time, sizeof(time)); }else if ((attributeId == ColorControl::Attributes::ClusterRevision::Id) && (maxReadLength == 2)) { uint16_t rev = ZCL_COLOR_CONTROL_CLUSTER_REVISION; memcpy(buffer, &rev, sizeof(rev)); } else if((attributeId == ColorControl::Attributes::ColorCapabilities::Id) && (maxReadLength == 2)) { BitMask<ColorControl::ColorCapabilities> colorCapa; colorCapa.Set(ColorControl::ColorCapabilities::kHueSaturationSupported); colorCapa.Set(ColorControl::ColorCapabilities::kColorTemperatureSupported); colorCapa.Set(ColorControl::ColorCapabilities::kEnhancedHueSupported); colorCapa.Set(ColorControl::ColorCapabilities::kColorLoopSupported); colorCapa.Set(ColorControl::ColorCapabilities::kXYAttributesSupported); uint32_t color = 0x1F; ChipLogAutomation("HandleReadColorControlAttribute: Options: %d", color); memcpy(buffer, &colorCapa, sizeof(colorCapa)); } else if((attributeId == ColorControl::Attributes::ColorTempPhysicalMinMireds::Id) && (maxReadLength == 2)) { uint16_t min = 0x0000; ChipLogAutomation("HandleReadColorControlAttribute: ColorTempPhysicalMinMireds: %d", min); memcpy(buffer, &min, sizeof(min)); } else if((attributeId == ColorControl::Attributes::ColorTempPhysicalMaxMireds::Id) && (maxReadLength == 2)) { uint16_t min = 0xFEFF; ChipLogAutomation("HandleReadColorControlAttribute: ColorTempPhysicalMaxMireds: %d", min); memcpy(buffer, &min, sizeof(min)); } else if((attributeId == ColorControl::Attributes::Options::Id) && (maxReadLength == 1)) { uint8_t options = 0x00; ChipLogAutomation("HandleReadColorControlAttribute: Options: %d", options); memcpy(buffer, &options, sizeof(options)); } else if((attributeId == ColorControl::Attributes::NumberOfPrimaries::Id) && (maxReadLength==1)){ uint8_t num = 0x00; ChipLogAutomation("HandleReadColorControlAttribute: NumberOfPrimaries: %d", num); memcpy(buffer, &num, sizeof(num)); } else { return EMBER_ZCL_STATUS_FAILURE; } }

Function Read LevelControl: `EmberAfStatus HandleReadLevelControlAttribute(DeviceLevelControl dev, chip::AttributeId attributeId, uint8_t buffer, uint16_t maxReadLength) { ChipLogProgress(DeviceLayer, "HandleReadLevelControlAttribute: attrId=%d, maxReadLength=%d", attributeId, maxReadLength);

if ((attributeId == LevelControl::Attributes::CurrentLevel::Id) && (maxReadLength == 1))
{
    uint8_t Current = dev->GetCurrentLevel();
    memcpy(buffer, &Current, sizeof(Current));
    ChipLogAutomation("HandleReadLevelControlAttribute: CurrentLevel: %d", buffer[0]);

}
else if ((attributeId == LevelControl::Attributes::RemainingTime::Id) && (maxReadLength == 2))
{
    uint16_t time = 0;
    memcpy(buffer, &time, sizeof(time));
    ChipLogAutomation("HandleReadLevelControlAttribute: RemainingTime: %d", buffer[0]);
}
else if ((attributeId == LevelControl::Attributes::CurrentFrequency::Id) && (maxReadLength == 2))
{
    uint16_t frequency = 0;
    memcpy(buffer, &frequency, sizeof(frequency));
    ChipLogAutomation("HandleReadLevelControlAttribute: CurrentFrequency: %d", buffer[0]);
}
else if((attributeId == LevelControl::Attributes::MinFrequency::Id) && (maxReadLength == 2)){
    uint16_t min = 0;
    memcpy(buffer, &min, sizeof(min));
    ChipLogAutomation("HandleReadLevelControlAttribute: MinFrequency: %d", buffer[0]);
}
else if((attributeId == LevelControl::Attributes::MaxFrequency::Id) && (maxReadLength == 2)){
    uint16_t max = 0;
    memcpy(buffer, &max, sizeof(max));
    ChipLogAutomation("HandleReadLevelControlAttribute: MaxFrequency: %d", buffer[0]);
}
else if ((attributeId == LevelControl::Attributes::MinLevel::Id) && (maxReadLength == 1))
{
    uint8_t min = 0x01;
    memcpy(buffer, &min, sizeof(min));
    ChipLogAutomation("HandleReadLevelControlAttribute: MinLevel: %d", buffer[0]);
}
else if ((attributeId == LevelControl::Attributes::MaxLevel::Id) && (maxReadLength == 1))
{
    uint8_t max = 0xFE;
    memcpy(buffer, &max, sizeof(max));
    ChipLogAutomation("HandleReadLevelControlAttribute: MaxLevel: %d", buffer[0]);
}
else if((attributeId == LevelControl::Attributes::Options::Id) && (maxReadLength == 1))
{
    uint8_t options = 0x00;
    memcpy(buffer, &options, sizeof(options));
    ChipLogAutomation("HandleReadLevelControlAttribute: Options: %d", buffer[0]);
}
else if((attributeId == LevelControl::Attributes::OnOffTransitionTime::Id) && (maxReadLength == 2)){
    uint16_t time = 0;
    memcpy(buffer, &time, sizeof(time));
    ChipLogAutomation("HandleReadLevelControlAttribute: OnOffTransitionTime: %d", buffer[0]);
}
else if((attributeId == LevelControl::Attributes::OnTransitionTime::Id) && (maxReadLength == 16)){
    uint16_t time = 0;
    memcpy(buffer, &time, sizeof(time));
    ChipLogAutomation("HandleReadLevelControlAttribute: OnTransitionTime: %d", buffer[0]);
}
else if((attributeId == LevelControl::Attributes::OffTransitionTime::Id) && (maxReadLength == 16)){
    uint16_t time = 0;
    memcpy(buffer, &time, sizeof(time));
    ChipLogAutomation("HandleReadLevelControlAttribute: OffTransitionTime: %d", buffer[0]);
}
else if((attributeId == LevelControl::Attributes::DefaultMoveRate::Id) && (maxReadLength == 1)){
    uint8_t rate = 50;
    memcpy(buffer, &rate, sizeof(rate));
    ChipLogAutomation("HandleReadLevelControlAttribute: DefaultMoveRate: %d", buffer[0]);
}
else if((attributeId == LevelControl::Attributes::OnLevel::Id) && (maxReadLength == 1)){
    uint8_t onlevel = 0xff;
    memcpy(buffer, &onlevel, sizeof(onlevel));
    ChipLogAutomation("HandleReadLevelControlAttribute: OnLevel: %d", buffer[0]);
}
else if((attributeId == LevelControl::Attributes::StartUpCurrentLevel::Id) && (maxReadLength == 1))
{
    uint8_t startUp = 255;
    memcpy(buffer, &startUp, sizeof(startUp));
    ChipLogAutomation("HandleReadLevelControlAttribute: StartUpCurrentLevel: %d", buffer[0]);
}
else if ((attributeId == LevelControl::Attributes::ClusterRevision::Id) && (maxReadLength == 2))
{
    uint16_t rev = ZCL_LEVEL_CONTROL_CLUSTER_REVISION;
    memcpy(buffer, &rev, sizeof(rev));
}
else if ((attributeId == LevelControl::Attributes::FeatureMap::Id) && (maxReadLength == 4))
{
    uint32_t featureMap = 0x03;
    ChipLogAutomation("HandleReadLevelControlAttribute: FeatureMap : %d", featureMap);
    memcpy(buffer, &featureMap, sizeof(featureMap));

}
else if((attributeId == LevelControl::Attributes::Options::Id) && (maxReadLength == 1))
{
    uint8_t options = 0x00;
    memcpy(buffer, &options, sizeof(options));
    ChipLogAutomation("HandleReadLevelControlAttribute: Options: %d", buffer[0]);
}
else if((attributeId == LevelControl::Attributes::StartUpCurrentLevel::Id) && (maxReadLength == 1))
{
    uint8_t startUp = 255;
    memcpy(buffer, &startUp, sizeof(startUp));
    ChipLogAutomation("HandleReadLevelControlAttribute: StartUpCurrentLevel: %d", buffer[0]);
}
else if((attributeId == LevelControl::Attributes::DefaultMoveRate::Id) && (maxReadLength == 1))
{
    uint8_t startUp = 50;
    memcpy(buffer, &startUp, sizeof(startUp));
    ChipLogAutomation("HandleReadLevelControlAttribute: StartUpOnOff: %d", buffer[0]);
}
else
{
    return EMBER_ZCL_STATUS_FAILURE;
}

}`

[main.txt](https://github.com/project-chip/connectedhomeip/files/15087954/main.txt)

Bug prevalence

every

GitHub hash of the SDK that was being used

v1.1 branch

Platform

vscode, other

Platform Version(s)

No response

Type

Test Improvement

Anything else?

No response

bzbarsky-apple commented 7 months ago

@ngocuong86 That comment is entirely unreadable, sorry. Can you please attach, not paste, large chunks of code, and attach, not paste, the logs you are getting?

ngocuong86 commented 7 months ago

@ngocuong86 That comment is entirely unreadable, sorry. Can you please attach, not paste, large chunks of code, and attach, not paste, the logs you are getting?

Sorry, I have attached the main.txt file above. You can read the code in there. main.txt And The log I getting that: "Status IB: 0x40 "

ngocuong86 commented 7 months ago

@bzbarsky-apple After I update to v1.3-branch. I have the error: status = 0x4c (Unallocated). That is my log of chiptool: logChiptool.txt Do you have any updates for that error?

bzbarsky-apple commented 7 months ago

@ngocuong86 So looking at your HandleReadColorControlAttribute function... if (attributeId == ColorControl::Attributes::CurrentHue::Id) && (maxReadLength == 1) then it never hits a return statement. Presumably your compiler warns about this but does not error, and it's returning whatever value happens to be on the stack (which in your case seems to be 0x4C).