- {{getTexts.connectLock}}
[TTObject connectPeripheralWithLockMac:(NSString *)lockMac];
- {{getTexts.ios.bluetooth.tip_2}}
-(void)onBTConnectSuccess_peripheral:(CBPeripheral *)peripheral lockName:(NSString*)lockName{
[_TTObject stopBTDeviceScan];
self.TTObject.uid = openid; // 服务器上用户的唯一标识,用于锁内部存储操 作记录
NSTimeInterval time = [[NSDate date] timeIntervalSince1970];
NSNumber *uniqueid = [NSNumber numberWithInt:time];
//管理员调用
[self.TTObject unlockByAdministrator_adminPS:
lockKey:
aesKey:
version:
unlockFlag:
uniqueid:];
//普通用户调用
NSDate *startDate = [NSDate dateWithTimeIntervalSince1970:self.currentKey.startDate/1000];
NSDate *endDate = [NSDate dateWithTimeIntervalSince1970:self.currentKey.endDate/1000];
[self.TTObject unlockByUser_lockKey:
aesKey:
startDate:
endDate:
version:
lockFlagPos:
uniqueid:
timezoneRawOffset:];
}
-(void)onBTConnectSuccess_peripheral:(CBPeripheral *)peripheral lockName:(NSString*)lockName{
[_TTObject stopBTDeviceScan];
self.TTObject.uid = openid; // Which user's operation is recorded,corresponding to the "openid" of the "openAPI".
NSTimeInterval time = [[NSDate date] timeIntervalSince1970];
NSNumber *uniqueid = [NSNumber numberWithInt:time];
// admin call
[self.TTObject unlockByAdministrator_adminPS:
lockKey:
aesKey:
version:
unlockFlag:
uniqueid:];
// ekey call
NSDate *startDate = [NSDate dateWithTimeIntervalSince1970:self.currentKey.startDate/1000];
NSDate *endDate = [NSDate dateWithTimeIntervalSince1970:self.currentKey.endDate/1000];
[self.TTObject unlockByUser_lockKey:
aesKey:
startDate:
endDate:
version:
lockFlagPos:
uniqueid:
timezoneRawOffset:];
}
- {{getTexts.ios.bluetooth.tip_3}}
// 成功的回调
-(void)onUnlockWithLockTime:(NSTimeInterval)lockTime electricQuantity:(int)electricQuantity{
[self.TTObject setLockTime_lockKey:self.currentKey.lockKey
aesKey:self.currentKey.aesKeyStr
version:self.currentKey.lockVersion
unlockFlag:self.currentKey.lockFlagPos
referenceTime:[NSDate date]
timezoneRawOffset:self.currentKey.timezoneRawOffset];
}
// 失败的回调
-(void)onUnlockWithLockTime:(NSTimeInterval)lockTime electricQuantity:(int)electricQuantity{
// 如果返回“CRC校验出错”,可以重试一次以提高成功率
if (error == TTErrorDataCRCError) {
}
}
// A successful callback
-(void)onUnlockWithLockTime:(NSTimeInterval)lockTime electricQuantity:(int)electricQuantity{
[self.TTObject setLockTime_lockKey:self.currentKey.lockKey
aesKey:self.currentKey.aesKeyStr
version:self.currentKey.lockVersion
unlockFlag:self.currentKey.lockFlagPos
referenceTime:[NSDate date]
timezoneRawOffset:self.currentKey.timezoneRawOffset];
}
// A failed callback
-(void)onUnlockWithLockTime:(NSTimeInterval)lockTime electricQuantity:(int)electricQuantity{
// If you return the "CRC check error", you can try again to improve the success rate.
if (error == TTErrorDataCRCError) {
}
}