0

I have a zigbee usb dongle that plugs into the usb port on my Windows laptop. I need to be able to capture the incoming packets.

I am trying to write a c program that will capture the incoming packets by monitoring the bus associated with the corresponding usb port.

Are there some c libraries that facilitate this monitoring? If not how can I access the contents of the bus?

JasonMArcher
  • 14,195
  • 22
  • 56
  • 52
user1165788
  • 63
  • 1
  • 4

3 Answers3

2

This is what a hardware driver does for you: it monitors low-level hardware directly, and then processes and exposes that data to user-level programs in a more convenient interface.

I think Telegesis and Adaptive offer Windows drivers for download; whoever manufactured your Zigbee should provide drivers of their own, if those aren't compatible.

Or you could write your own driver, but that is a very difficult and tricky piece of work not for the faint of heart.

Crashworks
  • 40,496
  • 12
  • 101
  • 170
  • 2 Questions, 1 - Are there no basic libraries to stream the bus inputs. It sounds like a basic task in windows, that should be available. 2 - Assuming that one of the drivers you recommended work or I build one, how would I be able to reference it in an independent c program that will manipulate the packets? – user1165788 Jan 24 '12 at 03:56
  • @user1165788 It looks like libusb can be linked from C and C++. – Crashworks Jan 24 '12 at 10:36
  • i did some research and found that a driver exists, the Texas Instrument cebal2_x64.sys. Now how would I leverage this driver to write a program in c? – user1165788 Jan 24 '12 at 23:04
1

You can easily read and write USB packets using libusb. Normally I use libusb via the python wrappers pyUSB

However, do you actually have documentation on how to encode/decode the packet formats coming from your particular dongle? The actual zigbee packets may be wrapped up in some proprietary protocol that you would need to be able to decode.

I am also assuming your USB dongle is actually communicating via raw USB, and not using an FTDI chip to create a virtual serial port over USB. If that was the case, then you don't need to muck with USB, just use the virtual COM port for serial data.

TJD
  • 11,800
  • 1
  • 26
  • 34
  • I am quite constrained in the languages which I can used, which are C/C++, Visual Basic, Pascal, and Fortran. But this looks promising, I will check it out. Thanks!! – user1165788 Jan 24 '12 at 04:11
0

It would be useful to open case of the dongle and take a look at the chips used (only do so if it's easy to open and you're comfortable with the idea).

You say it's Texas Instruments based: then it's probably running TI's Z-Stack firmware. If that's the case there is a good chance it's running the Z-Stack Monitor and Test API (search for document code SWRA198). You can easily write C/C++ to interact with that.

However your first hurdle is to be able to read/write to the device. If it has a FTDI chip then that's going to be easy: it should appear as a virtual comm port as mentioned in a previous post. A chip like the CC2531 is capable of connecting directly to the USB bus. I'm not familiar with that configuration. I've got one such dongle and they use some weird Texas Instruments serial-over-USB protocol. But if you get the right Windows driver it should appear as a regular comm port for applications to use.

jdesbonnet
  • 251
  • 3
  • 7