Datacake LNS Nodes

LoRaWAN Network Server integration nodes for monitoring gateway status and performance from The Things Stack. More LNS to follow.

Overview

The Datacake LNS (LoRaWAN Network Server) nodes provide seamless integration with The Things Stack (TTS) API, enabling you to:

  • 🌐 Monitor gateway connection status in real-time

  • 📊 Track uplink and downlink message counters

  • ⏱️ Measure network latency and round-trip times

  • 📍 Retrieve gateway location information

  • 🔄 Query gateway details on-demand or at intervals

  • 🚨 Build alerting systems for gateway offline events

Perfect for LoRaWAN network operators, IoT service providers, and anyone managing TTS gateways who needs programmatic access to gateway status.


Configuration

TTS Config

Configuration node for storing The Things Stack API credentials securely.

Settings

  • Name - Optional descriptive name for this configuration

  • Server URL - The URL of your TTS server

    • Community Edition: https://eu1.cloud.thethings.network

    • Community Edition (US): https://nam1.cloud.thethings.network

    • Community Edition (AU): https://au1.cloud.thethings.network

    • Enterprise/Private: Your instance URL (e.g., https://thethings.example.com)

  • API Key - Your TTS API key with gateway read permissions

How to Get Your API Key

  1. Go to your application or user settings

  2. Navigate to API Keys

  3. Click Add API Key

  4. Required Rights:

    • RIGHT_GATEWAY_INFO - Read gateway information

    • RIGHT_GATEWAY_STATUS_READ - Read gateway status and statistics

  5. Generate and copy the API key

  6. Store it in the TTS Config node

⚠️ Important: Keep your API key secure. Never share it or commit it to version control.

Server URL Examples

  • The Things Network (Community):

    • Europe: https://eu1.cloud.thethings.network

    • North America: https://nam1.cloud.thethings.network

    • Australia: https://au1.cloud.thethings.network

  • The Things Stack (Enterprise/Cloud):

    • Your dedicated instance URL

    • Format: https://<tenant>.thethings.industries or custom domain

  • Private Deployment:

    • Your self-hosted instance URL


TTS Gateway Node

Monitor LoRaWAN gateway status and connection statistics from The Things Stack.

Configuration

Gateway ID Source

  • Configured - Use a fixed gateway ID from the node configuration

  • From Message - Extract gateway ID dynamically from incoming messages

Gateway ID

The gateway ID to query (only visible when "Gateway ID Source" is set to "Configured").

Gateway ID Format:

  • Usually starts with eui- followed by the gateway EUI

  • Example: eui-b827ebfffe8b1234

  • Found in The Things Stack Console under your gateway details

Input Properties

When Gateway ID Source is "Configured":

  • msg.payload - Any input triggers the query

When Gateway ID Source is "From Message":

  • msg.payload.gatewayId - Gateway ID to query (preferred)

  • msg.gatewayId - Alternative location for gateway ID

  • msg.payload (string) - Gateway ID as direct payload

Output Properties

Property
Type
Description

msg.payload

object

Normalized gateway status data

msg.gatewayId

string

The gateway ID that was queried

Output Structure

Status Display

The node provides real-time visual feedback:

Status
Indicator
Description

Connected

🟢 Green dot

Gateway is online with uplink/downlink counts shown

Disconnected

🟡 Yellow ring

Gateway is offline or not reporting

Error

🔴 Red ring

Error occurred (API error, invalid config, etc.)

Fetching

🔵 Blue dot

Query in progress

Example Status:

  • Connected (↑15234 ↓127) - Online with 15,234 uplinks and 127 downlinks

Connection Status Logic

A gateway is considered connected when:

  • connected_at exists (has connected at least once)

  • AND disconnected_at is null (not explicitly disconnected)

If connection stats are not available (404 response), the gateway is marked as not connected.


Use Cases & Examples

1. Periodic Gateway Monitoring

Monitor gateway status at regular intervals and alert when offline.

Flow:

Benefits:

  • Early detection of gateway failures

  • Proactive maintenance

  • Reduced downtime

  • Better network reliability


2. Gateway Performance Dashboard

Create a real-time dashboard showing gateway metrics.

Flow:

Dashboard Widgets:

  • Connection status indicator (green/red)

  • Uplink/downlink counters

  • Latency gauge

  • Last activity timestamp

  • Signal strength trends


3. Multi-Gateway Fleet Monitoring

Monitor multiple gateways and aggregate status.

Flow:

Use Cases:

  • Fleet overview dashboard

  • Aggregate network statistics

  • Identify problematic gateways

  • Coverage analysis


4. Gateway Offline Alert System

Send notifications only when gateway goes offline (avoid spam).

Flow:

Benefits:

  • No alert spam (only on status changes)

  • Tracks recovery automatically

  • Provides context in alerts

  • Easy to see disconnection duration


5. Gateway Health Check Report

Generate daily reports on gateway performance.

Flow:

Report Contents:

  • Gateway status

  • 24-hour statistics

  • Latency metrics

  • Activity timestamps

  • Location info


6. Coverage Analysis

Map gateway locations and coverage areas.

Flow:

Use Cases:

  • Visualize gateway coverage

  • Plan gateway deployments

  • Identify coverage gaps

  • Optimize gateway placement


7. Latency Monitoring and Alerting

Monitor network latency and alert on degradation.

Flow:

Thresholds:

  • Normal: < 100ms

  • Warning: 100-200ms

  • Critical: > 200ms


Advanced Features

Dynamic Gateway Queries

Query different gateways based on runtime conditions:

Batch Gateway Monitoring

Monitor many gateways efficiently:

Historical Tracking

Store gateway metrics over time:


Best Practices

Polling Intervals

Use Case
Recommended Interval
Reason

Real-time monitoring

1-2 minutes

Catch issues quickly

General monitoring

5-10 minutes

Balance freshness and API calls

Health checks

15-30 minutes

Reduce load, still responsive

Daily reports

Once per day

Sufficient for reports

Error Handling

Always implement proper error handling:

Caching

Reduce API calls by caching gateway data:

Status Persistence

Store gateway status in context for comparison:


Troubleshooting

Common Issues

"Missing configuration" error

  • Ensure TTS Config node is properly configured

  • Verify Server URL and API Key are entered

  • Check API Key has required permissions

"Gateway ID not configured" error

  • Select a gateway ID in the node configuration (Configured mode)

  • Or ensure msg.payload contains gateway ID (From Message mode)

API Error: 401 Unauthorized

  • API Key is invalid or expired

  • Generate new API Key in TTS Console

  • Ensure API Key has RIGHT_GATEWAY_INFO and RIGHT_GATEWAY_STATUS_READ

API Error: 404 Not Found

  • Gateway ID is incorrect or doesn't exist

  • Verify gateway ID format (usually eui-...)

  • Check gateway exists in The Things Stack Console

Connection stats not available (null)

  • Gateway has never connected

  • Gateway is not currently active

  • Connection stats API returned 404 (expected for inactive gateways)

  • Gateway will show as connected: false

High latency or timeouts

  • TTS server might be slow or overloaded

  • Network connectivity issues

  • Try increasing polling interval


Performance & Limitations

API Calls

Each TTS Gateway node makes 2 API calls per execution:

  1. Gateway info (/api/v3/gateways/{gateway_id})

  2. Connection stats (/api/v3/gs/gateways/{gateway_id}/connection/stats)

Response Times

  • Typical: 1-3 seconds

  • Slow: 3-10 seconds (server load, network latency)

  • Timeout: 30 seconds

Rate Limits

The Things Stack has rate limits:

  • Community: Varies by server region

  • Enterprise: Configurable per deployment

Best Practices:

  • Don't poll faster than 1 minute intervals

  • Use caching for frequently accessed data

  • Batch queries when monitoring multiple gateways

  • Monitor for 429 (Too Many Requests) errors


Integration Examples

With Datacake Nodes

Combine gateway monitoring with device monitoring:

With InfluxDB

Store gateway metrics for historical analysis:

With Grafana Dashboard

Query InfluxDB for visualization:


Resources


API Reference

Gateway Info Endpoint

Returns:

  • Gateway identification

  • Configuration details

  • Location information

  • Frequency plan

  • Antenna details

  • Version information

Connection Stats Endpoint

Returns:

  • Connection status

  • Connected/disconnected timestamps

  • Protocol in use

  • Message counters

  • Round-trip times

  • Sub-band utilization

Note: Returns 404 if gateway has never connected or connection stats are unavailable.


Appendix: Gateway ID Formats

Common Formats

  • EUI-based: eui-b827ebfffe8b1234

  • Custom ID: my-office-gateway

  • With dashes: office-gateway-01

Finding Your Gateway ID

  1. Log in to The Things Stack Console

  2. Navigate to Gateways

  3. Click on your gateway

  4. Copy the Gateway ID from the overview page

The gateway ID is shown at the top of the gateway details page and in the URL.

Last updated

Was this helpful?