Line 85: |
Line 85: |
| For certain types of nodes, a broker that maintains state is useful. | | For certain types of nodes, a broker that maintains state is useful. |
| For details of this system, see https://github.com/eastein/thingsbus | | For details of this system, see https://github.com/eastein/thingsbus |
| + | |
| + | == Communication == |
| + | |
| + | The software for a node can be written in any language that supports zmq and json. |
| + | |
| + | Sensors send data like this: |
| + | |
| + | socket = zmq.NewSocket(zmq.PUB) |
| + | socket.Bind("tcp://*:5556") |
| + | socket.SendMessage("dot.delimited.filter", '{"json":"message"}') |
| + | |
| + | Neurons receive data like this: |
| + | |
| + | sensor = context.socket(zmq.SUB) |
| + | sensor.connect("tcp://sensor.tld:5556") |
| + | topic, message = sensor.recv_multipart() |
| + | data = json.loads(message) |
| + | |
| + | Neurons send data like this: |
| + | |
| + | actuator = context.socket(zmq.PUSH) |
| + | actuator.connect('tcp://actuator.tld:5558') |
| + | actuator.send_json(data) |
| + | |
| + | Actuators receive data like this: |
| + | |
| + | socket = context.socket(zmq.PULL) |
| + | socket.bind('tcp://*:5558') |
| + | data = socket.recv_json() |
| | | |
| == Existing Nodes == | | == Existing Nodes == |