Latest 2.6.4
Homepage https://github.com/ttlock/ios_sdk_demo
License MIT
Platforms ios 7.0, requires ARC
Frameworks CoreBluetooth
Authors

步骤:
1.下载SDK压缩包并解压缩,将其拖到 Xcode 项目中。

2.在应用的设置中Build Phases -> Link Binary With Libraries 里添加以下 framework:CoreBluetooth

3.重要! 在应用对应 target 的设置中,Build Settings -> Linking 项下的 Other Linker Flags 中添加 -ObjC(如果已有,则不需要再添加)注意 O,C 大写

4.创建蓝牙对象
TTLock *TTObject = [[TTLock alloc]initWithDelegate:self];
[TTObject setupBlueTooth];// 启动蓝牙,开始扫描周边设备
[TTLock setDebug:YES];// 是否打开SDK日志 YES打印,NO不打印 默认为No

5.在蓝牙的状态改变TTLockManagerDidUpdateState的回调中,执行以下代码
if (central.state == CBCentralManagerStatePoweredOn) {
[_TTObject startBTDeviceScan];
}else if (central.state == CBCentralManagerStatePoweredOff){
[_TTObject stopBTDeviceScan];
}

6.扫描到设备后,会执行onFoundDevice_peripheral代理方法,这里可以获取到外设的基本信息,如蓝牙名,mac地址,广播的数据等。

7.在上面扫描到外设方法中 可以去连接特定的蓝牙
[TTObject connect:peripheral];

8.连接成功后,会执行onBTConnectSuccess_peripheral代理方法,在这里可以对锁发指令,比如添加管理员,开门,重置电子钥匙等。

Latest podspec

{
    "name": "TTLockSDK",
    "version": "2.6.4",
    "summary": "TTLock SDK for iOS.",
    "homepage": "https://github.com/ttlock/ios_sdk_demo",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "ttlock": "[email protected]"
    },
    "platforms": {
        "ios": "7.0"
    },
    "source": {
        "git": "https://github.com/ttlock/ios_sdk_demo.git",
        "tag": "2.6.4"
    },
    "source_files": "TTLockSDK/*.h",
    "preserve_paths": "TTLockSDK/*.a",
    "frameworks": "CoreBluetooth",
    "requires_arc": true
}

Pin It on Pinterest

Share This