Some examples of XBee API Frames.
Modem status frame
7E 00 02 8A 06 6F
7E
: API Frame00 02
: Length8A
: Modem status06
: Coordinator started6F
: checksum FF – ((8A +06) & FF) = 6FAT Command API Frame: MY
7e 00 04 08 52 4D 59 FF
7E
: API Frame00 02
: Length08
: AT Command Frame id52
: Frame id4d 59
: MY (4d 59) (4d => M, 59 => Y) Get the 16-bit network address of the module.FF
: checksum ff = ff – ((08+52+4d+59) & ff)AT Command Response: MY
7e 00 07 88 52 4d 59 00 00 00 7f
7E
: API Frame00 07
: Length88
: AT Command Response API Identifier52
: Frame id4d 59
: MY (4d 59) (4d => M, 59 => Y) Get the 16-bit network address of the module.00
: Status 0=OK00 00
: MY value, 00 000 not set7f
: checksum ff = ff – ((08+52+4d+59) & ff)Explicit Addressing Zigbee Command Frame:
7E 00 1D 11 01 00 13 A2 00 40 3E 25 75 00 00 01 01
04 02 01 04 00 00 18 01 01 00 00 00 29 63 CE 9F
7E
: Start frame00 1D
: Length (29 bytes)11
: explicit addressing transmit01
: Frame id00 13 A2 00 40 3E 25 75
: 64 bit address00 00
: 16 bit address01
: source endpoint01
: destination endpoint04 02
: cluster id (temperature measurement cluster id/ Measurement and sensing functional domain)01 04
: profile id (home automation profile)00
: broadcast radius00
: options18 01 01 00 00 00 29 63 CE
: payload9F
: checksum
In this case the payload is a Zigbee
18 01 01 00 00 00 29 63 CE
18: // 00011000 0×18 / general command = 00/ manufacturer specific = 0/ direction =1/ disable default rsp = 1 / reserved = 000
01: transaction sequence
01: read response 00 00: attribute identifier (temperature) 00: status success
29: attribute data type = 29 signed 16 bit integer 63 CE: temp value (25550 / 100)
01: transaction sequence
01: read response 00 00: attribute identifier (temperature) 00: status success
29: attribute data type = 29 signed 16 bit integer 63 CE: temp value (25550 / 100)
References:
- XBee(R) & XBee-PRO(R) ZB ZigBee(R) PRO RF Modules
- xbee manual
- What is API (Application Programming Interface) Mode and how does it work?
- Zigbee specification
- Zigbee Home Automation Public Application Profile
- Zigbee Cluster Library
XBee API Library for Processing
Dan Shiffman and I are continuing development on a Processing library for Digi’s XBee radios. Tom Igoe has also contributed code. The library now facilitates receiving multiple sample I/O packets in API mode (ATAP1) from both the 802.15.4 and ZNet 2.5 XBee radios, and returns an object that contains the analog values, digital values, sender’s address and RSSI values. We started with I/O frames because the only way to receive this information is via API mode. The ability to send remote AT commands is now included. The library has been tested on Mac OS X and Windows platforms.
DOWNLOAD
- XBee API Library 1.4 for Processing
including Example and new File Display Example
(posted January 2009) - XBee API LIbrary 1.3 for Processing(posted November 2008)
- XbeeApiExample13.zip
- XBee API Library 1.2 for Processing
- XBee API 1.2 Example
DOCUMENTATION
XBeeReader class
XBeeReader constructor takes the parent PApplet “this” and a reference to a made serial port
port = new Serial(this, Serial.list()[0], 9600);
xbee = new XBeeReader(this,port);
start() – takes in the string of your setup commands and returns a string of responses. The first command in the string must begin with AT. Any commands that follow must be separated by commas and do not use AT. There is no comma after the last command.
println("Setting up Xbee"); String response = xbee.start("ATRE,ID3333,MY89,DH0,DL0");
println("Setup response: " + response);
getXbeeReading() – returns the XBeeDataFrame object
XBeeDataFrame data = xbee.getXBeeReading();
XBeeDataFrame class
Contains the information delivered in an XBee data frame. IN THIS INITIAL EXAMPLE IT IS ONLY I/O DATA. The available methods are:
getAddress16() – returns the 16-bit transmitter address as an integer
getAddress64() – returns the 64-bit transmitter address as an long
getRSSI() – returns the RSSI reading in dBm as an integer (XBee Series 1 only)
getTotalSamples() – returns the total number of samples contained in the data frame
getDigital() – returns an array of integers that represent the current state of each digital channel with -1 indicating that the channel is not configured for digital. Use this when there is only one sample per frame.
getDigital(int n) – returns the nth sample of digital data as an array of integers with -1 indicating that the channel is not configured for digital.
getAddress64() – returns the 64-bit transmitter address as an long
getRSSI() – returns the RSSI reading in dBm as an integer (XBee Series 1 only)
getTotalSamples() – returns the total number of samples contained in the data frame
getDigital() – returns an array of integers that represent the current state of each digital channel with -1 indicating that the channel is not configured for digital. Use this when there is only one sample per frame.
getDigital(int n) – returns the nth sample of digital data as an array of integers with -1 indicating that the channel is not configured for digital.
getAnalog() – returns an array of integers that represents the current state of each analog channel with -1 indicating that the channel is not configured for analog. Use this when there is only one sample per frame.
getAnalog(int n) – returns the nth sample of analog data as an array of integers with -1 indicating that the channel is not configured for analog.
getAnalog(int n) – returns the nth sample of analog data as an array of integers with -1 indicating that the channel is not configured for analog.
int addr = data.getAddress16();
int rssi = data.getRSSI();
int[] digital = data.getDigital();
int[] analog = data.getAnalog();
XBeeEvent function
This function is similar to SerialEvent. The XBeeEvent is called for you when there is data available from your XBee radio.
public void xBeeEvent(XBeeReader xbee) {
XBeeDataFrame data = xbee.getXBeeReading();
}
沒有留言:
張貼留言