Matter - Adding the ability to control Color Control clusters on Light Bulb from Light Switch Matter samples

I'm implementing a wall switch that will control a variety of matter clusters/end devices and I'm using the Light Switch Matter sample as a starting point. It is not clear to me how to add clusters such as Color Control to both the Light Switch and Light Bulb project. I have added the color control cluster to the end devices and can control it via the chip-tool, but I am confused how to modify the Light Switch sample so that it can control the Color Control cluster on Light Bulb end devices.

I've dug into the Light Switch code and can see how you can schedule work in the form of a matter command. Below you can see this being done with the Level Control Cluster and MoveToLevel Command.

void LightSwitch::DimmerChangeBrightness()
{
	static uint16_t sBrightness;
	BindingHandler::BindingData *data = Platform::New<BindingHandler::BindingData>();
	if (data) {
		data->EndpointId = mLightSwitchEndpoint;
		data->CommandId = Clusters::LevelControl::Commands::MoveToLevel::Id;
		data->ClusterId = Clusters::LevelControl::Id;


		/* add to brightness 3 to approximate 1% step of brightness after each call dimmer change. */
		sBrightness += kOnePercentBrightnessApproximation;
		if (sBrightness > kMaximumBrightness) {
			sBrightness = 0;
		}
		data->Value = (uint8_t)sBrightness;
		data->IsGroup = BindingHandler::GetInstance().IsGroupBound();
		DeviceLayer::PlatformMgr().ScheduleWork(BindingHandler::SwitchWorkerHandler,
							reinterpret_cast<intptr_t>(data));
	}
}

I'd like to have an understanding how I can expand this capability to a number of other clusters/commands/attributes.

The light switch initiates OnOff and LevelControl Cluster commands via a endpointID, commandID, clusterID, and value. I thought this would be straight forward to extend this to the Color Control cluster but am finding it difficult. Currently I have ARGBW light strips and I can control color of the RGBW LEDs with the following chip-tool commands:

sudo ./chip-tool colorcontrol write color-point-rintensity 100 3 1    // Red
sudo ./chip-tool colorcontrol write color-point-gintensity 25 3 1     // Green
sudo ./chip-tool colorcontrol write color-point-bintensity 0 3 1      // Blue
sudo ./chip-tool colorcontrol write white-point-x 254 3 1             // White
 

This leads me to two questions:

Its not clear to me the Matter Color Control Command that interact with the ColorPointRIntensity, ColorPointRIntensity, ColorPointRIntensity, and WhitePointX. The only way I change these is by writing to those attributes rather than sending it a command. Is there a command to change these attributes I am overlooking? If that's the case I think I would be able to follow the source code in the Light Switch sample to add capabilities beyond OnOff and LevelControl.

Is there a way to write to cluster attributes like I do with the chip-tool commands in the Light Switch sample? I'm envisioning a function similar to LightSwitch::DimmerChangeBrightness above, in which I can give a endpointID, clusterID, attributeID, and value but it appears the current setup is only intended for Cluster Commands as opposed to Cluster Attributes.

Parents Reply Children
Related