Hi , i use node js https://github.com/jankolkmeier/xbee-api
my code recives the packets , analyses it and then respond accordingly.
I published the execution of my code in my last post.
the code :
var util = require(βutilβ);
var SerialPort = require(βserialportβ);
var xbee_api = require(βxbee-apiβ);
var C = xbee_api.constants;
var sleep = require(βsystem-sleepβ);
var xbeeAPI = new xbee_api.XBeeAPI({
api_mode: 1
});
var serialport = new SerialPort("/dev/ttyUSB3", {
baudrate: 9600,
parser: xbeeAPI.rawParser()
});
var cluster;
var frame_obj = {
type: 0x11, // xbee_api.constants.FRAME_TYPE.ZIGBEE_TRANSMIT_REQUEST
id: 0x03, // optional, nextFrameId() is called per default
destination64: "000d6f000bbb30c6", // default is broadcast address
destination16: "fffe", // default is "fffe" (unknown/broadcast)
sourceEndpoint: 0x00,
destinationEndpoint: 0x00,
clusterId: 0x0005,
profileId: 0x0000,
broadcastRadius: 0x00, // optional, 0x00 is default
options: 0x00, // optional, 0x00 is default
data: [0x0C, 0x00, 0xFF, 0xFE, 0x01, 0x08]
};
var frame_obj2 = {
type: 0x11, // xbee_api.constants.FRAME_TYPE.ZIGBEE_TRANSMIT_REQUEST
id: 0x03, // optional, nextFrameId() is called per default
destination64: "000d6f000bbb30c6", // default is broadcast address
destination16: "fffe", // default is "fffe" (unknown/broadcast)
sourceEndpoint: 0x00,
destinationEndpoint: 0x00,
clusterId: 0x0004,
profileId: 0x0000,
broadcastRadius: 0x00, // optional, 0x00 is default
options: 0x00, // optional, 0x00 is default
data: [0x0D, 0x00, 0xFF, 0xFE, 0x01, 0x08]
};
var frame_obj3 = {
type: 0x11, // xbee_api.constants.FRAME_TYPE.ZIGBEE_TRANSMIT_REQUEST
id: 0x03, // optional, nextFrameId() is called per default
destination64: "000d6f000bbb30c6", // default is broadcast address
destination16: "fffe", // default is "fffe" (unknown/broadcast)
sourceEndpoint: 0x00,
destinationEndpoint: 0x01,
clusterId: 0x0006,
profileId: 0x0104,
broadcastRadius: 0x00, // optional, 0x00 is default
options: 0x00, // optional, 0x00 is default
data: [0x00, 0xAA, 0x00, 0x00, 0x00]
};
serialport.on(βopenβ, function send(frame) {
xbeeAPI.on(βframe_objectβ, function (frame) {
console.log(">>", frame);
cluster= frame.clusterId;
if(cluster==β0013β){
serialport.write(xbeeAPI.buildFrame(frame_obj));
console.log(xbeeAPI.buildFrame(frame_obj));
console.log(βsent frame 1β);
}else if (cluster==β8005β){
serialport.write(xbeeAPI.buildFrame(frame_obj2));
console.log(xbeeAPI.buildFrame(frame_obj2));
console.log(βsent frame 2β);
}else if (cluster==β8004β){
serialport.write(xbeeAPI.buildFrame(frame_obj3));
console.log(xbeeAPI.buildFrame(frame_obj3));
console.log(βsent frame 3β);
}else{
console.log(βno frame sentβ);
}
});
i hope you can help me @JohnR to recive the data from this sensor .