Skip to content

Commit

Permalink
Rename ConfigureAttribute to SubscribeAttribute, remove isAnalog, and…
Browse files Browse the repository at this point in the history
… remove some dead code introduced in #9510 (#9913)

* Rename ConfigureAttribute to SubscribeAttribute, remove isAnalog, and remove some dead code introduced in #9510

* Update generated content
  • Loading branch information
vivien-apple authored and pull[bot] committed Nov 5, 2021
1 parent 1003540 commit 6c25956
Show file tree
Hide file tree
Showing 28 changed files with 487 additions and 657 deletions.
8 changes: 1 addition & 7 deletions examples/chip-tool/templates/commands.zapt
Original file line number Diff line number Diff line change
Expand Up @@ -319,9 +319,6 @@ public:
AddArgument("attr-name", "{{asDelimitedCommand (asUpperCamelCase name)}}");
AddArgument("min-interval", 0, UINT16_MAX, &mMinInterval);
AddArgument("max-interval", 0, UINT16_MAX, &mMaxInterval);
{{#if isAnalog}}
AddArgument("change", {{asTypeMinValue type}}, {{asTypeMaxValue type}}, &mChange);
{{/if}}
ModelCommand::AddArguments();
}

Expand All @@ -345,7 +342,7 @@ public:
return err;
}

return cluster.ConfigureAttribute{{asUpperCamelCase name}}(onSuccessCallback->Cancel(), onFailureCallback->Cancel(), mMinInterval, mMaxInterval{{#if isAnalog}}, mChange{{/if}});
return cluster.SubscribeAttribute{{asUpperCamelCase name}}(onSuccessCallback->Cancel(), onFailureCallback->Cancel(), mMinInterval, mMaxInterval);
}

private:
Expand All @@ -354,9 +351,6 @@ private:
chip::Callback::Callback<{{chipCallback.name}}AttributeCallback> * onReportCallback = new chip::Callback::Callback<{{chipCallback.name}}AttributeCallback>(On{{chipCallback.name}}AttributeResponse, this);
uint16_t mMinInterval;
uint16_t mMaxInterval;
{{#if isAnalog}}
{{chipType}} mChange;
{{/if}}
};

{{/if}}
Expand Down
29 changes: 6 additions & 23 deletions src/app/zap-templates/common/ClusterTestGeneration.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ function setDefaultType(test)
break;

case 'subscribeAttribute':
test.commandName = 'Configure';
test.commandName = 'Subscribe';
test.isAttribute = true;
test.isSubscribeAttribute = true;
break;
Expand Down Expand Up @@ -342,14 +342,6 @@ function isTestOnlyCluster(name)
return name == DelayCommands.name;
}

function chip_tests_with_command_attribute_info(options)
{
const promise = assertCommandOrAttribute(this).then(item => {
return [ item ];
});
return asBlocks.call(this, promise, options);
}

function chip_tests_item_parameters(options)
{
const commandValues = this.arguments.values;
Expand Down Expand Up @@ -425,20 +417,11 @@ function chip_tests_item_response_parameters(options)
return asBlocks.call(this, promise, options);
}

function chip_tests_WaitForAttributeReport_attribute_info(options)
{
const waitfor = Object.assign(JSON.parse(JSON.stringify(this.waitfor)), { command : 'readAttribute', isAttribute : true });
setDefaults(waitfor, this.parent);
return templateUtil.collectBlocks([ waitfor ], options, this);
}

//
// Module exports
//
exports.chip_tests = chip_tests;
exports.chip_tests_items = chip_tests_items;
exports.chip_tests_item_parameters = chip_tests_item_parameters;
exports.chip_tests_item_response_parameters = chip_tests_item_response_parameters;
exports.isTestOnlyCluster = isTestOnlyCluster;
exports.chip_tests_with_command_attribute_info = chip_tests_with_command_attribute_info;
exports.chip_tests_WaitForAttributeReport_attribute_info = chip_tests_WaitForAttributeReport_attribute_info;
exports.chip_tests = chip_tests;
exports.chip_tests_items = chip_tests_items;
exports.chip_tests_item_parameters = chip_tests_item_parameters;
exports.chip_tests_item_response_parameters = chip_tests_item_response_parameters;
exports.isTestOnlyCluster = isTestOnlyCluster;
1 change: 0 additions & 1 deletion src/app/zap-templates/common/ClustersHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,6 @@ function handleBasic(item, [ atomics, enums, bitmaps, structs ])
item.name = item.name || item.label;
item.isStruct = false;
item.atomicTypeId = atomic.atomicId;
item.isAnalog = atomic.isDiscrete == false && atomic.isString == false;
item.size = atomic.size;
item.chipType = atomic.chipType;
item.chipTypePutLength = asPutLength(atomic.chipType);
Expand Down
3 changes: 1 addition & 2 deletions src/app/zap-templates/templates/app/CHIPClusters-src.zapt
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,8 @@ CHIP_ERROR {{asUpperCamelCase parent.name}}Cluster::WriteAttribute{{asUpperCamel

{{/if}}
{{#if isReportableAttribute}}
CHIP_ERROR {{asUpperCamelCase parent.name}}Cluster::ConfigureAttribute{{asUpperCamelCase name}}(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, uint16_t minInterval, uint16_t maxInterval{{#if isAnalog}}, {{chipType}} change{{/if}})
CHIP_ERROR {{asUpperCamelCase parent.name}}Cluster::SubscribeAttribute{{asUpperCamelCase name}}(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, uint16_t minInterval, uint16_t maxInterval)
{
{{#if isAnalog}}IgnoreUnusedVariable(change);{{/if}}
chip::app::AttributePathParams attributePath;
attributePath.mEndpointId = mEndpoint;
attributePath.mClusterId = mClusterId;
Expand Down
2 changes: 1 addition & 1 deletion src/app/zap-templates/templates/app/CHIPClusters.zapt
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public:
{{/chip_server_cluster_attributes}}
{{#chip_server_cluster_attributes}}
{{#if isReportableAttribute}}
CHIP_ERROR ConfigureAttribute{{asUpperCamelCase name}}(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, uint16_t minInterval, uint16_t maxInterval{{#if isAnalog}}, {{chipType}} change{{/if}});
CHIP_ERROR SubscribeAttribute{{asUpperCamelCase name}}(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, uint16_t minInterval, uint16_t maxInterval);
CHIP_ERROR ReportAttribute{{asUpperCamelCase name}}(Callback::Cancelable * onReportCallback);
{{/if}}
{{/chip_server_cluster_attributes}}
Expand Down
16 changes: 8 additions & 8 deletions src/controller/python/chip-device-ctrl.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ def __init__(self, rendezvousAddr=None, controllerNodeId=0, bluetoothAdapter=Non
"resolve",
"zcl",
"zclread",
"zclconfigure",
"zclsubscribe",

"discover",

Expand Down Expand Up @@ -805,10 +805,10 @@ def do_zclwrite(self, line):
print("An exception occurred during processing input:")
print(str(ex))

def do_zclconfigure(self, line):
def do_zclsubscribe(self, line):
"""
To configure ZCL attribute reporting:
zclconfigure <cluster> <attribute> <nodeid> <endpoint> <minInterval> <maxInterval> <change>
To subscribe ZCL attribute reporting:
zclsubscribe <cluster> <attribute> <nodeid> <endpoint> <minInterval> <maxInterval>
"""
try:
args = shlex.split(line)
Expand All @@ -821,13 +821,13 @@ def do_zclconfigure(self, line):
cluster_attrs = all_attrs.get(args[1], {})
print('\n'.join([key for key in cluster_attrs.keys(
) if cluster_attrs[key].get("reportable", False)]))
elif len(args) == 7:
elif len(args) == 6:
if args[0] not in all_attrs:
raise exceptions.UnknownCluster(args[0])
self.devCtrl.ZCLConfigureAttribute(args[0], args[1], int(
args[2]), int(args[3]), int(args[4]), int(args[5]), int(args[6]))
self.devCtrl.ZCLSubscribeAttribute(args[0], args[1], int(
args[2]), int(args[3]), int(args[4]), int(args[5]))
else:
self.do_help("zclconfigure")
self.do_help("zclsubscribe")
except exceptions.ChipStackException as ex:
print("An exception occurred during configuring reporting of ZCL attribute:")
print(str(ex))
Expand Down
8 changes: 4 additions & 4 deletions src/controller/python/chip/ChipDeviceCtrl.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,19 +350,19 @@ def ZCLWriteAttribute(self, cluster, attribute, nodeid, endpoint, groupid, value
if blocking:
return im.GetAttributeWriteResponse(im.DEFAULT_ATTRIBUTEWRITE_APPID)

def ZCLConfigureAttribute(self, cluster, attribute, nodeid, endpoint, minInterval, maxInterval, change, blocking=True):
def ZCLSubscribeAttribute(self, cluster, attribute, nodeid, endpoint, minInterval, maxInterval, blocking=True):
device = c_void_p(None)
# We should really use pychip_GetConnectedDeviceByNodeId and do the
# ConfigureAttribute off its callback....
# SubscribeAttribute off its callback....
res = self._ChipStack.Call(lambda: self._dmLib.pychip_GetDeviceByNodeId(
self.devCtrl, nodeid, pointer(device)))
if res != 0:
raise self._ChipStack.ErrorToException(res)

commandSenderHandle = self._dmLib.pychip_GetCommandSenderHandle(device)
im.ClearCommandStatus(commandSenderHandle)
res = self._Cluster.ConfigureAttribute(
device, cluster, attribute, endpoint, minInterval, maxInterval, change, commandSenderHandle != 0)
res = self._Cluster.SubscribeAttribute(
device, cluster, attribute, endpoint, minInterval, maxInterval, commandSenderHandle != 0)
if blocking:
# We only send 1 command by this function, so index is always 0
return im.WaitCommandIndexStatus(commandSenderHandle, 1)
Expand Down
Loading

0 comments on commit 6c25956

Please sign in to comment.