Skip to content

problem getting device id in callback #34

@palsbo

Description

@palsbo

When I want to issue a serie of reads to several devices, the callback gives no way of telling which device is delivering result.
What to do?

var Client = require("owfs").Client;
var con = new Client('localhost');

var dev = [
        {'id':'/10.243EE400080086/temperature', 'topic':'/lolland/stuen'},
        {'id':'/10.8E6521010800E3/temperature', 'topic':'/lolland/vaerksted'},
        {'id':'/10.FD622101080073/temperature', 'topic':'/lolland/orangeri'},
        {'id':'/10.AFCE3503080058/temperature', 'topic':'/lolland/depot'},
]

for (i in dev) {
        con.read(dev[i].id, function(err, result) {
               console.log(dev[i].id,dev[i].topic, result);  //  this will not work!
        });
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions