TheThingsNetwork / arduino-device-lib

Arduino Library for TTN Devices
MIT License
206 stars 96 forks source link

Set custom DevEUI #284

Closed LasaleFamine closed 2 years ago

LasaleFamine commented 2 years ago

Hello, I'm looking to set a custom DevEUI on my The Things Uno but I can't see any function related to this on the doc. Is there any way to do it using this library?

jpmeijers commented 2 years ago

The RN2483 on the Things Uno has a hardware EUI that is used by this library. It's recommended to use this hardware EUI as it is guaranteed to be unique. Self assigning EUIs should only be done if the hardware does not have a unique identifier. And even when self assigning the EUI you need to use one from some other vendor's block. Normally one would generate one from the 10 free ones you get on The Things Stack CE.

So in short, don't set a custom EUI if you don't have a really good reason. The RN2483 does allow it though, but this library does not expose it. This library has been written to always use the hardware EUI as DevEUI: https://github.com/TheThingsNetwork/arduino-device-lib/blob/d2e30f1e99aa5a1909988b0b943ee700f5c5cd2d/src/TheThingsNetwork.cpp#L664

LasaleFamine commented 2 years ago

Just wondering, what if a device let's say it's broken, I want to replace it with the same device and access point on the server (so same keys), how should someone proceed? I need to register a new device on the server even if it is actually the same?

jpmeijers commented 2 years ago

On The Thins Stack you can delete the old device and register a new one, using the same Device ID.

Devices breaking and being swapped out is a common occurrence. I'm handling it as a primary feature in the business logic in my company's database. You should not depend on your network provider to do that for you. If you used Sigfox it would have been impossible to replace a device and make it look like the old one.

LasaleFamine commented 2 years ago

I see, that makes sense. Thank you for the explanation.