v3.20.2

Getting Started Devices Gateways Integrations Reference
Get The Things Stack

Devices

    Overview
  • Adding Devices
  • ABP vs OTAA
  • Best Practices
  • Class B
  • Class C
  • Multicast
  • Downlink Queue Operations
  • Confirmed Downlinks Behavior
  • MAC Settings
  • ATECC608A/B Secure Elements
  • Device Claiming
  • End Device Templates
    • Creating Templates
    • Converting Templates
    • Executing Templates
    • Mapping Templates
    • Assigning EUIs
  • Generating a QR Code
  • The Things Uno
  • Troubleshooting Devices

Assigning EUIs

Command-line interface only

The instructions below use the command-line interface (CLI).

Learn how to install the CLI

You can use the end-device template assign-euis command to assign the JoinEUI and DevEUI to device templates. The DevEUI is assigned from the given start number. This personalizes the device templates.

You can use the command in two different ways:

  1. Pipe a number of device templates to assign EUIs to, for example the result of Mapping Templates or Converting Templates
  2. Pipe a generic device template, for example the result of Creating Templates, and pass the --count flag to generate a number of personalized device templates

Once the device templates are personalized with EUIs, you can set additional fields (see Creating Templates) or execute templates (see Executing Templates).

To make your device compliant with most LoRaWAN networks, use the JoinEUI of the LoRaWAN Join Server where the devices will be registered and use a DevEUI from an IEEE issued MAC address block that is assigned to your company.

If you intend to operate your own LoRaWAN Join Server, use a JoinEUI from your IEEE assigned MAC address block as LoRa Alliance requires that for DNS lookup. Learn how to apply for a IEEE issued MAC address block.

Example

This example illustrates creating a device profile template, assigning 5 DevEUIs and creating them in your The Things Stack application.

We define some user parameters that will be used below:

APP_ID="test-app" 
FREQUENCY_PLAN="EU_863_870"
LORAWAN_VERSION="1.0.3"
LORAWAN_PHY_VERSION="1.0.3-a"
DEV_EUI="70b3d57ed0000000"
JOIN_EUI="70b3d57ed0000001"
COUNT="5"

Make sure to modify these according to your setup.

First, create a mapping file with a device profile in profile.json:

ttn-lw-cli end-devices template extend \
  --frequency-plan-id $FREQUENCY_PLAN \
  --lorawan-version $LORAWAN_VERSION \
  --lorawan-phy-version $LORAWAN_PHY_VERSION \
  --supports-join > profile.json

Second, assign the EUIs. The first argument is the JoinEUI, the second argument is the first DevEUI.

cat profile.json \
  | ttn-lw-cli end-devices template assign-euis $JOIN_EUI $DEV_EUI --count $COUNT > devices.json
Show output
{
  "end_device": {
    "ids": {
      "device_id": "eui-70b3d57ed0000001",
      "application_ids": {

      },
      "dev_eui": "70B3D57ED0000001",
      "join_eui": "70B3D57ED0000000"
    },
    "created_at": "0001-01-01T00:00:00Z",
    "updated_at": "0001-01-01T00:00:00Z",
    "attributes": {
    },
    "lorawan_version": "1.0.3",
    "lorawan_phy_version": "1.0.3-a",
    "frequency_plan_id": "EU_863_870",
    "supports_join": true
  },
  "field_mask": {
    "paths": [
      "lorawan_version",
      "ids.device_id",
      "ids.join_eui",
      "ids.dev_eui",
      "supports_join",
      "frequency_plan_id",
      "lorawan_phy_version"
    ]
  }
}
{
  "end_device": {
    "ids": {
      "device_id": "eui-70b3d57ed0000002",
      "application_ids": {

      },
      "dev_eui": "70B3D57ED0000002",
      "join_eui": "70B3D57ED0000000"
    },
    "created_at": "0001-01-01T00:00:00Z",
    "updated_at": "0001-01-01T00:00:00Z",
    "attributes": {
    },
    "lorawan_version": "1.0.3",
    "lorawan_phy_version": "1.0.3-a",
    "frequency_plan_id": "EU_863_870",
    "supports_join": true
  },
  "field_mask": {
    "paths": [
      "ids.dev_eui",
      "supports_join",
      "frequency_plan_id",
      "lorawan_phy_version",
      "lorawan_version",
      "ids.device_id",
      "ids.join_eui"
    ]
  }
}
{
  "end_device": {
    "ids": {
      "device_id": "eui-70b3d57ed0000003",
      "application_ids": {

      },
      "dev_eui": "70B3D57ED0000003",
      "join_eui": "70B3D57ED0000000"
    },
    "created_at": "0001-01-01T00:00:00Z",
    "updated_at": "0001-01-01T00:00:00Z",
    "attributes": {
    },
    "lorawan_version": "1.0.3",
    "lorawan_phy_version": "1.0.3-a",
    "frequency_plan_id": "EU_863_870",
    "supports_join": true
  },
  "field_mask": {
    "paths": [
      "supports_join",
      "frequency_plan_id",
      "lorawan_phy_version",
      "lorawan_version",
      "ids.device_id",
      "ids.join_eui",
      "ids.dev_eui"
    ]
  }
}
{
  "end_device": {
    "ids": {
      "device_id": "eui-70b3d57ed0000004",
      "application_ids": {

      },
      "dev_eui": "70B3D57ED0000004",
      "join_eui": "70B3D57ED0000000"
    },
    "created_at": "0001-01-01T00:00:00Z",
    "updated_at": "0001-01-01T00:00:00Z",
    "attributes": {
    },
    "lorawan_version": "1.0.3",
    "lorawan_phy_version": "1.0.3-a",
    "frequency_plan_id": "EU_863_870",
    "supports_join": true
  },
  "field_mask": {
    "paths": [
      "ids.device_id",
      "ids.join_eui",
      "ids.dev_eui",
      "supports_join",
      "frequency_plan_id",
      "lorawan_phy_version",
      "lorawan_version"
    ]
  }
}
{
  "end_device": {
    "ids": {
      "device_id": "eui-70b3d57ed0000005",
      "application_ids": {

      },
      "dev_eui": "70B3D57ED0000005",
      "join_eui": "70B3D57ED0000000"
    },
    "created_at": "0001-01-01T00:00:00Z",
    "updated_at": "0001-01-01T00:00:00Z",
    "attributes": {
    },
    "lorawan_version": "1.0.3",
    "lorawan_phy_version": "1.0.3-a",
    "frequency_plan_id": "EU_863_870",
    "supports_join": true
  },
  "field_mask": {
    "paths": [
      "supports_join",
      "frequency_plan_id",
      "lorawan_phy_version",
      "lorawan_version",
      "ids.device_id",
      "ids.join_eui",
      "ids.dev_eui"
    ]
  }
}

Finally, you can create these devices in your The Things Stack application test-app, see Executing Templates.

cat devices.json \
  | ttn-lw-cli end-devices template execute \
  | ttn-lw-cli end-devices create --application-id $APP_ID
← Mapping Templates Generating a QR Code →

On this page

  • Example

The Things Stack

Getting Started

Devices

Gateways

Integrations

Reference

Contributing

GitHub

Forum

About Us

The Things Network

The Things Industries

About this page

Last changed by Nejra Selimović on 08 Jun 2022.
doc: Update IEEE Standards Association references (#883)

Edit on Github