Need help ASAP: MKR WAN 1300 not sending proper data to TTN

It is quite hard to read code like this. Could you use code tags and proper indentation?