Skip to content
Christopher Piggott edited this page Apr 3, 2015 · 2 revisions

Welcome to the zdo-java-api wiki!

This library is a simple ZDO/ZCL parser for java. It has few dependencies, and doesn't deal with the origin of the byte stream, allowing you to use anything you want, including my xbee library. Currently the library does not support very many ZDO messages, and the only knowledge the library has of ZCL are that certain messages have 'attributes' which have 'types' and 'values.'

About Zigbee Licensing

Zigbee licensing is a bloody freakin' mess and I am staying out of it to the best extent possible. The code contained here should be considered for educational purposes and not suitable for anything else - especially with regard to life safety, legal issues, licensing, or anything like that. The fact that I'm licensing this in a way that says you can use it how you want doesn't alleviate you from obeying Zigbee's licensing terms, copyrights, labeling, or any other of their requirements. This is part of the reason I'm staying as far away from actual profiles/clusters as possible.

Basic Usage

This is a conceptual sample to give you the basic idea:

 import com.autofrog.zcl.api.ZclAttributeParser;

 ByteBuffer payload = ByteBuffer.wrap( bytes );
 ZigbeeClusterMessage zclMessage = ZclAttributeParser.parse( payload);
 for (ZclAttribute attribute : zclMessage .getAttributes()) {
    if (attribute instanceof ZclNumberAttribute) {
     ZclNumberAttribute numAttribute = (ZclNumberAttribute) attribute;
        System.out.println( String.format("Attribute 0x%04x has type 0x%02x and value %5.2f",
          numAttribute .getAttgributeId(),
          numAttribute .getType(),
          numAttribute .getValue().toFloatValue());
    }

More Advanced Usage

You can couple this to my xbee java api library if you wish:

 private final XbeeMessageListener<XbeeExplicitRxMessage> zclListener = new XbeeMessageListener<XbeeExplicitRxMessage>() {
    @Override
    public void onXbeeMessage(Object sender, XbeeExplicitRxMessage msg) {
        /* parse msg.getPayload() pretty much same as above */
    }
 }

 /* xbee is the actual parser interface */
 xbee.addListener(XbeeMessageType.EXPLICIT_RX, zclListener);

but it's not required. The input to this library is mainly just a string of bytes.

Limitations, Philosophies, and other notes

I develop for my own use case first, with an attempt to make things generic enough to be useful for other people later. I currently use ZDO subscription i.e. "Report Attributes" but the subscriptions themselves are static - remote Xbee device that launch off report attributes commands, only to the coordinator, on a timer. Eventually I'll support other kinds of messages in this library, including the ability to subscribe and poll.

Versioning

I plan to use the semver versioning scheme

MAJOR revisions MAY break the API (but might just enhance it) MINOR revisions may ADD to the API but won't break it PATCH revisions will be reserved for bug fixes only

Help me!

There is much more to ZDO and ZCL. If you want to contribute, please do - fork this project, try to follow my patterns, then submit a pull request. If you have any questions do not hesitate to ask.