使用XBEE S1 + api com.rapplogic.xbee发送

时间:2015-08-24 13:30:26

标签: send xbee

我使用com.rapplogic.xbee api和XBEE S1。

我想发送这个数组:

var http = require('http');

var jade = require('jade');

var moment = require('moment');

var Connection = require('tedious').Connection;
var Request = require('tedious').Request;

var express = require('express');
var app = express();

var config = {
    server: 'myserver',
    userName: 'myuser',
    password: 'mypassword',
    options: {
        instanceName: 'myinstance',
        database: 'mydb',
    }
};

app.set('views','./views');
app.set('view engine','jade');

app.use('/public',express.static(__dirname + '/public'));

var results = [];

function requete1(dated, datef) {
    return ligne = "select Batch, Parametres, Etat, Durée, Resultat " +
                            "from LancementsNuit where HeureDebut >= '"+dated+" 18:00:00' " +
                            "and HeureFin <= '"+datef+" 18:00:00'";
}

function connx(x_date1,x_date2) {
    var conn = new Connection(config);
    //flush de result
    result = [];
    conn.on('connect', function () {
        console.log(requete1(x_date1,x_date2));
        var request = new Request(requete1(x_date1,x_date2), function(err, rowCount) {
            if (err)
                console.error(err);
        });

            request.on('row', function(row) {
                results.push({
                    batch: row[0].value,
                    parametres: row[1].value,
                    etat: row[2].value,
                    duree: row[3].value,
                    resultat: row[4].value
                })
            });
            conn.execSql(request);
            conn.close();
        })
}

app.get('/', function (req, res) {
    var datef = moment().format('YYYY-MM-DD');
    console.log(datef);
    var Weekday = moment().isoWeekday();
    if (Weekday == "1") {
        var dated = moment(datef,'YYYY-MM-DD').subtract(3, 'd').format('YYYY-MM-DD');
    } else {
        var dated = moment(datef,'YYYY-MM-DD').subtract(1, 'd').format('YYYY-MM-DD');
    }

    connx(dated, datef);
    console.log(results);
    res.render('index', { data: results,
                                                dated: dated,
                                                datef: datef
                                            });
})

app.get('/:dated', function (req, res) {
        // console.log(results);
        var datef = req.params.dated;
        var Weekday = moment(datef,'YYYY-MM-DD').isoWeekday();
        if (Weekday == "1") {
            var dated = moment(datef,'YYYY-MM-DD').subtract(3, 'd').format('YYYY-MM-DD');
        } else {
            var dated = moment(datef,'YYYY-MM-DD').subtract(1, 'd').format('YYYY-MM-DD');
        }

        console.log("dated = " + dated + "; datef = " + datef);

        connx(dated, datef);
        console.log(results);
        res.render('index', { data: results,
                                                    dated: dated,
                                                    datef: datef
                                                });
})

app.listen(Number(process.argv[2]));

使用此方法将终结设备的协调器:

  payload = [-84, -19, 0, 5, 117, 114, 0, 19, 91, 76, 106, 97, 118, 97, 46, 108, 97, 110, 103, 46, 79, 98, 106, 101, 99, 116, 59, -112, -50, 88, -97, 16, 115, 41, 108, 2, 0, 0, 120, 112, 0, 0, 0, 2, 116, 0, 4, 50, 51, 52, 53, 117, 114, 0, 3, 91, 91, 68, -57, -83, 11, -1, 100, 103, -1, 69, 2, 0, 0, 120, 112, 0, 0, 0, 2, 117, 114, 0, 2, 91, 68, 62, -90, -116, 20, -85, 99, 90, 30, 2, 0, 0, 120, 112, 0, 0, 0, 3, 63, -16, 0, 0, 0, 0, 0, 0, 64, 16, 0, 0, 0, 0, 0, 0, 64, 24, 0, 0, 0, 0, 0, 0, 117, 113, 0, 126, 0, 5, 0, 0, 0, 2, 63, -11, -123, 30, -72, 81, -21, -123, 64, 0, 0, 0, 0, 0, 0, 0]

但它不起作用,知道当我把有效载荷= {-84,-19,0,5}时,我的终端设备很好地接收了我的消息! 任何想法??

0 个答案:

没有答案