Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // publish our nodes.
- function publish_nodes(){
- var nodeCursor = nodeCollection.find( { _id: {$gt: 0}} );
- nodeCursor.each(function (err, doc) {
- if (err) {
- console.log(err);
- } else if ( doc!= null) {
- //console.log('Fetched:', doc);
- var node_to_publish = doc;
- // Get sensors for this node.
- var sensor_cursor = sensorCollection.find( {node_id : node_to_publish['_id']} );
- var sensor = sensor_cursor.each(function ( serr, sdoc ){
- if (serr){
- console.log(err);
- } else if (sdoc!= null){
- //console.log('fetched sensor for node: ', node_info_json['_id'] ,":", sdoc);
- console.log( sdoc );
- }
- });
- //node_to_publish
- console.log('published node.');
- mqtt_client.publish("/zc/" + serial_number + "/node/", JSON.stringify(node_to_publish) );
- }
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement