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

标签 ios socketscan

我每次都得到 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/

相关文章:

android - 设置扫描持续时间

iphone - 检查文本字段文本是否几乎等于字符串

ios - 由于现有项目的 Xcode 12 uitextfields 具有黑色背景

ios - NumberFormatter 错误结果为 0.9972

ios - 无论我将构建版本或应用程序版本更改为什么,都会出现 ITEMS-4238 "Redundant Binary Upload"错误

ios - 在 iOS 中重新加载 ViewController 时套接字条形码扫描仪 sdk 崩溃

android - 无法让套接字扫描 api 与 oreo 8.1 一起使用

ios - SocketScan 在 Swift 中获取电池电量

android - 在 xamarin 表单设计方面需要帮助