Overview
Gets detailed battery information from a reader that uses a PowerPrecision+ (PP+) battery, using srfidGetBatteryStatus. For the charge level and charging state only, use the battery event described in Knowing Battery Status.
Details
The srfidGetBatteryStatus:batteryStatusArray:aStatusMessage: method returns the battery information as an array of srfidRfidBatteryStatusInformation objects. Each object holds one item: call getBatteryStatusTittle to get its name and getBatterStatusValue to get its value, both as strings. The array contains items such as the following:
GIFTED_BATTERY_PERCENTAGE: charge levelGIFTED_BATTERY_STATE_OF_HEALTH: battery healthGIFTED_BATTERY_CYCLE_COUNT: number of charge cyclesGIFTED_BATTERY_VOLTAGE,GIFTED_BATTERY_CURRENTandGIFTED_BATTERY_PACK_TEMPERATUREGIFTED_BATTERY_DESIGN_CAPACITY,GIFTED_BATTERY_FULL_CHARGE_CAPACITYandGIFTED_BATTERY_REMAINING_CAPACITYGIFTED_BATTERY_CHARGING_Y_N,GIFTED_BATTERY_CHARGE_STATUSandGIFTED_BATTERY_TIME_TO_FULL_CHARGEGIFTED_BATTERY_MODEL_NUMBER,GIFTED_BATTERY_MANUFACTURE_DATE,GIFTED_BATTERY_SERIAL_NUMBERandGIFTED_BATTERY_ID
The statusMessage parameter returns a status message from the reader when the call does not succeed.
/// Get battery status
/// @param readerID The reader id
/// @param statusMessage The status message
-(SRFID_RESULT)getBatteryStatus:(int)readerID aStatusMessage:(NSString**)statusMessage {
NSMutableArray *batteryStatusValueList = [[NSMutableArray alloc] init];
SRFID_RESULT srfid_result = SRFID_RESULT_FAILURE;
for(int i = 0; i < 3; i++)
{
srfid_result = [apiInstance srfidGetBatteryStatus:readerID batteryStatusArray:&batteryStatusValueList aStatusMessage:statusMessage];
if ((srfid_result != SRFID_RESULT_RESPONSE_TIMEOUT) && (srfid_result != SRFID_RESULT_FAILURE))
{
break;
}
}
if (srfid_result == SRFID_RESULT_SUCCESS)
{
for (srfidRfidBatteryStatusInformation *info in batteryStatusValueList) {
NSLog(@"%@: %@", [info getBatteryStatusTittle], [info getBatterStatusValue]);
}
}
else if(srfid_result == SRFID_RESULT_RESPONSE_ERROR)
{
NSLog(@"Get battery status: response error");
}
else if(srfid_result == SRFID_RESULT_FAILURE || srfid_result == SRFID_RESULT_RESPONSE_TIMEOUT)
{
NSLog(@"Get battery status: failure or timeout");
}
return srfid_result;
}