netmaster19 / libxbee

Automatically exported from code.google.com/p/libxbee
0 stars 0 forks source link

xbee_pktDataGet() error for xbeeZB fields #19

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
type the source code inside a connection callback that identifies the new nodes:

  uint8_t * pValue;
  /* .......... */

  ret = xbee_pktDataGet (pkt, "Parent Address", 0, 0, (void **)&pValue);
  if (ret == XBEE_ENONE && pValue != NULL) {

    n->usParentAddr = usXNetNtoH (pValue);
    vLog (LOG_DEBUG, "\tParent address: 0x%04X", n->usParentAddr);
  }

  ret = xbee_pktDataGet (pkt, "Device Type", 0, 0, (void **)&pValue);
  if (ret == XBEE_ENONE && pValue != NULL) {

    n->ucDeviceType = *pValue;
    vLog (LOG_DEBUG, "\tDevice type: 0x%02X", n->ucDeviceType);
  }

  ret = xbee_pktDataGet (pkt, "Source Event", 0, 0, (void **)&pValue);
  if (ret == XBEE_ENONE && pValue != NULL) {

    n->ucSourceEvent = *pValue;
    vLog (LOG_DEBUG, "\tSource event: 0x%02X", n->ucSourceEvent);
  }

  ret = xbee_pktDataGet (pkt, "Profile ID", 0, 0, (void **)&pValue);
  if (ret == XBEE_ENONE && pValue != NULL) {

    n->usProfileId = usXNetNtoH (pValue);
    vLog (LOG_DEBUG, "\tProfile Id: 0x%04X", n->usProfileId);
  }

  ret = xbee_pktDataGet (pkt, "Manufacturer ID", 0, 0, (void **)&pValue);
  if (ret == XBEE_ENONE && pValue != NULL) {

    n->usManufacturerId = usXNetNtoH (pValue);
    vLog (LOG_DEBUG, "\tManufacturer Id: 0x%04X", n->usManufacturerId);
  }

What is the expected output? What do you see instead?

trace debug with git version of libxbee3:
  xnetd(debug): An XBee joined the network !
  Identify Pkt: EF030013A20040C048182000FFFE0101C105101E
  xnetd(debug):     64-bit address:  0x0013A200 0x40C04818
  xnetd(debug):     16-bit address:  0xEF03
  xnetd(debug):     Node Id: [ ]
  xnetd(debug):     Parent address: 0xFE01
  xnetd(debug):     Device type: 0x01
  xnetd(debug):     Source event: 0xC1
  xnetd(debug):     Profile Id: 0x0510
  xnetd(debug):     Manufacturer Id: 0x1E00
  xnetd(debug):     Successfully add in the active list of nodes
It is seen that the decoding of the fields is incorrect. There is a byte offset 
relative to the packet.

trace debug after applying the patch below:
  xnetd(debug): An XBee joined the network !
  Identify Pkt: EF030013A20040C048182000FFFE0101C105101E
  xnetd(debug):     64-bit address:  0x0013A200 0x40C04818
  xnetd(debug):     16-bit address:  0xEF03
  xnetd(debug):     Node Id: [ ]
  xnetd(debug):     Parent address: 0xFFFE
  xnetd(debug):     Device type: 0x01
  xnetd(debug):     Source event: 0x01
  xnetd(debug):     Profile Id: 0xC105
  xnetd(debug):     Manufacturer Id: 0x101E
  xnetd(debug):     Successfully add in the active list of nodes

What version of the product are you using? On what operating system?
libxbee3 from git repository

Please provide any additional information below.
here there is the patch to fix this bug

Original issue reported on code.google.com by pascal.j...@gmail.com on 4 Oct 2014 at 2:58

Attachments:

GoogleCodeExporter commented 8 years ago
Hello,

Thanks very much for reporting this, and apologies for my slow uptake.
I've now merged this patch with the following branches:
* master
* osx
* win32
* mingw32

Attie

Original comment by attie@attie.co.uk on 15 Oct 2014 at 10:01