mirror of
https://github.com/chirpstack/chirpstack.git
synced 2025-05-28 13:34:16 +00:00
lrwn: Allow empty string for AES128Key, DevAddr, EUI64 and NetID.
In case an empty string is provided, the default "null" value will be used. Fixes #453.
This commit is contained in:
parent
920f485734
commit
f76a4b7f83
@ -62,7 +62,9 @@ impl FromStr for AES128Key {
|
|||||||
type Err = Error;
|
type Err = Error;
|
||||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||||
let mut bytes: [u8; 16] = [0; 16];
|
let mut bytes: [u8; 16] = [0; 16];
|
||||||
hex::decode_to_slice(s, &mut bytes)?;
|
if !s.is_empty() {
|
||||||
|
hex::decode_to_slice(s, &mut bytes)?;
|
||||||
|
}
|
||||||
Ok(AES128Key(bytes))
|
Ok(AES128Key(bytes))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -234,7 +234,9 @@ impl FromStr for DevAddr {
|
|||||||
type Err = Error;
|
type Err = Error;
|
||||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||||
let mut bytes: [u8; 4] = [0; 4];
|
let mut bytes: [u8; 4] = [0; 4];
|
||||||
hex::decode_to_slice(s, &mut bytes)?;
|
if !s.is_empty() {
|
||||||
|
hex::decode_to_slice(s, &mut bytes)?;
|
||||||
|
}
|
||||||
Ok(DevAddr(bytes))
|
Ok(DevAddr(bytes))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -70,7 +70,9 @@ impl FromStr for EUI64 {
|
|||||||
type Err = Error;
|
type Err = Error;
|
||||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||||
let mut bytes: [u8; 8] = [0; 8];
|
let mut bytes: [u8; 8] = [0; 8];
|
||||||
hex::decode_to_slice(s, &mut bytes)?;
|
if !s.is_empty() {
|
||||||
|
hex::decode_to_slice(s, &mut bytes)?;
|
||||||
|
}
|
||||||
Ok(EUI64(bytes))
|
Ok(EUI64(bytes))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -129,7 +129,9 @@ impl FromStr for NetID {
|
|||||||
|
|
||||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||||
let mut bytes: [u8; 3] = [0; 3];
|
let mut bytes: [u8; 3] = [0; 3];
|
||||||
hex::decode_to_slice(s, &mut bytes)?;
|
if !s.is_empty() {
|
||||||
|
hex::decode_to_slice(s, &mut bytes)?;
|
||||||
|
}
|
||||||
|
|
||||||
Ok(NetID(bytes))
|
Ok(NetID(bytes))
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user