Apply Upstream code (2021-03-15)
[platform/upstream/connectedhomeip.git] / src / app / zap-templates / templates / chip / CHIPClustersObjc.zapt
1 {{> header}}
2
3 #ifndef CHIP_CLUSTERS_H
4 #define CHIP_CLUSTERS_H
5
6 #import <Foundation/Foundation.h>
7
8 @class CHIPDevice;
9
10 typedef void (^ResponseHandler)(NSError * _Nullable error, NSDictionary * _Nullable values);
11
12 NS_ASSUME_NONNULL_BEGIN
13
14 /**
15  * CHIPCluster
16  *    This is the base class for clusters.
17  */
18 @interface CHIPCluster : NSObject
19
20 - (nullable instancetype)initWithDevice:(CHIPDevice *)device endpoint:(uint8_t)endpoint queue:(dispatch_queue_t)queue NS_DESIGNATED_INITIALIZER;
21 - (instancetype)init NS_UNAVAILABLE;
22 + (instancetype)new NS_UNAVAILABLE;
23
24 @end
25
26 {{#chip_clusters}}
27
28
29 /**
30  * Cluster {{name}}
31  *    {{description}}
32  */
33 @interface CHIP{{asCamelCased name false}} : CHIPCluster
34
35 {{#chip_server_cluster_commands}}
36 {{#if (zcl_command_arguments_count this.id)}}
37 - (void){{asCamelCased name}}:{{#chip_server_cluster_command_arguments}}{{#if (isFirstElement index)}}{{else}}{{asCamelCased label}}:{{/if}}({{asObjectiveCBasicType type}}){{asCamelCased label}} {{/chip_server_cluster_command_arguments}}completionHandler:(ResponseHandler)completionHandler;
38 {{else}}
39 - (void){{asCamelCased name}}:(ResponseHandler)completionHandler;
40 {{/if}}
41 {{/chip_server_cluster_commands}}
42
43 {{#chip_server_cluster_attributes}}
44 - (void)readAttribute{{asCamelCased name false}}:(ResponseHandler)completionHandler;
45 {{#if (isWritableAttribute)}}
46 - (void)writeAttribute{{asCamelCased name false}}:({{asObjectiveCBasicType type}})value completionHandler:(ResponseHandler)completionHandler;
47 {{/if}}
48 {{#if (isReportableAttribute)}}
49 - (void) configureAttribute{{asCamelCased name false}}:(uint16_t)minInterval  maxInterval:(uint16_t)maxInterval{{#unless (isDiscreteType)}} change:({{chipType}})change{{/unless}} completionHandler:(ResponseHandler)completionHandler;
50 - (void) reportAttribute{{asCamelCased name false}}:(ResponseHandler)reportHandler;
51 {{/if}}
52 {{/chip_server_cluster_attributes}}
53
54 @end
55
56 {{/chip_clusters}}
57
58 NS_ASSUME_NONNULL_END
59
60 #endif /* CHIP_CLUSTERS_H */