TuyaSmartBLEManager Class Reference

Inherits from NSObject
Declared in TuyaSmartBLEManager.h

Other Methods

+ sharedInstance

+ (instancetype)sharedInstance

  isPoweredOn

蓝牙是否打开可用

@property (nonatomic, assign, readonly) BOOL isPoweredOn

Discussion

蓝牙是否打开可用

Declared In

TuyaSmartBLEManager.h

  delegate

代理,用于扫描和蓝牙状态变更通知

@property (nonatomic, weak) id<TuyaSmartBLEManagerDelegate> delegate

Discussion

代理,用于扫描和蓝牙状态变更通知

Declared In

TuyaSmartBLEManager.h

– startListening:

开始扫描

- (void)startListening:(BOOL)clearCache

Parameters

clearCache

是否清理已扫描到的设备

Discussion

开始扫描

如果扫描到未激活设备,结果会通过 TuyaSmartBLEManagerDelegate 中的 - (void)didDiscoveryDeviceWithDeviceInfo:(TYBLEAdvModel *)deviceInfo 返回;

如果扫描到激活设备,会自动进行连接入网,不会返回扫描结果

Declared In

TuyaSmartBLEManager.h

– stopListening:

停止扫描

- (void)stopListening:(BOOL)clearCache

Parameters

clearCache

是否清理已扫描到的设备

Discussion

停止扫描

Declared In

TuyaSmartBLEManager.h

– connectBLEWithUUID:productKey:success:failure:

连接设备

- (void)connectBLEWithUUID:(NSString *)uuid productKey:(NSString *)productKey success:(TYSuccessHandler)success failure:(TYFailureHandler)failure

Parameters

uuid

设备 uuid

productKey

产品 key

success

成功回调

failure

失败回调

Discussion

连接设备

Declared In

TuyaSmartBLEManager.h

– queryNameWithUUID:productKey:success:failure:

查询设备名称

- (void)queryNameWithUUID:(NSString *)uuid productKey:(NSString *)productKey success:(void ( ^ ) ( NSString *name ))success failure:(TYFailureError)failure

Parameters

uuid

设备 uuid

productKey

产品 key

success

成功回调

failure

失败回调

Discussion

查询设备名称

Declared In

TuyaSmartBLEManager.h

– activeBLEWithUUID:homeId:productKey:success:failure:

激活设备,设备 uuid 来源于搜索发现的设备 激活过程会将设备信息注册到云端

- (void)activeBLEWithUUID:(NSString *)uuid homeId:(long long)homeId productKey:(NSString *)productKey success:(void ( ^ ) ( TuyaSmartDeviceModel *deviceModel ))success failure:(TYFailureHandler)failure

Parameters

uuid

设备 uuid

homeId

家庭 id

productKey

产品 key

success

成功回调

failure

失败回调

Discussion

激活设备,设备 uuid 来源于搜索发现的设备 激活过程会将设备信息注册到云端

Declared In

TuyaSmartBLEManager.h

– activeBLE:homeId:success:failure:

激活设备,设备 uuid 来源于搜索发现的设备 激活过程会将设备信息注册到云端

- (void)activeBLE:(TYBLEAdvModel *)deviceInfo homeId:(long long)homeId success:(void ( ^ ) ( TuyaSmartDeviceModel *deviceModel ))success failure:(TYFailureHandler)failure

Parameters

deviceInfo

设备信息 Model

homeId

家庭 id

success

成功回调

failure

失败回调

Discussion

激活设备,设备 uuid 来源于搜索发现的设备 激活过程会将设备信息注册到云端

Declared In

TuyaSmartBLEManager.h

– sendOTAPack:otaData:success:failure:

发送OTA包,升级固件。升级前请务必保证设备已通过蓝牙连接

- (void)sendOTAPack:(NSString *)uuid otaData:(NSData *)otaData success:(TYSuccessHandler)success failure:(TYFailureHandler)failure

Parameters

uuid

设备 uuid

otaData

升级固件的数据

success

成功回调

failure

失败回调

Discussion

发送OTA包,升级固件。升级前请务必保证设备已通过蓝牙连接

Declared In

TuyaSmartBLEManager.h

– sendOTAPack:pid:otaData:success:failure:

发送OTA包,升级固件。升级前请务必保证设备已通过蓝牙连接

- (void)sendOTAPack:(NSString *)uuid pid:(NSString *)pid otaData:(NSData *)otaData success:(TYSuccessHandler)success failure:(TYFailureHandler)failure

Parameters

uuid

设备 uuid

pid

设备 pid

otaData

升级固件的数据

success

成功回调

failure

失败回调

Discussion

发送OTA包,升级固件。升级前请务必保证设备已通过蓝牙连接

Declared In

TuyaSmartBLEManager.h

– sendOTAPack:pid:otaData:otaType:otaVersion:success:failure:

发送OTA包,升级固件。升级前请务必保证设备已通过蓝牙连接

- (void)sendOTAPack:(NSString *)uuid pid:(NSString *)pid otaData:(NSData *)otaData otaType:(TuyaSmartBLEOTAType)otaType otaVersion:(NSString *)otaVersion success:(TYSuccessHandler)success failure:(TYFailureHandler)failure

Parameters

uuid

设备 uuid

pid

设备 pid

otaData

升级固件的数据

otaType

升级类型

otaVersion

升级版本

success

成功回调

failure

失败回调

Discussion

发送OTA包,升级固件。升级前请务必保证设备已通过蓝牙连接

Declared In

TuyaSmartBLEManager.h

– getPeripheralRSSI:

获取蓝牙外设的信号

- (NSInteger)getPeripheralRSSI:(NSString *)uuid

Parameters

uuid

设备 uuid

Return Value

设备信号,若为 0,则获取失败。

Discussion

获取蓝牙外设的信号

Declared In

TuyaSmartBLEManager.h

– deviceStatueWithUUID:

根据 UUID 来判断设备是否已连接

- (BOOL)deviceStatueWithUUID:(NSString *)uuid

Parameters

uuid

设备 uuid

Return Value

该设备是否连接

Discussion

根据 UUID 来判断设备是否已连接

Declared In

TuyaSmartBLEManager.h

Channel Methods

– isBLEChannelDeviceConnect:

判断设备是否已连接 check the device is connected.

- (BOOL)isBLEChannelDeviceConnect:(NSString *)uuid

Parameters

uuid

设备id

Return Value

connected

Discussion

判断设备是否已连接 check the device is connected.

Declared In

TuyaSmartBLEManager+Channel.h

– setCompletionBlock:uuid:

判断设备是否已连接 check the device is connected.

- (void)setCompletionBlock:(TPBleResultBlock)block uuid:(NSString *)uuid

Parameters

block

回调

uuid

设备id

Discussion

判断设备是否已连接 check the device is connected.

Declared In

TuyaSmartBLEManager+Channel.h

– appApplyLaunch:

APP 申请启动大数据通道

- (void)appApplyLaunch:(NSString *)uuid

Parameters

uuid

设备id

Discussion

APP 申请启动大数据通道

Declared In

TuyaSmartBLEManager+Channel.h

– appMandatoryTrans:

APP 强制传输终止

- (BOOL)appMandatoryTrans:(NSString *)uuid

Parameters

uuid

设备id

Discussion

APP 强制传输终止

Declared In

TuyaSmartBLEManager+Channel.h