Skip to content

Commit

Permalink
Use of c++ casting
Browse files Browse the repository at this point in the history
  • Loading branch information
pjzander-signify committed Oct 27, 2021
1 parent d59d1e4 commit 7616990
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions examples/bridge-app/linux/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ void HandleDeviceOnOffStatusChanged(DeviceOnOff * dev, DeviceOnOff::Changed_t it
{
if (itemChangedMask & (DeviceOnOff::kChanged_Reachable | DeviceOnOff::kChanged_Name | DeviceOnOff::kChanged_Location))
{
HandleDeviceStatusChanged((Device *) dev, (Device::Changed_t) itemChangedMask);
HandleDeviceStatusChanged(static_cast<Device *>(dev), (Device::Changed_t) itemChangedMask);
}

if (itemChangedMask & DeviceOnOff::kChanged_OnOff)
Expand All @@ -314,31 +314,28 @@ void HandleDeviceSwitchStatusChanged(DeviceSwitch * dev, DeviceSwitch::Changed_t
{
if (itemChangedMask & (DeviceSwitch::kChanged_Reachable | DeviceSwitch::kChanged_Name | DeviceSwitch::kChanged_Location))
{
HandleDeviceStatusChanged((Device *) dev, (Device::Changed_t) itemChangedMask);
HandleDeviceStatusChanged(static_cast<Device *>(dev), (Device::Changed_t) itemChangedMask);
}

if (itemChangedMask & DeviceSwitch::kChanged_NumberOfPositions)
{
uint8_t numberOfPositions = dev->GetNumberOfPositions();
MatterReportingAttributeChangeCallback(((Device *) dev)->GetEndpointId(), ZCL_SWITCH_CLUSTER_ID,
ZCL_NUMBER_OF_POSITIONS_ATTRIBUTE_ID, CLUSTER_MASK_SERVER, 0,
ZCL_INT8U_ATTRIBUTE_TYPE, &numberOfPositions);
MatterReportingAttributeChangeCallback(dev->GetEndpointId(), ZCL_SWITCH_CLUSTER_ID, ZCL_NUMBER_OF_POSITIONS_ATTRIBUTE_ID,
CLUSTER_MASK_SERVER, 0, ZCL_INT8U_ATTRIBUTE_TYPE, &numberOfPositions);
}

if (itemChangedMask & DeviceSwitch::kChanged_CurrentPosition)
{
uint8_t currentPosition = dev->GetCurrentPosition();
MatterReportingAttributeChangeCallback(((Device *) dev)->GetEndpointId(), ZCL_SWITCH_CLUSTER_ID,
ZCL_CURRENT_POSITION_ATTRIBUTE_ID, CLUSTER_MASK_SERVER, 0, ZCL_INT8U_ATTRIBUTE_TYPE,
&currentPosition);
MatterReportingAttributeChangeCallback(dev->GetEndpointId(), ZCL_SWITCH_CLUSTER_ID, ZCL_CURRENT_POSITION_ATTRIBUTE_ID,
CLUSTER_MASK_SERVER, 0, ZCL_INT8U_ATTRIBUTE_TYPE, &currentPosition);
}

if (itemChangedMask & DeviceSwitch::kChanged_MultiPressMax)
{
uint8_t multiPressMax = dev->GetMultiPressMax();
MatterReportingAttributeChangeCallback(((Device *) dev)->GetEndpointId(), ZCL_SWITCH_CLUSTER_ID,
ZCL_MULTI_PRESS_MAX_ATTRIBUTE_ID, CLUSTER_MASK_SERVER, 0, ZCL_INT8U_ATTRIBUTE_TYPE,
&multiPressMax);
MatterReportingAttributeChangeCallback(dev->GetEndpointId(), ZCL_SWITCH_CLUSTER_ID, ZCL_MULTI_PRESS_MAX_ATTRIBUTE_ID,
CLUSTER_MASK_SERVER, 0, ZCL_INT8U_ATTRIBUTE_TYPE, &multiPressMax);
}
}

Expand Down Expand Up @@ -520,11 +517,12 @@ EmberAfStatus emberAfExternalAttributeReadCallback(EndpointId endpoint, ClusterI
}
else if (clusterId == ZCL_ON_OFF_CLUSTER_ID)
{
ret = HandleReadOnOffAttribute((DeviceOnOff *) dev, attributeMetadata->attributeId, buffer, maxReadLength);
ret = HandleReadOnOffAttribute(static_cast<DeviceOnOff *>(dev), attributeMetadata->attributeId, buffer, maxReadLength);
}
else if (clusterId == ZCL_SWITCH_CLUSTER_ID)
{
ret = HandleReadSwitchAttribute((DeviceSwitch *) dev, attributeMetadata->attributeId, buffer, maxReadLength);
ret =
HandleReadSwitchAttribute(static_cast<DeviceSwitch *>(dev), attributeMetadata->attributeId, buffer, maxReadLength);
}
}

Expand All @@ -547,7 +545,7 @@ EmberAfStatus emberAfExternalAttributeWriteCallback(EndpointId endpoint, Cluster

if ((dev->IsReachable()) && (clusterId == ZCL_ON_OFF_CLUSTER_ID))
{
ret = HandleWriteOnOffAttribute((DeviceOnOff *) dev, attributeMetadata->attributeId, buffer);
ret = HandleWriteOnOffAttribute(static_cast<DeviceOnOff *>(dev), attributeMetadata->attributeId, buffer);
}
else if (clusterId == ZCL_DESCRIPTOR_CLUSTER_ID)
{
Expand Down

0 comments on commit 7616990

Please sign in to comment.