Fix for x86_64 build fail
[platform/upstream/connectedhomeip.git] / src / app / zap-templates / partials / im_command_handler_cluster_commands.zapt
1 {{#if (zcl_command_arguments_count this.id)}}
2 CHIP_ERROR TLVError = CHIP_NO_ERROR;
3 {{#zcl_command_arguments}}
4 {{#if (isOctetString type)}}
5 chip::ByteSpan {{asSymbol label}};
6 {{else if (isString type)}}
7 const uint8_t * {{asSymbol label}};
8 {{else}}
9 {{asUnderlyingZclType type}} {{asSymbol label}};
10 {{/if}}
11 {{/zcl_command_arguments}}
12
13 while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
14 {
15   switch (TLV::TagNumFromTag(dataTlv.GetTag()))
16   {
17 {{#zcl_command_arguments}}
18     case {{index}}:
19 {{#if (isOctetString type)}}
20     {
21         const uint8_t * data = nullptr;
22         TLVError = dataTlv.GetDataPtr(data);
23         {{asSymbol label}} = chip::ByteSpan(data, dataTlv.GetLength());
24     }
25 {{else if (isString type)}}
26       TLVError = dataTlv.GetDataPtr({{asSymbol label}});
27 {{else if isArray}}
28       // Just for compatibility, we will add array type support in IM later.
29       TLVError = dataTlv.GetDataPtr(const_cast<const uint8_t *&>({{asSymbol label}}));
30 {{else}}
31       TLVError = dataTlv.Get({{asSymbol label}});
32 {{/if}}
33       break;
34 {{/zcl_command_arguments}}
35     default:
36       // Unsupported tag, ignore it.
37       ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
38       break;
39   }
40   if (TLVError != CHIP_NO_ERROR)
41   {
42     ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32, TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
43   }
44 }
45 {{/if}}
46 // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
47 emberAf{{asCamelCased parent.name false}}Cluster{{asCamelCased name false}}Callback({{#zcl_command_arguments}}{{#if (isCharString type)}}const_cast<uint8_t*>({{asSymbol label}}){{else}}{{asSymbol label}}{{/if}}{{#unless (isLastElement index count)}}, {{/unless}}{{/zcl_command_arguments}});