So, I set up and end device and API coordinator (trying to make a larger network), and I want to program the coordinator to extract the correct sender address so the coordinator can talk back to the end device. I figured out a lot of string formatting stuff, and I saved the final formatted string as long_add. When I print long_add, the following prints:
But when I put dest_addr_long = long_add in the transmit function, it returns the error “destination address was not 8 bytes long” even though it CLEARLY is…
What’s even weirder is, when I copy and paste the above printed out long_add into the transmit function as des_addr_long=“\x00\x13\xa2\x00\x40\x71\x04\x1c”, the code runs! It makes absolutely no sense! The type of long_add is also string; I checked all of this. The transmit function is in the same format as all of the examples/as the end device program that sends data successfully… I’m just so lost right now- I’d be so grateful to anyone who can help.
what firmware are you running? Is this ZB, 802.15.4, Digi Mesh, etc?
The app is running on your PC? Which is connected to the coordinator?
Just trying to understand your setup.
I have the coordinator connected to a BeagleBone and programmed to continuously read data from end devices on the network (the coordinator just runs a python program I wrote and saved to the BeagleBone). I have the end device hooked up to a computer running through XCTU. I send packets manually via XCTU. The problem isn’t with the setup- python is extracting the address wrong (converting some random hex values into ASCII and leaving others unchanged). And when I type in an address to the tx function, it works, but when I have the BeagleBone extract the address, there’s a runtime error in the program despite that the address prints out correctly…
This post can solve your problem .
Assume, you are having following scenario .
source_addr = [‘0x8f’, ‘0x18’]
source_addr_long = [‘0x00’, ‘0x13’, ‘0xa2’, ‘0x00’, ‘0x40’, ‘0xb5’, ‘0xad’, ‘0x6e’]
Coordinator transmit packet to any router .
Decision can be taken at run time by coordinator.
One to many nodes transmission is thus possible.
, dest_addr=bytearray( int(x,16) for x in source_addr)
, dest_addr_long= bytearray( int(x,16) for x in source_addr_long)
It will Work . Go to very basic thing .
string to int , int to hex , hex to int .
hex(19) => ‘0x13’
int(‘0x13’,16) => 19
x = ‘0x13’
then int(x,16) will be 19