Fix bytes -> data. Expose real codec error.

This commit is contained in:
Orne Brocaar 2022-04-24 12:48:06 +01:00
parent f5de67a817
commit f2e6d77ce4
2 changed files with 2 additions and 6 deletions

View File

@ -74,11 +74,7 @@ pub async fn binary_to_struct(
Ok(match codec {
Codec::NONE => None,
Codec::CAYENNE_LPP => Some(cayenne_lpp::decode(b).context("CayenneLpp decode")?),
Codec::JS => Some(
js::decode(f_port, variables, decoder_config, b)
.await
.context("JavaScript decoder")?,
),
Codec::JS => Some(js::decode(f_port, variables, decoder_config, b).await?),
})
}

View File

@ -45,7 +45,7 @@ export function Encode(input) {
// Input is an object with the following fields:
// - f_port = LoRaWAN fPort
// - variables = Device variables
// - bytes = Input byte array, e.g. [225, 230, 255, 0]
// - data = Input byte array, e.g. [225, 230, 255, 0]
//
// This function must return an object, e.g. {"temperature": 22.5}
export function Decode(input) {