Project

General

Profile

what does SketchType do?

Added by tve about 3 years ago

Dumb question: what is the purpose of SketchType and the Dispatcher after it in the rf12toDatabase sketch?
https://github.com/jcw/housemon/blob/master/setup.coffee\#L115-L116
I don’t have an rf12demo setup and I can’t follow what is expected by this thing…


Replies (5)

RE: what does SketchType do? - Added by lightbulb about 3 years ago

@tve,

SketchType gadget listens (meant for serial) for “[]” string. (like “[RF12Demo.10]”…)

When it sees it, it initiates a sequence, using (after stripping a few sequences).

Dispatch is used to dynamically ‘insert’ gadgets/circuits into the flow (sub-circuit?). In its most basic guise, it does this by looking at , locating the gadget/circuit in the registry (implies that gadget is linked into binary, or madeup via javascript! or circuit/json) and then passing the message into the new sub-circuit. This nesting ‘could’ go on and on….thats another story.

Dispatch is used in the RF12toDatabase circuit to handle the dynamic lifetime of decoders, through nodeMap mappings etc.

It works to an extent, but does not handle various multi-tennant messages. Also, I think it needed a close token if the node changes, otherwise it keeps mapping messages to the original nodes decoders…but that was a while ago for me now. I’ll try locate the original changes I made. I dont use dispatch for those type of things, but it IS still very useful for general stuff (with a few tweaks).

—lightbulb

RE: what does SketchType do? - Added by tve about 3 years ago

There are two dispatchers in the rf12toDatabase circuit. You’re describing what the second one does, which I understand. I don’t understand what the first one does….

RE: what does SketchType do? - Added by lightbulb about 3 years ago

@tve,

Appols - not getting email notifications (@martynj - can u help?)

OK, read your email wrong maybe - it seemed like you wanted info on SketchType & Dispatcher.!

So…there are 2 dispatcher’s in the rf12toDatabase, a d1 and a d2.

d1 is there to dynamically load Gadget ‘Sketch-RF12demo’ if/when it sees it in the flow.
d2 is there to load a node’s decoder produced by Sketch-RF12Demo as is passes its output through nodeMap. nodeMap is the datasource with this mapping in it.

You don’t have to use RFM12Demo sketch, you could use your own (I use a cut down version on one of my tiny’s called RF12Mini, and have a ‘Sketch-RF12Mini’ that does a few ‘ack’ related things that RF12Demo does not do). So long at the packet format (OK HDR []byte) is same then you can still just plug in a nodeMap of whatever to do the down chain decoder creation.

hope that helps

—lightbulb

RE: what does SketchType do? - Added by tve about 3 years ago

AH, I hadn’t caught the dynamic loading of the RF12demo sketch. Thanks for clarifying.

RE: what does SketchType do? - Added by lightbulb about 3 years ago

@tve, no worries :)

This dynamic load is actually quite important, especially when you have lots of Stty’s with things like bluetooth modems, gps’s, srf’s, zigbee, dmx etc, as its less of a worry during configuration. I did have to modify my sketchtype to be a bit more ‘signature’ based (using a lookup) rather that a simple regex/pattern. That way I use it for more than RF.
Infact, it’s a lookup ‘into’ a regex in most cases, so its very dynamic/flexible.

PS: Your PacketMap is VERY close to what I have, so perhaps there is commonality. I’ll put my bits relating to this online also shortly in this case, because if the two of us have ‘similar’ solutions then perhaps its a more common requirement than we think. Perhaps we can even do a common refactor and come up with a single generic solution??

—lightbulb

    (1-5/5)