I’m starting to understand how things work in Node.js. Just wrote a little module to take serial output from the RF12demo sketch and decode its “OK …” output lines:
This quick demo only has decoders for nodes 3 and 9 so far, but it shows the basic idea.
This relies on the EventEmitter class, which offers a very lightweight mechanism of passing around objects on channels, and adding listeners to get called when such “events” happen. A very efficient in-process pub-sub mechanism, in effect!
Here is the “serial-rf12demo” module which does the rest of the magic:
And that’s really all there is to it – very modular!