Skip to content

Device Association

Device association can associate multiple devices. For example, the master device is a smart socket and the slave device is a smart switch.

Feature Description

See QuecDeviceModel Definition in Device Management

objc
#import <QuecDeviceKit/QuecDeviceKit.h>
/// Initialize
[QuecDeviceAssociationService sharedInstance]

Device Association Management

Associate Device

API

Associate a device.

objc
- (void)deviceAssociationWithList:(NSArray<QuecDeviceModel *> *)list
                           master:(QuecDeviceModel *)masterDevice
                          success:(QuecVoidBlock)success
                          failure:(QuecErrorBlock)failure;

Parameter

ParameterRequiredDescription
listYList of slave devices to be associated (element array of QuecDeviceModel).
masterDeviceYMaster device.
successNCallback function of successful request.
failureNCallback function of failed request.

Example

objc
[QuecDeviceAssociationService.sharedInstance deviceAssociationWithList:@[deviceModel] master:masterDevice success:^{
        /// Next Action
    } failure:^(NSError *error) {
        NSLog(@"check error: %@", error);
    }];

Query Device Association Information

API

Query device association information.

objc
- (void)getDeviceAssociationInfoWithMaster:(QuecDeviceModel *)masterDevice
                                      code:(NSString *)code
                                   success:(void(^)(QuecDeviceAssociationModel *model))success
                                   failure:(QuecErrorBlock)failure;

Parameter

ParameterRequiredDescription
masterDeviceYMaster device (QuecDeviceModel type).
codeYProperty identifier to be queried. Separate multiple properties by commas.
successNCallback function of successful request.
failureNCallback function of failed request.

QuecDeviceAssociationModel Definition

FieldTypeDescription
slaveDeviceListNSArray<QuecDeviceAssociationSlaveModel *> *Slave device data list.
masterDeviceQuecDeviceAssociationMasterModelMaster device data.

QuecDeviceAssociationSlaveModel Definition

FieldTypeDescription
deviceAssociationMasterIdNSIntegerMaster device ID.
deviceAssociationSlaveIdNSIntegerSlave device ID.
slaveDeviceKeyNSStringSlave DeviceKey.
slaveDeviceNameNSStringSlave device name.
slaveProductKeyNSStringSlave ProductKey.
tslDeviceDetailQuecProductTSLInfoModelTSL model.

See QuecProductTSLInfoModel Definition above.

QuecDeviceAssociationMasterModel Definition

FieldTypeDescription
deviceAssociationMasterIdNSIntegerMaster device ID.
masterProductKeyNSStringMaster ProductKey.
masterDeviceKeyNSStringMaster DeviceKey.
masterDeviceNameNSStringMaster device name.
siddhiNameNSStringRule name. Must be unique, composed of uppercase/lowercase English letters and digits, and 32 characters in length.

Example

objc
[QuecDeviceAssociationService.sharedInstance getDeviceAssociationInfoWithMaster:masterDevice code:@"" success:^(QuecDeviceAssociationModel * _Nonnull model) {
        /// Next Action
    } failure:^(NSError *error) {
        NSLog(@"check error: %@", error);
    }];

Disassociate Device

API

Disassociate a device.

objc
- (void)deviceDisassociationWithDevice:(QuecDeviceModel *)model success:(QuecVoidBlock)success failure:(QuecErrorBlock)failure;

Parameter

ParameterRequiredDescription
modelYDevice to be disassociated (QuecDeviceModel type).
successNCallback function of successful request.
failureNCallback function of failed request.

Example

objc
[QuecDeviceAssociationService.sharedInstance deviceDisassociationWithDevice:device success:^{
        /// Next Action
    } failure:^(NSError *error) {
        NSLog(@"check error: %@", error);
    }];

Configure Device Association

API

Configure device association.

objc
- (void)deviceAssociationConfigWithProductKey:(NSString *)productKey success:(void(^)(QuecDeviceAssociationConfig *config))success failure:(QuecErrorBlock)failure;

Parameter

ParameterRequiredDescription
productKeyYProductKey.
successNCallback function of successful request.
failureNCallback function of failed request.

QuecDeviceAssociationConfig Definition

FieldTypeDescription
productKeyNSStringMaster ProductKey.
masterItemCodeNSStringMaster category code.
slaveItemCodeNSStringSlave category code.
slaveDeviceLimitNSIntegerThe maximum number of slaves.
slaveProductKeyNSArray<NSString *> *Slave ProductKey array.

Example

objc
[QuecDeviceAssociationService.sharedInstance deviceAssociationConfigWithProductKey:@"pk" success:^(QuecDeviceAssociationConfig * _Nonnull config) {
        /// Next Action
    } failure:^(NSError *error) {
        NSLog(@"check error: %@", error);
    }];