Skip to main content

Usage

Device Lifecycle

OTAA Join Process

  1. Registration: Register device with DevEUI and AppKey
  2. Device Power On: Device sends JoinRequest
  3. Server Validation: Module verifies MIC and checks DevNonce
  4. Session Creation: Server generates session keys and DevAddr
  5. JoinAccept: Server sends encrypted JoinAccept via gateway
  6. Ready: Device is now joined and can send data

ABP Activation

  1. Registration: Register device with DevEUI, DevAddr, NwkSKey, AppSKey
  2. Device Power On: Device immediately sends data frames
  3. Ready: No join procedure needed

When a device sends an uplink:

  1. Gateway receives the LoRa transmission
  2. Gateway forwards to Ignition via UDP
  3. Module processes the frame:
    • Verifies MIC (Message Integrity Code)
    • Validates frame counter
    • Decrypts payload
    • Runs payload decoder (if assigned)
  4. Tags are updated in real-time
  5. Device state is persisted

Multi-Gateway Deduplication

When multiple gateways receive the same uplink:

  • First reception is fully processed
  • Duplicates with better signal update gateway routing only
  • Duplicates with worse signal are ignored
  • 5-second deduplication window

Queue via REST API

Endpoint: POST /data/lorawan/devices/:devEui/downlink

curl -X POST "http://localhost:8088/data/lorawan/devices/A358C4B192543F75/downlink" \
-H "Content-Type: application/json" \
-d '{
"fPort": 10,
"payload": "48656C6C6F",
"confirmed": false
}'
FieldTypeRequiredDescription
fPortintegerYesLoRaWAN port (1-223)
payloadstringYesHex-encoded payload
confirmedbooleanNoRequest device acknowledgment
curl "http://localhost:8088/data/lorawan/devices/A358C4B192543F75/downlinks"
curl -X DELETE "http://localhost:8088/data/lorawan/devices/A358C4B192543F75/downlinks/{id}"

Transmission Timing

Device ClassTiming
Class ARX1 window (+1s after uplink) or RX2 (+2s)
Class CImmediate (no wait for uplink)

RX Window Fallback

If RX1 transmission fails (gateway error), the module automatically retries via RX2:

  • RX2 uses regional default frequency and data rate
  • Only retries on recoverable errors (TOO_LATE, COLLISION)

Device Status

Automatic Status Requests

The module automatically requests device status every 100 uplinks.

On-Demand Status Request

Via API:

curl -X POST "http://localhost:8088/data/lorawan/devices/A358C4B192543F75/status-request"

Via Tag: Write true to [LoRaWAN]/Devices/{Name}/Status/Request

Status Information

FieldDescription
Battery0 = External power, 1-254 = Battery level, 255 = Unknown
BatteryLevelHuman-readable: "External", "XX%", "Unknown"
MarginSNR margin in dB (-32 to +31)

Adaptive Data Rate (ADR)

The module implements ADR to optimize device transmission parameters.

How It Works

  1. Server collects SNR history (last 20 uplinks)
  2. Calculates optimal data rate based on link margin
  3. Sends LinkADRReq MAC command
  4. Device adjusts spreading factor and TX power

ADR Formula

Margin = Max SNR - Required SNR (SF7) - Installation Margin (5dB)
If margin >= 0: Use SF7 (fastest)
If margin < 0: Use higher SF based on margin deficit

REST API Reference

Device Status

# Get all devices status
curl "http://localhost:8088/data/lorawan/devices/status"

# Response
{
"devices": {
"A358C4B192543F75": {
"joined": true,
"devAddr": "26011234",
"fCntUp": 142,
"fCntDown": 5,
"lastSeen": 1706180000000,
"rssi": -85,
"snr": 7.5,
"battery": 180,
"margin": 12
}
}
}

Gateway Status

# Get all gateways status
curl "http://localhost:8088/data/lorawan/gateways/status"

# Response
{
"gateways": {
"A840411234567890": {
"connected": true,
"address": "192.168.1.100",
"port": 54321,
"lastSeen": 1706180000000
}
},
"connectedCount": 1
}

Device Registration

# Register OTAA device
curl -X POST "http://localhost:8088/data/api/v1/resources/com.operametrix.ignition.lorawan/device" \
-H "Content-Type: application/json" \
-d '[{
"name": "A358C4B192543F75",
"config": {
"name": "TempSensor_01",
"devEui": "A358C4B192543F75",
"appKey": "925742558798bfb46e938d7a5a1b161f",
"mode": "OTAA",
"deviceClass": "A"
}
}]'

Ignition Integration

Tag Bindings

Bind device data to Ignition components:

[LoRaWAN]/Devices/TempSensor_01/temperature
[LoRaWAN]/Devices/TempSensor_01/Radio/RSSI
[LoRaWAN]/Devices/TempSensor_01/Status/Connection

Historian

Enable history on LoRaWAN tags to store time-series data:

  1. Right-click a device tag
  2. Select Edit Tag
  3. Enable History
  4. Configure sample mode (typically "On Change")

Alarming

Create alarms on LoRaWAN device data:

[LoRaWAN]/Devices/TempSensor_01/temperature > 80
[LoRaWAN]/Devices/TempSensor_01/Status/Connection == "Offline"
[LoRaWAN]/Devices/TempSensor_01/Status/Battery < 50

Scripting

Access LoRaWAN data in scripts:

# Read device temperature
temp = system.tag.read("[LoRaWAN]/Devices/TempSensor_01/temperature").value

# Check device status
status = system.tag.read("[LoRaWAN]/Devices/TempSensor_01/Status/Connection").value

# Request device status
system.tag.write("[LoRaWAN]/Devices/TempSensor_01/Status/Request", True)

Troubleshooting

IssuePossible CauseSolution
Gateway not connectingUDP blockedCheck firewall for port 1700
Gateway not connectingWrong server addressVerify gateway configuration
Device not joiningWrong AppKeyVerify 32-character hex key
Device not joiningDevNonce replayDevice may need factory reset
Uplinks not processedGateway not registeredAdd gateway in web UI
Decoder errorsJavaScript syntaxCheck decoder console output
Downlinks not receivedClass A timingDevice must uplink first
Downlinks not receivedRX window missedCheck gateway TX capability

Best Practices

  1. Register gateways first - Unregistered gateways can connect but payloads may be dropped
  2. Use OTAA - Provides better security than ABP
  3. Assign decoders - Convert raw payloads to meaningful tags
  4. Enable historian - Store time-series data for analysis
  5. Monitor battery - Set up alarms for low battery levels
  6. Use Class A - Unless immediate downlinks are required
  7. Check signal quality - Low RSSI/SNR indicates poor coverage
  8. Backup device keys - Store AppKeys securely outside Ignition