Overview

This guide explains how to configure and integrate RFID readers with the traphIQ Employee Tracking System. The system supports multiple RFID reader types and communication protocols through a comprehensive REST API.

Quick Start: For immediate testing, use the Simple API endpoints which require no authentication. For production deployments, use Bearer Token authentication.

System Architecture

The traphIQ system uses a centralized server architecture where RFID readers communicate with the main application server via HTTP/HTTPS REST API calls.

┌─────────────────┐ HTTP/HTTPS ┌─────────────────┐ │ RFID Reader │ ──────────────→ │ traphIQ Server │ │ (Station 1) │ REST API │ (Central) │ └─────────────────┘ └─────────────────┘ │ ┌─────────────────┐ HTTP/HTTPS │ │ RFID Reader │ ──────────────────────────┤ │ (Station 2) │ REST API │ └─────────────────┘ │ │ ┌─────────────────┐ HTTP/HTTPS │ │ RFID Reader │ ──────────────────────────┤ │ (Station N) │ REST API │ └─────────────────┘ │ ▼ ┌─────────────────┐ │ Database │ │ (SQLite) │ └─────────────────┘

API Endpoints

Base URLs

  • Development: http://localhost:8080
  • Production: https://your-domain.com

Core RFID Endpoints

POST /api/rfid/entry

Record an entry event when a tag is detected entering an area

{
    "rfid_tag": "TAG001",
    "area_id": 1,
    "reader_id": "READER_ENTRANCE_A1",
    "metadata": {
        "reader_location": "Main Entrance",
        "signal_strength": 85
    }
}
POST /api/rfid/exit

Record an exit event when a tag is detected leaving an area

{
    "rfid_tag": "TAG001", 
    "area_id": 1,
    "reader_id": "READER_EXIT_A1",
    "metadata": {
        "reader_location": "Main Exit",
        "signal_strength": 90
    }
}
POST /api/rfid/toggle

Smart detection - system automatically determines entry/exit based on current location

{
    "rfid_tag": "TAG001",
    "area_id": 1, 
    "reader_id": "READER_TUNNEL_1",
    "metadata": {
        "detection_type": "proximity",
        "signal_strength": 78
    }
}

Alternative API Versions

API Type Endpoint Authentication Use Case
Session-based /api/rfid/{eventType} Session cookies Web UI integration
Bearer Token /api/v1/rfid/{eventType} Bearer token Hardware integration
Simple API /api/simple/rfid/{eventType} None Testing only

Authentication Methods

1. Bearer Token Authentication (Recommended)

Generate an API token through the admin interface and include it in the Authorization header:

Steps to Generate Token:
1. Login as administrator
2. Navigate to Configuration → API Tokens
3. Create new token with appropriate permissions (read/write/admin)
curl -X POST "http://your-server:8080/api/v1/rfid/entry" \
  -H "Authorization: Bearer your-api-token-here" \
  -H "Content-Type: application/json" \
  -d '{
    "rfid_tag": "TAG001",
    "area_id": 1,
    "reader_id": "READER_01"
  }'

2. Simple API (Testing Only)

For testing and development, use the Simple API endpoints with no authentication required:

curl -X POST "http://your-server:8080/api/simple/rfid/entry" \
  -H "Content-Type: application/json" \
  -d '{
    "rfid_tag": "TAG001",
    "area_id": 1,
    "reader_id": "TEST_READER"
  }'
Security Warning: Simple API endpoints should only be used for testing. Always use Bearer Token authentication in production environments.

RFID Reader Configuration

Required Data Fields

Field Type Required Description
rfid_tag string RFID tag identifier (must exist in system)
area_id integer Target area ID (must exist in system)
reader_id string Unique reader identifier
event_type string Auto 'entry', 'exit', or 'toggle' (auto-determined)
metadata object Additional reader/event data

Event Types

Entry Events

  • Use when reader detects tag entering an area
  • Explicit entry detection (e.g., entrance turnstile)
  • Endpoint: /api/rfid/entry

Exit Events

  • Use when reader detects tag exiting an area
  • Explicit exit detection (e.g., exit turnstile)
  • Endpoint: /api/rfid/exit

Toggle Events (Recommended)

  • Use for general proximity detection
  • System automatically determines entry/exit based on current employee location
  • Endpoint: /api/rfid/toggle
Recommendation: Use toggle events for most implementations as they provide automatic entry/exit detection and are more robust for general RFID deployments.

Hardware Compatibility

Supported Reader Types

Network-Enabled Readers

  • TCP/IP Communication capability
  • HTTP Client functionality
  • Examples: Impinj R700, Zebra FX9600, Alien ALR-9900+

Serial/USB Readers with Gateway

  • Standard RFID reader (RS-232, USB, Wiegand)
  • Gateway device with network connectivity
  • Examples: Arduino + ESP32, Raspberry Pi, industrial PC

Existing System Integration

  • Legacy system integration via middleware
  • Building management system integration
  • Examples: HID, Honeywell, Johnson Controls systems

Minimum Requirements

  • Network Connectivity: Ethernet or WiFi
  • HTTP Client: Ability to make HTTP POST requests
  • JSON Support: Parse and generate JSON data
  • Authentication: Support for Bearer token headers

Recommended Features

  • HTTPS Support: Secure communication for production
  • Error Handling: Retry logic for failed API calls
  • Local Buffering: Store events during network outages
  • Configurable Endpoints: Easy server URL updates

Network Configuration

Network Topology

┌─────────────────┐ │ RFID Reader │ │ IP: 192.168.1.10│ ──┐ └─────────────────┘ │ │ ┌─────────────────┐ ┌─────────────────┐ ├───→│ Network Switch │ │ RFID Reader │ │ │ │ │ IP: 192.168.1.11│ ──┘ └─────────────────┘ └─────────────────┘ │ │ ┌─────────────────┐ │ traphIQ Server │ │ IP: 192.168.1.5 │ │ Port: 8080 │ └─────────────────┘

Firewall Configuration

  • Inbound: Allow port 8080 (or configured port) on server
  • Outbound: Allow HTTP/HTTPS from readers to server
  • DNS: Ensure readers can resolve server hostname (if used)

Example Reader Configuration

{
  "network": {
    "ip": "192.168.1.10",
    "netmask": "255.255.255.0", 
    "gateway": "192.168.1.1",
    "dns": "192.168.1.1"
  },
  "api": {
    "server_url": "http://192.168.1.5:8080",
    "endpoint": "/api/v1/rfid/toggle",
    "token": "your-api-token-here",
    "timeout": 5000,
    "retry_count": 3
  },
  "reader": {
    "id": "READER_ENTRANCE_01",
    "area_id": 1,
    "location": "Main Entrance"
  }
}

Testing & Validation

Quick API Tests

Test server connectivity and authentication:

# Test server connectivity
curl -I http://your-server:8080/api/status

# Test authentication
curl -X GET "http://your-server:8080/api/v1/employees" \
  -H "Authorization: Bearer your-token"

# Test RFID event submission
curl -X POST "http://your-server:8080/api/v1/rfid/entry" \
  -H "Authorization: Bearer your-token" \
  -H "Content-Type: application/json" \
  -d '{
    "rfid_tag": "TEST001",
    "area_id": 1,
    "reader_id": "TEST_READER"
  }'

Using the Demo Interface

  1. Navigate to /demo on your server
  2. Select employee with valid RFID tag
  3. Simulate events for different areas
  4. Verify results on dashboard for real-time updates

Python Test Script

#!/usr/bin/env python3
import requests
import json
import time

# Configuration
SERVER_URL = "http://192.168.1.5:8080"
API_TOKEN = "your-api-token-here"
READER_ID = "TEST_READER_01"

def test_rfid_event(rfid_tag, area_id, event_type="toggle"):
    """Send test RFID event to server"""
    
    url = f"{SERVER_URL}/api/v1/rfid/{event_type}"
    headers = {
        "Authorization": f"Bearer {API_TOKEN}",
        "Content-Type": "application/json"
    }
    data = {
        "rfid_tag": rfid_tag,
        "area_id": area_id,
        "reader_id": READER_ID,
        "metadata": {
            "test": True,
            "timestamp": time.time()
        }
    }
    
    try:
        response = requests.post(url, headers=headers, json=data, timeout=5)
        
        if response.status_code == 201:
            print(f"✅ Event sent successfully: {rfid_tag}")
            return True
        else:
            print(f"❌ Error {response.status_code}: {response.text}")
            return False
            
    except requests.exceptions.RequestException as e:
        print(f"❌ Network error: {e}")
        return False

# Test sequence
if __name__ == "__main__":
    test_rfid_event("TAG001", 1, "entry")
    time.sleep(2)
    test_rfid_event("TAG001", 1, "exit")

Troubleshooting

Common Issues

401 Authentication Errors
• Verify API token is valid and active
• Check token permissions (needs 'write' for RFID events)
• Ensure Bearer token format: Authorization: Bearer your-token
• Regenerate token if expired
404 RFID Tag Not Found
• Verify RFID tag exists in employee database
• Check tag format matches exactly (case-sensitive)
• Ensure employee has active status
• Add missing employees via Configuration → Employees
404 Area Not Found
• Verify area_id exists in system
• Check area is active/enabled
• List available areas: GET /api/v1/areas
Network Connectivity Issues
• Verify network connectivity between reader and server
• Check firewall rules allow traffic on required ports
• Test with ping and telnet to server IP/port
• Verify DNS resolution (if using hostnames)

Debug Tools

# Monitor server logs
tail -f /path/to/traphiq/logs/api.log
tail -f /path/to/traphiq/logs/app.log

# Capture network traffic
sudo tcpdump -i eth0 port 8080 -A
sudo tcpdump -i eth0 host 192.168.1.10 -A

Best Practices

Security

Production Security

  • Use HTTPS for all API communication
  • Regularly rotate API tokens
  • Implement network segmentation for RFID devices
  • Limit API token permissions to minimum required

Reliability

Error Handling

  • Implement exponential backoff for failed requests
  • Store events locally during network outages
  • Monitor reader connectivity and API response times
  • Set up alerting for system failures

Performance

Optimization

  • Use connection pooling for high-volume readers
  • Implement local queuing for event buffering
  • Consider WebSocket connections for real-time data
  • Cache area/employee data locally when possible

Health Monitoring Script

#!/bin/bash
# Reader health check script
READER_IP="192.168.1.10"
SERVER_URL="http://192.168.1.5:8080"

# Check reader connectivity
ping -c 1 $READER_IP > /dev/null
if [ $? -eq 0 ]; then
    echo "✅ Reader $READER_IP is reachable"
else
    echo "❌ Reader $READER_IP is unreachable"
fi

# Check server API
curl -s -I $SERVER_URL/api/status > /dev/null
if [ $? -eq 0 ]; then
    echo "✅ Server API is responsive"
else
    echo "❌ Server API is not responding"
fi

Support Resources

This guide provides comprehensive instructions for integrating RFID readers with the traphIQ system. The modular API design supports various reader types and deployment scenarios while maintaining security and reliability.

Additional Support:
API Documentation - Complete REST API reference
Demo Mode: Use /demo endpoint for testing
Admin Interface: Configuration pages for system management
System Logs: Monitor logs for debugging information
Email Support: sales@traphiq.ca