Read this:
https://www.thethingsnetwork.org/docs/devices/bytes/
and look the code related to the payloadBuffer: