Struggling on Souliss Android Apps

69 views
Skip to first unread message

Brylianrst

unread,
Feb 3, 2017, 11:42:12 AM2/3/17
to souliss
So I was trying to make a souliss network using :

- arduino mega and ethernet shield w5100 as gateway 
- Esp8266 Wemos shield as peer node
- arduino mega and ethernet shield w5100 as peer node 

the idea was i wanna make a wireless lamp switch using esp 8266 wemos as a remote switch, so i can switch the lamp on/off ( for example using LED in a breadboard) from either the gateway arduino and peer arduino, the result was great, i can switch the led on and off wirelessly using the esp8266 wemos, but the main problem was when using the souliss apps on android i can only switch on and off the led on the gateway arduino side, but not on the peer arduino side, i dont know why and the health bar ont the peer node was also low, can anyone check what's wrong on my codes or if there's something missing, thanks a lot

/**************************************************************************
    Souliss - Dynamic Arduino Gateway                                                                                                                                                                                                       
    
    It handle two lights located on two different boards and act them together
    if receive a command from the push button. Control from Android is also 
    available.
        
    Run this code on one of the following boards:
      - Arduino Ethernet (W5100) 
      - Arduino with Ethernet Shield (W5100)                                                                      
      
    As option you can run the same code on the following, just changing the
    relevant configuration file at begin of the sketch
      - Arduino with ENC28J60 Ethernet Shield
      - Arduino with W5200 Ethernet Shield
      - Arduino with W5500 Ethernet Shield
      
***************************************************************************/

// Let the IDE point to the Souliss framework
#include "SoulissFramework.h"
// Configure the framework
#include "bconf/StandardArduino.h"          // Use a standard Arduino
#include "conf/ethW5100.h"                  // Ethernet through Wiznet W5100
#include "conf/Gateway.h"                   // The main node is the Gateway, we have just one node
#include "conf/Webhook.h"                   // Enable DHCP and DNS
#include "conf/IPBroadcast.h"   //NEW ADD

// Include framework code and libraries
#include <SPI.h>
#include <EEPROM.h>   //NEW ADD

#include "Souliss.h"

// This identify the number of the LED logic
#define FLAMP             0               // This identify the number of the logic on this node
#define PEERLAMP           0               // This identify the number of the logic on peer node
#define Souliss_T1n_ToggleCmd       0x01
#define Souliss_T1n_Coil            0x01

void setup()
{   
    Initialize();

    // Get the IP address from DHCP
    GetIPAddress();                          
    SetAsGateway(myvNet_dhcp);       // Set this node as gateway for SoulissApp  

    // This is the vNet address for this node, used to communicate with other
    
    // Set IPBroadcast vNet Address 
    SetAddress(0xAB01, 0xFF00, 0x0000);
        
  // This node as gateway will get data from the Peer
    SetAsPeerNode(0xAB02, 1);
    SetAsPeerNode(0xAB03, 2);
    
    Set_SimpleLight(FLAMP);        // Define a simple LED light logic
   
    // We connect a pushbutton between 5V and pin2 with a pulldown resistor 
    // between pin2 and GND, the LED is connected to pin9 with a resistor to
    // limit the current amount
    pinMode(2, INPUT);                  // Hardware pulldown required
    pinMode(4, OUTPUT);                 // Power the LED
    
}

void loop()
    // Here we start to play                                           
    EXECUTEFAST() {                     
        UPDATEFAST();   
        
        FAST_50ms() {   // We process the logic and relevant input and output every 50 milliseconds
            if(DigIn(2, Souliss_T1n_ToggleCmd, FLAMP))            // Use the pin2 as ON/OFF toggle command 
             Send(0xAB02, PEERLAMP, Souliss_T1n_ToggleCmd);                // and replicate the command on the peer node
            
            Logic_SimpleLight(FLAMP);                          // Drive the LED as per command
            DigOut(4, Souliss_T1n_Coil, FLAMP);                // Use the pin9 to give power to the LED according to the logic
            
        } 
              
        // Here we handle here the communication with Android, commands and notification
        // are automatically assigned to FLAMP
        FAST_GatewayComms();                                        
    }





/**************************************************************************
    Souliss - DynmicArduinoPeer                                                                                                                                                                                                
    
    It handle two lights located on two different boards and act them together
    if receive a command from the push button. Control from Android is also 
    available.
        
    Run this code on one of the following boards:
      - Arduino Ethernet (W5100) 
      - Arduino with Ethernet Shield (W5100)                                                                      
      
    As option you can run the same code on the following, just changing the
    relevant configuration file at begin of the sketch
      - Arduino with ENC28J60 Ethernet Shield
      - Arduino with W5200 Ethernet Shield
      - Arduino with W5500 Ethernet Shield
      
***************************************************************************/

// Let the IDE point to the Souliss framework
#include "SoulissFramework.h"
// Configure the framework
#include "bconf/StandardArduino.h"          // Use a standard Arduino
#include "conf/ethW5100.h"                  // Ethernet through Wiznet W5100
#include "conf/Gateway.h"                   // The main node is the Gateway, we have just one node
#include "conf/Webhook.h"                   // Enable DHCP and DNS
#include "conf/IPBroadcast.h"   //NEW ADD

// Include framework code and libraries
#include <SPI.h>
#include <EEPROM.h>   //NEW ADD

#include "Souliss.h"

// This identify the number of the LED logic
#define FLAMP_1            0              // This ident-ify the number of the logic on this node
#define PEERLAMP_1           0               // This identify the number of the logic on peer node
#define Souliss_T1n_ToggleCmd       0x01
#define Souliss_T1n_Coil            0x01

void setup()
{   
    Initialize();
    
        // Get the IP address from DHCP
    GetIPAddress();   
    
    // This is the vNet address for this node, used to communicate with other
  // nodes in your Souliss network
    SetAddress(0xAB03, 0xFF00, 0x0000);
    
    Set_SimpleLight(FLAMP_1);        // Define a simple LED light logic
   
    // We connect a pushbutton between 5V and pin2 with a pulldown resistor 
    // between pin2 and GND, the LED is connected to pin9 with a resistor to
    // limit the current amount
    pinMode(0, INPUT);                  // Hardware pulldown required
    pinMode(5, OUTPUT);                 // Power the LED
    
}

void loop()
    // Here we start to play                                           
    EXECUTEFAST() {                     
        UPDATEFAST();   
        
        FAST_50ms() {   // We process the logic and relevant input and output every 50 milliseconds
            if(DigIn(0, Souliss_T1n_ToggleCmd, FLAMP_1))            // Use the pin2 as ON/OFF toggle command 
             Send(0xAB02, PEERLAMP_1, Souliss_T1n_ToggleCmd);                // and replicate the command on the peer node
            
            Logic_SimpleLight(FLAMP_1);                          // Drive the LED as per command
            DigOut(5, Souliss_T1n_Coil, FLAMP_1);                // Use the pin9 to give power to the LED according to the logic
            
        } 
              
        // Here we handle here the communication with Android, commands and notification
        // are automatically assigned to FLAMP
         FAST_PeerComms();

    START_PeerJoin();                                    
    }




/**************************************************************************
    Souliss - Dynamic ESP Peer
    
    It handle two lights located on two different boards and act them together
    if receive a command from the push button. Control from Android is also 
    available.
        
    Run this code on one of the following boards:
      - Arduino Ethernet (W5100) 
      - Arduino with Ethernet Shield (W5100)
      
    As option you can run the same code on the following, just changing the
    relevant configuration file at begin of the sketch
      - Arduino with ENC28J60 Ethernet Shield
      - Arduino with W5200 Ethernet Shield
      - Arduino with W5500 Ethernet Shield
      
***************************************************************************/


// Let the IDE point to the Souliss framework
#include "SoulissFramework.h"

// Configure the framework
#include "bconf/MCU_ESP8266.h"              // Load the code directly on the ESP8266
#include "conf/DynamicAddressing.h"    // NEW ADD

// **** Define the WiFi name and password ****
#define WIFICONF_INSKETCH
#define WiFi_SSID               "TP-LINK_96ED10"
#define WiFi_Password           "81299430"    

// Include framework code and libraries
#include <ESP8266WiFi.h>
#include <EEPROM.h>   // NEW ADD

#include "Souliss.h"

// This identify the number of the LED logic
#define FLAMP            0              // This ident-ify the number of the logic on this node
#define PEERLAMP           0               // This identify the number of the logic on peer node
#define FLAMP_1            0              // This ident-ify the number of the logic on this node
#define PEERLAMP_1           0               // This identify the number of the logic on peer node

#define Souliss_T1n_ToggleCmd       0x01
#define Souliss_T1n_Coil            0x01
void setup() 
{   
    Initialize();

    // Connect to the WiFi network and get an address from DHCP
    GetIPAddress();
    
    // This is the vNet address for this node, used to communicate with other
  // nodes in your Souliss network
    SetAddress(0xAB02, 0xFF00, 0xAB01);
  
    Set_SimpleLight(FLAMP);        // Define a simple LED light logic
    
    pinMode(2, INPUT);
    pinMode(4, OUTPUT);         // Use pin as output


      // This is the vNet address for this node, used to communicate with other
  // nodes in your Souliss network
    SetAddress(0xAB02, 0xFF00, 0xAB03);
  
    Set_SimpleLight(FLAMP_1);        // Define a simple LED light logic
    
    pinMode(0, INPUT);
    pinMode(5, OUTPUT);         // Use pin as output

}

void loop()
{
    // Here we start to play
    EXECUTEFAST() {                     
        UPDATEFAST();   
        
        FAST_50ms() {   // We process the logic and relevant input and output every 50 milliseconds
            if(DigIn(2,Souliss_T1n_ToggleCmd, FLAMP))
             Send(0xAB01, PEERLAMP, Souliss_T1n_ToggleCmd);             // and replicate the command on the peer node
            
            Logic_SimpleLight(FLAMP);
            DigOut(4, Souliss_T1n_Coil,FLAMP);
 
             if(DigIn(0,Souliss_T1n_ToggleCmd, FLAMP_1))
              Send(0xAB03, PEERLAMP_1, Souliss_T1n_ToggleCmd);             // and replicate the command on the peer node
            
             Logic_SimpleLight(FLAMP_1);
             DigOut(5, Souliss_T1n_Coil,FLAMP_1);
            }
        }
      
        // Here we handle here the communication with Android
        FAST_PeerComms();                                     
    }

 
Apps.jpg

Di Maio, Dario

unread,
Feb 4, 2017, 3:51:53 AM2/4/17
to sou...@googlegroups.com

Hi,

looks strange that SoulissApp shows two nodes rather you Gateway has two Peers so three nodes totally.

Drop your SoulissApp database and rebuild it again, once press the rebuild keep the screen on and do not move to other screens of the app for a minute.

You should see three "toast" messages, one for each node of your network. Then in SoulissApp there will be three nodes and not only two.

Have a try and let know what you get.

Dario.

From Mobile.

--
You received this message because you are subscribed to the Google Groups "souliss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to souliss+unsubscribe@googlegroups.com.
To post to this group, send email to sou...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/souliss/377a7075-9cad-4289-9cd9-e92d67cf789d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Brilian

unread,
Feb 5, 2017, 10:29:46 PM2/5/17
to souliss
Hi Dario, it was flawless, thank you very much it worked, now i have 3 nodes on my souliss apps, but there is somethin else i wanna ask, why the LED on arduino mega as peer wont work as fast as the arduino as gateway, the esp have such remote delay for the arduino as peer around 0.4 ms slower than the gateway, is there any specific code or somethin i can try to fix it ?
To unsubscribe from this group and stop receiving emails from it, send an email to souliss+u...@googlegroups.com.
node.jpg

Di Maio, Dario

unread,
Feb 6, 2017, 1:51:16 AM2/6/17
to sou...@googlegroups.com

Didn't got your problem.

Dario.

From Mobile.

To unsubscribe from this group and stop receiving emails from it, send an email to souliss+unsubscribe@googlegroups.com.

To post to this group, send email to sou...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages