gateway: minor refactoring and pack as many mavlink packets into a commsec packet as will fit.