I am trying to build an XBee dest_addr_long
(Hex address of the XBee) but I keep getting error
ValueError: The data provided for 'dest_addr_long' was not 8 bytes long
I have tried the example:
device={
"CO3":'\x00\x13\xa2\x00\x40\x52\x8d\x8a'
}
and this works, but I don't know the address until the device shows up on my PAN and then I get the address and store it in a database and change the Node ID.
Here is my code and how I am trying to generate the XBee Address
xbee_source_addr_long = xbee_packet['source_addr_long']
source_addr_long= ''.join(x.encode('hex') for x in xbee_source_addr_long)
xbee_source_addr_long_hex = (r"\x" + str(source_addr_long [0:2]) +
r"\x" + str(source_addr_long [2:4]) +
r"\x" + str(source_addr_long [4:6]) +
r"\x" + str(source_addr_long [6:8]) +
r"\x" + str(source_addr_long [8:10]) +
r"\x" + str(source_addr_long [10:12]) +
r"\x" + str(source_addr_long [12:14]) +
r"\x" + str(source_addr_long [14:16]))
This gives me a string in the correct format but the len is 32.
Question: How can I take the source_addr_long and generate a readable string that has a len of 8 and looks like this \x00\x13\xa2\x00\x40\x52\x8d\x8a