Sunteți pe pagina 1din 51

Documentación grupo de trabajo:

INTEGRACIÓN DE PLATAFORMAS
LIBRES Y COMERCIALES EN EL
ÁMBITO DEL HOGAR DIGITAL
Curso 2017-2018
CTIF Madrid Capital
IES PACÍFICO (Madrid)
Miembros:
DIEGO CASAS ROBLES
JESÚS JAVIER RAYA LUNA
JAVIER LÓPEZ LÓPEZ
RAMON RODRIGUEZ LUQUE
JOSÉ MARÍA ROSA HERRANZ
JOSÉ ERNESTO VELA ESCOLANO
INTEGRACIÓN DE PLATAFORMAS LIBRES Y
COMERCIALES EN EL ÁMBITO DEL HOGAR DIGITAL
Curso: 2017/2018

Índice:
Introducción..........................................................................................................................................3
Trabajos previos....................................................................................................................................3
Materiales.............................................................................................................................................4
Desarrollo realizado..............................................................................................................................7
Nodo pasarela..................................................................................................................................8
Nodo independiente.........................................................................................................................9
Aplicación de control remoto por móvil........................................................................................11
Conclusiones.......................................................................................................................................11
Propuestas futuras...............................................................................................................................11
Código fuente de las prácticas............................................................................................................13
Nodo pasarela................................................................................................................................13
Nodo independiente Nº1................................................................................................................15
Nodo independiente Nº2................................................................................................................18
Nodo independiente Nº3................................................................................................................20
Nodo independiente Nº4................................................................................................................23
Introducción a Souliss........................................................................................................................26
Descripción breve sobre Souliss....................................................................................................26
Arquitectura de red e interfaces de usuario...................................................................................26
Lógicas e interfaces...................................................................................................................26
Hardware de Souliss......................................................................................................................27
Comenzando con Souliss...............................................................................................................27
Comenzando con Souliss....................................................................................................................27
Lista de inicio para comenzar:.......................................................................................................27
Paso 1: verifica si tu nodo es compatible.......................................................................................27
Paso 2: obtenga el último IDE de Arduino compatible.................................................................28
Paso 3: verificar el ejemplo de parpadeo: “BLINK”.....................................................................28
Paso 4: obtenga el último código de marco de Souliss..................................................................28
Paso 5: obtenga la última aplicación de Android Souliss..............................................................29
Paso 6: Configura las funciones de Souliss...................................................................................29
Paso 7: compila y carga Souliss, y luego diviértete.......................................................................29
Configuración del Framework............................................................................................................29
Una configuración de ejemplo.......................................................................................................29
Lista de archivos de configuración disponibles.............................................................................30
Lista de archivos de configuración de la placa disponibles...........................................................31
Definiciones para el modo de configuración: “Speakeasy”...............................................................33

2/51
INTEGRACIÓN DE PLATAFORMAS LIBRES Y
COMERCIALES EN EL ÁMBITO DEL HOGAR DIGITAL
Curso: 2017/2018

Introducción
El presente grupo de trabajo se ha desarrollado con la intención de explorar la viabilidad de utilizar
plataformas de software y hardware libre en el ámbito del hogar digital.
Para ello se ha empezado por el estudio y puesta en práctica de
plataformas libres como arduino.
El software utilizado se denomina: “Framework Souliss”
(http://souliss.net/ )
Consiste en una serie de librerías de software que permiten el
desarrollo de programas para la pasarela y los nodos de la
instalación domótica. Se trata por tanto de un desarrollo libre
para la construcción del hardware asociado a una instalación
domótica.
El proyecto que lo sustenta ha desarrollado así mismo una
aplicación para teléfono móvil que permite tener el telecontrol
de todos los elementos de la instalación domótica.
Illustration 1: Logo del proyecto
Souliss

Trabajos previos
En una primera fase se ha realizado un estudio de la documentación existente del proyecto. El
principal inconveniente es que la mayoría de la documentación (toda la oficial) se encuentra en
inglés.
También existe un blog en castellano muy útil para documentarse de nuevos desarrollos:
http://souliss-es.blogspot.com.es/
Esto anterior, unido a la diversidad del profesorado, ha ralentizado mucho la puesta en marcha de
las experiencias prácticas.
Hay que indicar que era la primera toma de contacto para todos los miembros del grupo en mayor o
menor medida.
Se instaló el software asociado a las placas de arduino. Es importante indicar que no se debe instalar
la última versión del software sino la que se indique en el sitio web de la wiki de souliss
(https://github.com/souliss/souliss/wiki)
Se realizaron algunos test de los ejemplos típicos y se validó el uso de todas las herramientas.

Souliss
(http://docplayer.es/45285950-Introduccion-a-souliss.html)

3/51
INTEGRACIÓN DE PLATAFORMAS LIBRES Y
COMERCIALES EN EL ÁMBITO DEL HOGAR DIGITAL
Curso: 2017/2018

Introducción
Souliss se construye sobre tres capas que construye una completa red de nodos con lógicas
distribuidas y funcionalidad, todos los nodos pueden intercambiar datos de peer-to-peer y no hay
necesidad de un nodo central que coordine las lógicas y las comunicaciones.
Gracias a su estructura escalable, la funcionalidad de Souliss se puede mover sobre diferentes nodos
o se fusiona en una sola, la mejor solución puede ser orientada para el tamaño y los requisitos de
red. Memoria compartida, esto es, cada nodo Souliss tiene un área de memoria compartida.
Es un array dividido en tres partes: typicals, inputs y outputs. Cada parte contiene N Bytes y cada
Byte es un slot. El area de memoria compartida tiene la siguiente estructura:
La idea básica es que
cada funcionalidad
básica
(lights,heating/cooling,
garage doors, ...) está
asociada a un slot. Toda
la información está
contenida en un slot
relevante, por lo que la
información es
accessible por el
número de nodo y el
número de slot.

Capas Souliss
Una instalación flexible
es fácil gracias a la
implementación
construir en capas.
Desde el punto de vista
del usuario, estas capas
no se utilizan
directamente, porque
están incrustados en la
API de Souliss.
Illustration 2: Area de memoria para almacenar la estructura de los
elementos de souliss llamados typical

4/51
INTEGRACIÓN DE PLATAFORMAS LIBRES Y
COMERCIALES EN EL ÁMBITO DEL HOGAR DIGITAL
Curso: 2017/2018

Vnet
La comunicación se establece a través de vnet, es construir una red plana virtual, llevar a cabo los
complementos y el enrutamiento a través de diferentes medios de comunicación (por cable e
inalámbrica) a un nivel inferior, sin requerir ningún tipo de configuración especial de su propia red.
“Vnet” incluye controladores para muchos transceptores y potencialmente corre sobre todos los
controladores de los medios de comunicación que tiene un mecanismo de detección de colisiones.

Macaco
Es un protocolo basado en eventos,binario y pequeño. Permite la comunicación punto a punto entre
los nodos. Se lleva a cabo también en la aplicación de Android que da una conexión directa, el
mecanismo basado en eventos ahorrar batería y ofrecer una rápida interacción. Lógica y pasarelas
Actividades de manejo (luces, ventanas, puertas,...) se construyen como típicas, un conjunto de
lógicas pre-configurados que también tiene una interfaz disponible en la aplicación Android. Todos
los nodos pueden proporcionar una lista de los típicos utilizados en ella. Leer la página
DataStructure para saber más. Hardware Souliss Hay varias plataformas disponibles que se pueden
ejecutar Souliss, todos están basados en microcontroladores AVR y tiene diferentes transceptor de
extensión de E/S.

Materiales
Para el desarrollo del proyecto se han utilizado materiales del aula taller del centro. En concreto se
han utilizado los siguientes:
• Placas Arduino Mega.
• Placas Arduino Ethernet.
• Placas Ethernet Shield.
• Módulos de comunicaciones RS485 basados en el MAX485.
• Componentes varios para entradas y salidas.
• Cables dupont para el montaje rápido.
• Resistencias.
• Leds.
• Pulsadores.
• Cable UTP para el bus.
• Adaptadores varios para conectores.

5/51
INTEGRACIÓN DE PLATAFORMAS LIBRES Y
COMERCIALES EN EL ÁMBITO DEL HOGAR DIGITAL
Curso: 2017/2018

Illustration 3: Conjunto de materiales utilizados para las prácticas

6/51
INTEGRACIÓN DE PLATAFORMAS LIBRES Y
COMERCIALES EN EL ÁMBITO DEL HOGAR DIGITAL
Curso: 2017/2018

Illustration 4: Diagrama de conesiones de la placa arduino mega utilizada para los nodos
independientes.

Illustration 5: Diagrama de conexiones de la placa usada para


la pasarela: Arduino ethernet
7/51
INTEGRACIÓN DE PLATAFORMAS LIBRES Y
COMERCIALES EN EL ÁMBITO DEL HOGAR DIGITAL
Curso: 2017/2018

Desarrollo realizado
Se realizado una red domótica basada en cuatro nodos, uno de los cuales corresponde con la
pasarela a internet.
La red física se ha basado en par trenzado con el estándar RS485 como especificación.
La pasarela se conecta también a la red Ethernet para dar acceso a la red local y por ella a internet,
previa la apertura de los puertos correspondientes en el router de la vivienda.

Illustration 6: Diagrama del escenario planteado para las pruebas donde solo se muestra uno de
los nodos por cable y otro inhalámbrico, cuando realmente se montaron cuatro nodos.
El planteamiento mostrado en la figura se hace usando un arduino mega con ethernet shield para la
pasarela, cuando realmente se montó sobre una placa arduino ethernet.
Las comunicaciones entre los nodos se realizan utilizando el estándar RS485. Se usa el chip
MAX485 para adaptar las señales del puerto serie del microcontrolador (5V/0V) a los niveles del
bus RS485 (señales diferenciales).

8/51
INTEGRACIÓN DE PLATAFORMAS LIBRES Y
COMERCIALES EN EL ÁMBITO DEL HOGAR DIGITAL
Curso: 2017/2018

Illustration 7: Características de un bus como el utilizado para la comunicación entre los


nodos.

Nodo pasarela
El primer montaje que se realizó es el del nodo pasarela. Su interés radica en que permite la
conexión de la domótica con el exterior a través de internet.

Illustration 8: Nodo pasarela basado en Arduino Ethernet con un typical de control de punto de luz

9/51
INTEGRACIÓN DE PLATAFORMAS LIBRES Y
COMERCIALES EN EL ÁMBITO DEL HOGAR DIGITAL
Curso: 2017/2018

Illustration 9: Módulo RS485 para conectar al bus


Conexiones:
Conector Ethernet ↔ Cable de red de la LAN
Arduino Ethernet RX (pin 0) ↔ MAX485 - RO
Arduino Ethernet TX (pin 1) ↔ MAX485 – DI
Arduino Ethernet pin2 (pin 2) ↔ MAX485 – RE + DE
Arduino Ethernet 5V (pin 5V) ↔ MAX485 - 5V
Arduino Ethernet 0V (pin 0V) ↔ MAX485 – 0V
Arduino Ethernet 8 (pin 8) ↔PULSADOR (con resistencia de 10K de PULL-UP)
Arduino Ethernet 9 (pin 9) ↔LED (con resistencia de 1K de PULL-DOWN)
BUS RS485 A ↔ MAX485 – A
BUS RS485 B ↔ MAX485 – B

Nodo independiente
Conexiones:
Arduino Mega RX (pin 0) ↔ MAX485 - RO
Arduino Mega TX (pin 1) ↔ MAX485 – DI

10/51
INTEGRACIÓN DE PLATAFORMAS LIBRES Y
COMERCIALES EN EL ÁMBITO DEL HOGAR DIGITAL
Curso: 2017/2018

Arduino Mega pin2 (pin 2) ↔ MAX485 – RE + DE


Arduino Mega 5V (pin 5V) ↔ MAX485 - 5V
Arduino Mega 0V (pin 0V) ↔ MAX485 – 0V
Arduino Mega 6 (pin 6) ↔PULSADOR 1 (con resistencia de 10K de PULL-UP)
Arduino Mega 7 (pin 7) ↔LED 1 (con resistencia de 1K de PULL-DOWN)
Arduino Mega 8 (pin 8) ↔PULSADOR 2 (con resistencia de 10K de PULL-UP)
Arduino Mega 9 (pin 9) ↔LED 2 (con resistencia de 1K de PULL-DOWN)
BUS RS485 A ↔ MAX485 – A
BUS RS485 B ↔ MAX485 – B

Illustration 10: Nodo independiente comunicado por RS485 con dos typicals de control de punto de
luz

11/51
INTEGRACIÓN DE PLATAFORMAS LIBRES Y
COMERCIALES EN EL ÁMBITO DEL HOGAR DIGITAL
Curso: 2017/2018

Illustration 11: Nodo independiente con punto de luz (Typical) controlado desde la APP

Illustration 12: Otro nodo independiente con dos puntos de luz

12/51
INTEGRACIÓN DE PLATAFORMAS LIBRES Y
COMERCIALES EN EL ÁMBITO DEL HOGAR DIGITAL
Curso: 2017/2018

Aplicación de control remoto por móvil

Illustration 13: Varios móviles con la aplicación Souliss controlando el mismo nodo.

Conclusiones
Las pruebas han sido bastante satisfactorias, aunque no libres de numerosos bugs que han
ralentizado aún más los logros a alcanzar.
Los resultados se pueden valorar como adecuados para indicar que el proyecto está maduro, pero
que requiere el desarrollo de materiales para su uso. Esta tarea debe realizarse tras la
experimentación y ha escapado de las posibilidades de este grupo de trabajo.

Propuestas futuras
Existe un gran potencial en el uso de este software/hardware debido a su compatibilidad mediante
un binding con el software de código abierto “OpenHAB”.
OpenHAB es utilizado en el centro en el módulo de Sistemas integrados y hogar digital como
pasarela domótica montada sobre un hardware abierto bien conocido hoy en día: Raspberry PI.

13/51
INTEGRACIÓN DE PLATAFORMAS LIBRES Y
COMERCIALES EN EL ÁMBITO DEL HOGAR DIGITAL
Curso: 2017/2018

Es deseable desarrollar módulos integrables con dicha pasarela para las prácticas en dicho módulo.
En la actualidad se integra sobre una instalación comercial KNX y permitiría ser contrastada dicha
red con una abierta como souliss.
La redacción clara de documentación para las prácticas sería muy deseable dado la escasa o
inexistente documentación.

14/51
INTEGRACIÓN DE PLATAFORMAS LIBRES Y
COMERCIALES EN EL ÁMBITO DEL HOGAR DIGITAL
Curso: 2017/2018

Código fuente de las prácticas


A continuación se muestran los listados de los códigos fuente utilizados en las placas de los dos
tipos de nodos.

Nodo pasarela
Placa basada en arduino ethernet con conexión a MAX485 (RS485)

/**************************************************************************
Souliss - RGB LED Strip

Control and RGB LED or a Strip using the PWM, fade in/out and flash
effects are available as the Android interface.

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/usart.h" // USART RS485

/*************/
// Use the following if you are using an RS485 transceiver with
// transmission enable pin, otherwise delete this section.
//
#define USARTDRIVER_INSKETCH
#define USART_TXENABLE 1
#define USART_TXENPIN 2
#define USARTDRIVER Serial
/*************/

15/51
INTEGRACIÓN DE PLATAFORMAS LIBRES Y
COMERCIALES EN EL ÁMBITO DEL HOGAR DIGITAL
Curso: 2017/2018

// Include framework code and libraries


#include <SPI.h>

/*** All configuration includes should be above this line ***/


#include "Souliss.h"

// Define the RS485 network configuration


#define myvNet_subnet 0xFF00
#define Gateway_RS485 0xCE01
#define Peer_RS485_1 0xCE02
#define Peer_RS485_2 0xCE03
#define Peer_RS485_3 0xCE04
#define Peer_RS485_4 0xCE05

#define LEDCONTROL 0 // This is the memory slot for the


logic that handle the light
#define LEDINTENSITY 1 // This is the memory slot for the
logic that handle the light

void setup()
{
Initialize();

// Get the IP address from DHCP


GetIPAddress();
SetAsGateway(myvNet_dhcp); // Set this node as gateway for
SoulissApp

SetAddress(Gateway_RS485, myvNet_subnet, 0);


// Set the address on the RS485 bus
// This node as gateway will get data from the Peer
SetAsPeerNode(Peer_RS485_1, 1);
SetAsPeerNode(Peer_RS485_2, 2);
SetAsPeerNode(Peer_RS485_3, 3);
SetAsPeerNode(Peer_RS485_4, 4);

Set_DimmableLight(LEDCONTROL); // Set a logic to control a LED strip

// Define inputs, outputs pins


pinMode(8, INPUT); // Hardware pulldown required
pinMode(9, OUTPUT); // Power the LED
}

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

// Execute the code every 1 time_base_fast


FAST_10ms() {

// Use Pin2 as command


DigIn(8, Souliss_T1n_ToggleCmd, LEDCONTROL);

16/51
INTEGRACIÓN DE PLATAFORMAS LIBRES Y
COMERCIALES EN EL ÁMBITO DEL HOGAR DIGITAL
Curso: 2017/2018

// Execute the logic that handle the LED


Logic_DimmableLight(LEDCONTROL);

// Use the output values to control the PWM


analogWrite(9, mOutput(LEDINTENSITY));

// Just process communication as fast as the logics


ProcessCommunication();
}

// Process the other Gateway stuffs


FAST_GatewayComms();
}
EXECUTESLOW()
{
UPDATESLOW();

SLOW_10s() {

// The timer handle timed-on states


Timer_DimmableLight(LEDCONTROL);
}
}
}

Nodo independiente Nº1


Placa basada en arduino mega con conexión a MAX485 (RS485)

/**************************************************************************
Souliss - RGB LED Strip

Control and RGB LED or a Strip using the PWM, fade in/out and flash
effects are available as the Android interface.

Run this code on one of the following boards:


- Arduino Ethernet (W5100)

***************************************************************************/

// 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

17/51
INTEGRACIÓN DE PLATAFORMAS LIBRES Y
COMERCIALES EN EL ÁMBITO DEL HOGAR DIGITAL
Curso: 2017/2018

#include "conf/usart.h" // USART RS485

/*************/
// Use the following if you are using an RS485 transceiver with
// transmission enable pin, otherwise delete this section.
//
#define USARTDRIVER_INSKETCH
#define USART_TXENABLE 1
#define USART_TXENPIN 2
#define USARTDRIVER Serial
/*************/

// Include framework code and libraries


#include <SPI.h>

/*** All configuration includes should be above this line ***/


#include "Souliss.h"

// Define the RS485 network configuration


#define myvNet_subnet 0xFF00
#define Gateway_RS485 0xCE01
#define Peer_RS485_1 0xCE02
#define Peer_RS485_2 0xCE03
#define Peer_RS485_3 0xCE04
#define Peer_RS485_4 0xCE05

#define LEDCONTROL 0 // This is the memory slot for the


logic that handle the light
#define LEDINTENSITY 1 // This is the memory slot for the
logic that handle the light
#define LEDCONTROL2 2 // This is the memory slot for the
logic that handle the light
#define LEDINTENSITY2 3 // This is the memory slot for the
logic that handle the light

void setup()
{
Initialize();

// Set network parameters


SetAddress(Peer_RS485_1, myvNet_subnet, Gateway_RS485);

// Get the IP address from DHCP


// GetIPAddress();
// SetAsGateway(myvNet_dhcp); // Set this node as gateway
for SoulissApp

Set_DimmableLight(LEDCONTROL); // Set a logic to control a


LED strip
Set_DimmableLight(LEDCONTROL2); // Set a logic to control a
LED strip

// Define inputs, outputs pins

18/51
INTEGRACIÓN DE PLATAFORMAS LIBRES Y
COMERCIALES EN EL ÁMBITO DEL HOGAR DIGITAL
Curso: 2017/2018

pinMode(6, INPUT); // Hardware pulldown required


pinMode(7, OUTPUT); // Power the LED
pinMode(8, INPUT); // Hardware pulldown required
pinMode(9, OUTPUT); // Power the LED
}

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

// Execute the code every 1 time_base_fast


FAST_10ms() {

// Use Pin2 as command


DigIn(8, Souliss_T1n_ToggleCmd, LEDCONTROL);

// Execute the logic that handle the LED


Logic_DimmableLight(LEDCONTROL);

// Use the output values to control the PWM


analogWrite(9, mOutput(LEDINTENSITY));

// Use Pin2 as command


DigIn(6, Souliss_T1n_ToggleCmd, LEDCONTROL2);

// Execute the logic that handle the LED


Logic_DimmableLight(LEDCONTROL2);

// Use the output values to control the PWM


analogWrite(7, mOutput(LEDINTENSITY2));

// Just process communication as fast as the logics


ProcessCommunication();
}
FAST_PeerComms();

// Process the other Gateway stuffs


// FAST_GatewayComms();
}
EXECUTESLOW()
{
UPDATESLOW();

SLOW_10s() {

// The timer handle timed-on states


Timer_DimmableLight(LEDCONTROL);
}
}
}

19/51
INTEGRACIÓN DE PLATAFORMAS LIBRES Y
COMERCIALES EN EL ÁMBITO DEL HOGAR DIGITAL
Curso: 2017/2018

Nodo independiente Nº2


Placa basada en arduino mega con conexión a MAX485 (RS485)

/**************************************************************************
Souliss - RGB LED Strip

Control and RGB LED or a Strip using the PWM, fade in/out and flash
effects are available as the Android interface.

Run this code on one of the following boards:


- Arduino Ethernet (W5100)

***************************************************************************/

// 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/usart.h" // USART RS485

/*************/
// Use the following if you are using an RS485 transceiver with
// transmission enable pin, otherwise delete this section.
//
#define USARTDRIVER_INSKETCH
#define USART_TXENABLE 1
#define USART_TXENPIN 2
#define USARTDRIVER Serial
/*************/

// Include framework code and libraries


#include <SPI.h>

/*** All configuration includes should be above this line ***/


#include "Souliss.h"

// Define the RS485 network configuration


#define myvNet_subnet 0xFF00
#define Gateway_RS485 0xCE01
#define Peer_RS485_1 0xCE02
#define Peer_RS485_2 0xCE03
#define Peer_RS485_3 0xCE04
#define Peer_RS485_4 0xCE05

20/51
INTEGRACIÓN DE PLATAFORMAS LIBRES Y
COMERCIALES EN EL ÁMBITO DEL HOGAR DIGITAL
Curso: 2017/2018

#define LEDCONTROL 0 // This is the memory slot for the


logic that handle the light
#define LEDINTENSITY 1 // This is the memory slot for the
logic that handle the light
#define LEDCONTROL2 2 // This is the memory slot for the
logic that handle the light
#define LEDINTENSITY2 3 // This is the memory slot for the
logic that handle the light

void setup()
{
Initialize();

// Set network parameters


SetAddress(Peer_RS485_2, myvNet_subnet, Gateway_RS485);

// Get the IP address from DHCP


// GetIPAddress();
// SetAsGateway(myvNet_dhcp); // Set this node as gateway
for SoulissApp

Set_DimmableLight(LEDCONTROL); // Set a logic to control a


LED strip
Set_DimmableLight(LEDCONTROL2); // Set a logic to control a
LED strip

// Define inputs, outputs pins


pinMode(6, INPUT); // Hardware pulldown required
pinMode(7, OUTPUT); // Power the LED
pinMode(8, INPUT); // Hardware pulldown required
pinMode(9, OUTPUT); // Power the LED
}

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

// Execute the code every 1 time_base_fast


FAST_10ms() {

// Use Pin2 as command


DigIn(8, Souliss_T1n_ToggleCmd, LEDCONTROL);

// Execute the logic that handle the LED


Logic_DimmableLight(LEDCONTROL);

// Use the output values to control the PWM


analogWrite(9, mOutput(LEDINTENSITY));

// Use Pin2 as command


DigIn(6, Souliss_T1n_ToggleCmd, LEDCONTROL2);

21/51
INTEGRACIÓN DE PLATAFORMAS LIBRES Y
COMERCIALES EN EL ÁMBITO DEL HOGAR DIGITAL
Curso: 2017/2018

// Execute the logic that handle the LED


Logic_DimmableLight(LEDCONTROL2);

// Use the output values to control the PWM


analogWrite(7, mOutput(LEDINTENSITY2));

// Just process communication as fast as the logics


ProcessCommunication();
}
FAST_PeerComms();

// Process the other Gateway stuffs


// FAST_GatewayComms();
}
EXECUTESLOW()
{
UPDATESLOW();

SLOW_10s() {

// The timer handle timed-on states


Timer_DimmableLight(LEDCONTROL);
}
}
}

Nodo independiente Nº3


Placa basada en arduino mega con conexión a MAX485 (RS485)

/**************************************************************************
Souliss - RGB LED Strip

Control and RGB LED or a Strip using the PWM, fade in/out and flash
effects are available as the Android interface.

Run this code on one of the following boards:


- Arduino Ethernet (W5100)

***************************************************************************/

// 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

22/51
INTEGRACIÓN DE PLATAFORMAS LIBRES Y
COMERCIALES EN EL ÁMBITO DEL HOGAR DIGITAL
Curso: 2017/2018

#include "conf/usart.h" // USART RS485

/*************/
// Use the following if you are using an RS485 transceiver with
// transmission enable pin, otherwise delete this section.
//
#define USARTDRIVER_INSKETCH
#define USART_TXENABLE 1
#define USART_TXENPIN 2
#define USARTDRIVER Serial
/*************/

// Include framework code and libraries


#include <SPI.h>

/*** All configuration includes should be above this line ***/


#include "Souliss.h"

// Define the RS485 network configuration


#define myvNet_subnet 0xFF00
#define Gateway_RS485 0xCE01
#define Peer_RS485_1 0xCE02
#define Peer_RS485_2 0xCE03
#define Peer_RS485_3 0xCE04
#define Peer_RS485_4 0xCE05

#define LEDCONTROL 0 // This is the memory slot for the


logic that handle the light
#define LEDINTENSITY 1 // This is the memory slot for the
logic that handle the light
#define LEDCONTROL2 2 // This is the memory slot for the
logic that handle the light
#define LEDINTENSITY2 3 // This is the memory slot for the
logic that handle the light

void setup()
{
Initialize();

// Set network parameters


SetAddress(Peer_RS485_3, myvNet_subnet, Gateway_RS485);

// Get the IP address from DHCP


// GetIPAddress();
// SetAsGateway(myvNet_dhcp); // Set this node as gateway
for SoulissApp

Set_DimmableLight(LEDCONTROL); // Set a logic to control a


LED strip
Set_DimmableLight(LEDCONTROL2); // Set a logic to control a
LED strip

23/51
INTEGRACIÓN DE PLATAFORMAS LIBRES Y
COMERCIALES EN EL ÁMBITO DEL HOGAR DIGITAL
Curso: 2017/2018

// Define inputs, outputs pins


pinMode(6, INPUT); // Hardware pulldown required
pinMode(7, OUTPUT); // Power the LED
pinMode(8, INPUT); // Hardware pulldown required
pinMode(9, OUTPUT); // Power the LED
}

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

// Execute the code every 1 time_base_fast


FAST_10ms() {

// Use Pin2 as command


DigIn(8, Souliss_T1n_ToggleCmd, LEDCONTROL);

// Execute the logic that handle the LED


Logic_DimmableLight(LEDCONTROL);

// Use the output values to control the PWM


analogWrite(9, mOutput(LEDINTENSITY));

// Use Pin2 as command


DigIn(6, Souliss_T1n_ToggleCmd, LEDCONTROL2);

// Execute the logic that handle the LED


Logic_DimmableLight(LEDCONTROL2);

// Use the output values to control the PWM


analogWrite(7, mOutput(LEDINTENSITY2));

// Just process communication as fast as the logics


ProcessCommunication();
}
FAST_PeerComms();

// Process the other Gateway stuffs


// FAST_GatewayComms();
}
EXECUTESLOW()
{
UPDATESLOW();

SLOW_10s() {

// The timer handle timed-on states


Timer_DimmableLight(LEDCONTROL);
}
}
}

24/51
INTEGRACIÓN DE PLATAFORMAS LIBRES Y
COMERCIALES EN EL ÁMBITO DEL HOGAR DIGITAL
Curso: 2017/2018

Nodo independiente Nº4


Placa basada en arduino mega con conexión a MAX485 (RS485)

/**************************************************************************
Souliss - RGB LED Strip

Control and RGB LED or a Strip using the PWM, fade in/out and flash
effects are available as the Android interface.

Run this code on one of the following boards:


- Arduino Ethernet (W5100)

***************************************************************************/

// 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/usart.h" // USART RS485

/*************/
// Use the following if you are using an RS485 transceiver with
// transmission enable pin, otherwise delete this section.
//
#define USARTDRIVER_INSKETCH
#define USART_TXENABLE 1
#define USART_TXENPIN 2
#define USARTDRIVER Serial
/*************/

// Include framework code and libraries


#include <SPI.h>

/*** All configuration includes should be above this line ***/


#include "Souliss.h"

// Define the RS485 network configuration


#define myvNet_subnet 0xFF00
#define Gateway_RS485 0xCE01
#define Peer_RS485_1 0xCE02
#define Peer_RS485_2 0xCE03
#define Peer_RS485_3 0xCE04
#define Peer_RS485_4 0xCE05

25/51
INTEGRACIÓN DE PLATAFORMAS LIBRES Y
COMERCIALES EN EL ÁMBITO DEL HOGAR DIGITAL
Curso: 2017/2018

#define LEDCONTROL 0 // This is the memory slot for the


logic that handle the light
#define LEDINTENSITY 1 // This is the memory slot for the
logic that handle the light
#define LEDCONTROL2 2 // This is the memory slot for the
logic that handle the light
#define LEDINTENSITY2 3 // This is the memory slot for the
logic that handle the light

void setup()
{
Initialize();

// Set network parameters


SetAddress(Peer_RS485_4, myvNet_subnet, Gateway_RS485);

// Get the IP address from DHCP


// GetIPAddress();
// SetAsGateway(myvNet_dhcp); // Set this node as gateway
for SoulissApp

Set_DimmableLight(LEDCONTROL); // Set a logic to control a


LED strip
Set_DimmableLight(LEDCONTROL2); // Set a logic to control a
LED strip

// Define inputs, outputs pins


pinMode(6, INPUT); // Hardware pulldown required
pinMode(7, OUTPUT); // Power the LED
pinMode(8, INPUT); // Hardware pulldown required
pinMode(9, OUTPUT); // Power the LED
}

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

// Execute the code every 1 time_base_fast


FAST_10ms() {

// Use Pin2 as command


DigIn(8, Souliss_T1n_ToggleCmd, LEDCONTROL);

// Execute the logic that handle the LED


Logic_DimmableLight(LEDCONTROL);

// Use the output values to control the PWM


analogWrite(9, mOutput(LEDINTENSITY));

// Use Pin2 as command


DigIn(6, Souliss_T1n_ToggleCmd, LEDCONTROL2);

26/51
INTEGRACIÓN DE PLATAFORMAS LIBRES Y
COMERCIALES EN EL ÁMBITO DEL HOGAR DIGITAL
Curso: 2017/2018

// Execute the logic that handle the LED


Logic_DimmableLight(LEDCONTROL2);

// Use the output values to control the PWM


analogWrite(7, mOutput(LEDINTENSITY2));

// Just process communication as fast as the logics


ProcessCommunication();
}
FAST_PeerComms();

// Process the other Gateway stuffs


// FAST_GatewayComms();
}
EXECUTESLOW()
{
UPDATESLOW();

SLOW_10s() {

// The timer handle timed-on states


Timer_DimmableLight(LEDCONTROL);
}
}
}

27/51
INTEGRACIÓN DE PLATAFORMAS LIBRES Y
COMERCIALES EN EL ÁMBITO DEL HOGAR DIGITAL
Curso: 2017/2018

Traducción libre de la wiki: https://github.com/souliss/souliss/wiki

Introducción a Souliss
Framework de redes de control distribuido basado en Arduino para Smart Homes y IoT
Souliss es un proyecto de código abierto que recopila código fuente y personas con intereses
comunes en el campo del SmartHome e Internet of Things. Está diseñado para ser ligero y
escalable, se ejecuta en múltiples nodos y por disitintos medios de comunicación. Puede usar
Souliss para construir un sistema domótico completo basado en Ethernet y RS485 , crear sus
propios dispositivos inteligentes inalámbricos ZigBee, Z-Wave o simplemente abrir la puerta de
su garaje desde su teléfono inteligente Android.
La wiki contiene toda la información necesaria para configurar una red de Souliss, incluye detalles
sobre arquitecturas e implementaciones compatibles.

Descripción breve sobre Souliss


Souliss está construido sobre tres capas que construyen una red completa de nodos con lógica y
funcionalidad distribuidas, todos los nodos pueden intercambiar datos “peer to peer” y no hay
necesidad de un nodo central que coordine la lógica y las comunicaciones. Gracias a su estructura
escalable, la funcionalidad de Souliss se puede mover a través de diferentes nodos o fusionarse en
uno solo, la mejor solución se puede orientar según el tamaño y los requisitos de la red.
Si ya tiene una placa compatible , puede comenzar desde cualquiera de los ejemplos.

Arquitectura de red e interfaces de usuario


Puede definir una arquitectura que mezcle diferentes medios de comunicación como Ethernet, punto
a punto inalámbrico y RS485 según sus necesidades teniendo todos los datos informados a un nodo
de puerta de enlace que actúa como recopilador de datos para la interfaz de usuario como la
aplicación de Android SoulissApp u openHAB .
Puede comenzar desde un único nodo Ethernet como Gateway agregando otros nodos más adelante.

Lógicas e interfaces
Cada nodo ejecuta un conjunto de lógica definida por el usuario (denominada: “Typical”), estos
ofrecen una forma común de interactuar con la interfaz de usuario , reduciendo el esfuerzo de
configuración y aumentando la estandarización entre nodos.
Los datos no se almacenan de manera predeterminada en la puerta de enlace que actúa como
elemento de paso a su través; si es necesario, puede configurar las interfaces , una colección de
protocolos para la transferencia de datos diseñada para integrar Souliss con otros dispositivos.

28/51
INTEGRACIÓN DE PLATAFORMAS LIBRES Y
COMERCIALES EN EL ÁMBITO DEL HOGAR DIGITAL
Curso: 2017/2018

Hardware de Souliss
Hay varias plataformas disponibles que pueden ejecutar Souliss, todas están basadas en
microcontroladores AVR y tienen diferentes transceptores de extensión de E/S.

Comenzando con Souliss


Si eres nuevo en el mundo de Arduino y su IDE, sigue la primera guía de carga e inicio .
Los ejemplos son el mejor punto de partida, comience desde un nodo Ethernet . Considere que
siempre necesita configurar el Framework para especificar la plataforma de hardware y las opciones
a habilitar.

Comenzando con Souliss


Souliss es un Framework de interconexión compuesto de dos partes principales:
• El Framework : Es el código que se ejecuta en sus nodos, se distribuye como código fuente
y necesita compilarse y cargarse en sus nodos. Un nodo es un objeto que interactúa, basado
en un módulo electrónico compatible con Arduino.
• La interfaz de usuario : es la forma en que puede interactuar con sus nodos, SoulissApp es
el punto de partida y le permite controlar sus nodos desde cualquier dispositivo basado en
Android. Hay otras interfaces de usuario, pero dejemos las cosas simples aún.
La siguiente lista de verificación lo ayudará a comenzar con Souliss, generalmente es una tarea que
requiere menos de una hora si se utiliza con entornos Arduino.

Lista de inicio para comenzar:


• Verifica si tu nodo es compatible
• Obtenga el último IDE Arduino compatible
• Obtenga el último código de marco de Souliss para Arduino
• Obtenga la última aplicación de Android SoulissApp
• Verificar el ejemplo “Blink”
• Configura el Souliss
• Compila y carga Souliss, luego hazte fan

Paso 1: verifica si tu nodo es compatible


El Framework de Souliss está diseñado para ejecutarse en múltiples arquitecturas e interfaces de
comunicación, por lo que primero debe verificar cuáles son las plataformas de hardware
compatibles . Si su hardware está en la lista, entonces puede avanzar más.

29/51
INTEGRACIÓN DE PLATAFORMAS LIBRES Y
COMERCIALES EN EL ÁMBITO DEL HOGAR DIGITAL
Curso: 2017/2018

Hay dos opciones principales: obtener una placa que contenga todo el hardware requerido (como las
placas ProDINO de KMP Electronics) o ensamblar un nodo con una o varias interfaces de
comunicación y E/S según sus necesidades.

Paso 2: obtenga el último IDE de Arduino compatible


Arduino IDE es una herramienta para escribir, compilar y cargar el framework de Souliss en sus
nodos. Debería descargar Arduino IDE 1.6.12 para el archivo ZIP de Windows para instalación sin
privilegios de administración ya que Souliss se ha probado en esa versión en modo portable .
Tenga en cuenta que el Arduino IDE se envía por defecto con soporte para algunos
microcontroladores ATmega y otros basados en los productos oficiales Arduino; sin embargo,
algunas placas pueden requerir la instalación de núcleos adicionales para admitir
microcontroladores específicos (como placas Moteino y ESP8266).
Consulte la sección de microcontroladores compatibles para obtener detalles sobre los núcleos
necesarios para el microcontrolador utilizado en Souliss.

Paso 3: verificar el ejemplo de parpadeo: “BLINK”


Si es la primera vez que usa su placa Arduino, lo mejor es comenzar con un ejemplo simple, para
asegurarse de que su IDE esté listo para la compilación. Desde el menú Archivo -> Ejemplos ->
Conceptos básicos, carga el sketch Blink.
Desde el sitio web de Arduino ( http://www.arduino.cc/ ) puede obtener la guía de inicio para el
ejemplo Blink. Una vez que compile y ejecute Blink correctamente, puede pasar al siguiente paso.

Paso 4: obtenga el último código de marco de Souliss


El código fuente del framework está disponible en el Administrador de Bibliotecas , siga la guía en
el sitio web Arduino, simplemente busque souliss en el Administrador de Bibliotecas e instale la
última versión disponible.
También puede instalar manualmente la biblioteca, desde la página de descarga usar el archivo zip e
importarlo al IDE de Arduino, esto le permite usar la última compilación que aún no se ha
publicado en el Administrador de Bibliotecas. Antes de la instalación, Souliss eliminará
manualmente la versión anterior de Souliss del Administrador de Bibliotecas y descargará el
archivo ZIP y usará la función Importar desde el IDE de Arduino.
Una vez instalado, puede ver en Archivo -> Ejemplo -> Souliss una lista de ejemplos, cada uno
tiene una pequeña descripción en la parte superior. Tenga cuidado, los ejemplos incluyen aún la
configuración de una placa específica y un tipo de transceptor. Puede usar fácilmente el mismo
ejemplo en diferentes tarjetas o transceptores, cambiando los archivos de configuración.

30/51
INTEGRACIÓN DE PLATAFORMAS LIBRES Y
COMERCIALES EN EL ÁMBITO DEL HOGAR DIGITAL
Curso: 2017/2018

Paso 5: obtenga la última aplicación de Android Souliss


La interfaz de SoulissApp es el punto de entrada de su red Souliss, puede descargar los archivos
binarios de Google Play Store e instalarlos directamente en su dispositivo.
Si su dispositivo no tiene Play Store, puede descargar los archivos binarios para la instalación
manual (necesita habilitar habilitar fuentes desconocidas).

Paso 6: Configura las funciones de Souliss


Dado que Souliss se ejecuta en múltiples arquitecturas y transceptores, requiere una configuración.
En la configuración, especifica la placa, el transceptor y la funcionalidad que desea en su nodo.
Si está empezando con un simple Arduino Ethernet (o compatible), solo tiene que especificar una
dirección IP y definir su nodo Souliss Gateway .

Paso 7: compila y carga Souliss, y luego diviértete


Ahora estás listo, compila y carga tu código y estarás listo para jugar con Souliss y SoulissApp.
Si cree que se necesita más explicación, eche un vistazo a “Su primera carga” para tener una
descripción paso a paso de un caso simple con una placa Ethernet.
Puede solicitar ayuda utilizando la lista de correo de la comunidad .

Configuración del Framework


La configuración del framework es simplemente una colección de ajustes necesarios para
especificar la arquitectura, el transceptor y el módulo de E/S utilizados en su nodo, de esta manera
el código apropiado se compila automáticamente y puede ejecutar el mismo sketch sobre diferentes
arquitecturas.
La configuración se realiza a través de sentencias #define que se enumeran en los archivos de
configuración general. Están ubicados dentro de las carpetas /conf y /bconf , puede #define
mayoría de estas configuraciones en el sketch teniendo la oportunidad de enlazar el sketch y la
configuración pertinente, esto se llama INSKETCH .

Una configuración de ejemplo


Es más fácil ver cómo se configura un sketch que explicarlo; considere el e01_HelloWorld , esto
está configurado para ejecutarse sobre un Arduino Ethernet o Arduino UNO / Leonardo / Mega con
escudo Ethernet. La configuración se parece a lo siguiente:
// Configurar el marco
# include "bconf/StandardArduino.h " // Utiliza un Arduino estándar
# incluye "conf/ethW5100.h " // Ethernet a través de Wiznet W5100

31/51
INTEGRACIÓN DE PLATAFORMAS LIBRES Y
COMERCIALES EN EL ÁMBITO DEL HOGAR DIGITAL
Curso: 2017/2018

# include "conf/Gateway.h " // El nodo principal es el Gateway, solo tenemos un


nodo
# incluye "conf/Webhook.h " // Habilita DHCP y DNS

// Incluye código de framework y bibliotecas


# include < SPI.h >
# incluye " Souliss.h "

El #include "bconf/StandardArduino.h" especifica el tipo de placa ( bconf significa


configuración de placa ) como Standard Arduino con Wiznet W5100 Ethernet Shield (o una
integrada, como en Arduino Ethernet) #include "conf/ethW5100.h" y configurado como
una puerta de enlace .
Los archivos deben estar incluidos antes de la declaración #include "Souliss.h" , de lo
contrario no tendrá ningún efecto .

Lista de archivos de configuración disponibles


Los siguientes archivos se encuentran en la carpeta /conf y se usan para especificar una placa o
funcionalidad requerida:
Nombre del archivo Descripción
DisableEEPROM.h Deshabilitar configuración guardar en EEPROM
DynamicAddressing.h Habilite el direccionamiento dinámico ( detalles )
ethENC28J60.h Utilice el transceptor Ethernet Microchip ENC28J60
ethW5100.h Utilice el transceptor Ethernet Wiznet W5100
ethW5200.h Utilice el transceptor Ethernet Wiznet W5200
ethW5500.h Utilice el transceptor Ethernet Wiznet W5500
Gateway.h Establecer el nodo como Gateway
Gateway_wLastin.h Establezca el nodo como Puerta de enlace con Última persistencia
Gateway_wPersistence.h Establezca el nodo como Puerta de enlace con plena persistencia
HTTPinterface.h Habilitar la interfaz HTTP
IPBroadcast.h Habilitar la comunicación de difusión IP ( detalles
ModbusRTU.h Habilitar la interfaz Modbus RTU
ModbusTCP.h Habilitar la interfaz Modbus TCP
nRF24L01.h Use la radio nRF24L01 (+) 2.4 GHz
Construya un nodo que pueda cambiar entre Gateway y Peer en el
RuntimeGateway.h
tiempo de ejecución
Habilite la funcionalidad Sleep para dispositivos que funcionan con
Sleep.h
batería
Reduzca el tamaño de la red y el uso de RAM relevante (debe aplicarse
SmallNetwork.h
en todos los nodos)
SuperNode.h Establecer el nodo como Supernodo
usart.h Use el USART para comunicarse con otros nodos (RS485 y wireless-

32/51
INTEGRACIÓN DE PLATAFORMAS LIBRES Y
COMERCIALES EN EL ÁMBITO DEL HOGAR DIGITAL
Curso: 2017/2018

Nombre del archivo Descripción


usart)
Use el USART para comunicarse entre dos microcontroladores
usart_fast.h
conectados directamente
UserinterfaceLockDown.h Habilitar el bloqueo de inteface del usuario
WEBCONFinterface.h Habilite la interfaz WebConfig
Webhook.h Incluir DNS y DHCP, para dispositivos basados en Wiznet
wifiMRF24.h Utilice el transceptor WiFi Microchip MRF24
WirelessExtender.h Establecer el nodo como extensor inalámbrico
XMLinterface.h Habilite la Interfaz XML
Debe consultar la guía de cada una de estas funcionalidades para comprender completamente
cuándo y cómo se pueden usar.

Lista de archivos de configuración de la placa disponibles


Los siguientes archivos se encuentran dentro de la carpeta /bconf y se utilizan para especificar
una tabla completa, incluidas todas las funcionalidades disponibles.
Nombre del archivo Descripción
Chibiduino, Arduino Duemilanove (compatible) con radio
Chibiduino_v1.h
integrada de 2.4 GHz
ControllinoMaxi.h Controllino Maxi
ControllinoMaxi_EthernetBridge_
Controllino Maxi, con Ethernet y RS485
RS485.h
ControllinoMaxi_RS485.h Controllino Maxi, solo RS485
Arduino UNO (compatible) con toma nRF24L01 para nodos
DevDuino_v2.h
operados por batería
Arduino Duemilanove (compatible) con relé y el transceptor
DINo_v1.h
Ethernet ENC28J60 de Microchip
Arduino Duemilanove (compatible) con relé y transceptor
DINo_v1.h
Ethernet ENC28J60 de Microchip y RS485
Arduino Leonardo (compatible) con relé, transceptor Ethernet
DINo_v2.h
Wiznet W5200
Arduino Leonardo (compatible) con relé, transceptor Wiznet
DINo_v2_EthernetBridge_RS485.h
W5200 Ethernet y RS485
DINo_v2_RS485.h Arduino Leonardo (compatible) con relé y RS485
DINo_WiFi.h ESP8266 Wroom WiFi con relé y optoinputs
DINo_WiFi_Bridge_RS485.h ESP8266 Wroom WiFi con relé y optoinputs, con RS485
ESP8266 Wroom con relé y optoinputs, con RS485 y WiFi
DINo_WiFi_RS485.h
deshabilitados
Industruino.h Industruino
Industruino_Ethernet.h Industruino con Ethernet

33/51
INTEGRACIÓN DE PLATAFORMAS LIBRES Y
COMERCIALES EN EL ÁMBITO DEL HOGAR DIGITAL
Curso: 2017/2018

Nombre del archivo Descripción


Industruino_EthernetBridge_RS485
Industruino con Ethernet y RS485
.h
IonoEthernet.h IONO Shield con Arduino Ethernet
LYT8266_LEDBulb.h Authometion LYT8266 WiFi Bulb
LYT88_LEDBulb_Radio.h Authometion LYT88 Shield
MCU_ESP8266.h Expressif ESP8266 WiFi SoC
Moteino.h Arduino compatible con radio MRF69 de 900 MHz
OlimexAVRT32U4.h Arduino Leonardo (compatible) con pinout especial y UEXT
Olimex_ESP8266EVB ESP8266 WiFi SoC Development Board
Arduino Duemilanove (compatible) con pinout especial y
Olimexino328.h
UEXT
Olimexino32U4.h Arduino Leonardo (compatible) con pinout especial y UEXT
OlimexMOD-ENC28J60.h Transceptor Ethernet Microchip ENC28J60 para UEXT
OlimexMOD-IO.h Placa de E / S para UEXT
OlimexMOD-IO2.h Placa de E / S para UEXT
OlimexMOD-RGB.h Tablero LED para UEXT
OlimexMOD-RS485.h Tablero RS485 para UEXT
OlimexMOD-WIFI.h Transceptor WiFi Microchip MRF24 para UEXT
StandardArduino.h Tablero Arduino (Duemilanove, UNO, Leonardo o Mega)
XBoard.h Arduino UNO (compatible)
XBoardRelay.h Arduino Ethernet (compatible) con relé

34/51
INTEGRACIÓN DE PLATAFORMAS LIBRES Y
COMERCIALES EN EL ÁMBITO DEL HOGAR DIGITAL
Curso: 2017/2018

Definiciones para el modo de configuración:


“Speakeasy”
#ifndef SPEAKEASY_H
#define SPEAKEASY_H

#include "Typicals.h"

U8 memory_map[MaCaco_MEMMAP]; // define the shared memory map


U8 data_changed = 1; // flag

/************** Scheduler ******************/


#define time_base_fast 10 // Time cycle in milliseconds
#define time_base_slow 10000 // Time cycle in milliseconds
#define num_phases 1000 // Number of phases

U16 phase_speedy=0, phase_fast=0, phase_slow=0;


unsigned long tmr_fast=0, tmr_slow=0;

#define EXECUTEFAST() if((millis()-tmr_fast) > time_base_fast )


#define UPDATEFAST() tmr_fast = millis(); \
phase_fast = (phase_fast + 1) % num_phases

#define FAST_x10ms(n) if (!(phase_fast % n))


#define FAST_10ms() if (!(phase_fast % 1))
#define FAST_30ms() if (!(phase_fast % 3))
#define FAST_50ms() if (!(phase_fast % 5))
#define FAST_70ms() if (!(phase_fast % 7))
#define FAST_90ms() if (!(phase_fast % 9))
#define FAST_110ms() if (!(phase_fast % 11))
#define FAST_210ms() if (!(phase_fast % 21))
#define FAST_510ms() if (!(phase_fast % 51))
#define FAST_710ms() if (!(phase_fast % 71))
#define FAST_910ms() if (!(phase_fast % 91))
#define FAST_1110ms() if (!(phase_fast % 111))
#define FAST_2110ms() if (!(phase_fast % 211))
#define FAST_7110ms() if (!(phase_fast % 711))
#define FAST_9110ms() if (!(phase_fast % 911))
#define FAST_11110ms() if (!(phase_fast % 1111))
#define FAST_21110ms() if (!(phase_fast % 2111))

35/51
INTEGRACIÓN DE PLATAFORMAS LIBRES Y
COMERCIALES EN EL ÁMBITO DEL HOGAR DIGITAL
Curso: 2017/2018

#define FAST_71110ms() if (!(phase_fast % 7111))


#define FAST_91110ms() if (!(phase_fast % 9111))

#define SHIFT_10ms(n) if ((phase_fast % 1)==n)


#define SHIFT_30ms(n) if ((phase_fast % 3)==n)
#define SHIFT_50ms(n) if ((phase_fast % 5)==n)
#define SHIFT_70ms(n) if ((phase_fast % 7)==n)
#define SHIFT_90ms(n) if ((phase_fast % 9)==n)
#define SHIFT_110ms(n) if ((phase_fast % 11)==n)
#define SHIFT_210ms(n) if ((phase_fast % 21)==n)
#define SHIFT_310ms(n) if ((phase_fast % 31)==n)
#define SHIFT_510ms(n) if ((phase_fast % 51)==n)
#define SHIFT_710ms(n) if ((phase_fast % 71)==n)
#define SHIFT_910ms(n) if ((phase_fast % 91)==n)
#define SHIFT_1110ms(n) if ((phase_fast % 111)==n)
#define SHIFT_2110ms(n) if ((phase_fast % 211)==n)
#define SHIFT_7110ms(n) if ((phase_fast % 711)==n)
#define SHIFT_9110ms(n) if ((phase_fast % 911)==n)
#define SHIFT_11110ms(n) if ((phase_fast % 1111)==n)
#define SHIFT_21110ms(n) if ((phase_fast % 2111)==n)
#define SHIFT_71110ms(n) if ((phase_fast % 7111)==n)
#define SHIFT_91110ms(n) if ((phase_fast % 9111)==n)

#define EXECUTESLOW() else if((millis()-tmr_slow) >


time_base_slow )
#define UPDATESLOW() tmr_slow = millis(); \
phase_slow = (phase_slow + 1) %
num_phases

#define SLOW_x10s(n) if (!(phase_slow % n))


#define SLOW_10s() if (!(phase_slow % 1))
#define SLOW_50s() if (!(phase_slow % 5))
#define SLOW_70s() if (!(phase_slow % 7))
#define SLOW_90s() if (!(phase_slow % 9))
#define SLOW_110s() if (!(phase_slow % 11))
#define SLOW_210s() if (!(phase_slow % 21))
#define SLOW_310s() if (!(phase_slow % 31))
#define SLOW_510s() if (!(phase_slow % 51))
#define SLOW_710s() if (!(phase_slow % 71))
#define SLOW_15m() if (!(phase_slow % 91))
#define SLOW_30m() if (!(phase_slow % 181))
#define SLOW_1h() if (!(phase_slow % 361))
#define SLOW_2h() if (!(phase_slow % 721))
#define SLOW_4h() if (!(phase_slow % 1441))
#define SLOW_halfday() if (!(phase_slow % 4321))

36/51
INTEGRACIÓN DE PLATAFORMAS LIBRES Y
COMERCIALES EN EL ÁMBITO DEL HOGAR DIGITAL
Curso: 2017/2018

#define SLOW_1day() if (!(phase_slow % 8641))

#define SHIFT_SLOW_10s(n) if ((phase_slow % 1)==n)


#define SHIFT_SLOW_50s(n) if ((phase_slow % 5)==n)
#define SHIFT_SLOW_70s(n) if ((phase_slow % 7)==n)
#define SHIFT_SLOW_90s(n) if ((phase_slow % 9)==n)
#define SHIFT_SLOW_110s(n) if ((phase_slow % 11)==n)

#define EXECUTESPEEDY() else


#define UPDATESPEEDY() phase_speedy = (phase_speedy + 1) %
num_phases
#define SPEEDY_x(n) if (!(phase_speedy % n))

/***************************************/

/************** Typicals ******************/


#define Set_SimpleLight(slot) Souliss_SetT11(memory_map,
slot)
#define Logic_SimpleLight(slot)
Souliss_Logic_T11(memory_map, slot, &data_changed)
#define Timer_SimpleLight(slot)
Souliss_T11_Timer(memory_map, slot)
#define Set_T11(slot) Souliss_SetT11(memory_map,
slot)
#define Logic_T11(slot)
Souliss_Logic_T11(memory_map, slot, &data_changed)
#define Timer_T11(slot)
Souliss_T11_Timer(memory_map, slot)
#define Set_LightsGroup(firstSlot, lastSlot)
Souliss_SetT11Group(memory_map, firstSlot, lastSlot)
#define Timer_LightsGroup(firstSlot, lastSlot)
Souliss_T11Group_Timer(memory_map, firstSlot, lastSlot)
#define Logic_LightsGroup(firstSlot, lastSlot)
Souliss_Logic_T11Group(memory_map, firstSlot, lastSlot,
&data_changed)

#define Set_AutoLight(slot) Souliss_SetT12(memory_map, slot)


#define Logic_AutoLight(slot) Souliss_Logic_T12(memory_map, slot,
&data_changed)
#define Timer_AutoLight(slot) Souliss_T12_Timer(memory_map, slot)
#define Set_T12(slot) Souliss_SetT12(memory_map, slot)
#define Logic_T12(slot)
Souliss_Logic_T12(memory_map, slot, &data_changed)

37/51
INTEGRACIÓN DE PLATAFORMAS LIBRES Y
COMERCIALES EN EL ÁMBITO DEL HOGAR DIGITAL
Curso: 2017/2018

#define Timer_T12(slot)
Souliss_T12_Timer(memory_map, slot)

#define Set_DigitalInput(slot) Souliss_SetT13(memory_map,


slot)
#define Logic_DigitalInput(slot) Souliss_Logic_T13(memory_map,
slot, &data_changed)
#define Set_T13(slot) Souliss_SetT13(memory_map,
slot)
#define Logic_T13(slot)
Souliss_Logic_T13(memory_map, slot, &data_changed)

#define Set_PulseOutput(slot) Souliss_SetT14(memory_map, slot)


#define Logic_PulseOutput(slot)
Souliss_Logic_T14(memory_map, slot, &data_changed)
#define Set_T14(slot) Souliss_SetT14(memory_map,
slot)
#define Logic_T14(slot)
Souliss_Logic_T14(memory_map, slot, &data_changed)

#define Set_IrDA_Lamp(slot) Souliss_SetT15(memory_map,


slot)
#define Logic_IrDA_Lamp(slot)
Souliss_Logic_T15(memory_map, slot, &data_changed)
#define Set_T15(slot) Souliss_SetT15(memory_map,
slot)
#define Logic_T15(slot)
Souliss_Logic_T15(memory_map, slot, &data_changed)

#define Set_LED_Strip(slot) Souliss_SetT16(memory_map,


slot)
#define Logic_LED_Strip(slot) Souliss_Logic_T16(memory_map,
slot, &data_changed)
#define Timer_LED_Strip(slot) Souliss_T16_Timer(memory_map,
slot)
#define Set_T16(slot) Souliss_SetT16(memory_map,
slot)
#define Logic_T16(slot)
Souliss_Logic_T16(memory_map, slot, &data_changed)
#define Timer_T16(slot)
Souliss_T16_Timer(memory_map, slot)

#define Set_StepRelay(slot) Souliss_SetT18(memory_map,


slot)

38/51
INTEGRACIÓN DE PLATAFORMAS LIBRES Y
COMERCIALES EN EL ÁMBITO DEL HOGAR DIGITAL
Curso: 2017/2018

#define Logic_StepRelay(slot) Souliss_Logic_T18(memory_map,


slot, &data_changed)
#define Timer_StepRelay(slot) Souliss_T18_Timer(memory_map,
slot)
#define Set_T18(slot) Souliss_SetT18(memory_map,
slot)
#define Logic_T18(slot)
Souliss_Logic_T18(memory_map, slot, &data_changed)
#define Timer_T18(slot)
Souliss_T18_Timer(memory_map, slot)

#define Set_DimmableLight(slot) Souliss_SetT19(memory_map,


slot)
#define Logic_DimmableLight(slot) Souliss_Logic_T19(memory_map,
slot, &data_changed)
#define Timer_DimmableLight(slot) Souliss_T19_Timer(memory_map,
slot)
#define Set_T19(slot) Souliss_SetT19(memory_map,
slot)
#define Logic_T19(slot)
Souliss_Logic_T19(memory_map, slot, &data_changed)
#define Timer_T19(slot)
Souliss_T19_Timer(memory_map, slot)

#define Set_MultipleInputs(slot) Souliss_SetT1A(memory_map, slot)


#define Logic_MultipleInputst(slot)
Souliss_Logic_T1A(memory_map, slot, &data_changed)
#define Timer_MultipleInputs(slot) Souliss_T1A_Timer(memory_map,
slot)
#define Set_T1A(slot) Souliss_SetT1A(memory_map,
slot)
#define Logic_T1A(slot)
Souliss_Logic_T1A(memory_map, slot, &data_changed)
#define Timer_T1A(slot)
Souliss_T1A_Timer(memory_map, slot)

#define Set_GarageDoor(slot) Souliss_SetT21(memory_map, slot)


#define Logic_GarageDoor(slot)
Souliss_Logic_T21(memory_map, slot, &data_changed)
#define Timer_GarageDoor(slot)
Souliss_T21_Timer(memory_map, slot)
#define Set_T21(slot) Souliss_SetT21(memory_map,
slot)
#define Logic_T21(slot)
Souliss_Logic_T21(memory_map, slot, &data_changed)

39/51
INTEGRACIÓN DE PLATAFORMAS LIBRES Y
COMERCIALES EN EL ÁMBITO DEL HOGAR DIGITAL
Curso: 2017/2018

#define Timer_T21(slot)
Souliss_T21_Timer(memory_map, slot)

#define Set_Windows(slot) Souliss_SetT22(memory_map,


slot)
#define Logic_Windows(slot)
Souliss_Logic_T22(memory_map, slot, &data_changed)
#define Timer_Windows(slot)
Souliss_T22_Timer(memory_map, slot)
#define Set_T22(slot) Souliss_SetT22(memory_map,
slot)
#define Logic_T22(slot)
Souliss_Logic_T22(memory_map, slot, &data_changed)
#define Timer_T22(slot)
Souliss_T22_Timer(memory_map, slot)

#define Set_Thermostat(slot) Souliss_SetT31(memory_map, slot)


#define Logic_Thermostat(slot)
Souliss_Logic_T31(memory_map, slot, &data_changed)
#define Set_T31(slot) Souliss_SetT31(memory_map,
slot)
#define Logic_T31(slot)
Souliss_Logic_T31(memory_map, slot, &data_changed)

#define Set_IrDA_Aircon(slot) Souliss_SetT32(memory_map,


slot)
#define Logic_IrDA_Aircon(slot)
Souliss_Logic_T32(memory_map, slot, &data_changed)
#define Set_T32(slot) Souliss_SetT32(memory_map,
slot)
#define Logic_T32(slot)
Souliss_Logic_T32(memory_map, slot, &data_changed)

#define Set_Antitheft_Main(slot) Souliss_SetT41(memory_map, slot)


#define Logic_Antitheft_Main(slot)
Souliss_Logic_T41(memory_map, slot, &data_changed)
#define Timer_Antitheft_Main(slot)
Souliss_T41_Timer(memory_map, slot)
#define Set_T41(slot) Souliss_SetT41(memory_map,
slot)
#define Logic_T41(slot)
Souliss_Logic_T41(memory_map, slot, &data_changed)
#define Timer_T41(slot)
Souliss_T41_Timer(memory_map, slot)

40/51
INTEGRACIÓN DE PLATAFORMAS LIBRES Y
COMERCIALES EN EL ÁMBITO DEL HOGAR DIGITAL
Curso: 2017/2018

#define Set_Antitheft_Peer(slot)
Souliss_SetT42(memory_map, slot)
#define Logic_Antitheft_Peer(slot, main_antitheft_address)
Souliss_Logic_T42(memory_map, slot, &data_changed,
main_antitheft_address)
#define Set_T42(slot)
Souliss_SetT42(memory_map, slot)
#define Logic_T42(slot, main_antitheft_address)
Souliss_Logic_T42(memory_map, slot, &data_changed,
main_antitheft_address)

#define Set_AnalogIn(slot) Souliss_SetT51(memory_map,


slot)
#define Read_AnalogIn(slot)
Souliss_Logic_T51(memory_map, slot,
mOutputAsFloat(slot)*0.015, &data_changed)
#define Set_T51(slot) Souliss_SetT51(memory_map,
slot)
#define Read_T51(slot)
Souliss_Logic_T51(memory_map, slot,
mOutputAsFloat(slot)*0.015, &data_changed)

#define Set_Temperature(slot) Souliss_SetT52(memory_map,


slot)
#define Logic_Temperature(slot)
Souliss_Logic_T52(memory_map, slot,
mOutputAsFloat(slot)*0.015, &data_changed)
#define Logic_Temperature_FixedDB(slot)
Souliss_Logic_T52(memory_map, slot, 0.1, &data_changed)
#define Set_T52(slot) Souliss_SetT52(memory_map,
slot)
#define Logic_T52(slot)
Souliss_Logic_T52(memory_map, slot,
mOutputAsFloat(slot)*0.015, &data_changed)

#define Set_Humidity(slot) Souliss_SetT53(memory_map,


slot)
#define Logic_Humidity(slot)
Souliss_Logic_T53(memory_map, slot,
mOutputAsFloat(slot)*0.015, &data_changed)
#define Set_T53(slot) Souliss_SetT53(memory_map,
slot)
#define Logic_T53(slot)
Souliss_Logic_T53(memory_map, slot,
mOutputAsFloat(slot)*0.015, &data_changed)

41/51
INTEGRACIÓN DE PLATAFORMAS LIBRES Y
COMERCIALES EN EL ÁMBITO DEL HOGAR DIGITAL
Curso: 2017/2018

#define Set_Light(slot)
Souliss_SetT54(memory_map, slot)
#define Logic_Light(slot)
Souliss_Logic_T54(memory_map, slot,
mOutputAsFloat(slot)*0.015, &data_changed)
#define Set_T54(slot) Souliss_SetT54(memory_map,
slot)
#define Logic_T54(slot) 42Souliss_Logic_T54(memory_map, slot,
mOutputAsFloat(slot)*0.015, &data_changed)

#define Set_Voltage(slot) Souliss_SetT55(memory_map,


slot)
#define Logic_Voltage(slot)
Souliss_Logic_T55(memory_map, slot,
mOutputAsFloat(slot)*0.015, &data_changed)
#define Set_T55(slot) Souliss_SetT55(memory_map,
slot)
#define Logic_T55(slot)
Souliss_Logic_T55(memory_map, slot,
mOutputAsFloat(slot)*0.015, &data_changed)

#define Set_Current(slot) Souliss_SetT56(memory_map,


slot)
#define Logic_Current(slot)
Souliss_Logic_T56(memory_map, slot,
mOutputAsFloat(slot)*0.015, &data_changed)
#define Set_T56(slot) Souliss_SetT56(memory_map,
slot)
#define Logic_T56(slot)
Souliss_Logic_T56(memory_map, slot,
mOutputAsFloat(slot)*0.015, &data_changed)

#define Set_Power(slot)
Souliss_SetT57(memory_map, slot)
#define Logic_Power(slot)
Souliss_Logic_T57(memory_map, slot,
mOutputAsFloat(slot)*0.015, &data_changed)
#define Set_T57(slot) Souliss_SetT57(memory_map,
slot)
#define Logic_T57(slot)
Souliss_Logic_T57(memory_map, slot,
mOutputAsFloat(slot)*0.015, &data_changed)

42/51
INTEGRACIÓN DE PLATAFORMAS LIBRES Y
COMERCIALES EN EL ÁMBITO DEL HOGAR DIGITAL
Curso: 2017/2018

#define Set_Pressure(slot) Souliss_SetT58(memory_map,


slot)
#define Logic_Pressure(slot)
Souliss_Logic_T58(memory_map, slot,
mOutputAsFloat(slot)*0.015, &data_changed)
#define Set_T58(slot) Souliss_SetT58(memory_map,
slot)
#define Logic_T58(slot)
Souliss_Logic_T58(memory_map, slot,
mOutputAsFloat(slot)*0.015, &data_changed)

#define Set_Analog_Setpoint(slot) Souliss_SetT61(memory_map, slot)


#define Logic_AnalogIn(slot)
Souliss_Logic_T61(memory_map, slot, &data_changed)
#define Set_T61(slot) Souliss_SetT61(memory_map,
slot)
#define Logic_T61(slot)
Souliss_Logic_T61(memory_map, slot, &data_changed)

#define Set_Temperature_Setpoint(slot)
Souliss_SetT62(memory_map, slot)
#define Logic_Temperature_Setpoint(slot)
Souliss_Logic_T62(memory_map, slot, &data_changed)
#define Set_T62(slot)
Souliss_SetT62(memory_map, slot)
#define Logic_T62(slot)
Souliss_Logic_T62(memory_map, slot, &data_changed)

#define Set_Humidity_Setpoint(slot)
Souliss_SetT63(memory_map, slot)
#define Logic_Humidity_Setpoint(slot)
Souliss_Logic_T63(memory_map, slot, &data_changed)
#define Set_T63(slot)
Souliss_SetT63(memory_map, slot)
#define Logic_T63(slot)
Souliss_Logic_T63(memory_map, slot, &data_changed)

#define Set_Light_Setpoint(slot)
Souliss_SetT64(memory_map, slot)
#define Logic_Light_Setpoint(slot)
Souliss_Logic_T64(memory_map, slot, &data_changed)
#define Set_T64(slot)
Souliss_SetT64(memory_map, slot)
#define Logic_T64(slot)
Souliss_Logic_T64(memory_map, slot, &data_changed)

43/51
INTEGRACIÓN DE PLATAFORMAS LIBRES Y
COMERCIALES EN EL ÁMBITO DEL HOGAR DIGITAL
Curso: 2017/2018

#define Set_Voltage_Setpoint(slot)
Souliss_SetT65(memory_map, slot)
#define Logic_Voltage_Setpoint(slot)
Souliss_Logic_T65(memory_map, slot, &data_changed)
#define Set_T65(slot)
Souliss_SetT65(memory_map, slot)
#define Logic_T65(slot)
Souliss_Logic_T65(memory_map, slot, &data_changed)

#define Set_Current_Setpoint(slot)
Souliss_SetT66(memory_map, slot)
#define Logic_Current_Setpoint(slot)
Souliss_Logic_T66(memory_map, slot, &data_changed)
#define Set_T66(slot)
Souliss_SetT66(memory_map, slot)
#define Logic_T66(slot)
Souliss_Logic_T66(memory_map, slot, &data_changed)

#define Set_Power_Setpoint(slot)
Souliss_SetT67(memory_map, slot)
#define Logic_Power_Setpoint(slot)
Souliss_Logic_T67(memory_map, slot, &data_changed)
#define Set_T67(slot)
Souliss_SetT67(memory_map, slot)
#define Logic_T67(slot)
Souliss_Logic_T67(memory_map, slot, &data_changed)

#define Set_Pressure_Setpoint(slot)
Souliss_SetT68(memory_map, slot)
#define Logic_Pressure_Setpoint(slot)
Souliss_Logic_T68(memory_map, slot, &data_changed)
#define Set_T68(slot)
Souliss_SetT68(memory_map, slot)
#define Logic_T68(slot)
Souliss_Logic_T68(memory_map, slot, &data_changed)

#define Watchdog(chain_address, chain_slot, alarm_command)


Souliss_Watchdog(memory_map, chain_address, chain_slot,
alarm_command)
/******************************************/

/************** Souliss ******************/


#define myMap memory_map
#define myData &data_changed

44/51
INTEGRACIÓN DE PLATAFORMAS LIBRES Y
COMERCIALES EN EL ÁMBITO DEL HOGAR DIGITAL
Curso: 2017/2018

#define myNode memory_map, &data_changed

#define SetAddress
Souliss_SetAddress
#define SetAddressingServer()
Souliss_SetAddressingServer(memory_map)
#define SetDynamicAddressing()
Souliss_SetDynamicAddressing()
#define SetIPAddress
Souliss_SetIPAddress
#define GetIPAddress
Souliss_GetIPAddress
#define SetAccessPoint
Souliss_SetAccessPoint
#define ReadIPConfiguration
Souliss_ReadIPConfiguration
#define IsRuntimeGateway
MaCaco_IsRuntimeGateway
#define JoinNetwork()
Souliss_JoinNetwork()
#define JoinAndReset()
Souliss_JoinAndReset()
#define SetUserInterface
UserMode_ManualRecord
#define SetAsGateway(address)
Souliss_SetLocalAddress(memory_map, address)
#define RemoveAsGateway()
Souliss_ResetLocalAddress(memory_map)
#define GetAsGateway()
Souliss_GetLocalAddress(memory_map)
#define SetAsPeerNode(address, index)
Souliss_SetRemoteAddress(memory_map, address, index)
#define SetAsBatteryNode(address, index)
Souliss_SetRemoteAddress(memory_map, address, index); \

Souliss_BatteryChannels(memory_map, address)

#define HardcodedChannel
Souliss_HardcodedCommunicationChannel
#define GetTypicals()
Souliss_GetTypicals(memory_map)
#define CommunicationChannels()
Souliss_CommunicationChannels(memory_map)
#define ProcessCommunication()
Souliss_CommunicationData(memory_map, &data_changed)

45/51
INTEGRACIÓN DE PLATAFORMAS LIBRES Y
COMERCIALES EN EL ÁMBITO DEL HOGAR DIGITAL
Curso: 2017/2018

#define DigIn(pin,value,slot)
Souliss_DigIn(pin, value, memory_map, slot)
#define LowDigIn(pin,value,slot)
Souliss_LowDigIn(pin, value, memory_map, slot)
#define DigIn2State(pin,value_state_on,value_state_off,slot)
Souliss_DigIn2State(pin, value_state_on, value_state_off,
memory_map, slot)
#define LowDigIn2State(pin,value_state_on,value_state_off,slot)
Souliss_LowDigIn2State(pin, value_state_on, value_state_off,
memory_map, slot)
#define DigInHold(pin, value_state1,value_state2,slot)
Souliss_DigInHold(pin, value_state1, value_state2, memory_map,
slot)
#define LowDigInHold(pin, value_state1,value_state2,slot)
Souliss_LowDigInHold(pin, value_state1, value_state2,
memory_map, slot)
#define DigKeepHold(pin, value_state1,value_state2,slot)
Souliss_DigKeepHold(pin, value_state1, value_state2,
memory_map, slot)
#define LowDigKeepHold(pin, value_state1,value_state2,slot)
Souliss_LowDigKeepHold(pin, value_state1, value_state2,
memory_map, slot)
#define DigOut(pin,value,slot)
Souliss_DigOut(pin, value, memory_map, slot)
#define PulseDigOut(pin,value,slot)
Souliss_PulseDigOut(pin, value, memory_map, slot)
#define nDigOut(pin,value,slot)
Souliss_nDigOut(pin, value, memory_map, slot)
#define LowDigOut(pin,value,slot)
Souliss_LowDigOut(pin, value, memory_map, slot)
#define PulseLowDigOut(pin,value,slot)
Souliss_PulseLowDigOut(pin, value, memory_map, slot)
#define nLowDigOut(pin,value,slot)
Souliss_nLowDigOut(pin, value, memory_map, slot)
#define DigOutToggle(pin,value,slot)
Souliss_DigOutToggle(pin, value, memory_map, slot)
#define ImportAnalog(slot,analogvalue)
Souliss_ImportAnalog(memory_map, slot, analogvalue)
#define AnalogIn(pin, slot, conv, bias)
Souliss_AnalogIn(pin, memory_map, slot, conv, bias)
#define isTrigged(slot)
Souliss_isTrigged(memory_map, slot)
#define RemoteInput
Souliss_RemoteInput

46/51
INTEGRACIÓN DE PLATAFORMAS LIBRES Y
COMERCIALES EN EL ÁMBITO DEL HOGAR DIGITAL
Curso: 2017/2018

#define RemoteInputs
Souliss_RemoteInputs
#define Send
Souliss_RemoteInput
#define SendData
Souliss_RemoteInputs
#define ResetInput(slot)
Souliss_ResetInput(memory_map, slot)
#define PullData(addr, slot, remote_slot, remote_numbof)
Souliss_PullData(addr, slot, remote_slot, remote_numbof)
#define RoutingTable
vNet_SetRoutingTable
#define DonotRouteTable
vNet_SetDoNotRoutingTable
#define Init_XMLServer()
XMLSERVERInit(memory_map)
#define Run_XMLServer()
XMLSERVERInterface(memory_map)
#define Init_Modbus()
ModbusInit(memory_map)
#define Run_Modbus()
Modbus(memory_map)
#define Init_HTTPServer()
{}
#define Run_HTTPServer()
HTTPServer(memory_map)

#define RemoteDigIn
Souliss_RemoteDigIn
#define RemoteLowDigIn
Souliss_RemoteLowDigIn
#define RemoteDigIn2State
Souliss_RemoteDigIn2State
#define RemoteAnalogIn2Buttons
Souliss_RemoteAnalogIn2Buttons
#define RemoteLowDigIn2State
Souliss_RemoteLowDigIn2State
#define RemoteDigInHold
Souliss_RemoteDigInHold
#define RemoteLowDigInHold
Souliss_RemoteLowDigInHold

#define Persistence_IsData(id)
Souliss_Persistence_IsData(memory_map, id)

47/51
INTEGRACIÓN DE PLATAFORMAS LIBRES Y
COMERCIALES EN EL ÁMBITO DEL HOGAR DIGITAL
Curso: 2017/2018

#define Persistence_ClearData(id)
Souliss_Persistence_ClearData(memory_map, id)

#define LastIn_IsData(id)
Souliss_LastIn_IsData(memory_map, id)
#define LastIn_ClearData(id)
Souliss_LastIn_ClearData(memory_map, id)
#define LastIn_GetData(id, slot)
Souliss_LastIn_GetData(memory_map, id, slot)
#define LastIn_GetAnalog(id, slot)
Souliss_LastIn_GetAnalog(memory_map, id, slot)

/*****************************************/

/************* Let be lazy ***************/


#define FAST_GatewayComms() FAST_30ms()
\

ProcessCommunication(); \

FAST_1110ms() \

CommunicationChannels(); \

FAST_2110ms() \

GetTypicals()

#define FAST_BridgeComms() FAST_30ms()


\

ProcessCommunication(); \

#define FAST_PeerComms() FAST_70ms()


\

ProcessCommunication();

#define START_PeerJoin()
FAST_71110ms() \
{
\

if(!MaCaco_IsSubscribed()) \

48/51
INTEGRACIÓN DE PLATAFORMAS LIBRES Y
COMERCIALES EN EL ÁMBITO DEL HOGAR DIGITAL
Curso: 2017/2018

{
\

JoinNetwork(); \
}
\
}

#define JoinInProgress() (!
MaCaco_IsSubscribed())

#define SLOW_PeerJoin()
SLOW_510s() { \

JoinNetwork(); \
}

#define GetAddress()
Souliss_DynamicAddressing_FirstBoot (memory_map);
\

for(uint8_t n=0;n<VNET_MEDIA_NUMBER;n++) {
\

while(Souliss_DynamicAddressing (memory_map, __TIME__, 9)) {


\

for(U16 i=0; i<1000; i++) {


\

if(Souliss_CommunicationData(memory_map, &data_changed))
\

break;
\

delay(10); }
\

}
\

while(!MaCaco_IsSubscribed()) {
\

49/51
INTEGRACIÓN DE PLATAFORMAS LIBRES Y
COMERCIALES EN EL ÁMBITO DEL HOGAR DIGITAL
Curso: 2017/2018

Souliss_JoinAndReset();
\

for(U16 i=0; i<1000; i++) {


\

if(Souliss_CommunicationData(memory_map, &data_changed))
\

break;
\

delay(10); }
\
}}

#define WaitSubscription() while(!


MaCaco_IsSubscribed()) { \

ProcessCommunication(); \

delay(100);}

#define aMinuteToSleep() for(uint8_t


s=0; s<255; s++) { \

ProcessCommunication(); \

delay(200);}

/*****************************************/

/*****************************************/
/*!
Macros
*/
/*****************************************/
#define AUX MaCaco_AUXIN_s
#define IN MaCaco_IN_s
#define TYP MaCaco_TYP_s
#define OUT MaCaco_OUT_s
#define mAuxiliary(slot) memory_map[AUX+slot]

50/51
INTEGRACIÓN DE PLATAFORMAS LIBRES Y
COMERCIALES EN EL ÁMBITO DEL HOGAR DIGITAL
Curso: 2017/2018

#define mInput(slot) memory_map[IN+slot]


#define mTypical(slot) memory_map[TYP+slot]
#define mOutput(slot) memory_map[OUT+slot]
#define mOutputAsFloat(slot)
Souliss_SinglePrecisionFloating(memory_map+MaCaco_OUT_s+slot)

#define pTYP MaCaco_P_TYP_s


#define pOUT MaCaco_P_OUT_s
#define pTypical(node,slot) memory_map[pTYP+slot+
(node*MaCaco_SLOT)]
#define pOutput(node,slot) memory_map[pOUT+slot+
(node*MaCaco_SLOT)]
#define pOutputAsFloat(node,slot)

Souliss_SinglePrecisionFloating(memory_map+MaCaco_P_OUT_s+slot+
(node*MaCaco_SLOT))

#define SetTrigger() (data_changed=1);


#define ResetTrigger() (data_changed=0);
#define Initialize()
Souliss_Initialize(memory_map)
#define isTrigger() data_changed

#define SetInput(slot, value) mInput(slot) = value

#define ReqTyp MaCaco_reqtyp

#endif

51/51

S-ar putea să vă placă și