gpt4 book ai didi

ios - SocketScan 始终返回 100% 电池生命周期

转载 作者:行者123 更新时间:2023-11-29 11:58:59 24 4
gpt4 key购买 nike

我每次都得到 100% 的结果...为什么(iOS/SocketScan API v.10.2.227)?这是我的代码:

-(void) onGetBatteryInfo:(ISktScanObject*)scanObj {

SKTRESULT result=[[scanObj Msg]Result];
if(SKTSUCCESS(result)){

long batteryLevel = SKTBATTERY_GETCURLEVEL([[scanObj Property] getUlong]);
NSLog(@"BatteryInfo %ld", batteryLevel);

[self setBatteryLevel:batteryLevel];
[self.tableView reloadData];

} else {

NSLog(@"ES-GetBatteryInfo set status returned the error %ld",result);
}
}

谢谢,标记

scanner config

最佳答案

你能仔细检查以下...

viewDidLoad 中创建 ScanApiHelper 和一个计时器

if(ScanApi==nil) {
ScanApi=[[ScanApiHelper alloc]init];
[ScanApi setDelegate:self];
[ScanApi open];
ScanApiConsumer=[NSTimer scheduledTimerWithTimeInterval:.2 target:self selector:@selector(onTimer:) userInfo:nil repeats:YES];
}

您的计时器调用 doScanApiReceive

-(void)onTimer: (NSTimer*)theTimer{
if(theTimer==ScanApiConsumer){
[ScanApi doScanApiReceive];
}
}

最后,在收到 onDeviceArrival 通知

之前,您不会查询电池电量
-(void)onDeviceArrival:(SKTRESULT)result device:(DeviceInfo*)deviceInfo {
[ScanApi postGetBattery:deviceInfo Target:self Response:@selector(onGetBatteryInfo:)];
}

关于ios - SocketScan 始终返回 100% 电池生命周期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37868463/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com