Please edit your post to have your code as preformatted text, see Wiki - how to post code on this forum. You can edit your post by clicking the pencil icon in the bottom right.
Also, if possible please provide actual screenshots, instead of camera pictures of your screen. Users on mobile will not be able to read your second screenshot(I can barely read any of it)
To start, try adding some logging statements throughout your script to determine what format the data is in at various points and what the value of the data actually is. You might need to decode a byte array into a usable format.