I am using the Socket Mobile barcode scanner (Socket 7Xi) in my application. I enabled the SDK from Socket Mobile (ScanApiSDK-10.2.227) and configured the scanner for iOS mode. My application receives barcodes as expected. However, the device seems a bit frustrated when the battery level is low (I think). I would like to display the battery level in the application, so I can remind users to plug in a socket scanner and generally debug scanning problems.
I use the following call to get the battery level:
[_scanApiHelper postGetBattery:_deviceInfo Target:self Response:@selector(onGetBattery:)]
What is returned in the following method:
-(void)onGetBattery:(ISktScanObject*)obj{ ISktScanProperty* property = [obj Property]; if (property){ unsigned char level = SKTBATTERY_GETCURLEVEL([property getUlong]); unsigned char minLevel = SKTBATTERY_GETMINLEVEL([property getUlong]); unsigned char maxLevel = SKTBATTERY_GETMAXLEVEL([property getUlong]); float levelf = level; float minLevelf = minLevel; float maxLevelf = maxLevel; float percentf = (levelf-minLevelf)/(maxLevelf-minLevelf)*100; NSLog(@"percent: %f", percentf); } }
The onGetBattery method is called, but the oolong that I get is 1677747200, which after calling the utility methods gives me the level = 64, minLevel = 0, maxLevel = 64. Which should be interpreted as 100% (% f = 100.00).
However, it always returns this value. Never anything but a fully charged one.
I also tried the getBatteyLevel method in DeviceInfo, but that just returns nil.
How to get the current battery level for my device?
Thanks!
source share