Skip to content

Commit

Permalink
Include occupancy sensor from SiLabs (#5731)
Browse files Browse the repository at this point in the history
* Add Occupancy sensor from SimplicityStudio v5

* Move to cpp

* Adapt Occupancy Sensor Server Cluster to CHIP

* Add Occupancy Sensor Server Cluster to all-clusters-app

* Add Occupancy Sensing to the list of objects with init function

* Add weak implementation of Occupancy Sensor Type

* Add occupancy-sensor-server to ESP32 build

* Restyled by whitespace

* Restyled by clang-format

* Apply review suggestions from Lukas Duda.

* Remove commented code.

* Enable OCCUPANCY_SENSING_CLUSTER/occupancy-sensor-server in zap_cluster_list.py

* Add generated modified files

Co-authored-by: Restyled.io <[email protected]>
  • Loading branch information
2 people authored and pull[bot] committed Jul 28, 2021
1 parent d335dbc commit 5fc4394
Show file tree
Hide file tree
Showing 12 changed files with 446 additions and 9 deletions.
97 changes: 97 additions & 0 deletions examples/all-clusters-app/all-clusters-common/all-clusters-app.zap
Original file line number Diff line number Diff line change
Expand Up @@ -13020,6 +13020,103 @@
}
]
},
{
"name": "Occupancy Sensing",
"code": 1030,
"mfgCode": null,
"define": "OCCUPANCY_SENSING_CLUSTER",
"side": "client",
"enabled": 0,
"commands": [],
"attributes": [
{
"name": "cluster revision",
"code": 65533,
"mfgCode": null,
"side": "client",
"included": 1,
"storageOption": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "2",
"reportable": 0,
"minInterval": 0,
"maxInterval": 65344,
"reportableChange": 0
}
]
},
{
"name": "Occupancy Sensing",
"code": 1030,
"mfgCode": null,
"define": "OCCUPANCY_SENSING_CLUSTER",
"side": "server",
"enabled": 1,
"commands": [],
"attributes": [
{
"name": "cluster revision",
"code": 65533,
"mfgCode": null,
"side": "server",
"included": 1,
"storageOption": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "2",
"reportable": 0,
"minInterval": 0,
"maxInterval": 65344,
"reportableChange": 0
},
{
"name": "occupancy",
"code": 0,
"mfgCode": null,
"side": "server",
"included": 1,
"storageOption": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "",
"reportable": 1,
"minInterval": 0,
"maxInterval": 65344,
"reportableChange": 0
},
{
"name": "occupancy sensor type",
"code": 1,
"mfgCode": null,
"side": "server",
"included": 1,
"storageOption": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "",
"reportable": 0,
"minInterval": 0,
"maxInterval": 65344,
"reportableChange": 0
},
{
"name": "occupancy sensor type bitmap",
"code": 2,
"mfgCode": null,
"side": "server",
"included": 1,
"storageOption": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "",
"reportable": 0,
"minInterval": 0,
"maxInterval": 65344,
"reportableChange": 0
}
]
},
{
"name": "Temperature Measurement",
"code": 1026,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ EmberAfStatus emberAfLowPowerClusterServerCommandParse(EmberAfClusterCommand * c
EmberAfStatus emberAfNetworkCommissioningClusterServerCommandParse(EmberAfClusterCommand * cmd);
EmberAfStatus emberAfOtaSoftwareUpdateClientClusterServerCommandParse(EmberAfClusterCommand * cmd);
EmberAfStatus emberAfOtaSoftwareUpdateServerClusterServerCommandParse(EmberAfClusterCommand * cmd);
EmberAfStatus emberAfOccupancySensingClusterServerCommandParse(EmberAfClusterCommand * cmd);
EmberAfStatus emberAfOnOffClusterServerCommandParse(EmberAfClusterCommand * cmd);
EmberAfStatus emberAfOperationalCredentialsClusterServerCommandParse(EmberAfClusterCommand * cmd);
EmberAfStatus emberAfPumpConfigurationAndControlClusterServerCommandParse(EmberAfClusterCommand * cmd);
Expand Down Expand Up @@ -161,6 +162,10 @@ EmberAfStatus emberAfClusterSpecificCommandParse(EmberAfClusterCommand * cmd)
case ZCL_OTA_SERVER_CLUSTER_ID:
result = emberAfOtaSoftwareUpdateServerClusterServerCommandParse(cmd);
break;
case ZCL_OCCUPANCY_SENSING_CLUSTER_ID:
// No commands are enabled for cluster Occupancy Sensing
result = status(false, true, cmd->mfgSpecific);
break;
case ZCL_ON_OFF_CLUSTER_ID:
result = emberAfOnOffClusterServerCommandParse(cmd);
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ void emberAfClusterInitCallback(EndpointId endpoint, ClusterId clusterId)
case ZCL_OTA_SERVER_CLUSTER_ID:
emberAfOtaSoftwareUpdateServerClusterInitCallback(endpoint);
break;
case ZCL_OCCUPANCY_SENSING_CLUSTER_ID:
emberAfOccupancySensingClusterInitCallback(endpoint);
break;
case ZCL_ON_OFF_CLUSTER_ID:
emberAfOnOffClusterInitCallback(endpoint);
break;
Expand Down Expand Up @@ -220,6 +223,11 @@ void __attribute__((weak)) emberAfOtaSoftwareUpdateServerClusterInitCallback(End
// To prevent warning
(void) endpoint;
}
void __attribute__((weak)) emberAfOccupancySensingClusterInitCallback(EndpointId endpoint)
{
// To prevent warning
(void) endpoint;
}
void __attribute__((weak)) emberAfOnOffClusterInitCallback(EndpointId endpoint)
{
// To prevent warning
Expand Down
79 changes: 79 additions & 0 deletions examples/all-clusters-app/all-clusters-common/gen/callback.h
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,14 @@ void emberAfOtaSoftwareUpdateClientClusterInitCallback(chip::EndpointId endpoint
*/
void emberAfOtaSoftwareUpdateServerClusterInitCallback(chip::EndpointId endpoint);

/** @brief Occupancy Sensing Cluster Init
*
* Cluster Init
*
* @param endpoint Endpoint that is being initialized
*/
void emberAfOccupancySensingClusterInitCallback(chip::EndpointId endpoint);

/** @brief On/off Cluster Init
*
* Cluster Init
Expand Down Expand Up @@ -1623,6 +1631,77 @@ EmberAfStatus emberAfOtaSoftwareUpdateServerClusterServerPreAttributeChangedCall
*/
void emberAfOtaSoftwareUpdateServerClusterServerTickCallback(chip::EndpointId endpoint);

//
// Occupancy Sensing Cluster server
//

/** @brief Occupancy Sensing Cluster Server Init
*
* Server Init
*
* @param endpoint Endpoint that is being initialized
*/
void emberAfOccupancySensingClusterServerInitCallback(chip::EndpointId endpoint);

/** @brief Occupancy Sensing Cluster Server Attribute Changed
*
* Server Attribute Changed
*
* @param endpoint Endpoint that is being initialized
* @param attributeId Attribute that changed
*/
void emberAfOccupancySensingClusterServerAttributeChangedCallback(chip::EndpointId endpoint, chip::AttributeId attributeId);

/** @brief Occupancy Sensing Cluster Server Manufacturer Specific Attribute Changed
*
* Server Manufacturer Specific Attribute Changed
*
* @param endpoint Endpoint that is being initialized
* @param attributeId Attribute that changed
* @param manufacturerCode Manufacturer Code of the attribute that changed
*/
void emberAfOccupancySensingClusterServerManufacturerSpecificAttributeChangedCallback(chip::EndpointId endpoint,
chip::AttributeId attributeId,
uint16_t manufacturerCode);

/** @brief Occupancy Sensing Cluster Server Message Sent
*
* Server Message Sent
*
* @param type The type of message sent
* @param destination The destination to which the message was sent
* @param apsFrame The APS frame for the message
* @param msgLen The length of the message
* @param message The message that was sent
* @param status The status of the sent message
*/
void emberAfOccupancySensingClusterServerMessageSentCallback(EmberOutgoingMessageType type,
chip::MessageSendDestination destination, EmberApsFrame * apsFrame,
uint16_t msgLen, uint8_t * message, EmberStatus status);

/** @brief Occupancy Sensing Cluster Server Pre Attribute Changed
*
* server Pre Attribute Changed
*
* @param endpoint Endpoint that is being initialized
* @param attributeId Attribute to be changed
* @param attributeType Attribute type
* @param size Attribute size
* @param value Attribute value
*/
EmberAfStatus emberAfOccupancySensingClusterServerPreAttributeChangedCallback(chip::EndpointId endpoint,
chip::AttributeId attributeId,
EmberAfAttributeType attributeType, uint16_t size,
uint8_t * value);

/** @brief Occupancy Sensing Cluster Server Tick
*
* server Tick
*
* @param endpoint Endpoint that is being served
*/
void emberAfOccupancySensingClusterServerTickCallback(chip::EndpointId endpoint);

//
// On/off Cluster server
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1179,7 +1179,7 @@

#define ZAP_ATTRIBUTE_MASK(mask) ATTRIBUTE_MASK_##mask
// This is an array of EmberAfAttributeMetadata structures.
#define GENERATED_ATTRIBUTE_COUNT 250
#define GENERATED_ATTRIBUTE_COUNT 254
#define GENERATED_ATTRIBUTES \
{ \
\
Expand Down Expand Up @@ -1512,6 +1512,12 @@
/* Endpoint: 2, Cluster: On/off (server) */ \
{ 0x0000, ZAP_TYPE(BOOLEAN), 1, 0, ZAP_SIMPLE_DEFAULT(0x00) }, /* on/off */ \
{ 0xFFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(2) }, /* cluster revision */ \
\
/* Endpoint: 2, Cluster: Occupancy Sensing (server) */ \
{ 0x0000, ZAP_TYPE(BITMAP8), 1, 0, ZAP_EMPTY_DEFAULT() }, /* occupancy */ \
{ 0x0001, ZAP_TYPE(ENUM8), 1, 0, ZAP_EMPTY_DEFAULT() }, /* occupancy sensor type */ \
{ 0x0002, ZAP_TYPE(BITMAP8), 1, 0, ZAP_EMPTY_DEFAULT() }, /* occupancy sensor type bitmap */ \
{ 0xFFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(2) }, /* cluster revision */ \
}

// This is an array of EmberAfCluster structures.
Expand Down Expand Up @@ -1548,10 +1554,13 @@
(EmberAfGenericClusterFunction) emberAfIasZoneClusterServerInitCallback, \
(EmberAfGenericClusterFunction) emberAfIasZoneClusterServerMessageSentCallback, \
(EmberAfGenericClusterFunction) emberAfIasZoneClusterServerPreAttributeChangedCallback, \
}; \
const EmberAfGenericClusterFunction chipFuncArrayOccupancySensingServer[] = { \
(EmberAfGenericClusterFunction) emberAfOccupancySensingClusterServerInitCallback, \
};

#define ZAP_CLUSTER_MASK(mask) CLUSTER_MASK_##mask
#define GENERATED_CLUSTER_COUNT 33
#define GENERATED_CLUSTER_COUNT 34
#define GENERATED_CLUSTERS \
{ \
{ \
Expand Down Expand Up @@ -1684,14 +1693,20 @@
3, \
ZAP_CLUSTER_MASK(SERVER) | ZAP_CLUSTER_MASK(INIT_FUNCTION), \
chipFuncArrayOnOffServer }, /* Endpoint: 2, Cluster: On/off (server) */ \
{ 0x0406, \
ZAP_ATTRIBUTE_INDEX(250), \
4, \
5, \
ZAP_CLUSTER_MASK(SERVER) | ZAP_CLUSTER_MASK(INIT_FUNCTION), \
chipFuncArrayOccupancySensingServer }, /* Endpoint: 2, Cluster: Occupancy Sensing (server) */ \
}

#define ZAP_CLUSTER_INDEX(index) ((EmberAfCluster *) (&generatedClusters[index]))

// This is an array of EmberAfEndpointType structures.
#define GENERATED_ENDPOINT_TYPES \
{ \
{ ZAP_CLUSTER_INDEX(0), 12, 3726 }, { ZAP_CLUSTER_INDEX(12), 20, 2130 }, { ZAP_CLUSTER_INDEX(32), 1, 3 }, \
{ ZAP_CLUSTER_INDEX(0), 12, 3726 }, { ZAP_CLUSTER_INDEX(12), 20, 2130 }, { ZAP_CLUSTER_INDEX(32), 2, 8 }, \
}

// Largest attribute size is needed for various buffers
Expand All @@ -1701,7 +1716,7 @@
#define ATTRIBUTE_SINGLETONS_SIZE (875)

// Total size of attribute storage
#define ATTRIBUTE_MAX_SIZE (5859)
#define ATTRIBUTE_MAX_SIZE (5864)

// Number of fixed endpoints
#define FIXED_ENDPOINT_COUNT (3)
Expand Down Expand Up @@ -1971,10 +1986,10 @@
#define ZAP_REPORT_DIRECTION(x) ZRD(x)

// User options for plugin Reporting
#define EMBER_AF_PLUGIN_REPORTING_TABLE_SIZE (13)
#define EMBER_AF_PLUGIN_REPORTING_TABLE_SIZE (14)
#define EMBER_AF_PLUGIN_REPORTING_ENABLE_GROUP_BOUND_REPORTS

#define EMBER_AF_GENERATED_REPORTING_CONFIG_DEFAULTS_TABLE_SIZE (13)
#define EMBER_AF_GENERATED_REPORTING_CONFIG_DEFAULTS_TABLE_SIZE (14)
#define EMBER_AF_GENERATED_REPORTING_CONFIG_DEFAULTS \
{ \
\
Expand Down Expand Up @@ -2034,4 +2049,9 @@
{ \
ZAP_REPORT_DIRECTION(REPORTED), 0x0002, 0x0006, 0x0000, ZAP_CLUSTER_MASK(SERVER), 0x0000, { { 0, 65344, 0 } } \
}, /* on/off */ \
\
/* Endpoint: 2, Cluster: Occupancy Sensing (server) */ \
{ \
ZAP_REPORT_DIRECTION(REPORTED), 0x0002, 0x0406, 0x0000, ZAP_CLUSTER_MASK(SERVER), 0x0000, { { 0, 65344, 0 } } \
}, /* occupancy */ \
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
#define EMBER_AF_NETWORK_COMMISSIONING_CLUSTER_SERVER_ENDPOINT_COUNT (1)
#define EMBER_AF_OTA_CLIENT_CLUSTER_SERVER_ENDPOINT_COUNT (1)
#define EMBER_AF_OTA_SERVER_CLUSTER_SERVER_ENDPOINT_COUNT (1)
#define EMBER_AF_OCCUPANCY_SENSING_CLUSTER_SERVER_ENDPOINT_COUNT (1)
#define EMBER_AF_ON_OFF_CLUSTER_SERVER_ENDPOINT_COUNT (2)
#define EMBER_AF_OPERATIONAL_CREDENTIALS_CLUSTER_SERVER_ENDPOINT_COUNT (1)
#define EMBER_AF_PUMP_CONFIG_CONTROL_CLUSTER_SERVER_ENDPOINT_COUNT (1)
Expand Down Expand Up @@ -167,6 +168,11 @@
#define EMBER_AF_PLUGIN_OTA_SOFTWARE_UPDATE_SERVER_SERVER
#define EMBER_AF_PLUGIN_OTA_SOFTWARE_UPDATE_SERVER

// Use this macro to check if the server side of the Occupancy Sensing cluster is included
#define ZCL_USING_OCCUPANCY_SENSING_CLUSTER_SERVER
#define EMBER_AF_PLUGIN_OCCUPANCY_SENSING_SERVER
#define EMBER_AF_PLUGIN_OCCUPANCY_SENSING

// Use this macro to check if the server side of the On/off cluster is included
#define ZCL_USING_ON_OFF_CLUSTER_SERVER
#define EMBER_AF_PLUGIN_ON_OFF_SERVER
Expand Down
1 change: 1 addition & 0 deletions examples/all-clusters-app/esp32/main/component.mk
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ COMPONENT_SRCDIRS :=
../third_party/connectedhomeip/src/app/clusters/bindings \
../third_party/connectedhomeip/src/app/reporting \
../third_party/connectedhomeip/src/app/clusters/door-lock-server \
../third_party/connectedhomeip/src/app/clusters/occupancy-sensor-server \
../third_party/connectedhomeip/src/app/clusters/ias-zone-server \
# ../third_party/connectedhomeip/src/app/clusters/ias-zone-client \
Expand Down
Loading

0 comments on commit 5fc4394

Please sign in to comment.