//
|
// Tuyalib.m
|
// TYtest
|
//
|
// Created by kaede wei on 2021/1/21.
|
//
|
|
#import "Tuyalib.h"
|
|
@implementation Tuyalib
|
|
+ (Tuyalib *)sharedInstance {
|
|
static Tuyalib *sharedInstance = nil;
|
static dispatch_once_t onceToken;
|
dispatch_once(&onceToken, ^{
|
if (!sharedInstance) {
|
sharedInstance = [Tuyalib new];
|
}
|
});
|
return sharedInstance;
|
}
|
|
- (TuyaSmartRequest *)request {
|
if (!_request) {
|
_request = [[TuyaSmartRequest alloc] init];
|
}
|
return _request;
|
}
|
|
|
//开启调试模式
|
- (void) changeDebugMode:(BOOL)isDebug
|
{
|
[[TuyaSmartSDK sharedInstance] setDebugMode:isDebug];
|
}
|
|
|
#pragma mark 住宅
|
- (void)getHomeList {
|
[self.homeManager getHomeListWithSuccess:^(NSArray<TuyaSmartHomeModel *> *homes) {
|
// homes 家庭列表
|
|
} failure:^(NSError *error) {
|
NSLog(@"get home list failure: %@", error);
|
}];
|
}
|
|
//获取住宅token
|
- (void)getToken:(long long)homeId {
|
[[TuyaSmartActivator sharedInstance] getTokenWithHomeId:homeId success:^(NSString *token) {
|
NSLog(@"getToken success: %@", token);
|
// TODO: startConfigWiFi
|
} failure:^(NSError *error) {
|
NSLog(@"getToken failure: %@", error.localizedDescription);
|
}];
|
}
|
|
|
@end
|