Charmed Quark Systems, Ltd. - Support Forums and Community
Zigbee Information - Printable Version

+- Charmed Quark Systems, Ltd. - Support Forums and Community (https://www.charmedquark.com/vb_forums)
+-- Forum: General Discussion (https://www.charmedquark.com/vb_forums/forumdisplay.php?fid=3)
+--- Forum: Driver Development (https://www.charmedquark.com/vb_forums/forumdisplay.php?fid=13)
+--- Thread: Zigbee Information (/showthread.php?tid=9674)

Pages: 1 2 3


Zigbee Information - dkulesza - 02-07-2016

I've been lurking on CQC for the past few months and have been slowly planning the architecture and design for my home automation. ZigBee has been a technology with gaps across many vendors, but seems like the ideal technology to use for wireless.

The general Internet sentiment seems to be: Find a ZigBee adapter with the Home Automation Profile loaded. The reality is - most ZigBee RS232/USB devices that can be programmed require $$$$ development kits and you'll most likely never see a "AT Command" version for the Home Automation Profile including all clusters.

I've stumbled across the following post: https://ms-iot.github.io/content/en-US/win10/samples/ZigBeeAdapterTutorial.htm and looked at the XBEE implementation. This is a fairly interesting (and robust) sample because of the following:

C#/.NET compatible library
Interfaces with the common XBEE (API mode)
Has numerous Home Automation clusters predefined
Fairly simple API to interface with ZigBee devices

Because of the above, I felt it would be valuable to share with the CQC community as this may be a Jumpstart path to build out a ZigBee HA compatible driver.

I've successfully stripped out the "AllJoyn" bridge components from the example and have successfully been able to query my Kwikset ZigBee locks and issue lock/unlock commands.

This seems like the most robust "ZigBee HA" API example I can find published online. It really eliminates the need for finding Unicorn HA 1.2 adapters and gives you a much more robust mechanism to support additional (or non HA 1.2 spec) clusters.

Advice for anyone wanting to experiment:
You must properly configure your XBEE device with XCTU
Other than the obvious (API mode, coordinator, etc.) you'll need to ensure you set the Encryption Key (Required for lock pairing). This key is published in the ZigBee Alliance spec (and can be found with google). In addition, must setup the EE and other parameters accordingly.

Also, when dealing with battery devices, you'll need to make sure your coordinator has power settings appropriately defined so when the battery devices wake up - they aren't spending time trying to re-associate and able to quickly communicate.

With this - someone so included could:
Leverage Windows 10 IoT example and make a custom "gateway/bridge" and call using CML/PDL.
Write a native Windows C# to run local on CQC box and connect via socket locally using CML/PDL
Port C# example to C++ for native CQC driver
Ability to call windows libraries (.NET) from CQC???? (Don't know if possible but would make it easy to consume)

Anyways - just wanted to share this with everyone as it has felt painful to find a way to programmatically interface with ZigBee without a Hue/Smart Things or other device (which I needed more direct interface). (My end goal is to have an Analog I/O to ZigBee devices - not necessarily native CQC).

Hopefully this helps someone out in achieving goal to support ZigBee with CQC!


Zigbee Information - Dean Roddey - 02-07-2016

I was looking at the XBee devices as well a couple weeks ago. I'd want to do a C++ CQC driver optimally. Otherwise it would have to be a Windows service that CQC could talk to via some API.

Maybe you've already verified this, but keep in mind that just because something use the HA profile, that doesn't necessarily mean that you can control it from a generic HA profile enabled Zigbee controller. They can define manufacturer specific messages that they require the controller to understand and respond to, and they will just refuse to join if you don't know how to respond.

I dunno if that applies to any of the devices you are interested in or not, but just in case it's relevant for you I figured I'd throw that out there.

Anyway, if you can help me out with getting it all set up, I could begin to do some work in this direction. I'd be a little limited initially because 5.0 stuff has to come first. But since this would be a fairly big thing, it would be worth doing some experimentation for a while anyway before really committing.


Zigbee Information - dkulesza - 02-07-2016

Dean Roddey Wrote:I was looking at the XBee devices as well a couple weeks ago. I'd want to do a C++ CQC driver optimally. Otherwise it would have to be a Windows service that CQC could talk to via some API.

Maybe you've already verified this, but keep in mind that just because something use the HA profile, that doesn't necessarily mean that you can control it from a generic HA profile enabled Zigbee controller. They can define manufacturer specific messages that they require the controller to understand and respond to, and they will just refuse to join if you don't know how to respond.

I dunno if that applies to any of the devices you are interested in or not, but just in case it's relevant for you I figured I'd throw that out there.

Anyway, if you can help me out with getting it all set up, I could begin to do some work in this direction. I'd be a little limited initially because 5.0 stuff has to come first. But since this would be a fairly big thing, it would be worth doing some experimentation for a while anyway before really committing.

Hello Dean! Thanks for all the hard work on CQC.

I strongly encourage you to take a glance at the C# library that ms-iot has on GitHub. May be able to quickly jumpstart a native c++ library for you (or allow an adventurous individual to write the windows service/api version).

Regarding your concern about incompatibility - It very well may be valid, I've read Internet concerns, but when seeing how this library interfaces directly with the XBEE - it doesn't seem like it would matter. It appears they've recreated the Home Automation profile all in software and the XBEE is just the hardware/radio interface to send the packets.

Now, there are some coordinator / ZDO specifics I could see being a challenge, but honestly - I'd think getting a lock to pair/join would be the most challenging ZigBee HA device to interface with (considering security concerns). It's using Trust Center with encryption (not just a randomly negotiated network key) to begin join network. Now, you could run into complexities if you're joining devices with different base Trust Center Keys, but the reality is HA 1.2 all uses the same default key "ZigbeeAlliance09" or was it "ZigBeeAlliance09".

If you (or someone) is aware of a problematic device that is "outside of base" spec for integration, I'd love to try and interface. I have my XBEE development environment all ready to go. My two most hair pulling moments were figuring out why the lock wouldn't join (Trust Center encryption) and why messaging/communication quit working after 3-5 sends (Lock going to sleep). Both of those required me configuring settings on the XBEE to address.

The way this is implemented, I really don't see any dependency on HA 1.2 profile firmware. Bulk of HA 1.2 standard is about clusters, which you can quickly and easily add (Would be slick of your C++ interface allowed an XML cluster config for end-user expandability). It also seems like it's going pretty low level because it's mapping out the network devices in memory for delivery. Right now the example API I've shared can only talk to "Level 0" (peers) and has no awareness of the entire ZigBee network. I plan on writing some code to look at routers and their associated endpoints and build out an entire ZigBee map. Right now I'm smiling to have lock status and command ability in a weekends worth of work.

I'm all for helping you (or anyone else) get started with ZigBee. I'm hoping in the next two weeks or so I'll have a hardware device to provide analog pins (both input and output) interfacing with a ZigBee lock. Think leveraging a traditional commercial access control panel with a ZigBee lock and using a device to map voltage input to send door unlock and issue analog/digital out for door status (open/closed). Goal is to use commercial capable access control with house friendly hardware (Door strike for day to day access and ZigBee deadbolt for "lockdown/secure" mode.)


Zigbee Information - Dean Roddey - 02-07-2016

It's not that they are out of spec really. The HA spec doesn't preclude manufacturer specific messages. They wouldn't be used in the normal course of interaction, since that needs to be HA profile compliant. But, during the device inclusion process, if you are trying to use a network coordinator other than their own, and to get them to pair with it, they can send out manufacturer specific messages during the inclusion process. If the coordinator doesn't respond correctly, they'll just refuse to include that network.

That way, they can use standard HA profile stuff, but require that only their own controller or hub can be used paired with their own devices. That's what I reading a couple weeks ago.

Clearly, for a driver, one requirement would be that we identify modules and allow the user to tell us names for them, assuming Zigbee HA profile doesn't inherently include a module naming scheme and the ability to query that info. But, somehow, we have to find the target modules, get a unique address for them, figure out what they are, create appropriate fields for them based on type, and associate incoming messages with a C++ object that represents that type (and presumably is keyed on the unique Zigbee address of the module.)

However, I'm not sure that it's a good thing to just allow auto-inclusion in your CQC network just because it's found. It may be that we want to allow the user to select which devices he wants CQC to know about, if nothing else than to just cut down the clutter of fields and the Zigbee network traffic that would entail. If that's the case, then we still have to have some sort of configuration mechanism. And there may be things like, it's really a relay but the user is using it as a light and wants it to show up in CQC as a light. That sort of thing would require configuration as well.


Zigbee Information - Dean Roddey - 02-11-2016

Which specific XBee unit did you get that was pre-set up for HA profile?


Zigbee Information - dkulesza - 02-15-2016

I ordered mine from Mouser:

888-XBP24CZ7WIT-004
XBP24CZ7WIT-004
XBee-PRO ZB S2C TH

You want to find one that is XBP24C (The C is the latest revision of the Xbee). It has updated radio, one firmware can run in multiple modes (coordinator, endpoint, router) without reflashing. From what I understand, you need the S2C to support HA profile. However, this is an "HA READY" radio. A lot of code for ZDO/ZCL is required to be implemented by the driver/app leveraging the radio.

I've consistently had luck with the XBEE being able to communicate with my lock and other zigbee devices. Currently I'm trying to write support for Attribute Reporting. The downside (and upside) to the XBEE is all of the HA Profile implementation is on the developer to implement. You have to understand how the various packets are created to build out Zigbee HA Profile support. Right now I'm struggling to find documentation on how to send an Attribute Subscribe to the door lock so it will tell me when lock status changes (rather than me poll it). I did pick up a Telegesis HAI USB stick to tinker with as well. It has AT Command API specific to Zigbee HA. I can actually send an AT+DOORLOCK or AT+SUBSCRIBE etc type command to interface with devices. The XBEE version is much more involved requiring you to write API frames to the device (and understanding the format of those frames).

Said and done, it was ~50 bucks for the radio and a SparkFun USB dongle to get started. I'll be glad to donate my Telegesis kit (or buy you one) if you'd like to experiment with it as well.


Zigbee Information - dkulesza - 02-15-2016

Also:

http://www.programcreek.com/java-api-examples/index.php?source_dir=bekko-master/bekko-zcl/src/main/java/com/valleycampus/zigbee/zcl/core/ReportingRegistration.java

Another Library/Source I found online that's helping me understand how certain Frames should be created (Specific to Attribute Reporting Registration).


Zigbee Information - Dean Roddey - 02-17-2016

A couple questions to save me digging time...

1. Where does the USB dongle come in
2. What is the mechanism by which you interact with the XBee module in terms of setup and configuration to get it ready to use?


Zigbee Information - dkulesza - 02-17-2016

Dongle: https://www.sparkfun.com/products/11697

Converts the through hole Xbee to USB and makes it easy to use.

You'll interface with the XBEE using XCTU: http://www.digi.com/products/xbee-rf-solutions/xctu-software/xctu

I can give you all the configuration settings you want for HA Ready mode when you're at that point.


Zigbee Information - dkulesza - 02-17-2016

FYI - I'm experimenting with a Silicon Labs USB stick.

Why you would ask? I believe smart things is leveraging this hardware and the Zigbee software stack included with smart things is the same (EmberZNet). The benefit to this is all of the "open" integration with Zigbee devices and smart things would allow someone to leverage the same effort/research to jump start integration.

More to come - experimenting with it now and through the weekend. I'm hoping I can avoid the $$$$ development kit / programmer.