Stack-to-stack communication with Wifi

A key aspect of the power of Interstacks is that the same message flow that runs inside a stack can run between two stacks (or many stacks). Currently stack-to-stack communication is supported via the Wifi hardware block. In the future, other communication blocks will be supported.

To have two stacks on the same LAN network send messages to each other via Wifi: each stack must have a Wifi hardware block; the LAN name and password must be entered in the property list of the Wifi module; the blueprint of the sending stack must have an “Interstack Send” hardware block; the blueprint of the receiving stack must have an “Interstack Receive” hardware block; the “U” property in the “Interstack Send” and “Interstack Receive” blocks must be the same. You can then draw a channel to the “To Stacks" input of the “Interstack Send” block on the sending stack and from the “From Stacks" output of the “Interstack Receive” block on the receiving stack. The stacks will discover each other and messages will flow between the two stacks.

Here are step by step instructions.

Drag and drop a Wifi hardware block from the “Wireless Communication” category of the “Hardware” blocks palette.

wifi_block

Select the Wifi block by clicking on it once. Click in the “Property Editor” in the bottom right, in the first row, in the “Property” column. Type a ’N’ (without quotes). Click on the corresponding “Default Value” column and type the name of the local network e.g. ‘mynetwork’ (with quotes). Click on the second row and first column of the property editor to enter a second property. Type “P” (without quotes), then click on the corresponding “Default Value” and enter the password for the local LAN e.g. ‘mypassword’ (with quotes). The Wifi hardware block is now configured to connect to your LAN.

In the blueprint for the sending stack, drag and drop an “Interstack Send" hardware block from the “Wireless Communication” category of the “Hardware” blocks palette.

istacks_send

Select the block by clicking on it once. Click in the “Property Editor” in the bottom right, in the first row, in the “Property” column. Type a “U” (without quotes). Click in its corresponding “Default Value” column and type UUID(‘mystack1’). Or any other unique string, ideally, a unique UUID like UUID(‘~1e543cd783fed7899a5454def’). This will be used to match with the receiving stack. Click on the second row and first column of the property editor to enter a second property. Type “L” (without quotes), then click on the corresponding “Default Value” and enter a name for the stacks location e.g. ‘controlroom’ (with quotes).

In the blueprint for the receiving stack, drag and drop an “Interstack Receive" hardware block from the “Wireless Communication” category of the “Hardware” blocks palette.

istacks_receive

Select the block by clicking on it once. Click in the “Property Editor” in the bottom right, in the first row, in the “Property” column. Type a “U” (without quotes). Click in its corresponding “Default Value” column and type UUID(‘mystack1’). Or any other unique string, ideally, a unique UUID like UUID(‘~1e543cd783fed7899a5454def’). This will be used to match with the sending stack. Click on the second row and first column of the property editor to enter a second property. Type “L” (without quotes), then click on the corresponding “Default Value” and enter a name for the stacks location e.g. ‘receiver’ (with quotes).

You can then draw a channel to the “To Stacks” input of the “Interstack Send” block on the sending stack and from the “From Stacks" output of the “Interstack Receive” block on the receiving stack. The stacks will discover each other and messages will flow between the two stacks. You can "fan out" to as many stacks as you want as well as have messages from multiple stacks “fan in” to a single “Interstack Receive” block. As long as the “U” properties of the corresponding blocks match, messages will be delivered between blocks. You can also add multiple “Interstack Send” and “Interstack Receive” blocks to a blueprint.


For advanced users only, included here is the full blocks detail spec sheets with properties and terminals.

Interstack Send
For sending messages to other stacks via a Wifi network.
Properties
U (uuid): Unique terminal ID. must be a UUID. UUID(‘foobar’). This will be matched globally with all stacks.
L (Any): Stack location. If empty, the ‘L’ property in the Wifi hardware proxy is used. This is sent to the receiver, so it
knows who sent the message.

Terminals
“To Stacks” - 1 in (All): Data in to send to other stacks.
(Note that messages are buffered, then sent, once at least one receiver is discovered.)
“ACK”. - 1 out (List or int): List of locations (L property in wifi module) of receivers that successfully received the sent
message. If the send fails, the message stays in the send buffer and nothing is sent out the ACK terminal.
When the receiver connects, any buffered messages will be sent.
Note: If receiver’s ‘L’ property is empty, a successful ACK will be indicated with [None].
Note: It is the application’s responsibility to perform any timeout logic it desires.

Also outputs an int when a connection is made. The int is the total number of connections discovered.
If a message send fails, the sender logically disconnects. Hence when the receiver is discovered again,
another int will be sent out the ACK terminal indicating a successful connect.

Note: Transmission over networks can be unreliable.
If the message sent does not generate a successful ACK, the sender must decide whether to retransmit or not.
(Technical note: Below the blueprint layer, the hardware does try to re-transmit a low level packet that fails before a
failed ACK is generated to the Blueprint.)

Notes
This block is dynamically created on a Wifi hardware module.
The version 1 Wifi module supports four dynamic stack-to-stack blocks.

Interstack Receive
For receiving messages from other stacks via a Wifi network.
Properties
U (uuid): Unique terminal ID. must be a UUID. UUID(‘foobar’). This will be matched globally with all stacks you own.
L (Any): Stack location. If empty, the ‘L’ property in the Wifi hardware proxy is used. This is sent back to the sender
so it knows which receivers succeeded.

Terminals
“From Stacks” - 1 out (All): Data out from other stacks.
“Sender ID” - 2 out (String or int or Boolean): Location (L property) of the sender.
(Note: If sender’s ‘L’ property is empty, the sender ID will be [None].)
Outputs True, once upon connection.

Notes
This block is dynamically created on a Wifi hardware module.
The version 1 Wifi module supports four dynamic stack-to-stack blocks.

Refer to documentation on many other topics at interstacks.com/support.
Please email info@interstacks.com with any questions.