zebra_rfid_plugin 1.0.0 copy "zebra_rfid_plugin: ^1.0.0" to clipboard
zebra_rfid_plugin: ^1.0.0 copied to clipboard

PlatformAndroid

A Flutter plugin for Zebra RFID SDK (RFD40XX) with support for tag reading, writing, and locating.

Zebra RFID Plugin for Flutter #

pub package popularity likes pub points

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_USB for RFD40XX
    • SERVICE_SERIAL for 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:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. 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 #

Zebra SDK #

Community #


πŸ“Š 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

1
likes
150
points
119
downloads
screenshot

Publisher

unverified uploader

Weekly Downloads

A Flutter plugin for Zebra RFID SDK (RFD40XX) with support for tag reading, writing, and locating.

Repository (GitHub)
View/report issues

Topics

#zebra #rifd

Documentation

API reference

License

MIT (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on zebra_rfid_plugin

Packages that implement zebra_rfid_plugin