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

Restyle Part 4: feature/binary input basic cluster #7033

Closed
wants to merge 11 commits into from
3,611 changes: 1,694 additions & 1,917 deletions examples/chip-tool/commands/clusters/Commands.h

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions examples/chip-tool/commands/reporting/Commands.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ class Listen : public ReportingCommand

~Listen()
{
delete onReportBinaryInputBasicPresentValueCallback;
delete onReportBinaryInputBasicStatusFlagsCallback;
delete onReportColorControlCurrentHueCallback;
delete onReportColorControlCurrentSaturationCallback;
delete onReportColorControlCurrentXCallback;
Expand All @@ -51,6 +53,10 @@ class Listen : public ReportingCommand
void AddReportCallbacks(uint8_t endpointId) override
{
chip::app::CHIPDeviceCallbacksMgr & callbacksMgr = chip::app::CHIPDeviceCallbacksMgr::GetInstance();
callbacksMgr.AddReportCallback(chip::kTestDeviceNodeId, endpointId, 0x000F, 0x0055,
onReportBinaryInputBasicPresentValueCallback->Cancel());
callbacksMgr.AddReportCallback(chip::kTestDeviceNodeId, endpointId, 0x000F, 0x006F,
onReportBinaryInputBasicStatusFlagsCallback->Cancel());
callbacksMgr.AddReportCallback(chip::kTestDeviceNodeId, endpointId, 0x0300, 0x0000,
onReportColorControlCurrentHueCallback->Cancel());
callbacksMgr.AddReportCallback(chip::kTestDeviceNodeId, endpointId, 0x0300, 0x0001,
Expand Down Expand Up @@ -117,6 +123,10 @@ class Listen : public ReportingCommand
}

private:
chip::Callback::Callback<BooleanAttributeCallback> * onReportBinaryInputBasicPresentValueCallback =
new chip::Callback::Callback<BooleanAttributeCallback>(OnBooleanAttributeResponse, this);
chip::Callback::Callback<Int8uAttributeCallback> * onReportBinaryInputBasicStatusFlagsCallback =
new chip::Callback::Callback<Int8uAttributeCallback>(OnInt8uAttributeResponse, this);
chip::Callback::Callback<Int8uAttributeCallback> * onReportColorControlCurrentHueCallback =
new chip::Callback::Callback<Int8uAttributeCallback>(OnInt8uAttributeResponse, this);
chip::Callback::Callback<Int8uAttributeCallback> * onReportColorControlCurrentSaturationCallback =
Expand Down
81 changes: 81 additions & 0 deletions src/app/clusters/binary-input-server/binary-input-server.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/*
*
* Copyright (c) 2020 Project CHIP Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#include "binary-input-server.h"

#include <app/util/af.h>

#include "gen/att-storage.h"
#include "gen/attribute-id.h"
#include "gen/attribute-type.h"
#include "gen/cluster-id.h"
#include "gen/command-id.h"

static inline EmberAfStatus emberAfBinaryInputBasicClusterGetPresentValueCallback(chip::EndpointId endpoint, bool * presentValue)
{
return emberAfReadAttribute(endpoint, ZCL_BINARY_INPUT_BASIC_CLUSTER_ID, ZCL_PRESENT_VALUE_ATTRIBUTE_ID, CLUSTER_MASK_SERVER,
(uint8_t *) presentValue, sizeof(uint8_t), NULL);
}

static inline EmberAfStatus emberAfBinaryInputBasicClusterGetOutOfServiceCallback(chip::EndpointId endpoint, bool * isOutOfService)
{
return emberAfReadAttribute(endpoint, ZCL_BINARY_INPUT_BASIC_CLUSTER_ID, ZCL_OUT_OF_SERVICE_ATTRIBUTE_ID, CLUSTER_MASK_SERVER,
(uint8_t *) isOutOfService, sizeof(uint8_t), NULL);
}

void emberAfBinaryInputBasicClusterServerInitCallback(chip::EndpointId endpoint)
{
bool presentValue = false;
EmberAfStatus status = emberAfBinaryInputBasicClusterGetPresentValueCallback(endpoint, &presentValue);

if (EMBER_ZCL_STATUS_SUCCESS != status)
{
(void) emberAfBinaryInputBasicClusterSetPresentValueCallback(endpoint, false);
}

bool isOutOfService = false;
status = emberAfBinaryInputBasicClusterGetOutOfServiceCallback(endpoint, &isOutOfService);

if (EMBER_ZCL_STATUS_SUCCESS != status)
{
(void) emberAfBinaryInputBasicClusterSetOutOfServiceCallback(endpoint, false);
}
}

EmberAfStatus emberAfBinaryInputBasicClusterSetPresentValueCallback(chip::EndpointId endpoint, bool presentValue)
{
EmberAfStatus status = emberAfWriteAttribute(endpoint, ZCL_BINARY_INPUT_BASIC_CLUSTER_ID, ZCL_PRESENT_VALUE_ATTRIBUTE_ID,
CLUSTER_MASK_SERVER, (uint8_t *) &presentValue, ZCL_BOOLEAN_ATTRIBUTE_TYPE);
if (EMBER_ZCL_STATUS_SUCCESS != status)
{
emberAfBinaryInputBasicClusterPrintln("ERR: writing present value %x", status);
}

return status;
}

EmberAfStatus emberAfBinaryInputBasicClusterSetOutOfServiceCallback(chip::EndpointId endpoint, bool isOutOfService)
{
EmberAfStatus status = emberAfWriteAttribute(endpoint, ZCL_BINARY_INPUT_BASIC_CLUSTER_ID, ZCL_OUT_OF_SERVICE_ATTRIBUTE_ID,
CLUSTER_MASK_SERVER, (uint8_t *) &isOutOfService, ZCL_BOOLEAN_ATTRIBUTE_TYPE);
if (EMBER_ZCL_STATUS_SUCCESS != status)
{
emberAfBinaryInputBasicClusterPrintln("ERR: writing present value %x", status);
}

return status;
}
23 changes: 23 additions & 0 deletions src/app/clusters/binary-input-server/binary-input-server.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
*
* Copyright (c) 2020 Project CHIP Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#pragma once

#include <app/util/af-types.h>

EmberAfStatus emberAfBinaryInputBasicClusterSetPresentValueCallback(chip::EndpointId endpoint, bool presentValue);
EmberAfStatus emberAfBinaryInputBasicClusterSetOutOfServiceCallback(chip::EndpointId endpoint, bool isOutOfService);
8 changes: 5 additions & 3 deletions src/app/zap-templates/templates/app/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,10 @@ function asChipUnderlyingType(label, type)
// These helpers only works within the endpoint_config iterator

// List of all cluster with generated functions
var endpointClusterWithInit =
[ 'Basic', 'Identify', 'Groups', 'Scenes', 'Occupancy Sensing', 'On/off', 'Level Control', 'Color Control', 'IAS Zone' ];
var endpointClusterWithInit = [
'Basic', 'Binary Input (Basic)', 'Identify', 'Groups', 'Scenes', 'Occupancy Sensing', 'On/off', 'Level Control', 'Color Control',
'IAS Zone'
];
var endpointClusterWithAttributeChanged = [ 'Identify', 'Door Lock' ];
var endpointClusterWithPreAttribute = [ 'IAS Zone' ];
var endpointClusterWithMessageSent = [ 'IAS Zone' ];
Expand All @@ -219,7 +221,7 @@ function chip_endpoint_generated_functions()
let alreadySetCluster = [];
let ret = '\\\n';
this.clusterList.forEach((c) => {
let clusterName = extract_cluster_name(c.comment);
let clusterName = c.clusterName;
let functionList = '';
if (alreadySetCluster.includes(clusterName)) {
// Only one array of Generated functions per cluster across all endpoints
Expand Down
6 changes: 6 additions & 0 deletions src/app/zap_cluster_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@

# List of directories in src/app/clusters to build for server clusters.
SERVER_CLUSTERS: typing.Dict[str, typing.List[str]] = {
'AIR_PRESSURE_MEASUREMENT_CLUSTER': ['air-pressure-measurement-server'],
'ALARM_CLUSTER': [],
'APPLICATION_BASIC_CLUSTER': [],
'ACCOUNT_LOGIN_CLUSTER': [],
'APPLICATION_LAUNCHER_CLUSTER': ['application-launcher-server'],
'AUDIO_OUTPUT_CLUSTER': [],
'BARRIER_CONTROL_CLUSTER': ['barrier-control-server'],
'BASIC_CLUSTER': ['basic'],
'BINARY_INPUT_BASIC_CLUSTER': ['binary-input-server'],
'BINDING_CLUSTER': ['bindings'],
'COLOR_CONTROL_CLUSTER': ['color-control-server'],
'COMMISSIONING_CLUSTER': [],
Expand Down Expand Up @@ -44,6 +46,7 @@
'OTA_CLIENT_CLUSTER': [],
'POWER_CONFIG_CLUSTER': [],
'PUMP_CONFIG_CONTROL_CLUSTER': [],
'RELATIVE_HUMIDITY_MEASUREMENT_CLUSTER': ['relative-humidity-measurement-server'],
'SCENES_CLUSTER': ['scenes'],
'SWITCH_CLUSTER': [],
'TARGET_NAVIGATOR_CLUSTER': ['target-navigator-server'],
Expand All @@ -61,13 +64,15 @@

# List of directories in src/app/clusters to build for client clusters.
CLIENT_CLUSTERS: typing.Dict[str, typing.List[str]] = {
'AIR_PRESSURE_MEASUREMENT_CLUSTER': [],
'ALARM_CLUSTER': [],
'ACCOUNT_LOGIN_CLUSTER': [],
'APPLICATION_LAUNCHER_CLUSTER': [],
'AUDIO_OUTPUT_CLUSTER': [],
'APPLICATION_BASIC_CLUSTER': [],
'BARRIER_CONTROL_CLUSTER': [],
'BASIC_CLUSTER': [],
'BINARY_INPUT_BASIC_CLUSTER': [],
'BINDING_CLUSTER': [],
'COLOR_CONTROL_CLUSTER': [],
'COMMISSIONING_CLUSTER': [],
Expand Down Expand Up @@ -96,6 +101,7 @@
'OTA_CLIENT_CLUSTER': [],
'POWER_CONFIG_CLUSTER': [],
'PUMP_CONFIG_CONTROL_CLUSTER': [],
'RELATIVE_HUMIDITY_MEASUREMENT_CLUSTER': [],
'SCENES_CLUSTER': [],
'SWITCH_CLUSTER': [],
'TARGET_NAVIGATOR_CLUSTER': [],
Expand Down
Loading