Open Platform
Guideline
Card Encoder DLL
APP SDK V3
Cloud API V3
APP SDK(V2, LTS)
API-V2(Deprecated)
API-V1(Deprecated)
Add lock
  1. {@link onFoundDevice_peripheralWithInfoDic:} returns the parameter isContainAdmin, which must be NO before the administrator can be added.
    1
    [infoDic[@"isContainAdmin"] boolValue] == NO;

  2. Connect lock
    1
    [TTObject connectPeripheralWithLockMac:(NSString *)lockMac];

  3. Connection success executes a callback {@link onBTConnectSuccess_peripheral:lockName:}. Call the interface in this callback {@link lockInitializeWithInfoDic:}
    1
    2
    3
    4
    5
    -(void)onBTConnectSuccess_peripheral:(CBPeripheral *)peripheral lockName:(NSString*)lockName{
        [TTObject stopBTDeviceScan];
         
        [TTObject lockInitializeWithInfoDic:@{@"lockMac":_selectModel.lockMac,@"protocolType":@(_selectModel.protocolType),@"protocolVersion":@(_selectModel.protocolVersion)}];
    }

  4. After receiving a successful callback {@link onLockInitializeWithLockData:}, through network interface(v3/lock/initialize) uploading data.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
- (void)onLockInitializeWithLockData:(NSString *)lockData{
    NSMutableDictionary *parame = [NSMutableDictionary new];   
    parame[@"clientId"] = clientId;
    parame[@"accessToken"] = AccessToken;
    parame[@"date"] = @( [[NSDate date] timeIntervalSince1970]*1000 );
   parame[@"lockAlias"] = lockAlias;
    parame[@"lockData"] = lockData;
    
    [NetworkHelper apiPost:@"lock/initialize" parameters:parame completion:^(id info, NSError *error) {
        completion(info,error);
    }];
  
}