attie / libxbee3

A C/C++ library to aid the use of Digi XBee radios in API mode
GNU Lesser General Public License v3.0
68 stars 40 forks source link

xbeeZB source route packet is corrupt #32

Open mechazine opened 6 years ago

mechazine commented 6 years ago

The current xbee_sZB_createSourceRoute_tx_func in master overwrites the last byte of the last 16-bit address in the source route list as well as the last byte of the 16-bit destination address.

The offset 11 should be 12 as far as I can tell, and I am not sure why the last byte was overwritten by 0. The spec doesn't seem to indicate that.

This is the diff of my change.

diff --git a/modes/xbeeZB/route.c b/modes/xbeeZB/route.c
index cede0a9..1c94638 100644
--- a/modes/xbeeZB/route.c
+++ b/modes/xbeeZB/route.c
@@ -51,8 +51,8 @@ xbee_err xbee_sZB_createSourceRoute_tx_func(struct xbee *xbee, struct xbee_con *
        iBuf->data[0] = identifier;
        iBuf->data[1] = 0; /* the datasheet specifies that the frameID is always zero */
        memcpy(&(iBuf->data[2]), buf, len);
-       iBuf->data[11] = 0; /* the datasheet specifies that this is zero */
-       iBuf->data[bufLen - 1] = '\0';
+       iBuf->data[12] = 0; /* the datasheet specifies that this is zero */
+       //iBuf->data[bufLen - 1] = '\0';

        *oBuf = iBuf;