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 .