Skip to content

Invalid Decoding JoinRequest on mipsel #52

Closed
@devleesch001

Description

@devleesch001

Hello,

I have an importante issue.

What happened?

When the MQTT Forwarder deserialize JoinRequest Frame from Semtech UDP GWMP Frame, the MIC code is badly decoded.

For exemple the Semtech UDP GWMP JoinRequest have this MIC code [1 192 29 90] but after decoding by MQTT Forwarder have this [1 192 28 90].

All my JoinRequest with MQTT Packet Forwarder are in MIC Error.

I am sur the problem appears during json deserialization, especially when decoding the payload in base64.

How I found?

I added in code a debug print (only for me), before and After this line https://github.com/chirpstack/chirpstack-mqtt-forwarder/blob/8b2ed3d2a2bc1aab8d11a6a78a2d09929be983b9/src/backend/semtech_udp/mod.rs#L342C5-L342C51

Like this.

debug!("--- RAW UPLINK --- {:?}", data);

let pl = structs::PushData::from_slice(data)?;

debug!("--- DECODED PAYLOAD --- {:?}", pl.payload);

And I obtained this :

RAW UDP GWMP Frame :

7b 22 72 78 70 6b 22 3a 5b 7b 22 6a 76 65 72 22 3a 31 2c 22 74 6d 73 74 22 3a 38 36 33 34 32 32 31 33 2c 22 63 68 61 6e 22 3a 37 2c 22 72 66 63 68 22 3a 31 2c 22 66 72 65 71 22 3a 38 36 38 2e 35 30 30 30 30 30 2c 22 6d 69 64 22 3a 20 30 2c 22 73 74 61 74 22 3a 31 2c 22 6d 6f 64 75 22 3a 22 4c 4f 52 41 22 2c 22 64 61 74 72 22 3a 22 53 46 31 32 42 57 31 32 35 22 2c 22 63 6f 64 72 22 3a 22 34 2f 35 22 2c 22 72 73 73 69 73 22 3a 2d 35 32 2c 22 6c 73 6e 72 22 3a 36 2e 32 2c 22 66 6f 66 66 22 3a 2d 37 34 37 36 2c 22 72 73 73 69 22 3a 2d 35 31 2c 22 73 69 7a 65 22 3a 32 33 2c 22 64 61 74 61 22 3a 22 41 41 49 41 41 41 44 77 37 4a 41 41 2b 52 30 78 46 67 48 73 6b 41 41 6c 4c 77 48 41 48 56 6f 3d 22 7d 5d 7d

Manual decoding I optain this Payload in JSON

{"rxpk":[{"jver":1,"tmst":86342213,"chan":7,"rfch":1,"freq":868.500000,"mid": 0,"stat":1,"modu":"LORA","datr":"SF12BW125","codr":"4/5","rssis":-52,"lsnr":6.2,"foff":-7476,"rssi":-51,"size":23,"data":"AAIAAADw7JAA+R0xFgHskAAlLwHAHVo="}]}

This LoRaWAN DATA

AAIAAADw7JAA+R0xFgHskAAlLwHAHVo=
00 02 00 00 00 f0 ec 90 00 f9 1d 31 16 01 ec 90 00 25 2f 01 c0 1d 5a

Contain this MIC

MIC : [1 192 29 90], 01c01d5a

But after let pl = structs::PushData::from_slice(data)?;

When MQTT Forwarder deserialize the RAW UDP GWMP and decode the DATA of Payload Frame I obtaine this LoRaWAN Frame

00 02 00 00 00 f0 ec 90 00 f9 1d 31 16 01 ec 90 00 25 2f 01 c0 1c 5a
MIC : [1 192 28 90], 01c01c5a

The mic code does not correspond to the UDP frame.

GOOD 01c01d5a, BAD 01c01c5a

Material

Gateway : RAK7268CV2

uname : Linux RAK7268CV2 5.4.154 #0 Fri Nov 24 07:30:08 2023 mips GNU/Linux

cpuinfo :

system type		: MediaTek MT7628AN ver:1 eco:2
machine			: Rakwireless RAK636
processor		: 0
cpu model		: MIPS 24KEc V5.5
BogoMIPS		: 385.02
wait instruction	: yes
microsecond timers	: yes
tlb_entries		: 32
extra interrupt vector	: yes
hardware watchpoint	: yes, count: 4, address/irw mask: [0x0ffc, 0x0ffc, 0x0ffb, 0x0ffb]
isa			: mips1 mips2 mips32r1 mips32r2
ASEs implemented	: mips16 dsp
Options implemented	: tlb 4kex 4k_cache prefetch mcheck ejtag llsc pindexed_dcache userlocal vint perf_cntr_intr_bit perf
shadow register sets	: 1
kscratch registers	: 0
package			: 0
core			: 0
VCED exceptions		: not available
VCEI exceptions		: not available

OS : WisGateOS_2.2.1_RAK based on OpenWRT 21.2
Toolchain : make dist-mipsel-unknown-linux-musl

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions