andrewrapp / xbee-arduino

Arduino library for communicating with XBee radios in API mode
GNU General Public License v2.0
334 stars 162 forks source link

Add support for callbacks and various other improvements #9

Closed matthijskooijman closed 8 years ago

matthijskooijman commented 9 years ago

This implements a number of improvements mentioned in #5. Since they turned out to be orthogonal to the changes in #6, I decided to create a new PR instead of adding these commits there.

This PR adds support for a callback-based API style, which can make sketches significantly shorter and easier to read and write. Two new examples are added that use the callback API. Another significant change is support for Zigbee Explicit TX and RX packets (e.g using a custom profile/cluster id), which allows communication with non-XBee devices (e.g. using Zigbee Home Automation). The second example uses these to scan the network for devices and supported endpoints/profiles/clusters, making it a good starting point for integrating off-the-shelf zigbee devices.

The changes to the existing getXxxResponse() API and response internal fields mentioned in #5 are not present in this PR yet, I plan to submit those later after we figure out what the best approach is there (also, I don't strictly need those changes for my book, so there is less of a hurry).

@andrewrapp, any chance you could go over this PR (and preferably also #6) in the coming weeks? If so, I'll be able to use this new API in my book, which is due early august.

matthijskooijman commented 8 years ago

I just modified the last commit, renaming the example from ZdoScan to ZdpScan. On closer reading of the Zigbee spec, turns out the discovery uses the Zigbee Device Profile, not Zigbee Device Objects.