Not understanding TCP-out node

375 views
Skip to first unread message

Josh Conway

unread,
Jan 14, 2016, 9:30:47 AM1/14/16
to Node-RED

Greetings. I'm trying to write a handler for the Arduino MySensors library to handle the raw ethernet packets for TCP. There's 2 modes: server and client. I have the protocol down pat, but the Node-red TCP modules are confusing me.



The gist here is thus: Open up a TCP port on 5003, stream of string payloads delimited by "\n".

When data comes in via TCP-in of the appropriate type, format it for MQTT and send it to the Broker. Injecting data from port 5003 of appropriate type works 100%.

When data comes from the broker with a topic of MySensors/# (wildcard for all my sensors), translate it to the Serial MySensors protocol and send it out the already opened TCP port. TCP-out is configured to "Reply to TCP". Sending to TCP is *NOT* working. The Debug on the bottom shows that the data is of the appropriate format.

How do I get the topic outputs from MySensors/# to go to tcp-out? What am I missing?

Sincerely,
Josh Conway

Josh Conway

unread,
Jan 14, 2016, 10:00:38 AM1/14/16
to Node-RED
I've figured it partially out, but it's a "dirty ol hack".

TCP connection tracking is dependant on msg._session , so I have 2 function blocks. One is after TCP-in making a global context out of _session. Second function block is before TCP-out restoring the non-existent _session as msg._session.

Of course, this only works after the TCP connection sends a packet.

Is there a cleaner way to do this; perhaps read the _session directly from TCP-in?

Sincerely,
Josh Conway

Dave C-J

unread,
Jan 14, 2016, 10:01:41 AM1/14/16
to node...@googlegroups.com
Your hack is correct :-) - you need the msg._session to tie the two together...
Reply all
Reply to author
Forward
0 new messages