Open Platform
Skip to content

Lock or Unlock ​

Unlock ​

Diagrammatic drawing

img

Code ​

The range is only about 10 meters when you unlock the lock through bluetooth, but gateway can do it remotely.

c
/*Unlock*/
[TTLock controlLockWithControlAction:TTControlActionUnlock lockData:_keyModel.lockData success:^{
      NSLog(@"##############  Unlock success  ##############");
    } failure:^(TTError errorCode, NSString *errorMsg) {
        NSLog(@"##############  error: %@  ##############",errorMsg);
    }];
c
/*Suggestion:Getting the lock latest logs and set time after unlock*/
 
- (void)unlockThenGetLogThenSetTime{
 
     //Unlock
    [TTLock controlLockWithControlAction:TTControlActionUnlock lockData:lockData success:^(long long lockTime, NSInteger electricQuantity, long long uniqueId) {
        NSLog(@"##############  Unlock successed power: %ld  ##############",(long)electricQuantity);
    } failure:^(TTError errorCode, NSString *errorMsg) {
        NSLog(@"##############  Unlock failed errorMsg: %@  ##############",errorMsg);
    }];
 
     //Get logs
    [TTLock getOperationLogWithType:TTOperateLogTypeLatest lockData:lockData success:^(NSString *operateRecord) {
        //[Network uploadLog:operateRecord completion:nil];
        NSLog(@"##############  Log: %@  ##############",operateRecord);
    } failure:^(TTError errorCode, NSString *errorMsg) {
        NSLog(@"##############  Get log failed errorMsg: %@  ##############",errorMsg);
    }];
 
     //Set time
    //timestamp(millisecond)     [TTLock setLockTimeWithTimestamp:timestamp lockData:lockData success:^{
        NSLog(@"##############  Set time successed  ##############");
    } failure:^(TTError errorCode, NSString *errorMsg) {
        NSLog(@"##############  Set time failed errorMsg: %@  ##############",errorMsg);
    }];
}
CopyRight © 2012-2026 TTLock.All Rights Reserved