mcci-catena / arduino-lmic

LoraWAN-MAC-in-C library, adapted to run under the Arduino environment
https://forum.mcci.io/c/device-software/arduino-lmic/
MIT License
636 stars 207 forks source link

Setting Keys Dynamically APPEUI DEVEUI APPKEY #604

Closed peter3099 closed 3 years ago

peter3099 commented 3 years ago

Hello

Firstly thank you for all the hard work on this library it works great. I'm looking for some guidance on how to implement setting the LoraWan keys dynamically, mainly using a webserver running on the same device so keys don't need to be added to the program code. I'm aware of the os_getDevEui,os_getArtEui,os_getDevKey callbacks but I'm getting confused about how would I convert a string that I get through the webserver into a variable that the arduino-lmic library would understand.

Let's say I get devUI = "fec8a8bca1052457";

How would I get the conversion of that string in the callback so it returns the correct value for the library void os_getDevEui(u1_t *buf) { memcpy_P(buf, DEVEUI, 8); }

I'm using ESP32.

Thanks in advance and sorry if my question is too basic, I'm new in the space :)

Version of LMIC being used: 3.2.0

cyberman54 commented 3 years ago

Look e.g. in this example

terrillmoore commented 3 years ago

MCCI does everything dynamically -- see https://github.com/mcci-catena/Catena-Arduino-Platform for how we do it. We store the keys in FRAM. There is a refactor that is currently on a branch: https://github.com/mcci-catena/arduino-lmic/tree/devel-issue578, that refactors the lower edge to create a "secure element" abstraction. It works, but I've not merged it yet because my team is still working on making the Trusted Objects soft secure element work with it, and I anticipate there may be things I overlooked. But if you look at the apis -- you can run doxygen after you've cloned the branch, I use https://scoop.sh to install doxygen on Windows, and it works well -- you'll be able to see the structure somewhat.

An intermediate approach is shown in https://github.com/mcci-catena/Arduino-LoRaWAN, which intercepts the APIs and presents a structured C++ wrapper (without needing you to use all the other MCCI framework).

peter3099 commented 3 years ago

Thank for all the help, I'm looking into the pax counter example and I think I have what I need, I will close this for now, migth reopen it if I get stuck.

Thanks again