Latest 0.0.2
Homepage https://github.com/sk344208651/SmartKit
License MIT
Platforms ios 8.0
Dependencies CocoaLumberjack, AFNetworking, SocketRocket, CocoaAsyncSocket
Frameworks Security, CFNetwork, Foundation, SmartKit
Authors

Version
License
Platform

SmartKit是华三智慧家SDK,开发者可基于此SDK开发用于控制网关设备的APP。SmartKit依赖于其他第三方库和系统基础库。

如何开始

联系我们

  • 如果你 需要帮助, 发送电子邮件到 [email protected] 邮箱,我们会尽快与您联系。
  • 如果你 发现了BUG, 并且能够复现它, 创建一条issue,我们会尽快解决该BUG.

集成

SmartKit 现在只支持CocoaPods,将来我们会进一步支持其他集成方式。

使用CocoaPods集成

CocoaPods是Objective-C依赖管理工具, 使用CocoaPods能很方便地集成第三方库。你可以用下面的命令安装CocoaPods:

$ gem install cocoapods

Podfile

想要使用CocoaPods在项目中集成,你要在Podfile中这样声明:

platform :ios, '8.0'

target 'TargetName' do
    pod 'SmartKit'
end

然后,运行下面的命令:

$ pod install

系统要求

SmartKit 版本 iOS最低支持版本 watchOS最低支持版本 tvOS最低支持版本 Notes
0.0.x iOS 8 将来支持 将来支持 需要Xcode 7以上版本.

未来将支持Swift语言。

用法

SKGatewayBrowser

SKGatewayBrowser 网关浏览器用于搜索当前wifi网段内网关.

搜索当前wifi网段内网关

SKGatewayBrowser *gatewayBrowser = [[SKGatewayBrowser alloc] init];
[gatewayBrowser startBrowseGateway];
//从委托中获取搜索到的网关
-(void)browser:(SKGatewayBrowser *) browser didFoundGateway:(SKGateway *) gateway;

SKGatewayManager

SKGatewayManager 网关管理器,用于增加或删除设备到网关,用于在网关上部署触发器,用于更新网关上设备和场景信息

获取到网关下的设备

SKGatewayManager *gatewayManager = [SKGatewayManager managerForGateway:gateway];
[gatewayManager updateDevices];
//获取到网关下的设备
NSArray *deviceArr = gatewayManager.gateway.devices;

SKUserManager

SKUserManager 用户管理器,单例类,用于用户登录,注册,重置密码等。也用于管理用户和网关的绑定关系和打开某些服务

绑定网关

SKUserManager *userManager = [SKUserManager userManager];
//绑定网关
[userManager startBindingGateway:gateway];
//从委托中获取绑定网关的结果
-(void)manager:(SKUserManager * __nonnull) manager didBindingGateway:(SKGateway * __nonnull) gateway;
-(void)manager:(SKUserManager * __nonnull) manager bindingGateway:(SKGateway * __nonnull) gateway failed:(NSError * __nullable) error;

获取到用户绑定的网关

SKUserManager *userManager = [SKUserManager userManager];
[userManager loginWith:@"username" passwd:@"passwd"];
//刷新网关信息
[userManager updateGateways];
//获取到用户绑定的网关
NSArray *gatewayArr = userManager.user.gateways;

SKProperty

SKProperty 属性类,用于描述产品属性,通过本类可以读取或修改属性的具体值

获取设备属性

SKGateway *gateway = ...获取网关对象;
SKDevice *device = [gateway deviceForPortNum:portNum];
//获取设备名称
[device.name updateValue:nil completionHandler:^(NSError *error){
    if (!error) {
    //修改名称成功
    }else{
    //修改名称失败
    }
}];

修改设备属性

SKGateway *gateway = ...获取网关对象;
SKDevice *device = [gateway deviceForPortNum:portNum];
//修改设备名称
[device.name updateValue:@"空调_4" completionHandler:^(NSError *error){
    if (!error) {
    //修改名称成功
    }else{
    //修改名称失败
    }
}];

SKTriggerManager

SKTriggerManager 触发器管理器,用于下发动作集,更新动作集等操作

获取动作集

SKGateway *gateway = ...获取网关对象;
SKTrigger *trigger = [gateway triggerForTriggerId:triggerId];
SKTriggerManager *triggerManager = [SKTriggerManager managerForTrigger:trigger];
//获取动作集
[triggerManager updateActionSet:nil];
//从委托中获取请求的结果
-(void)manager:(SKTriggerManager * __nonnull) manager didUpdateActionSet:(NSSet<SKAction *> * __nonnull) actionSet;
-(void)manager:(SKTriggerManager * __nonnull) manager updateActionSet:(NSSet<SKAction *> * __nonnull) actionSet failed:(NSError * __nullable) error;

下发动作集

SKGateway *gateway = ...获取网关对象;
SKTrigger *trigger = [gateway triggerForTriggerId:triggerId];
SKTriggerManager *triggerManager = [SKTriggerManager managerForTrigger:trigger];
SKAirConditioner *airConditioner = [gateway deviceForPortNum:airConditionerPortNum];
//设置空调温度动作
SKPropertyModifyAction *setTempModifyAction = [[SKPropertyModifyAction alloc] init];
setTempModifyAction.property = airConditioner.setTemp;
setTempModifyAction.targetValue = @(30);
//下发动作集
[triggerManager updateActionSet:[NSSet setWithObjects:setTempModifyAction,nil]];
//从委托中获取请求的结果
-(void)manager:(SKTriggerManager * __nonnull) manager didUpdateActionSet:(NSSet<SKAction *> * __nonnull) actionSet;
-(void)manager:(SKTriggerManager * __nonnull) manager updateActionSet:(NSSet<SKAction *> * __nonnull) actionSet failed:(NSError * __nullable) error;

删除全部动作集

SKGateway *gateway = ...获取网关对象;
SKTrigger *trigger = [gateway triggerForTriggerId:triggerId];
SKTriggerManager *triggerManager = [SKTriggerManager managerForTrigger:trigger];
//删除动作集
[triggerManager updateActionSet:[NSSet set]];
//从委托中获取请求的结果
-(void)manager:(SKTriggerManager * __nonnull) manager didUpdateActionSet:(NSSet<SKAction *> * __nonnull) actionSet;
-(void)manager:(SKTriggerManager * __nonnull) manager updateActionSet:(NSSet<SKAction *> * __nonnull) actionSet failed:(NSError * __nullable) error;

License

SmartKit is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "SmartKit",
    "version": "0.0.2",
    "summary": "SmartKitu662fu534eu4e09u667au6167u5bb6SDKuff0cu5f00u53d1u8005u53efu57fau4e8eu6b64SDKu5f00u53d1u7528u4e8eu63a7u5236u7f51u5173u8bbeu5907u7684APP.",
    "homepage": "https://github.com/sk344208651/SmartKit",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "u6c88u51ef": "[email protected]"
    },
    "source": {
        "git": "https://github.com/sk344208651/SmartKit.git",
        "tag": "0.0.2"
    },
    "platforms": {
        "ios": "8.0"
    },
    "vendored_frameworks": "SmartKit/Frameworks/*.framework",
    "frameworks": [
        "Security",
        "CFNetwork",
        "Foundation",
        "SmartKit"
    ],
    "dependencies": {
        "CocoaLumberjack": [
            "~> 2.2.0"
        ],
        "AFNetworking": [
            "~> 3.0"
        ],
        "SocketRocket": [
            "~> 0.4.2"
        ],
        "CocoaAsyncSocket": [
            "~> 7.4.3"
        ]
    }
}

Pin It on Pinterest

Share This