Tuya iOS Smart Life App SDK 5.15.0
ThingCoreCacheService.h File Reference
#import <Foundation/Foundation.h>
#import "ThingSmartDeviceAdvancedAbility.h"

Go to the source code of this file.

Classes

protocol  <ThingCoreCacheServiceDelegate>
 The delegate of the ThingCoreCacheService class provides the callback of device or group status. More...
 

Functions

void setCacheHandlerQueue: (dispatch_queue_t queue)
 
void reset ()
 
ThingSmartDeviceModelgetDeviceInfoWithDevId: (NSString *devId)
 
void addDeviceModel: (ThingSmartDeviceModel *deviceModel)
 
void addDeviceModel:completion: (ThingSmartDeviceModel *deviceModel,[completion] nullable void(^ completion)(ThingSmartDeviceModel *device))
 
void addDeviceModelList: (NSArray< ThingSmartDeviceModel * > *deviceModelList)
 
void addDeviceModelList:completion: (NSArray< ThingSmartDeviceModel * > *deviceModelList,[completion] nullable void(^ completion)(NSArray< ThingSmartDeviceModel * > *deviceList))
 
void removeDeviceWithDevId: (NSString *devId)
 
void removeDeviceWithDevId:completion: (NSString *devId,[completion] nullable void(^ completion)(NSString *devId))
 
NSArray< ThingSmartDeviceModel * > * getAllDeviceList ()
 
void updateDeviceOtaInfoWithList: (NSArray< ThingSmartDeviceOTAModel * > *otaList)
 
void updateDeviceOtaInfoWithList:completion: (NSArray< ThingSmartDeviceOTAModel * > *otaList,[completion] nullable void(^ completion)(NSArray< ThingSmartDeviceOTAModel * > *))
 
ThingSmartDeviceOTAModelgetDeviceOtaInfoWithDevId: (NSString *devId)
 
void updateDeviceOtaMode: (ThingSmartDeviceOTAModel *otaModel)
 
void updateDeviceOtaModel:completion: (ThingSmartDeviceOTAModel *otaModel,[completion] nullable void(^ completion)(ThingSmartDeviceOTAModel *))
 
BOOL validateCachRoamDeviceSN: (NSDictionary *message)
 
ThingSmartGroupModelgetGroupInfoWithGroupId: (long long groupId)
 
void addGroupModel: (ThingSmartGroupModel *groupModel)
 
void addGroupModel:completion: (ThingSmartGroupModel *groupModel,[completion] nullable void(^ completion)(ThingSmartGroupModel *group))
 
void removeGroupWithGroupId: (long long groupId)
 
NSArray< ThingSmartGroupModel * > * getAllGroupList ()
 
NSDictionary * getGroupProductWithProductId: (NSString *productId)
 
NSDictionary * getGroupProductWithProductId:productVer: (NSString *productId,[productVer] NSString *productVer)
 
NSArray< ThingSmartDeviceModel * > * getDeviceListWithGroupId: (long long groupId)
 
void updateGroupProductList: (NSArray< NSDictionary * > *groupProductList)
 
void updateDeviceGroupRelationWithDeviceList:groupId: (NSArray *deviceList,[groupId] long long groupId)
 
void updateDeviceGroupRelationWithDeviceList:groupId:shouldNotify: (NSArray *deviceList,[groupId] long long groupId,[shouldNotify] BOOL shouldNotify)
 
NSArray< ThingSmartDeviceModel * > * getDeviceListWithHomeId: (long long homeId)
 
ThingSmartBleMeshModelgetMeshModelWithMeshId: (NSString *meshId)
 
void updateMeshModel: (ThingSmartBleMeshModel *meshModel)
 
NSArray< ThingSmartBleMeshModel * > * getAllMeshList ()
 
NSInteger getMeshGroupAddressFromLocalWithMeshId: (NSString *meshId)
 
NSInteger getMeshGroupCountFromLocalWithMeshId: (NSString *meshId)
 
void removeMeshGroupWithAddress:meshId: (NSInteger address,[meshId] NSString *meshId)
 
void addThingModel:completion: (ThingSmartThingModel *model,[completion] nullable void(^ completion)(ThingSmartThingModel *thingModel))
 
nullable ThingSmartThingModelgetThingModelWithProductId:productVersion: (NSString *productId,[productVersion] NSString *productVersion)
 
void addAdvancedAbilityModel:completion: (ThingSmartDeviceAdvancedAbility *model,[completion] nullable void(^ completion)(ThingSmartDeviceAdvancedAbility *thingModel))
 
BOOL hasAdvancedAbilityWithDevId:code: (NSString *devId,[code] NSString *code)
 
NSArray< ThingSmartDeviceAdvancedAbility * > * getAbilityList ()
 

Variables

id< ThingCoreCacheServiceDelegatedelegate
 The devices and group core cache classes allow you to add, modify, and delete data models. You can also subscribe to MQTT messages. More...
 
NSMutableDictionary< NSString *, ThingSmartDeviceModel * > * deviceData
 The device cache. More...
 
NSMutableDictionary< NSString *, ThingSmartGroupModel * > * groupData
 The group caching. More...
 
NSMutableDictionary< NSString *, NSDictionary * > * groupProductData
 The group product information cache. More...
 
NSMutableDictionary< NSString *, NSMutableArray< NSString * > * > * groupDeviceRelation
 The group device relationship cache. More...
 
NSMutableDictionary< NSString *, ThingSmartBleMeshModel * > * meshData
 The mesh information. More...
 
NSMutableDictionary * meshGroupAddData
 The mesh group information. More...
 

Function Documentation

◆ addAdvancedAbilityModel:completion:()

void addAdvancedAbilityModel:completion: ( ThingSmartDeviceAdvancedAbility model,
[completion] nullable void(^)(ThingSmartDeviceAdvancedAbility *thingModel)  completion 
)
virtual

◆ addDeviceModel:()

void addDeviceModel: ( ThingSmartDeviceModel deviceModel)
virtual

Adds a device to the cache.

After you add the device to the cache, subscribe to the topic of the device's MQTT messages. Make sure that the local key and protocol version are both configured. After the device is added, you can accept callbacks by implementing deviceDidAdd: of ThingCoreCacheServiceDelegate. The tasks to add devices, subscribe to messages, and execute callbacks are run in the asynchronous thread. The asynchronous queue.

Parameters
deviceModelThe model of the device to be added.

◆ addDeviceModel:completion:()

void addDeviceModel:completion: ( ThingSmartDeviceModel deviceModel,
[completion] nullable void(^)(ThingSmartDeviceModel *device)  completion 
)
virtual

Adds a device to the cache.

After you add the device to the cache, subscribe to the topic of the device's MQTT messages. Make sure that the local key and protocol version are both configured. During the process, you can set the completion block or implement the deviceDidAdd: of the proxy ThingCoreCacheServiceDelegate to handle the result of the event. The completion block is called and followed by the delegate. The tasks to add devices, subscribe to messages, block, and execute callbacks are run in the asynchronous thread. The asynchronous queue.

Parameters
deviceModelThe device model to be added.
completionThe callback after the completion of the join block.

◆ addDeviceModelList:()

void addDeviceModelList: ( NSArray< ThingSmartDeviceModel * > *  deviceModelList)
virtual

Adds multiple devices to the cache in an operation.

After you add the device to the cache, subscribe to the topic of each device's MQTT messages. Make sure that the local key and protocol version are both configured. After the device is added, you can accept callbacks by implementing deviceListDidAdd: of ThingCoreCacheServiceDelegate. The tasks to add devices, subscribe to messages, and execute callbacks are run in the asynchronous thread. The asynchronous queue.

Parameters
deviceModelListThe group of devices to be added

◆ addDeviceModelList:completion:()

void addDeviceModelList:completion: ( NSArray< ThingSmartDeviceModel * > *  deviceModelList,
[completion] nullable void(^)(NSArray< ThingSmartDeviceModel * > *deviceList)  completion 
)
virtual

Adds multiple devices to the cache in an operation.

After you add the device to the cache, subscribe to the topic of each device's MQTT messages. Make sure that the local key and protocol version are both configured. During the process, you can set the completion block or implement the deviceListDidAdd: of the proxy ThingCoreCacheServiceDelegate to handle the result of the event. The completion block is called and followed by the delegate. The tasks to add devices, subscribe to messages, and execute callbacks are run in the asynchronous thread. The asynchronous queue.

Parameters
deviceModelListThe group of devices to be added.
completionThe callback after the completion of the join block.

◆ addGroupModel:()

void addGroupModel: ( ThingSmartGroupModel groupModel)
virtual

Adds a group to the cache.

After you add the group to the cache, subscribe to the topic of the group's MQTT messages. Make sure that the local key and protocol version are both configured. After the group is added, you can accept callbacks by implementing groupDidAdd: of ThingCoreCacheServiceDelegate. The tasks to add groups, subscribe to messages, and execute callbacks are run in the asynchronous threads. The asynchronous queue.

Parameters
groupModelThe group model to be added.

◆ addGroupModel:completion:()

void addGroupModel:completion: ( ThingSmartGroupModel groupModel,
[completion] nullable void(^)(ThingSmartGroupModel *group)  completion 
)
virtual

Adds a group to the cache.

After you add the group to the cache, subscribe to the topic of the group's MQTT messages. Make sure that the local key and protocol version are both configured. During the process, you can set the completion block or implement the proxy groupDidAdd: of ThingCoreCacheServiceDelegate to handle the result of the event. The completion block is called and followed by the delegate. The tasks to add devices, subscribe to messages, and execute callbacks are run in the asynchronous thread. The asynchronous queue.

Parameters
groupModelThe group model to be joined.
completionCallback after the completion of the join block.

◆ addThingModel:completion:()

void addThingModel:completion: ( ThingSmartThingModel model,
[completion] nullable void(^)(ThingSmartThingModel *thingModel)  completion 
)
virtual

◆ getAbilityList()

NSArray< ThingSmartDeviceAdvancedAbility * > * getAbilityList ( )
virtual

◆ getAllDeviceList()

NSArray< ThingSmartDeviceModel * > * getAllDeviceList ( )
virtual

Returns all devices in the cache. The synchronous queue.

◆ getAllGroupList()

NSArray< ThingSmartGroupModel * > * getAllGroupList ( )
virtual

Returns all groups in the cache. The synchronous queue.

◆ getAllMeshList()

NSArray< ThingSmartBleMeshModel * > * getAllMeshList ( )
virtual

◆ getDeviceInfoWithDevId:()

ThingSmartDeviceModel * getDeviceInfoWithDevId: ( NSString *  devId)
virtual

Returns the device by device ID to synchronize device information. The synchronous queue.

Parameters
devIdThe device ID.

◆ getDeviceListWithGroupId:()

NSArray< ThingSmartDeviceModel * > * getDeviceListWithGroupId: ( long long  groupId)
virtual

Returns a list of devices in a group. The synchronous queue.

Parameters
groupIdThe group ID.

◆ getDeviceListWithHomeId:()

NSArray< ThingSmartDeviceModel * > * getDeviceListWithHomeId: ( long long  homeId)
virtual

◆ getDeviceOtaInfoWithDevId:()

ThingSmartDeviceOTAModel * getDeviceOtaInfoWithDevId: ( NSString *  devId)
virtual

Returns a device OTA information.

Parameters
devIdThe device ID.

◆ getGroupInfoWithGroupId:()

ThingSmartGroupModel * getGroupInfoWithGroupId: ( long long  groupId)
virtual

Returns the group cache information by group ID. The synchronous queue.

Parameters
groupIdThe group ID.

◆ getGroupProductWithProductId:()

NSDictionary * getGroupProductWithProductId: ( NSString *  productId)
virtual

Returns the group product information by product ID. The synchronous queue.

Parameters
productIdThe product ID.

◆ getGroupProductWithProductId:productVer:()

NSDictionary * getGroupProductWithProductId:productVer: ( NSString *  productId,
[productVer] NSString *  productVer 
)
virtual

Returns the group product information by product ID and productVer .

Parameters
productIdThe product ID.
productVerThe product Version.

◆ getMeshGroupAddressFromLocalWithMeshId:()

NSInteger getMeshGroupAddressFromLocalWithMeshId: ( NSString *  meshId)
virtual

◆ getMeshGroupCountFromLocalWithMeshId:()

NSInteger getMeshGroupCountFromLocalWithMeshId: ( NSString *  meshId)
virtual

◆ getMeshModelWithMeshId:()

ThingSmartBleMeshModel * getMeshModelWithMeshId: ( NSString *  meshId)
virtual

Returns the mesh information. The synchronous queue.

Parameters
meshIdThe mesh ID.

◆ getThingModelWithProductId:productVersion:()

nullable ThingSmartThingModel * getThingModelWithProductId:productVersion: ( NSString *  productId,
[productVersion] NSString *  productVersion 
)
virtual

◆ hasAdvancedAbilityWithDevId:code:()

BOOL hasAdvancedAbilityWithDevId:code: ( NSString *  devId,
[code] NSString *  code 
)
virtual

◆ removeDeviceWithDevId:()

void removeDeviceWithDevId: ( NSString *  devId)
virtual

Deletes the cached data of the device by device ID.

If the data is already deleted, the deletion task is not run to avoid duplicate operations. After the deletion, the subscription to the MQTT topic of the device is canceled. During the deletion process, you can handle the result of the event by implementing deviceDidRemove: of ThingCoreCacheServiceDelegate. The tasks to delete devices, unsubscribe from messages, and execute callbacks are run in the asynchronous thread. The asynchronous queue.

Parameters
devIdThe ID of the device to be removed.

◆ removeDeviceWithDevId:completion:()

void removeDeviceWithDevId:completion: ( NSString *  devId,
[completion] nullable void(^)(NSString *devId)  completion 
)
virtual

Delete the cached data of the device by device ID.

If the data is already deleted, the deletion task is not run to avoid duplicate operations. After deletion, the subscription to the MQTT topic of the device is canceled. During the deletion process, you can set the completion block or implement deviceDidRemove: as a proxy for ThingCoreCacheServiceDelegate to handle the result of the event. The completion block is called and followed by the delegate. The tasks to add devices, subscribe to messages, block, and execute callbacks are run in the asynchronous thread. The asynchronous queue.

Parameters
devIdThe device ID to be deleted.
completionThe callback block after the completion of the deletion.

◆ removeGroupWithGroupId:()

void removeGroupWithGroupId: ( long long  groupId)
virtual

Deletes the cached data of a group by group ID.

If the group is already deleted, the deletion task is not run to avoid duplicate operations. After deletion, the subscription to the MQTT topic of the device is canceled. During the deletion process, you can handle the result of the event by implementing groupDidRemove: of ThingCoreCacheServiceDelegate. The tasks to delete groups, unsubscribe from messages, and execute callbacks are run in the asynchronous thread. The asynchronous queue.

Parameters
groupIdThe device ID to be removed.

◆ removeMeshGroupWithAddress:meshId:()

void removeMeshGroupWithAddress:meshId: ( NSInteger  address,
[meshId] NSString *  meshId 
)
virtual

◆ reset()

void reset ( )
virtual

Clears the cached data. The asynchronous queue.

◆ setCacheHandlerQueue:()

void setCacheHandlerQueue: ( dispatch_queue_t  queue)
virtual

Sets the queue for processing the cached data.

Parameters
queueThe queue.

◆ updateDeviceGroupRelationWithDeviceList:groupId:()

void updateDeviceGroupRelationWithDeviceList:groupId: ( NSArray deviceList,
[groupId] long long  groupId 
)
virtual

The batch update group allows you to update device information relationships. The asynchronous queue.

Parameters
deviceListThe device list.
groupIdThe group ID.

◆ updateDeviceGroupRelationWithDeviceList:groupId:shouldNotify:()

void updateDeviceGroupRelationWithDeviceList:groupId:shouldNotify: ( NSArray deviceList,
[groupId] long long  groupId,
[shouldNotify] BOOL  shouldNotify 
)
virtual

The batch update group allows you to update device information relationships. The asynchronous queue.

Parameters
deviceListThe device list.
groupIdThe group ID.
shouldNotifySpecifies whether to send notifications. If the value is set to yes, kNotificationGroupUpdate is sent.

◆ updateDeviceOtaInfoWithList:()

void updateDeviceOtaInfoWithList: ( NSArray< ThingSmartDeviceOTAModel * > *  otaList)
virtual

Updates the over-the-air (OTA) information.

Parameters
otaListA list of device OTA information.

◆ updateDeviceOtaInfoWithList:completion:()

void updateDeviceOtaInfoWithList:completion: ( NSArray< ThingSmartDeviceOTAModel * > *  otaList,
[completion] nullable void(^)(NSArray< ThingSmartDeviceOTAModel * > *)  completion 
)
virtual

Updates the over-the-air (OTA) information.

Parameters
otaListA list of device OTA information.
completionThe callback block after the completion of the update.

◆ updateDeviceOtaMode:()

void updateDeviceOtaMode: ( ThingSmartDeviceOTAModel otaModel)
virtual

update the over-the-air (OTA) information.

Parameters
otaModeldevice OTA information.

◆ updateDeviceOtaModel:completion:()

void updateDeviceOtaModel:completion: ( ThingSmartDeviceOTAModel otaModel,
[completion] nullable void(^)(ThingSmartDeviceOTAModel *)  completion 
)
virtual

update the over-the-air (OTA) information.

Parameters
otaModeldevice OTA information.
completionThe callback block after the completion of the update.

◆ updateGroupProductList:()

void updateGroupProductList: ( NSArray< NSDictionary * > *  groupProductList)
virtual

Updates information about multiple products in an operation. The asynchronous queue.

Parameters
groupProductListA list of product information in the JSON format.

◆ updateMeshModel:()

void updateMeshModel: ( ThingSmartBleMeshModel meshModel)
virtual

Updates mesh information. The synchronous queue.

Parameters
meshModelThe mesh information.

◆ validateCachRoamDeviceSN:()

BOOL validateCachRoamDeviceSN: ( NSDictionary *  message)
virtual

Verify that the SN of the current device is valid. If yes is returned, the cache is updated

Parameters
messagemqtt message

Variable Documentation

◆ delegate

id<ThingCoreCacheServiceDelegate> delegate
readwritenonatomicweak

The devices and group core cache classes allow you to add, modify, and delete data models. You can also subscribe to MQTT messages.

Definition at line 30 of file ThingCoreCacheService.h.

◆ deviceData

NSMutableDictionary<NSString *, ThingSmartDeviceModel *>* deviceData
readnonatomicstrong

The device cache.

Definition at line 33 of file ThingCoreCacheService.h.

◆ groupData

NSMutableDictionary<NSString *, ThingSmartGroupModel *>* groupData
readnonatomicstrong

The group caching.

Definition at line 36 of file ThingCoreCacheService.h.

◆ groupDeviceRelation

NSMutableDictionary<NSString *, NSMutableArray<NSString *> *>* groupDeviceRelation
readnonatomicstrong

The group device relationship cache.

Definition at line 42 of file ThingCoreCacheService.h.

◆ groupProductData

NSMutableDictionary<NSString *, NSDictionary *>* groupProductData
readnonatomicstrong

The group product information cache.

Definition at line 39 of file ThingCoreCacheService.h.

◆ meshData

NSMutableDictionary<NSString *, ThingSmartBleMeshModel *>* meshData
readnonatomicstrong

The mesh information.

Definition at line 45 of file ThingCoreCacheService.h.

◆ meshGroupAddData

NSMutableDictionary* meshGroupAddData
readnonatomicstrong

The mesh group information.

Definition at line 48 of file ThingCoreCacheService.h.