New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Examples: Add support for overriding lorawan keys during build via LORA_APPKEY, LORA_DEVEUI.. values #232
Conversation
What about providing this as a util in the lorawan-device module? You could call the util from build.rs. |
Come to think of it, providing this as a util in the lorawan module will be difficult because this (and build.rs) can depend on std but lorawan can't. We could create lorawan-util crates that has std... but I think this is also fine the way it is. |
Actually, I was wrong above. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some non-blocking suggestions.
use std::path::PathBuf; | ||
|
||
fn hex_to_bytes(s: &str) -> Option<Vec<u8>> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hex::encode?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I initially didn't want to include extra dependency for just a single semi-trivial function (left-pad
🗡️ )..
const DEVEUI: Option<[u8; 8]> = {};\n\ | ||
const APPEUI: Option<[u8; 8]> = {};\n\ | ||
const APPKEY: Option<[u8; 16]> = {};\n", | ||
parse_lorawan_id(option_env!("LORA_DEVEUI"), "LORA_DEVEUI", 8).unwrap_or("None".to_string()), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
perhaps implement DevEui/AppEui/AppKey::from_str
? Feature-gated behind std being enabled in lorawan-encoding.
I also see that we hand-rolled the hex encoding here in lorawan-encoding. I've corrected there here. |
I went ahead and just made the PR for lorawan-encoding: #234 |
just for consideration the hex decoding can be done at compile time without custom build scripts by using the hex-literal crate. https://crates.io/crates/hex-literal |
So, I basically ran into a headache and current version is good enough.
(Also, |
Add possibility to overriding LoRaWAN keys from env during compile.
964a764
to
57c1c13
Compare
Implement lorawan key customization via environment variables (for nrf52840):
LORA_APPEUI= LORA_APPKEY= LORA_DEVEUI=1122334455667788 cargo build --release