Fix for x86_64 build fail
[platform/upstream/connectedhomeip.git] / examples / chip-tool / templates / reporting-commands.zapt
1 {{> header}}
2
3 #pragma once
4
5 #include "ReportingCommand.h"
6
7
8 typedef void (*UnsupportedAttributeCallback)(void * context);
9
10 class Listen : public ReportingCommand
11 {
12 public:
13     Listen() : ReportingCommand("listen")
14     {
15     }
16
17     ~Listen()
18     {
19 {{#chip_clusters}}
20 {{#chip_server_cluster_attributes}}
21 {{#if (isReportableAttribute)}}
22     delete onReport{{asCamelCased parent.name false}}{{asCamelCased name false}}Callback;
23 {{/if}}
24 {{/chip_server_cluster_attributes}}
25 {{/chip_clusters}}
26     }
27     
28     void AddReportCallbacks(uint8_t endpointId) override
29     {
30         chip::app::CHIPDeviceCallbacksMgr & callbacksMgr = chip::app::CHIPDeviceCallbacksMgr::GetInstance();
31 {{#chip_clusters}}
32 {{#chip_server_cluster_attributes}}
33 {{#if (isReportableAttribute)}}
34         callbacksMgr.AddReportCallback(chip::kTestDeviceNodeId, endpointId, {{asHex parent.code 4}}, {{asHex attributeCode 4}}, onReport{{asCamelCased parent.name false}}{{asCamelCased name false}}Callback->Cancel());
35 {{/if}}
36 {{/chip_server_cluster_attributes}}
37 {{/chip_clusters}}
38     }
39
40     static void OnDefaultSuccessResponse(void * context)
41     {
42         ChipLogProgress(chipTool, "Default Success Response");
43     }
44
45     static void OnDefaultFailureResponse(void * context, uint8_t status)
46     {
47         ChipLogProgress(chipTool, "Default Failure Response: 0x%02x", status);
48     }
49
50     static void OnUnsupportedAttributeResponse(void * context)
51     {
52         ChipLogError(chipTool, "Unsupported attribute Response. This should never happen !");
53     }
54
55     static void OnBooleanAttributeResponse(void * context, bool value)
56     {
57         ChipLogProgress(chipTool, "Boolean attribute Response: %d", value);
58     }
59
60     static void OnInt8uAttributeResponse(void * context, uint8_t value)
61     {
62         ChipLogProgress(chipTool, "Int8u attribute Response: %" PRIu8, value);
63     }
64
65     static void OnInt16uAttributeResponse(void * context, uint16_t value)
66     {
67         ChipLogProgress(chipTool, "Int16u attribute Response: %" PRIu16, value);
68     }
69
70     static void OnInt16sAttributeResponse(void * context, int16_t value)
71     {
72         ChipLogProgress(chipTool, "Int16s attribute Response: %" PRId16, value);
73     }
74
75 private:
76 {{#chip_clusters}}
77 {{#chip_server_cluster_attributes}}
78 {{#if (isReportableAttribute)}}
79     chip::Callback::Callback<{{asCallbackAttributeType atomicTypeId}}AttributeCallback> * onReport{{asCamelCased parent.name false}}{{asCamelCased name false}}Callback = new chip::Callback::Callback<{{asCallbackAttributeType atomicTypeId}}AttributeCallback>(On{{asCallbackAttributeType atomicTypeId}}AttributeResponse, this);
80 {{/if}}
81 {{/chip_server_cluster_attributes}}
82 {{/chip_clusters}}
83 };
84
85 void registerCommandsReporting(Commands & commands)
86 {
87     const char * clusterName = "Reporting";
88
89     commands_list clusterCommands = {
90         make_unique<Listen>(),
91     };
92
93     commands.Register(clusterName, clusterCommands);
94 }