Two-way communication between Meteor and Node

2019-06-14 05:07发布

问题:

I am building a Node app that talks to an Xbee over serial and reads/controls several sensors/relays that are also Xbee equipped. I would like to use Meteor for the user interface and data storage with the Node app simply sending sensor updates and controlling the relays when triggered by the Meteor app. What would be the proper way to communicate between the Node and Meteor app? I know I can use a Node DDP client to insert sensor readings to the Meteor app. The part I am having problems with is sending commands from Meteor to the Node app to control the relays. I simply need to send a command that will execute certain code on the Node app to switch the relays. Maybe this is a simple question, but I'm not sure of the best way to accomplish this. Thanks in advance for any input.

回答1:

You could just use Mongo as your point of integration. Each XBee device could just be a mongo document.

{
   address: 'xbeeaddress',
   relay1:  'on'
}