TheThingsArchive / ttn

The Things Network Stack V2
https://www.thethingsnetwork.org
MIT License
461 stars 279 forks source link

Export devices as V3 JSON #764

Closed htdvisser closed 4 years ago

htdvisser commented 5 years ago

This is a feature request for ttnctl.

What do you want to do?

I want to migrate devices from v2 to v3.

What steps did you take?

What went wrong or what is missing?

It's too much work. It would be a lot easier if there was a ttnctl devices export [id] that would print V3 JSON so that I can pipe it directly into ttn-lw-cli end-devices create.

Can you fix this yourself and submit a pull request?

Yes

htdvisser commented 5 years ago

When this is done and working, we may want to add the same to the console.

htdvisser commented 4 years ago

Work started in https://github.com/TheThingsNetwork/ttn/compare/feature/v3-export

@rvolosatovs please see what other fields we may need to transfer when migrating existing devices from v2 to v3.

johanstokking commented 4 years ago

@neoaggelos is taking this over

@htdvisser can you let @neoaggelos know if the branch that you mentioned is still relevant and like we want this to be?

htdvisser commented 4 years ago

This was practically done. Only thing left was for @rvolosatovs to confirm what MAC settings need to be set in the network server.

johanstokking commented 4 years ago

OK. @neoaggelos please coordinate with @rvolosatovs and file an issue in lorawan-stack for documenting migrating devices from V2 to V3 via CLI.

neoaggelos commented 4 years ago

OK. @neoaggelos please coordinate with @rvolosatovs and file an issue in lorawan-stack for documenting migrating devices from V2 to V3 via CLI.

There is https://github.com/TheThingsNetwork/lorawan-stack/issues/1685

neoaggelos commented 4 years ago

I'm having trouble telling apart OTAA from ABP devices from v2 with ttnctl. What I've seen is that all devices (both OTAA and ABP) have ActivationConstraints equal to Local. The console seems to be telling them apart by looking up the usages for devaddr prefixes in https://console.thethingsnetwork.org/api/handlers.

ttnctl discover broker --metadata is the closest I can get, but it does not include the usages of the prefixes.

Can we retrieve this info from the handler itself?

johanstokking commented 4 years ago

I don't think you can get this from the Handler, but you should be able to get this from the V2 NS. Indeed it's buried in a map value, @htdvisser probably knows best.

htdvisser commented 4 years ago

The v2 API only allows talking to the Handler, so you can't talk to the NetworkServer.

The difference between OTAA and ABP devices in v2 is that OTAA devices have an AppKey and ABP devices don't.