Page 1 of 1

Zigbee address and data

Posted: Tue Feb 16, 2016 11:56 am
by Walbeek
Hi there,

I'm testing with several Zigbee Eblocks.
I would like to give the modules a address (byte) and let them receive data (byte)
The Zigbee command is "SendChar" to send a byte on the Zigbee network.
How can I send more than one byte (from coordinator) and let the zigbee routers know that the first one is a address?
Do we need a checksum here and how does the router answers?
Can anyone point me in the right direction?
Please let me know.

Re: Zigbee address and data

Posted: Tue Feb 16, 2016 12:18 pm
by Benj
Hello Rinie,

I would create a protocol to allow you to do what you need.

A simple protocol might look like this.

Start Byte
Address
Data0
Data1
...
End Byte / Checksum

When sending out a packet you simply send out the bytes in order e.g.

start byte = 0x5A
Address = 0x01
...
end byte = 0xA5

At the receiving end you wait for the value 0x5A to be received, you then know that the next byte will be the address and bytes after that will be data. If one of the data bytes is 0xA5 then it could be the end of packet or it could be a data value.

Fixing the number of data bytes would help to get around this potential issue but there are other workarounds if you need variable data lengths. One is to send the number of data bytes before or after the address.

Implementing a checksum instead of the fixed end byte would allow for error checking so the receiver knows the data it receives is correct.

To do a simple checksum you can simply do something like this.

Checksum = 0
Send Start Byte
Checksum = Checksum ^ Start Byte
Send Address
Checksum = Checksum ^ Address
Send Data0
Checksum = Checksum ^ Data0
Send Data1
Checksum = Checksum ^ Data1
...
Send Checksum

At the receiver end you do the same calculations on the incoming data and if the checksum byte matches your calculation you know the data is valid and can be actioned.