zebra_rfid_plugin 1.0.0
zebra_rfid_plugin: ^1.0.0 copied to clipboard
A Flutter plugin for Zebra RFID SDK (RFD40XX) with support for tag reading, writing, and locating.
Zebra RFID Plugin for Flutter #
A comprehensive Flutter plugin for integrating Zebra RFID SDK with support for tag reading, writing, locationing, and real-time event streaming. Designed for RFD40XX, RFD90XX, MC33XXR, RFD8500, and other Zebra RFID readers.
β¨ Features #
π·οΈ RFID Operations #
- Tag Reading: Real-time tag inventory with RSSI tracking
- Tag Writing: Write to EPC, USER, TID, and RESERVED memory banks
- Tag Locationing: Track and locate specific tags with distance measurement
- Batch Operations: Handle 25K+ tags efficiently
π‘ Device Management #
- Auto-Discovery: Automatically detect available RFID readers
- Connection Management: Connect/disconnect with status monitoring
- Battery Monitoring: Real-time battery level for handheld readers
- Trigger Support: Hardware trigger button integration
βοΈ Configuration #
- Antenna Power: Adjustable power levels (0-300)
- Beeper Control: Enable/disable audio feedback
- Session Management: S0, S1, S2, S3 session configuration
- Tag Population: Optimize for expected tag count
- Dynamic Power: Automatic power optimization
π Real-Time Events #
- Tag read events with count tracking
- Connection status updates
- Trigger press/release events
- Battery level notifications
- Operation status events
π± Supported Devices #
| Device | Connection | Status |
|---|---|---|
| RFD40XX | USB | β Fully Supported |
| RFD90XX | USB/Bluetooth | β Fully Supported |
| MC33XXR | USB/Bluetooth | β Fully Supported |
| RFD8500 | Bluetooth | β Fully Supported |
| FX7500 | Ethernet/Serial | β Supported |
| FX9600 | Ethernet | β Supported |
π Requirements #
Android #
- Minimum SDK: 26 (Android 8.0)
- Target SDK: 34 (Android 14)
- Zebra RFID SDK: 3.x (included)
Permissions #
Automatically handled by the plugin:
- β Bluetooth (for Bluetooth readers)
- β Location (required for Bluetooth scanning)
- β USB Host (for USB readers)
π Installation #
Step 1: Add Dependency #
Add to your pubspec.yaml:
dependencies:
zebra_rfid_plugin: ^1.0.0
Run:
flutter pub get
Step 2: Android Configuration #
Update android/app/build.gradle:
android {
compileSdkVersion 34
defaultConfig {
minSdkVersion 26
targetSdkVersion 34
}
}
Step 3: Initialize #
import 'package:zebra_rfid_plugin/zebra_rfid_plugin.dart';
// Initialize for USB readers (RFD40XX)
await ZebraRfidPlugin.initialize(transportType: 'SERVICE_USB');
// Or for Bluetooth readers
await ZebraRfidPlugin.initialize(transportType: 'SERVICE_SERIAL');
That's it! β The Zebra RFID SDK AAR is included in the plugin.
π Quick Start #
Basic Tag Scanning #
import 'package:zebra_rfid_plugin/zebra_rfid_plugin.dart';
class RfidScanner {
Future<void> scanTags() async {
// 1. Initialize SDK
await ZebraRfidPlugin.initialize(transportType: 'SERVICE_USB');
// 2. Get available readers
List<ReaderDevice> readers = await ZebraRfidPlugin.getAvailableReaders();
// 3. Connect to first reader
if (readers.isNotEmpty) {
await ZebraRfidPlugin.connect(readers.first.name);
}
// 4. Listen to tag reads
ZebraRfidPlugin.tagReadStream.listen((event) {
print('π Tag: ${event.tagId}');
print('πΆ RSSI: ${event.rssi} dBm');
print('π’ Count: ${event.count}');
});
// 5. Start scanning
await ZebraRfidPlugin.startInventory();
// 6. Stop when done
await Future.delayed(Duration(seconds: 5));
await ZebraRfidPlugin.stopInventory();
}
}
π‘ Common Use Cases #
1. Retail Inventory #
class InventoryManager {
final Map<String, int> inventory = {};
Future<void> performInventory() async {
inventory.clear();
ZebraRfidPlugin.tagReadStream.listen((event) {
inventory[event.tagId] = (inventory[event.tagId] ?? 0) + 1;
});
await ZebraRfidPlugin.startInventory();
await Future.delayed(Duration(seconds: 10));
await ZebraRfidPlugin.stopInventory();
print('Found ${inventory.length} unique items');
}
}
2. Tag Cloning #
Future<void> cloneTag(String sourceTag, String targetTag) async {
// Extract EPC data (skip PC and CRC)
String epc = sourceTag.substring(8);
// Write to target tag
bool success = await ZebraRfidPlugin.writeTag(
tagId: targetTag,
data: epc,
memoryBank: 'EPC',
offset: 2, // Write EPC only
);
if (success) {
print('β
Tag cloned successfully!');
}
}
3. Asset Tracking #
Future<void> trackAsset(String assetTag) async {
// Start locationing
await ZebraRfidPlugin.startLocationing(assetTag);
// Monitor distance
ZebraRfidPlugin.tagReadStream.listen((event) {
if (event.locationInfo != null) {
double distance = event.locationInfo!;
print('Distance: ${distance.toStringAsFixed(2)}m');
if (distance < 1.0) {
print('π― Asset found!');
}
}
});
}
4. Batch Tag Writing #
Future<void> writeProductCodes(List<String> tagIds, List<String> productCodes) async {
for (int i = 0; i < tagIds.length; i++) {
try {
await ZebraRfidPlugin.writeTag(
tagId: tagIds[i],
data: productCodes[i],
memoryBank: 'EPC',
offset: 2,
);
print('β
Tag ${i + 1}/${tagIds.length} written');
} catch (e) {
print('β Failed to write tag ${i + 1}: $e');
}
}
}
π Documentation #
Essential Guides #
-
Tag Writing Guide - Comprehensive guide for writing data to RFID tags, including:
- Memory bank structure
- Offset usage
- Tag cloning
- Troubleshooting
-
API Reference - Complete method documentation
-
Example App - Full working application
Key Concepts #
Memory Banks
| Bank | Purpose | Writable |
|---|---|---|
| EPC | Product identifier | β Yes |
| USER | Custom data | β Yes |
| TID | Tag ID (unique) | β No |
| RESERVED | Passwords | β Yes |
Writing Offsets
| Offset | Writes | Recommended |
|---|---|---|
| 0 | PC + CRC + EPC | β Advanced |
| 1 | PC + EPC | β οΈ Careful |
| 2 | EPC only | β Best |
π API Reference #
Core Methods #
Initialize & Connect
// Initialize SDK
static Future<bool> initialize({required String transportType})
// Get available readers
static Future<List<ReaderDevice>> getAvailableReaders()
// Connect to reader
static Future<bool> connect(String readerName)
// Check connection
static Future<bool> isConnected()
// Disconnect
static Future<bool> disconnect()
Inventory Operations
// Start tag scanning
static Future<bool> startInventory()
// Stop tag scanning
static Future<bool> stopInventory()
Tag Operations
// Write to tag
static Future<bool> writeTag({
required String tagId,
required String data,
required String memoryBank, // EPC, USER, TID, RESERVED
required int offset,
})
// Start tag locationing
static Future<bool> startLocationing(String tagId)
// Stop tag locationing
static Future<bool> stopLocationing()
Configuration
// Configure reader
static Future<bool> configureReader(ReaderConfig config)
// Get current configuration
static Future<ReaderConfig> getReaderConfig()
// Set antenna power (0-300)
static Future<bool> setAntennaPower(int level)
// Control beeper
static Future<bool> setBeeper(bool enabled)
// Get battery level
static Future<int> getBatteryLevel()
Event Streams #
// Tag read events
static Stream<TagReadEvent> get tagReadStream
// Status events
static Stream<StatusEvent> get statusEventStream
Models #
TagReadEvent
class TagReadEvent {
final String tagId; // Tag EPC
final int rssi; // Signal strength (-100 to 0 dBm)
final int count; // Number of times read
final String memoryBank; // Memory bank name
final String? memoryBankData;// Memory data
final int? pc; // Protocol control
final double? locationInfo; // Distance (when locationing)
final DateTime timestamp; // Event timestamp
}
StatusEvent
class StatusEvent {
final StatusEventType type;
final String message;
final Map<String, dynamic>? data;
final DateTime timestamp;
}
enum StatusEventType {
TRIGGER_PRESSED,
TRIGGER_RELEASED,
INVENTORY_STARTED,
INVENTORY_STOPPED,
READER_CONNECTED,
READER_DISCONNECTED,
BATTERY_LOW,
BATTERY_CRITICAL,
WRITE_SUCCESS,
WRITE_FAILED,
// ... more types
}
ReaderConfig
class ReaderConfig {
final int? antennaPower; // 0-300
final bool? beeperEnabled; // true/false
final String? session; // S0, S1, S2, S3
final int? tagPopulation; // Expected tag count
final bool? dynamicPowerEnabled; // Auto power optimization
}
β οΈ Troubleshooting #
Reader Not Found #
Problem: getAvailableReaders() returns empty list
Solutions:
- β Ensure device is powered on
- β Check USB connection (for RFD40XX)
- β Verify Bluetooth pairing (for Bluetooth readers)
- β Check Android permissions
- β Restart reader device
Tags Not Reading #
Problem: No tags appear when scanning
Solutions:
- β Check antenna power (increase if needed)
- β Verify inventory is started
- β Ensure tags are in range (< 5 meters)
- β Check tag orientation
- β Verify reader is connected
Write Failures #
Problem: writeTag() returns false or throws error
Solutions:
- β Stop inventory before writing
- β Keep tag close to reader (< 30cm)
- β Verify data format (hex string, multiple of 4)
- β Check tag is writable (not locked)
- β Use offset 2 for EPC writes
Example Fix:
// β Wrong
await ZebraRfidPlugin.writeTag(
data: '300', // Not multiple of 4!
offset: 0, // Too complex!
);
// β
Correct
await ZebraRfidPlugin.stopInventory(); // Stop first!
await Future.delayed(Duration(milliseconds: 500));
await ZebraRfidPlugin.writeTag(
data: '3008', // 4 chars β
offset: 2, // EPC only β
);
Connection Issues #
Problem: connect() fails
Solutions:
- β
Use correct transport type:
SERVICE_USBfor RFD40XXSERVICE_SERIALfor Bluetooth
- β Close other RFID apps
- β Restart reader
- β Check permissions
π± Platform Support #
| Platform | Status | Notes |
|---|---|---|
| Android | β Fully Supported | Min SDK 26 |
| iOS | π Planned | Future release |
| Windows | β Not Planned | - |
| macOS | β Not Planned | - |
| Linux | β Not Planned | - |
π― Best Practices #
1. Resource Management #
// β
Good
class RfidService {
StreamSubscription? _tagSubscription;
StreamSubscription? _statusSubscription;
void start() {
_tagSubscription = ZebraRfidPlugin.tagReadStream.listen(...);
_statusSubscription = ZebraRfidPlugin.statusEventStream.listen(...);
}
void dispose() {
_tagSubscription?.cancel();
_statusSubscription?.cancel();
ZebraRfidPlugin.dispose();
}
}
2. Error Handling #
// β
Good
try {
await ZebraRfidPlugin.writeTag(...);
} on RfidException catch (e) {
// Handle RFID-specific errors
showError('RFID Error: ${e.message}');
} catch (e) {
// Handle unexpected errors
showError('Unexpected error: $e');
}
3. Tag Validation #
// β
Good
bool isValidHex(String data) {
return RegExp(r'^[0-9A-Fa-f]+$').hasMatch(data) &&
data.length % 4 == 0;
}
Future<void> safeWrite(String tagId, String data) async {
if (!isValidHex(data)) {
throw Exception('Invalid hex data format');
}
await ZebraRfidPlugin.writeTag(
tagId: tagId,
data: data.toUpperCase(),
memoryBank: 'EPC',
offset: 2,
);
}
4. Performance #
// β
Good - Batch processing
final Set<String> uniqueTags = {};
ZebraRfidPlugin.tagReadStream.listen((event) {
uniqueTags.add(event.tagId);
// Update UI every 100 tags
if (uniqueTags.length % 100 == 0) {
updateUI(uniqueTags.length);
}
});
π€ Contributing #
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Development Setup #
git clone https://github.com/logicpixel31/zebra_rfid_plugin.git
cd zebra_rfid_plugin
flutter pub get
cd example
flutter run
π License #
This plugin is licensed under the MIT License - see the LICENSE file for details.
Important: This plugin uses the Zebra RFID SDK which is property of Zebra Technologies Corporation. Users must comply with Zebra's SDK license terms.
π Support #
Plugin Issues #
- π Open an issue
- π¬ Discussions
Zebra SDK #
- π Zebra Developer Portal
- π Zebra TechDocs
- π§ Zebra Support
Community #
- π Flutter Discord
- π± Stack Overflow
π Changelog #
See CHANGELOG.md for version history.
π Acknowledgments #
- Zebra Technologies for the RFID SDK
- Flutter team for the excellent framework
- Contributors and users for feedback and support
π Star History #
If this plugin helped you, please consider giving it a βοΈ on GitHub!
Made with β€οΈ for the Flutter community
