Click here to Skip to main content
12,952,181 members (62,201 online)
Click here to Skip to main content
Add your own
alternative version


6 bookmarked
Posted 19 Jun 2014

Zena Sniffer Advanced

, 19 Jun 2014 CPOL
Rate this:
Please Sign up or sign in to vote.
This tip solves the problem of filtering and getting correct date time information on zigbee package with ZENA sniffer.


Microchip zena sniffer for zigbee network has user interface with couple of disadvantages:

  • Can’t filter saved messages
  • Can’t see current date time of package (you can get only relative timestamp of package arrival from start of program and that is only in micro seconds)
  • Can't export packages in format suitable for custom processing and analyzing

These disadvantages make zena software very hard to use on a large amount of messages. It is practically inusable for analyzing huge amount of data.

So I decided to fix this problem by creating Windows application that can communicate with USB ZENA driver, parse captured messages and then put it in database. This enables you to analyze stored data in database using SQL, create reports, etc.


Windows ZENA driver (MPLABComm) is based on Linux port of libusb to Windows (libusb-win32 ) driver. To communicate with driver, I used LibUSBDotNet USB library.

How to communicate to Zena using libusb I found online in these articles:

I adopted the upper functionality and source code from Linux c to .NET C#

LibUsbDotNetLibrary can be found at:

Driver and ZENA description can be found at:

Using the Code

To be as simple as possible, in the project I attached with this tip, I removed functionality to store data in database. Message arrival from ZENA device is indicated by message box, you can easily change that code to store data to database, file, etc.

The main limitation of project attached is that I parsed only subset of zigbee messages (only messages that my end device and coordinator are using) but you will get the idea how it is done. I used standard ZENA tool to figure out structure off each zigbee message that I use.

Code Snippets

First thing you have to do is to get a list of available ZENA devices connected to your computer. You can do it like this.

List<USBDeviceDescriptor> devices = UsbZenaAccess.GetAllDevices();

Then you must start sniffer like this (third argument of function is zigbee channel byte value between 11 and 26):

USBDeviceDescriptor selected = (USBDeviceDescriptor)devices[0];
ZenaAccesss = new UsbZenaAccess(selected.Pid, selected.Vid, (byte)26));

Parsing of arrived zigbee massages is in this code:

public static void StartProcessing(UsbZenaAccess usbZenaAccess)
          ZenaPackage zd;
          ZenaData current;
          Thread t = (new Thread(() =>
                                         while (true)
                                             current = usbZenaAccess.CollectedPackages.FirstOrDefault();
                                             if (current != null)
                                                 zd = Populate(current);
                                                 MessageBox.Show("Message arrived " + zd.CommandType);

          t.IsBackground = true;
          t.Priority = ThreadPriority.Lowest;


  • First version of this article


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Croatia Croatia
No Biography provided

You may also be interested in...

Comments and Discussions

QuestionWhere can i download`the code? Pin
Member 1153787718-Mar-15 22:46
memberMember 1153787718-Mar-15 22:46 
QuestionZena Adapter c# application help Pin
Member 1124808421-Nov-14 12:13
memberMember 1124808421-Nov-14 12:13 
GeneralMy vote of 5 Pin
Lydia Gabriella16-Jul-14 10:55
memberLydia Gabriella16-Jul-14 10:55 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170525.1 | Last Updated 19 Jun 2014
Article Copyright 2014 by amaletic
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid