I am using a Socket Mobile barcode scanner (Socket 7Xi) in my app. I have integrated the SDK from Socket Mobile (ScanApiSDK-10.2.227) and setup the scanner for iOS mode. My application receives barcodes as expected. However, the device seems to get a little cranky 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 the socket scanner in, and generally debug scanning issues.
I am using the following call to get the battery level:
[_scanApiHelper postGetBattery:_deviceInfo Target:self Response:@selector(onGetBattery:)];
Which gets 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 gets called, but the ulong I get back is 1677747200, which after calling the utility methods gives me a level=64, minLevel=0, maxLevel=64. Which should be interpreted as 100% (percentf = 100.00).
However, it seems to always return this value. Never anything less than fully charged.
I also tried the getBatteyLevel method on DeviceInfo, but that just returns nil.
How do I get the current battery level for my device?
Thanks!