What is the correct way to create and activate devices with the API

Hello,

I am trying to create and activate devices using the API (version 3).

Here is what I do (so far):

  1. Create devices with POST http://x.x.x.x:8080/api/devices
  2. Get a random devAddr with POST http://x.x.x.x:8080/api/devices/devEUI/getRandomDevAddr
  3. Activate device with POST "http://x.x.x.x:8080/api/devices/devEUI/activate"

But on step 3, I get an error:

{"error":"nwkSEncKey: lorawan: exactly 16 bytes are expected","code":3,"message":"nwkSEncKey: lorawan: exactly 16 bytes are expected","details":[]}

It see that I am missing a step. Where do I get the missing nwkSEncKey ?

Another question: in the API page the format for the activation is:
/api/devices/{device_activation.dev_eui}/activate]

What should be {device_activation.dev_eui} ? Just the DevEUI?

Any help is appreciated!

EDIT: I sorted it out. If the device is OTAA, the 3rd step is much more simple: we have to add the key supplied by the device manufacturer with the following command:

POST http://x.x.x.x:8080/api/devices/DevEUI/keys
payload:

{
   "deviceKeys": {
     "nwkKey": "theKey",
   }
}

And then everything works when the device is turned on.

1 Like