The long packet command is specially designed to work on RAK WisGate Edge gateways and follow the rules of LoRaWAN specs (though technically it is still a non-standard).
If you use WisGate Edge with WisGateOS built-in network server, those long packets will be automatically merged. However, if you are using an external network server like Chirpstack, you have to manually combined those packets.
I discussed this before with development team if we can expose the long payload algorithm. However, it is proprietary to RAK ecosystem (RUI3 and WisGate OS) at the moment. I will check this again if new direction has been set since we are leaning towards now to open source.