1
wei
2021-01-21 62d098cb78296feaa6f786a20748921338db838c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
//
// TuyaSmartBleMesh.h
// TuyaSmartBLEMeshKit
//
// Copyright (c) 2014-2021 Tuya Inc. (https://developer.tuya.com)
 
#import <Foundation/Foundation.h>
 
@protocol TuyaSmartBleMeshDelegate<NSObject>
 
@optional
 
/// DP data update.
- (void)subDeviceUpdateWithAddress:(NSString *)address dps:(NSDictionary *)dps;
 
/// Raw transparent command received.
- (void)bleMeshReceiveRawData:(NSString *)raw;
 
/// Batch report of received data.
- (void)bleMeshReceiveBatchDeviceDpsInfo;
 
@end
 
@interface TuyaSmartBleMesh : NSObject
 
@property (nonatomic, strong, readonly) TuyaSmartBleMeshModel *bleMeshModel;
 
@property (nonatomic, weak) id<TuyaSmartBleMeshDelegate> delegate;
 
/// Get device object.
/// @param meshId The mesh ID.
/// @param homeId The home ID.
+ (instancetype)bleMeshWithMeshId:(NSString *)meshId homeId:(long long)homeId;
 
/// Get device object.
/// @param meshId The mesh ID.
/// @param homeId The home ID.
- (instancetype)initWithMeshId:(NSString *)meshId homeId:(long long)homeId NS_DESIGNATED_INITIALIZER;
 
- (instancetype)init NS_UNAVAILABLE;
 
/// Create mesh.
/// @param meshName The mesh name.
/// @param homeId The home ID.
/// @param success Called when the task finishes successfully.
/// @param failure Called when the task is interrupted by an error.
+ (void)createBleMeshWithMeshName:(NSString *)meshName homeId:(long long)homeId success:(void(^)(TuyaSmartBleMeshModel *meshModel))success failure:(TYFailureError)failure;
 
/// Get the sub device information of mesh.
/// @param success Called when the task finishes successfully.
/// @param failure Called when the task is interrupted by an error.
- (void)getSubDeviceListFromCloudWithSuccess:(void (^)(NSArray <TuyaSmartDeviceModel *> *subDeviceList))success failure:(TYFailureError)failure;
 
/// Get single sub device information.
/// @param deviceId The device ID.
/// @param success Called when the task finishes successfully.
/// @param failure Called when the task is interrupted by an error.
- (void)getSubDeviceFromCloudWithDeviceId:(NSString *)deviceId success:(void (^)(TuyaSmartDeviceModel *subDeviceModel))success failure:(TYFailureError)failure;
 
/// Single sub device DPS command issued.
/// @param nodeId The node ID.
/// @param pcc Size class label.
/// @param dps Command dictionary.
/// @param success Called when the task finishes successfully.
/// @param failure Called when the task is interrupted by an error.
- (void)publishNodeId:(NSString *)nodeId
                  pcc:(NSString *)pcc
                  dps:(NSDictionary *)dps
              success:(TYSuccessHandler)success
              failure:(TYFailureError)failure;
 
/// Group control equipment.
/// @param localId Local ID.
/// @param pcc Size class label.
/// @param dps Command dictionary.
/// @param success Called when the task finishes successfully.
/// @param failure Called when the task is interrupted by an error.
- (void)multiPublishWithLocalId:(NSString *)localId
                            pcc:(NSString *)pcc
                            dps:(NSDictionary *)dps
                        success:(TYSuccessHandler)success
                        failure:(TYFailureError)failure;
 
/// Broadcast DPS command issued.
/// @param dps Command dictionary.
/// @param pcc Size class label.
/// @param success Called when the task finishes successfully.
/// @param failure Called when the task is interrupted by an error.
- (void)broadcastDps:(NSDictionary *)dps
                 pcc:(NSString *)pcc
             success:(TYSuccessHandler)success
             failure:(TYFailureError)failure;
 
/// Get the latest DPS information of the sub device.
/// @param nodeId The node ID.
/// @param pcc Size class label.
/// @param dpIdList List of keys in DPS.
/// @param success Called when the task finishes successfully.
/// @param failure Called when the task is interrupted by an error.
- (void)getSubDeviceDpsWithNodeId:(NSString *)nodeId
                              pcc:(NSString *)pcc
                         dpIdList:(NSArray <NSNumber *> *)dpIdList
                          success:(TYSuccessHandler)success
                          failure:(TYFailureError)failure;
 
/// Send transparent instruction to device.
/// @param raw Transmission value.
/// @param pcc Size class label.
/// @param success Called when the task finishes successfully.
/// @param failure Called when the task is interrupted by an error.
- (void)publishRawDataWithRaw:(NSString *)raw
                          pcc:(NSString *)pcc
                      success:(TYSuccessHandler)success
                      failure:(TYFailureError)failure;
 
/// Modify mesh name.
/// @param meshName The mesh name.
/// @param success Called when the task finishes successfully.
/// @param failure Called when the task is interrupted by an error.
- (void)updateMeshName:(NSString *)meshName success:(TYSuccessHandler)success failure:(TYFailureError)failure;
 
/// Delete mesh. If there are devices under the mesh group, the sub devices are also removed. The WiFi connector is also removed.
/// @param success Called when the task finishes successfully.
/// @param failure Called when the task is interrupted by an error.
- (void)removeMeshWithSuccess:(TYSuccessHandler)success failure:(TYFailureError)failure;
 
/// Bluetooth device access 2.0.
/// @param uuid Bluetooth sub device short address identification.
/// @param homeId The home ID.
/// @param authKey The authority key.
/// @param nodeId The node ID.
/// @param productKey The product key.
/// @param ver Version.
/// @param success Called when the task finishes successfully.
/// @param failure Called when the task is interrupted by an error.
- (void)addSubDeviceWithUuid:(NSString *)uuid
                      homeId:(long long)homeId
                     authKey:(NSString *)authKey
                      nodeId:(NSString *)nodeId
                  productKey:(NSString *)productKey
                         ver:(NSString *)ver
                     success:(void (^)(NSString *devId, NSString *name))success
                     failure:(TYFailureError)failure;
 
/// Rename mesh subdevice.
/// @param deviceId The device ID.
/// @param name The device name.
/// @param success Called when the task finishes successfully.
/// @param failure Called when the task is interrupted by an error.
- (void)renameMeshSubDeviceWithDeviceId:(NSString *)deviceId name:(NSString *)name success:(TYSuccessHandler)success failure:(TYFailureError)failure;
 
/// Remove mesh sub device.
/// @param deviceId The device ID.
/// @param success Called when the task finishes successfully.
/// @param failure Called when the task is interrupted by an error.
- (void)removeMeshSubDeviceWithDeviceId:(NSString *)deviceId success:(TYSuccessHandler)success failure:(TYFailureError)failure;
 
@end