Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed wrong datamodel on Occupancy Sensing Cluster #24363

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3383,9 +3383,26 @@ server cluster RelativeHumidityMeasurement = 1029 {
}

server cluster OccupancySensing = 1030 {
readonly attribute bitmap8 occupancy = 0;
readonly attribute enum8 occupancySensorType = 1;
readonly attribute bitmap8 occupancySensorTypeBitmap = 2;
enum OccupancySensorTypeEnum : ENUM8 {
kPir = 0;
jsloth marked this conversation as resolved.
Show resolved Hide resolved
kUltrasonic = 1;
kPIRAndUltrasonic = 2;
kPhysicalContact = 3;
}

bitmap OccupancyBitmap : BITMAP8 {
kOccupied = 0x1;
}

bitmap OccupancySensorTypeBitmap : BITMAP8 {
kPir = 0x1;
kUltrasonic = 0x2;
kPhysicalContact = 0x4;
}

readonly attribute OccupancyBitmap occupancy = 0;
readonly attribute OccupancySensorTypeEnum occupancySensorType = 1;
readonly attribute OccupancySensorTypeBitmap occupancySensorTypeBitmap = 2;
readonly attribute command_id generatedCommandList[] = 65528;
readonly attribute command_id acceptedCommandList[] = 65529;
readonly attribute event_id eventList[] = 65530;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2721,9 +2721,26 @@ server cluster RelativeHumidityMeasurement = 1029 {
}

server cluster OccupancySensing = 1030 {
readonly attribute bitmap8 occupancy = 0;
readonly attribute enum8 occupancySensorType = 1;
readonly attribute bitmap8 occupancySensorTypeBitmap = 2;
enum OccupancySensorTypeEnum : ENUM8 {
kPir = 0;
kUltrasonic = 1;
kPIRAndUltrasonic = 2;
kPhysicalContact = 3;
}

bitmap OccupancyBitmap : BITMAP8 {
kOccupied = 0x1;
}

bitmap OccupancySensorTypeBitmap : BITMAP8 {
kPir = 0x1;
kUltrasonic = 0x2;
kPhysicalContact = 0x4;
}

readonly attribute OccupancyBitmap occupancy = 0;
readonly attribute OccupancySensorTypeEnum occupancySensorType = 1;
readonly attribute OccupancySensorTypeBitmap occupancySensorTypeBitmap = 2;
readonly attribute command_id generatedCommandList[] = 65528;
readonly attribute command_id acceptedCommandList[] = 65529;
readonly attribute event_id eventList[] = 65530;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1378,9 +1378,26 @@ server cluster FixedLabel = 64 {
}

client cluster OccupancySensing = 1030 {
readonly attribute bitmap8 occupancy = 0;
readonly attribute enum8 occupancySensorType = 1;
readonly attribute bitmap8 occupancySensorTypeBitmap = 2;
enum OccupancySensorTypeEnum : ENUM8 {
kPir = 0;
kUltrasonic = 1;
kPIRAndUltrasonic = 2;
kPhysicalContact = 3;
}

bitmap OccupancyBitmap : BITMAP8 {
kOccupied = 0x1;
}

bitmap OccupancySensorTypeBitmap : BITMAP8 {
kPir = 0x1;
kUltrasonic = 0x2;
kPhysicalContact = 0x4;
}

readonly attribute OccupancyBitmap occupancy = 0;
readonly attribute OccupancySensorTypeEnum occupancySensorType = 1;
readonly attribute OccupancySensorTypeBitmap occupancySensorTypeBitmap = 2;
readonly attribute command_id generatedCommandList[] = 65528;
readonly attribute command_id acceptedCommandList[] = 65529;
readonly attribute event_id eventList[] = 65530;
Expand Down
23 changes: 20 additions & 3 deletions examples/chef/devices/rootnode_dimmablelight_bCwGYSDpoe.matter
Original file line number Diff line number Diff line change
Expand Up @@ -1244,9 +1244,26 @@ server cluster FixedLabel = 64 {
}

client cluster OccupancySensing = 1030 {
readonly attribute bitmap8 occupancy = 0;
readonly attribute enum8 occupancySensorType = 1;
readonly attribute bitmap8 occupancySensorTypeBitmap = 2;
enum OccupancySensorTypeEnum : ENUM8 {
kPir = 0;
kUltrasonic = 1;
kPIRAndUltrasonic = 2;
kPhysicalContact = 3;
}

bitmap OccupancyBitmap : BITMAP8 {
kOccupied = 0x1;
}

bitmap OccupancySensorTypeBitmap : BITMAP8 {
kPir = 0x1;
kUltrasonic = 0x2;
kPhysicalContact = 0x4;
}

readonly attribute OccupancyBitmap occupancy = 0;
readonly attribute OccupancySensorTypeEnum occupancySensorType = 1;
readonly attribute OccupancySensorTypeBitmap occupancySensorTypeBitmap = 2;
readonly attribute command_id generatedCommandList[] = 65528;
readonly attribute command_id acceptedCommandList[] = 65529;
readonly attribute event_id eventList[] = 65530;
Expand Down
23 changes: 20 additions & 3 deletions examples/chef/devices/rootnode_occupancysensor_iHyVgifZuo.matter
Original file line number Diff line number Diff line change
Expand Up @@ -1111,9 +1111,26 @@ server cluster FixedLabel = 64 {
}

server cluster OccupancySensing = 1030 {
readonly attribute bitmap8 occupancy = 0;
readonly attribute enum8 occupancySensorType = 1;
readonly attribute bitmap8 occupancySensorTypeBitmap = 2;
enum OccupancySensorTypeEnum : ENUM8 {
kPir = 0;
kUltrasonic = 1;
kPIRAndUltrasonic = 2;
kPhysicalContact = 3;
}

bitmap OccupancyBitmap : BITMAP8 {
kOccupied = 0x1;
}

bitmap OccupancySensorTypeBitmap : BITMAP8 {
kPir = 0x1;
kUltrasonic = 0x2;
kPhysicalContact = 0x4;
}

readonly attribute OccupancyBitmap occupancy = 0;
readonly attribute OccupancySensorTypeEnum occupancySensorType = 1;
readonly attribute OccupancySensorTypeBitmap occupancySensorTypeBitmap = 2;
readonly attribute command_id generatedCommandList[] = 65528;
readonly attribute command_id acceptedCommandList[] = 65529;
readonly attribute event_id eventList[] = 65530;
Expand Down
17 changes: 17 additions & 0 deletions examples/chef/devices/rootnode_thermostat_bm3fb8dhYi.matter
Original file line number Diff line number Diff line change
Expand Up @@ -1278,6 +1278,23 @@ client cluster RelativeHumidityMeasurement = 1029 {
}

client cluster OccupancySensing = 1030 {
enum OccupancySensorTypeEnum : ENUM8 {
kPir = 0;
kUltrasonic = 1;
kPIRAndUltrasonic = 2;
kPhysicalContact = 3;
}

bitmap OccupancyBitmap : BITMAP8 {
kOccupied = 0x1;
}

bitmap OccupancySensorTypeBitmap : BITMAP8 {
kPir = 0x1;
kUltrasonic = 0x2;
kPhysicalContact = 0x4;
}

readonly attribute command_id generatedCommandList[] = 65528;
readonly attribute command_id acceptedCommandList[] = 65529;
readonly attribute event_id eventList[] = 65530;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1345,9 +1345,26 @@ server cluster BooleanState = 69 {
}

server cluster OccupancySensing = 1030 {
readonly attribute bitmap8 occupancy = 0;
readonly attribute enum8 occupancySensorType = 1;
readonly attribute bitmap8 occupancySensorTypeBitmap = 2;
enum OccupancySensorTypeEnum : ENUM8 {
kPir = 0;
kUltrasonic = 1;
kPIRAndUltrasonic = 2;
kPhysicalContact = 3;
}

bitmap OccupancyBitmap : BITMAP8 {
kOccupied = 0x1;
}

bitmap OccupancySensorTypeBitmap : BITMAP8 {
kPir = 0x1;
kUltrasonic = 0x2;
kPhysicalContact = 0x4;
}

readonly attribute OccupancyBitmap occupancy = 0;
readonly attribute OccupancySensorTypeEnum occupancySensorType = 1;
readonly attribute OccupancySensorTypeBitmap occupancySensorTypeBitmap = 2;
readonly attribute command_id generatedCommandList[] = 65528;
readonly attribute command_id acceptedCommandList[] = 65529;
readonly attribute event_id eventList[] = 65530;
Expand Down
8 changes: 5 additions & 3 deletions examples/lighting-app/infineon/cyw30739/src/ButtonHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ wiced_result_t app_button_init(void)
void app_button_event_handler(const button_manager_button_t * button_mgr, button_manager_event_t event,
button_manager_button_state_t state)
{
uint8_t attributeValue;
chip::BitMask<OccupancySensing::OccupancyBitmap> attributeValue;
if (button_mgr[0].configuration->button == PLATFORM_BUTTON_1 && event == BUTTON_CLICK_EVENT && state == BUTTON_STATE_RELEASED)
{
if (LightMgr().IsLightOn())
Expand All @@ -93,7 +93,9 @@ void app_button_event_handler(const button_manager_button_t * button_mgr, button
{
// update the current occupancy here for hardcoded endpoint 1
OccupancySensing::Attributes::Occupancy::Get(1, &attributeValue);
printf("Button Holding Toggle: %d -> %d\n", attributeValue, !attributeValue);
OccupancySensing::Attributes::Occupancy::Set(1, !attributeValue);
uint8_t bitValue = attributeValue.Raw();
printf("Button Holding Toggle: %d -> %d\n", bitValue, !bitValue);
attributeValue.SetRaw(!bitValue);
OccupancySensing::Attributes::Occupancy::Set(1, attributeValue);
}
}
23 changes: 20 additions & 3 deletions examples/lighting-app/lighting-common/lighting-app.matter
Original file line number Diff line number Diff line change
Expand Up @@ -1815,9 +1815,26 @@ server cluster ColorControl = 768 {
}

server cluster OccupancySensing = 1030 {
readonly attribute bitmap8 occupancy = 0;
readonly attribute enum8 occupancySensorType = 1;
readonly attribute bitmap8 occupancySensorTypeBitmap = 2;
enum OccupancySensorTypeEnum : ENUM8 {
kPir = 0;
kUltrasonic = 1;
kPIRAndUltrasonic = 2;
kPhysicalContact = 3;
}

bitmap OccupancyBitmap : BITMAP8 {
kOccupied = 0x1;
}

bitmap OccupancySensorTypeBitmap : BITMAP8 {
kPir = 0x1;
kUltrasonic = 0x2;
kPhysicalContact = 0x4;
}

readonly attribute OccupancyBitmap occupancy = 0;
readonly attribute OccupancySensorTypeEnum occupancySensorType = 1;
readonly attribute OccupancySensorTypeBitmap occupancySensorTypeBitmap = 2;
readonly attribute command_id generatedCommandList[] = 65528;
readonly attribute command_id acceptedCommandList[] = 65529;
readonly attribute event_id eventList[] = 65530;
Expand Down
23 changes: 20 additions & 3 deletions examples/placeholder/linux/apps/app1/config.matter
Original file line number Diff line number Diff line change
Expand Up @@ -2352,9 +2352,26 @@ server cluster RelativeHumidityMeasurement = 1029 {
}

server cluster OccupancySensing = 1030 {
readonly attribute bitmap8 occupancy = 0;
readonly attribute enum8 occupancySensorType = 1;
readonly attribute bitmap8 occupancySensorTypeBitmap = 2;
enum OccupancySensorTypeEnum : ENUM8 {
kPir = 0;
kUltrasonic = 1;
kPIRAndUltrasonic = 2;
kPhysicalContact = 3;
}

bitmap OccupancyBitmap : BITMAP8 {
kOccupied = 0x1;
}

bitmap OccupancySensorTypeBitmap : BITMAP8 {
kPir = 0x1;
kUltrasonic = 0x2;
kPhysicalContact = 0x4;
}

readonly attribute OccupancyBitmap occupancy = 0;
readonly attribute OccupancySensorTypeEnum occupancySensorType = 1;
readonly attribute OccupancySensorTypeBitmap occupancySensorTypeBitmap = 2;
attribute access(write: manage) int16u PIROccupiedToUnoccupiedDelay = 16;
attribute access(write: manage) int16u PIRUnoccupiedToOccupiedDelay = 17;
attribute access(write: manage) int8u PIRUnoccupiedToOccupiedThreshold = 18;
Expand Down
23 changes: 20 additions & 3 deletions examples/placeholder/linux/apps/app2/config.matter
Original file line number Diff line number Diff line change
Expand Up @@ -2321,9 +2321,26 @@ server cluster RelativeHumidityMeasurement = 1029 {
}

server cluster OccupancySensing = 1030 {
readonly attribute bitmap8 occupancy = 0;
readonly attribute enum8 occupancySensorType = 1;
readonly attribute bitmap8 occupancySensorTypeBitmap = 2;
enum OccupancySensorTypeEnum : ENUM8 {
kPir = 0;
kUltrasonic = 1;
kPIRAndUltrasonic = 2;
kPhysicalContact = 3;
}

bitmap OccupancyBitmap : BITMAP8 {
kOccupied = 0x1;
}

bitmap OccupancySensorTypeBitmap : BITMAP8 {
kPir = 0x1;
kUltrasonic = 0x2;
kPhysicalContact = 0x4;
}

readonly attribute OccupancyBitmap occupancy = 0;
readonly attribute OccupancySensorTypeEnum occupancySensorType = 1;
readonly attribute OccupancySensorTypeBitmap occupancySensorTypeBitmap = 2;
attribute access(write: manage) int16u PIROccupiedToUnoccupiedDelay = 16;
attribute access(write: manage) int16u PIRUnoccupiedToOccupiedDelay = 17;
attribute access(write: manage) int8u PIRUnoccupiedToOccupiedThreshold = 18;
Expand Down
17 changes: 17 additions & 0 deletions examples/pump-app/pump-common/pump-app.matter
Original file line number Diff line number Diff line change
Expand Up @@ -1280,6 +1280,23 @@ server cluster FlowMeasurement = 1028 {
}

client cluster OccupancySensing = 1030 {
enum OccupancySensorTypeEnum : ENUM8 {
kPir = 0;
kUltrasonic = 1;
kPIRAndUltrasonic = 2;
kPhysicalContact = 3;
}

bitmap OccupancyBitmap : BITMAP8 {
kOccupied = 0x1;
}

bitmap OccupancySensorTypeBitmap : BITMAP8 {
kPir = 0x1;
kUltrasonic = 0x2;
kPhysicalContact = 0x4;
}

readonly attribute command_id generatedCommandList[] = 65528;
readonly attribute command_id acceptedCommandList[] = 65529;
readonly attribute event_id eventList[] = 65530;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,25 +33,29 @@ using namespace chip::app::Clusters::OccupancySensing;
void emberAfOccupancySensingClusterServerInitCallback(EndpointId endpoint)
{
auto deviceType = halOccupancyGetSensorType(endpoint);
Attributes::OccupancySensorType::Set(endpoint, deviceType);

uint8_t deviceTypeBitmap = 0;
chip::BitMask<OccupancySensorTypeBitmap> deviceTypeBitmap = 0;
switch (deviceType)
{
case HAL_OCCUPANCY_SENSOR_TYPE_PIR:
deviceTypeBitmap = EMBER_AF_OCCUPANCY_SENSOR_TYPE_BITMAP_PIR;
deviceTypeBitmap.Set(OccupancySensorTypeBitmap::kPir);
Attributes::OccupancySensorType::Set(endpoint, OccupancySensorTypeEnum::kPir);
break;

case HAL_OCCUPANCY_SENSOR_TYPE_ULTRASONIC:
deviceTypeBitmap = EMBER_AF_OCCUPANCY_SENSOR_TYPE_BITMAP_ULTRASONIC;
deviceTypeBitmap.Set(OccupancySensorTypeBitmap::kUltrasonic);
Attributes::OccupancySensorType::Set(endpoint, OccupancySensorTypeEnum::kUltrasonic);
break;

case HAL_OCCUPANCY_SENSOR_TYPE_PIR_AND_ULTRASONIC:
deviceTypeBitmap = (EMBER_AF_OCCUPANCY_SENSOR_TYPE_BITMAP_PIR | EMBER_AF_OCCUPANCY_SENSOR_TYPE_BITMAP_ULTRASONIC);
deviceTypeBitmap.Set(OccupancySensorTypeBitmap::kPir);
deviceTypeBitmap.Set(OccupancySensorTypeBitmap::kUltrasonic);
Attributes::OccupancySensorType::Set(endpoint, OccupancySensorTypeEnum::kPIRAndUltrasonic);
break;

case HAL_OCCUPANCY_SENSOR_TYPE_PHYSICAL:
deviceTypeBitmap = EMBER_AF_OCCUPANCY_SENSOR_TYPE_BITMAP_PHYSICAL_CONTACT;
deviceTypeBitmap.Set(OccupancySensorTypeBitmap::kPhysicalContact);
Attributes::OccupancySensorType::Set(endpoint, OccupancySensorTypeEnum::kPhysicalContact);
break;

default:
Expand All @@ -67,8 +71,10 @@ void emberAfOccupancySensingClusterServerInitCallback(EndpointId endpoint)
//******************************************************************************
void halOccupancyStateChangedCallback(EndpointId endpoint, HalOccupancyState occupancyState)
{
if (occupancyState == HAL_OCCUPANCY_STATE_OCCUPIED)
chip::BitMask<OccupancyBitmap> mappedOccupancyState;
if (occupancyState & HAL_OCCUPANCY_STATE_OCCUPIED)
{
mappedOccupancyState.Set(OccupancyBitmap::kOccupied);
emberAfOccupancySensingClusterPrintln("Occupancy detected");
}
else
Expand Down
Loading