{{getTexts.ios.headers}}
{{getTexts.blutoothTran}}
<TTLock/TTLock.h>   //调用方法类
<TTLock/TTSDKDelegate.h>  //代理方法类
<TTLock/TTSpecialValueUtil.h> //特征值工具类
<TTLock/TTUtils.h>
<TTLock/SecurityUtil.h>
<TTLock/TTLock.h>   // Call method class
<TTLock/TTSDKDelegate.h>  // Delegate class
<TTLock/TTSpecialValueUtil.h> // Special value tool class
<TTLock/TTUtils.h>
<TTLock/SecurityUtil.h>
{{getTexts.gateway}}
<TTLock/TTLockGateway.h>
{{getTexts.staUpdate}}
<TTLock/TTLockDFU.h>
{{getTexts.ios.instructions.ttlockUsage}}
  1. {{getTexts.ios.instructions.usage_1}}

    #import <TTLock/TTLock.h>
  2. {{getTexts.ios.instructions.usage_2}}

    TTLock *TTObject = [[TTLock alloc]initWithDelegate:self];
  3. {{getTexts.ios.instructions.usage_3}}

    [TTObject setupBlueTooth];
  4. {{getTexts.ios.instructions.usage_4}}

    [TTLock setDebug:YES];
  5. {{getTexts.ios.instructions.usage_5}}

    -(void)TTManagerDidUpdateState:(TTManagerState)state{
    
        if (state == TTManagerStatePoweredOn) {
    		[_TTObject startBTDeviceScan:YES];
        }else if (state == TTManagerStatePoweredOff){
    		[_TTObject stopBTDeviceScan];
        }else if (state == TTManagerStateUnsupported){
            NSLog(@"Your device does not support ble4.0, unable to use our app.");   
        }
    
    }
  6. {{getTexts.ios.instructions.usage_6}}

    Key Type Description
    peripheralCBPeripheral搜索到的蓝牙对象
    rssiint信号值
    lockNameNSString锁名
    lockMacNSString锁的mac地址
    isContainAdminBOOL锁是否存在管理员
    isAllowUnlockBOOLYES为有人摸锁(车位锁一直为NO)
    oneMeterRSSIint三代锁广播中的一个离锁一米左右的rssi,其他锁为一个固定值-85
    protocolTypeint协议类别 例:5 是门锁 10 是车位锁
    protocolVersion int {{getTexts.ios.instructions.usage_6_9}}
    protocolType == 5 && protocolVersion == 1 {{getTexts.ios.instructions.usage_6_9_1}}
    protocolType == 5 && protocolVersion == 4 {{getTexts.ios.instructions.usage_6_9_2}}
    protocolType == 5 && protocolVersion == 3 {{getTexts.ios.instructions.usage_6_9_3}}
    sceneDoorSceneType
    lockSwitchStateTTLockSwitchState
    doorSensorStateTTDoorSensorState
    electricQuantityint
  7. {{getTexts.ios.instructions.usage_7}}

    [TTObject connectPeripheralWithLockMac:(NSString *)lockMac];
  8. {{getTexts.ios.instructions.usage_8}}

    -(void)onBTConnectSuccess_peripheral:(CBPeripheral *)peripheral lockName:(NSString*)lockName {
        [TTObject stopBTDeviceScan];
      	TTObject.uid = openid;//服务器上用户的唯一标识,用于锁内部存储操  作记录可以调用与锁通讯的接口, 比如添加管理员,开门,校准时间等
    
    }
    
    -(void)onBTConnectSuccess_peripheral:(CBPeripheral *)peripheral lockName:(NSString*)lockName {
        [TTObject stopBTDeviceScan];
      	TTObject.uid = openid;	// Which user's operation is recorded,corresponding to the "openid" of the "openAPI".
    
    }
    
  9. {{getTexts.ios.instructions.usage_9}}

  10. {{getTexts.ios.instructions.usage_10}}

    [TTObject startBTDeviceScan];
{{getTexts.ios.instructions.attention}}
  1. {{getTexts.ios.instructions.att_1}}

    {{getTexts.ios.instructions.error}}
    -(void)onBTConnectSuccess_peripheral:(CBPeripheral )peripheral lockName:(NSString)lockName{ 
    	// unlock 
    	[TTObject unlockByUser_lockKey:lockKey 
    			aesKey:aesKeyStr 
    			startDate:startDate 
    			endDate:endDate 
    			version:version 
    			unlockFlag:unlockFlag 
    			uniqueid:uniqueid 
    			timezoneRawOffset:timezoneRawOffset]; 
    	
    	//calibrate time 
    	[TTObject setLockTime_lockKey:lockKey 
    			aesKey:aesKeyStr 
    			version:version 
    			unlockFlag:unlockFlag 
    			referenceTime:referenceTime 
    			timezoneRawOffset:timezoneRawOffset];
    }
    
    {{getTexts.ios.instructions.right}}
    -(void)onBTConnectSuccess_peripheral:(CBPeripheral *)peripheral lockName:(NSString*)lockName{
    
    	// unlock
    	[TTObject unlockByUser_lockKey:lockKey 
    	   		aesKey:aesKeyStr 
    	   		startDate:startDate 
    	   		endDate:endDate 
    	   		version:version 
    	   		unlockFlag:unlockFlag 
    	   		uniqueid:uniqueid 
    	   		timezoneRawOffset:timezoneRawOffset];
       
    }
    
    //after receiving the callback of unlock successfully
    -(void)onUnlockWithLockTime:(NSTimeInterval)lockTime{
    
    	//calibrate time
    	[TTObject setLockTime_lockKey:lockKey 
    			aesKey:aesKeyStr 
    			version:version 
    			unlockFlag:unlockFlag 
    			referenceTime:referenceTime 
    			timezoneRawOffset:timezoneRawOffset];
    
    }
    

  2. {{getTexts.ios.instructions.att_2}}

  3. {{getTexts.ios.instructions.att_3}}

  4. {{getTexts.ios.instructions.att_4}}

    TTObject.uid = openid;