Skip to content

Add Nodes

Alessandro Del Pex edited this page Nov 5, 2019 · 7 revisions

Introduction

Souliss uses a virtualization network layer to make communication between nodes easy and peer-to-peer, however in order to simplify the network connectivity, all data shall be collected into a single gateway that will make them available to SoulissApp or others user interfaces.

This architecture makes easier the routing out of your LAN, either using a VPN or a simple Port Forwarding; if you want increase the reliability, you can even have more than one gateway node to switch in case of failure.

Defining a gateway node

A gateway node has no special function, you are just instructing it to gather data from all other nodes in the network. Add the following code to a Gateway node to let it collect data from all the peer_address defined.

SetAsGateway(myaddress);
SetAsPeerNode(peer_address, index);

The code above declare the list of nodes (including itself) located in your network, add this code in your setup() as shown below

SetAsGateway(myaddress);
SetAsPeerNode(node1_address, 1);	
SetAsPeerNode(node2_address, 2);	
...
SetAsPeerNode(node10_address, 10);	

The maximum number of remote nodes from your gateway is by default 45, it can be increased if needed, but before proceeding please ask for support in our Community as more advanced configuration may be needed.

Retrieving data

Once you've defined the list of nodes in your network, next step is to get data from them. There are mainly two type of data that need to be retrieved:

  • Typical Codes Are the identification codes of the appliances running on a node,
  • Status Data Are live data relative to those devices.

The FAST_GatewayComms(); instruction is used to start process communication for the gateway, this also includes the retrieval of Typical Codes and Status Data. This is defined as a general macro and doesn't need to be included into a phase explicitly.

Your sketch will look somewhat like this:

void loop()
{   
    // Here we start to play
    EXECUTEFAST() {                     
        UPDATEFAST();   

        // Run some logics here 
        FAST_510ms() {
           ....
        } 
        
        // Here we handle here the communication with Android, commands and notification
        FAST_GatewayComms();        
                        
   }
} 

Defining Peer Nodes

Peer nodes share roughly the same sketch code used for the gateway, with the following differences:

  • #include "conf/Gateway.h" is no longer required and shall be removed from the Peer sketch
  • The communication is processed using FAST_PeerComms() instead of FAST_GatewayComms()
  • Peer nodes shall not be listed in the Peer itself, so both SetAsGateway(...) and SetAsPeerNode(...) instructions are not required.

Among examples there are several sketches for Gateway and Peer nodes that can be used as reference and template.

Clone this wiki locally