Overview
Receives battery status from an active RFID reader, either as an asynchronous event after subscribing to events or on request, using srfidRequestBatteryStatus.
Details
A particular active RFID reader could send an asynchronous notification regarding battery status. The SDK will inform the application about received asynchronous battery status event if the application has subscribed for events of this type. The SDK also provides an ability to cause a particular active RFID reader to immediately send information about current battery status. The following examples demonstrate both requesting and processing of asynchronous battery status related notifications.
For detailed battery information from a reader that uses a PowerPrecision+ (PP+) battery, see PP + Battery Support.
Request Battery Status
The requestBatteryStatus method subscribes to battery events and asks the reader to send its battery status.
-(void)requestBatteryStatus {
/* subscribe for battery related events */
[apiInstance srfidSubsribeForEvents:SRFID_EVENT_MASK_BATTERY];
/* cause RFID reader to generate asynchronous battery status notification */
SRFID_RESULT result = [apiInstance srfidRequestBatteryStatus:readerID];
if (SRFID_RESULT_SUCCESS == result) {
NSLog(@"Request succeed\n");
}
else {
NSLog(@"Request failed\n");
}
}
Battery Status Event
The SDK calls srfidEventBatteryNotity: when the reader sends a battery status event. The method prints the battery level, the charging state and the event cause.
- (void)srfidEventBatteryNotity:(int)readerID aBatteryEvent:(srfidBatteryEvent *)batteryEvent {
/* print the received information regarding battery status */
NSLog(@"Battery status event received from RFID reader with ID = %d\n", readerID);
NSLog(@"Battery level: %d\n", [batteryEvent getPowerLevel]);
NSLog(@"Charging: %@\n", ((NO == [batteryEvent getIsCharging]) ? @"NO" : @"YES"));
NSLog(@"Event cause: %@\n", [batteryEvent getEventCause]);
}