Closed Shiny380 closed 1 month ago
This means removing the device address, inner header (4 + 3 = 7) from the start and the CMAC and the RSSI, SNR bytes on the end (4 + 2 = 6)
@Shiny380 Don't the payloads for Micro Edge from this comment https://github.com/NubeIO/module-core-loraraw/issues/28#issuecomment-2196103555 have inner header? The current implementation for Micro Edge does not account for inner header and data after the address is decoded as value.
I tried extracting values from the above payloads after removing these bytes from the front and end but the remaining bytes were not sufficient (maybe because of the inner header & cmac). Do you have some test data?
@Shiny380 I've created a draft PR for this issue. The PR is in draft as I'm still confused about the following,
func CheckPayloadLength(data string) bool {
dl := len(data)
return dl == 36 || dl == 32 || dl == 44
}
Are payload for Micro Edge and Droplet similar to Ziphydrotap/Rubix? Where, In Hex,
Based on this, I might need to adjust bytes for decoders.
Ah sorry I forgot to account for that. We can detect 2 scenarios like so: (taken from here)
# +4 for HEADER, +4 for CMAC, +1 for RSSI and +1 for SNR. total = 10 bytes (4+4+1+1)
if length % 16 == (LORA_RAW_HEADER_LEN + LORA_RAW_CMAC_LEN + RSSI_LEN + SNR_LEN):
# LoRaRAW Unique device (Rubix, Zip)
else:
# Legacy device (Droplet, MicroEdge)
If LoRaRAW device, do new approach, else lets just keep the droplet and microedge decoders as they are. the old legacy devices suck and are a mess haha best to not touch them :sweat_smile:
driver-lora has been printing data slightly wrong this whole time and we need to align it to existing firmware. See that ticket here.
This small refactor will require several changes
First, only send the data section to the decoder. This means removing the device address, inner header (4 + 3 = 7) from the start and the CMAC and the RSSI, SNR bytes on the end (4 + 2 = 6) so something like
decode(data[7:-6], ...)
(Note this is bytes not hex, so double if accounting for hex string).You will need to account for this difference in EACH decoder as the location of each byte will be different now.
Remove the RSSI and SNR decoding and writing from EACH decoder and do it in one place instead: AFTER the main decoding and IF the main decoding returns successfully. i.e. here