C/ C++ code snippet needed: Unwrap MAC commands from payload KI

I want to enhance my paxcounter software with a simple MAC command display, to show MAC commands received by the network.

For this purpose i’m looking for a c/c++ code snippet, which unwraps MAC commands from a (already decrypted bei LMiC) Lmic.frame.

Any hints?

Isn’t it already implemented in mac_decode()?

If you want an implementation that unpacks the fields into a structure you can use this one.

I think i need to unwrap the MAC command from the frame structure (FHDR etc.), this part is still missing.

My problem is here, where calling the decoder with the unwrapped frame: