Device Import with device.json generating dev_eui and app_key

Hello, I have to regiter about 50 self build LoRaNodes. They are based on ESP8266 + RFM95 + MCCI LMIC library.
I can register via TTN V3 consol without any problem. For dev_eui and AppKey I use the ‘Generate’ button.
It would be much elegant instead of register manually via the TTN V3 console Web GUI to use the ‘Import end devices’ button of the Web GUI. The problem for me is that I can not find a way to generate the dev_eui and AppKey during the import process. Is there a way to use something like a wildcard in the device.joson file for the dev_eui and app_key fields to generate this IDs during the import process? Thanks

Good day. I have a similar problem. I want to upload devices using a CSV file to use ABP mode.
I use the following data and error. I specify the frequency plan manually. Any help will be highly appreciated.

id;dev_eui;join_eui;name;dev_addr;app_s_key;f_nwk_s_int_key;last_f_cnt_up;last_n_f_cnt_down;last_a_f_cnt_down;app_key
tv-1194414082-540488273;526973696E674846;526973696E674846;TV_40;5260D5A2;2B7E151628AED2A6ABF7158809CF4F3F;FF7E151628AED2A6ABF7158809CF4F88;0;0;0;2B7E151628AED2A6ABF7158809CF499F

ERROR:
Converting end device templates…
{
“end_device”: {
“ids”: {
“device_id”: “tv-1194414082-540488273”,
“dev_eui”: “526973696E674846”,
“join_eui”: “526973696E674846”
},
“name”: “TV_40”,
“supports_join”: true,
“root_keys”: {
“app_key”: {
“key”: “2B7E151628AED2A6ABF7158809CF499F”
}
},
“session”: {
“dev_addr”: “5260D5A2”,
“keys”: {
“session_key_id”: “AZBun3Mkd9lPTrxAKiRCnQ==”,
“f_nwk_s_int_key”: {
“key”: “FF7E151628AED2A6ABF7158809CF4F88”
},
“app_s_key”: {
“key”: “2B7E151628AED2A6ABF7158809CF4F3F”
}
}
}
},
“field_mask”: {
“paths”: [
“ids.device_id”,
“ids.dev_eui”,
“ids.join_eui”,
“name”,
“session.dev_addr”,
“session.keys.app_s_key.key”,
“session.keys.f_nwk_s_int_key.key”,
“session.last_f_cnt_up”,
“session.last_n_f_cnt_down”,
“session.last_a_f_cnt_down”,
“root_keys.app_key.key”,
“supports_join”
]
}
}
Creating end devices…
{
“code”: 3,
“message”: “error:pkg/networkserver:field_value (invalid value of field session.keys.session_key_id)”,
“details”: [
{
@type”: “type.googleapis.com/ttn.lorawan.v3.ErrorDetails”,
“namespace”: “pkg/networkserver”,
“name”: “field_value”,
“message_format”: “invalid value of field {field}”,
“attributes”: {
“field”: “session.keys.session_key_id”
},
“correlation_id”: “cce963cff44a4d9dba6ddd12c06a6527”,
“code”: 3
}
]
}

Import operation complete

Screenshot 2024-07-01 160923

Please format blocks of output using the </> tool - makes it so much easier to dig in to the detail if formatted properly. If you click on the … you can use the pencil tool to edit your post.

I don’t normally import ABP but I can see what happens if I try to yield some idea.

Thanks for the reply. Any advise would be highly appreciated! I’m struggling to edit the post, so will try again.
I was thinking that it might the app_key that is giving a problem, as I chose a random number.

id;dev_eui;join_eui;name;dev_addr;app_s_key;f_nwk_s_int_key;last_f_cnt_up;last_n_f_cnt_down;last_a_f_cnt_down;app_key
tv-1194414082-540488273;526973696E674846;526973696E674846;TV_40;5260D5A2;2B7E151628AED2A6ABF7158809CF4F3F;FF7E151628AED2A6ABF7158809CF4F88;0;0;0;2B7E151628AED2A6ABF7158809CF499F

image

image


Converting end device templates…
{
  "end_device": {
    "ids": {
      "device_id": "tv-1194414082-540488273",
      "dev_eui": "526973696E674846",
      "join_eui": "526973696E674846"
    },
    "name": "TV_40",
    "supports_join": true,
    "root_keys": {
      "app_key": {
        "key": "2B7E151628AED2A6ABF7158809CF499F"
      }
    },
    "session": {
      "dev_addr": "5260D5A2",
      "keys": {
        "session_key_id": "AZBx9Z7s8C7mBcmEIgAUhA==",
        "f_nwk_s_int_key": {
          "key": "FF7E151628AED2A6ABF7158809CF4F88"
        },
        "app_s_key": {
          "key": "2B7E151628AED2A6ABF7158809CF4F3F"
        }
      }
    }
  },
  "field_mask": {
    "paths": [
      "ids.device_id",
      "ids.dev_eui",
      "ids.join_eui",
      "name",
      "session.dev_addr",
      "session.keys.app_s_key.key",
      "session.keys.f_nwk_s_int_key.key",
      "session.last_f_cnt_up",
      "session.last_n_f_cnt_down",
      "session.last_a_f_cnt_down",
      "root_keys.app_key.key",
      "supports_join"
    ]
  }
}
Creating end devices…
{
  "code": 3,
  "message": "error:pkg/networkserver:field_value (invalid value of field `session.keys.session_key_id`)",
  "details": [
    {
      "@type": "type.googleapis.com/ttn.lorawan.v3.ErrorDetails",
      "namespace": "pkg/networkserver",
      "name": "field_value",
      "message_format": "invalid value of field `{field}`",
      "attributes": {
        "field": "session.keys.session_key_id"
      },
      "correlation_id": "4768387f249b429c8fd7183b458fe0f4",
      "code": 3
    }
  ]
}

Import operation complete

Clearly something going on here trying your data (EUI’s changed to prevent clashes) I get the same result and the error message doesn’t really make sense given that it is produced by the stack, it’s not part of the import csv.

As you need 50 setup which is outside the normal scope of TTN / Sandbox, perhaps you should get a support contract with TTI, @rish1 will provide you with the details.

Thank you very much for your effort!

Hi, I managed to import APB devices using JSON. I include the JSON that worked:

{
  "ids": {
    "device_id": "grove-4",
    "dev_eui":  "2CF7F1204200A644",
    "join_eui": "526973696E674846"
  },
  "name": "My grove4",
  "description": "json for APB",
  "lorawan_version": "MAC_V1_0_3",
  "lorawan_phy_version": "PHY_V1_0_3_REV_A",
  "frequency_plan_id": "EU_863_870_TTN",
  "supports_join": false,
  "root_keys": {
    "app_key": {
      "key": "2B7E151628AED2A6ABF7158809CF4F3C"
    }
  },
  "session": {	
    "keys": {
		"f_nwk_s_int_key":{
			"key": "AA02030405060FF801020304050607CC"	  
			},
		"app_s_key":{
			"key": "01FF030405060708010203040506CCAA"	  
			}
	},
	"dev_addr":"FF0203BB",
	 "last_f_cnt_up":1,
	  "last_n_f_cnt_down":1,
	  "last_a_f_cnt_down":1 
 }
}

1 Like