Guys,
Apologies for yet another post. I figured it would be best to put this in a seperate thread.
I want to be able to send a byte from TTN to my LoPy4, read it and then process it.
My code on the LoPy4 follows the Core-Electronics example:
if len(rx_pkt) > 0:
print("Downlink data on port 200:", rx_pkt)
print('length:', len(rx_pkt))
print("Unpacked Downlink_packet is:", ustruct.unpack('f',rx_pkt)[0]) # This is the line that errors out
pycom.rgbled(0xffa500)
# #input("Downlink recieved, press Enter to continue")
utime.sleep(3)
pycom.heartbeat(False)
On the TTN website I can send a Downlink byte of 01, it schedules it and sends. The LoPy4 receives it and displays the following in the REPL.
In short, its the ustruct.unpack()
that Im struggling with - but after all I learnt previously I have no idea why. Why is a buffer too small?
My TTN encoder is left unchanged from Default, ie:
function Encoder(object, port) {
// Encode downlink messages sent as
// object to an array or buffer of bytes.
var bytes = [];
// if (port === 1) bytes[0] = object.led ? 1 : 0;
return bytes;
}
Im wondering if this could be the problem? Although if it is, again I do not know why because I am getting what I expect on the REPL before decoding.
Thoughts please.
Thanks
Jon