Sofia2 participa en el Laboratorio Virtual SESIAD

labVirtual

 

El Laboratorio Virtual de la Secretaría de Estado para la Sociedad de la Información y Agenda Digital (SESIAD) nace bajo la norma UNE 178104 “Sistemas integrales de gestión de la ciudad inteligente” con el objetivo de convertirse en una referencia de plataformas a nivel nacional e internacional, siendo un lugar de experimentación en el que empresas y desarrolladores puedan evaluar la compatibilidad de sus productos con diferentes plataformas Smart Cities.

 

labVirtual

 

Actualmente, plataformas que participan en el Laboratorio Virtual son Sofia2, de Minsait by Indra, SmartBrain de Cellnex y Thinking City de Telefónica. Éstas colaboran con SESIAD aportando su expertise y participando en la mejora de la interoperabilidad entre plataformas.

 

plataformas

 

Como vimos en IoT Data Models: Iniciativas y Sofia2 Data Modelexisten diferentes Iniciativas de estandarización de un Data Model en IoT. Un Data Model representa la estructura de tus datos y relaciones, y por tanto, organiza los elementos y estandariza como se relacionan unos con otros.

 

gsma1

 

Los Data Models GSMA y FIWARE se definen en JSON por lo que su representación como Ontología Sofia2 es inmediata. Vimos cómo se soportan y de qué manera tan sencilla se puede trabajar con estas entidades en Sofia2

 

Para conseguir una mejor interoperabilidad entre plataformas, se seleccionó NGSI 9/10 v2 como protocolo común para la Capa de Interoperabilidad. Vimos en este documento cómo se soportan y cómo consumir APIS modeladas conforme semántica FIWARE Data Model y publicadas en Sofia2 siguiendo el protocolo NGSI 9/10 v2.

 

En nuestra experiencia con el Laboratorio Virtual, además de realizar recomendaciones de nuevos atributos y modificaciones en los Data Model, hemos tenido la posibilidad de realizar una Prueba de Concepto (PoC) creando un Flujo de conexión y transformación de datos reales provenientes de Smart City A Coruña a GSMA/FIWARE Data Model en la Plataforma Sofia2.

 

En este ejemplo, se recogen datos de parkings de Smart Coruña y se ingestan en la plataforma Sofia2 a una Ontología. Cada vez que se recibe una instancia de esta ontología se lanza un Script que transforma estos datos adaptándolos a los Data Model y, consultándolos, vemos como efectivamente, se cumple con los Data Model.

 

flujodeconexion

 

También, en esta Prueba de Concepto, pudimos publicar estos datos por medio del API MANAGER de Sofia2, para posteriormente, ver que cualquiera con los debidos permisos, puede acceder a estos datos vía API, Curl o mediante el portal del Laboratorio Virtual.

 

consumodatos

 

Todo este proceso queda explicado en el post Adquisición, transformación y consumo de datos GSMA/FIWARE Data Model, y ha sido plasmado en el demostradorque, además de los datos de parkings, recoge datos de playas y museos.

 

demostrador

 

Puedes encontrar toda la información relativa al Laboratorio Virtual SESIAD aquí, así como todas las herramientas (Data Model, APIs, Tokens de seguridad, ejemplos…) necesarias para desarrollar en las plataformas cumpliendo con este modelo de interoperabilidad aquí

Sofia2 participa en el Laboratorio Virtual SESIAD

Integration of Lora and Sofia2

The communication between Lora and Sofia2 is done through the Multitech kit, formed by a test node that simulates the transmissions between a Lora device and a Gateway. This Gateway is needed to communicate this type of devices within the network and to send the captured data.

Kit
Used Multiconnect Conduit Kit.

Before the integration in Sofia2, the configuration between the Gateway and the test node is needed. In this brief tutorial, the steps to develop both configurations are collected, as well as all the information needed in Sofia2 to receive and store the data sent by Lora.

Configuration of Lora technology

  • Gateway configuration

    In order to use the gateway without any connection problem, an initial configuration is needed. First access to the Gateway must be done by means of serial communication, though Putty or another similar tool. Credentials needed to access by console are admin/admin. We can get its IP address with the command ifconfig. Once the IP address is known, we use the explorer to access to the Multitech webpage, where we introduce the same credentials again.

    Acceso web al gateway
    Access to the gateway webpage

    Once we start the session, and only by the first time that we do it, we will find an assistant that requires us to change the password, to select the timezone and to configure the IP address. When the last window appears, we must to configure the static IP, to select the corresponding Gateway, and to add the DNS servers.

    Once we finish the IP configuration, we will configurate Lora. To do that, we have to access to Setup -> Lora. Then, we will see a screen where we will see some configurable fields. Anyway, we only need to modify Name and Passphrases.

    Web
    Lora configuration
  • Node-Red configuration

    Once we activate the Node-Red application, we can access though the “App” menu of the webpage. By default, a program that receives Lora test data and shows them is designed, but we have to modify it in order to send the information to Sofia2. Image shows the final flow diagram, with the option “Sofia2 API WEB encoder” added. This option is uncharged of giving the desired format, adding a header to the send message and an output HTTP.

    Node-Red
    Node-Red diagram
  •  Configuration of test node

    To configurate the parameters of the test node is really simple. We only have to connect the mDot to the PC, by means of a USB, and to connect it to the test node with the kit programming cable. Then, we select the “Configuration” option in the mDot Box and we access to the device by using the Putty serial communication at 115200 baud.

    Tester
    Lora tester

    We only need to configure two parameters, using the following AT commands:

    AT+NI=1,<Name>

    AT+NK=1,<Passphrase>

    AT&W is used to save changes and  AT+Exit to exit the configuration mode.

    <Name> y <Passphrase> fields have to be the same values as used previously in the gateway.

    Configuración del tester
    Test node configuration

    In order to check if the configuration of both devices has been correct, we can do a test with the Node-Red.

Sofia2

Once that the devices have been configured, we have to develop the next steps in Sofia2. We need two new ontologies, an API rest and a rule script to deal with data. This section briefly explains with each of them.

  • Defining new ontologies

    First of all, we have to create an ontology that will receive the data sent by the test node. In this ontology we will insert raw data, without any previously filtering.

    ontologia
    Ontology example with raw data

    As we can see in the previous image, data usually have hexadecimal codifications, undesirable formats or information that needs to be treated before work with it. To do that, we have to create a rule script and a new ontology, where we will insert filtered data with the format required by the data base to correctly store it.

  • API REST

    Once the ontologies are defined, we will create an API REST of type POST, to insert data in the ontology of raw data. To do that, we have to go to the API MANAGER -> APIs, where we will find the option “New API”. There, we write the name of our API, and select the option “Publish Ontology as REST API” and the ontology desired. It is convenient to disable the maximum number of calls per minute, in order to assure that we do not lose information. At the end, we select the “POST” operation and create the API.

    API
    API

    The URL of the “Base Endpoint” field is the one that we have to insert in the Node-Red.

  • Rule script

    Once verified that the data sent directly from the device is correctly inserted in the desired ontology, we must create a script to filter them, extract all possible information and provide them with the corresponding format. To do this, we simply enter Rules-> Wizard New Rules and select the option “Generate rule using a template “. With this type of rules, each time the device sends new data to the ontology, the script will be executed and data will be processed and inserted into the final ontology.

  • Presentation on results

    We can use Sofia2’s visualization tools to show the data we’re storing quickly and easily. To do that, we have to go to the Visualization ->My Gadgets -> New Gadget, where we can select the optimal tool depending on our data. On the basic of measured data from Lora tester, the following representation could be interesting: to drawn the coordinates on a map or Signal to Noise Rate (SNR) along the time.

Mapa
Coordinates shows on a map
SNR
SNR representation.
Integration of Lora and Sofia2

Integración de Lora con Sofia2

Para llevar a cabo la comunicación entre un dispositivo Lora y Sofia2 hemos utilizado un kit de Multitech formado por un nodo de pruebas que simula las transmisiones de un dispositivo con tecnología Lora y un gateway, necesario para que estos dispositivos puedan comunicarse con la red y enviar así los datos que tomen.

Kit
Kit Multiconnect utilizado.

Es necesario configurar tanto el gateway como el nodo de pruebas antes de integrar estos dispositivos en Sofia2. En esta breve guía se recogen los pasos a seguir para ambas configuraciones y todo lo necesario en Sofia2 para poder recibir y almacenar los datos enviados por Lora.

Configuración de la tecnología Lora

  • Configuración del gateway

    Es necesario hacer una configuración inicial para poder usar el gateway sin problemas de conexión. La primera vez que accedemos a él lo haremos por comunicación serie usando Putty u otra herramienta similar. Las credenciales necesarias para acceder por terminal son admin/admin, y con el comando ifconfig podemos obtener su dirección IP. Una vez conocida esta IP, accedemos a ella mediante un navegador y nos encontramos con una página de Multitech donde podemos acceder usando de nuevo las mismas credenciales que antes.

    Acceso web al gateway
    Acceso web al gateway

    Nada más iniciar sesión, y solo la primera vez que lo hacemos, nos encontramos con un asistente que nos va solicitando en varios pasos modificar la contraseña, seleccionar la zona horaria y configurar la IP. Cuando nos sale esta última ventana debemos configurarla como IP estática, seleccionar el gateway correspondiente y añadir los servidores DNS.

    Una vez terminada la configuración de la IP, configuramos la parte de Lora. Para ello basta con acceder a Setup -> Lora. Aparece una pantalla como la que se muestra en la siguiente imagen donde hay muchos campos configurables de los cuales solo necesitamos modificar Name y Passphrases.

    Web
    Pantalla de configuración de Lora.
  • Configuración de Node-Red

    Una vez activada la aplicación de Node-Red podemos acceder a ella desde el menú “App” de la web. Por defecto viene diseñado un programa que simplemente recibe los datos del tester de Lora y los muestra por pantalla, pero debemos modificarlo para que la información se envíe a Sofia2.  En la imagen se muestra el diagrama de flujos final, en el que ha añadido la función “Sofia2 API WEB encoder”, encargada de dar el formato deseado y añadir una cabecera al mensaje a enviar y una salida HTTP (envío).

    Node-Red
    Configuración de Node-Red
  • Configuración del nodo de pruebas

    Configurar los parámetros del nodo de pruebas es realmente sencillo. Solamente hay que conectar el mDot vía USB a nuestro ordenador y conectarlo al nodo de pruebas con el cable de programación que viene en el mismo kit, de la forma que se muestra en la figura. Una vez hecho esto seleccionamos la opción “Configuration” en el mDot Box y accedemos al dispositivo utilizando la comunicación serie de Putty a velocidad 115200 baudios.

    Tester
    Tester de Lora utilizado

    Solamente es necesario configurar dos parámetros y para ello se utilizan los siguientes comandos AT:

    AT+NI=1,<Name>

    AT+NK=1,<Passphrase>

    AT&W para guardar los cambios realizados Y finalmente AT+Exit para salir del modo configuración.

    Los campos <Name> y <Passphrase> tienen que ser los mismos valores que los fijados anteriormente en el Gateway.

    Configuración del tester
    Configuración del tester

    Para comprobar si la configuración de ambos dispositivo ha sido correcta, podemos hacer una prueba con Node-Red.

Sofia2

Una vez configurada toda la parte de los dispositivos, solamente queda desarrollar la parte necesaria en Sofia2. Necesitamos dos nuevas ontologías, un API rest y un Script de reglas para tratar los datos. En este apartado se explica brevemente cómo crear cada uno de ellos.

  • Definir las nuevas ontologías

    Lo primero que debemos hacer es crear una nueva ontología que recibirá los datos que envía el nodo de pruebas. En esta ontología se insertarán los datos “en crudo” (data RAW) tal y como los envía el dispositivo, sin aplicar ningún filtrado previo.

    ontologia
    Ejemplo de ontología con datos sin tratar.

    Estos datos suelen contener tramas con codificaciones en hexadecimal, formatos no deseados o información que debe ser tratada antes de trabajar con ella. Por ello es necesario crear un Script de reglas y una nueva ontología donde se insertarán los datos ya tratados y con el formato requerido por la base de datos para su correcto almacenamiento.

  • Api Rest

    Una vez definidas las ontologías, crearemos una API REST de tipo POST a la ontología de datos sin tratar para que los datos puedan ser insertados en ella.

    Para ello debemos entrar en API MANAGER -> APIs donde encontramos la opción “Crear API”. Una vez aquí, escribimos un nombre para nuestra API, seleccionamos la opción “Publicar ontología como API REST” y la ontología deseada. Es conveniente desactivar el número máximo de peticiones por minuto para asegurarnos de que no perdemos información. Por último, seleccionamos la operación “POST” y creamos nuestra API.

     API
    Pantalla de creación de API

     La URL que aparece en el campo “EndPoint base” es la que se debe insertar en Node-RED.

  • Script de reglas

    Una vez comprobado que los datos enviados directamente desde el dispositivo se insertan de forma correcta en la ontología deseada, debemos crear un Script para tratarlos, extraer toda la información posible y dotarlos del formato correspondiente. Para ello simplemente entramos en Reglas->Wizard creación de reglas y seleccionamos la opción “Generar regla script ontología”. Con este tipo de reglas, cada vez que el dispositivo envíe nuevos datos a la ontología se ejecutará este script en el que se tratarán los datos para luego insertarlos en la ontología final.

  • Representación de resultados

    Utilizando las herramientas de visualización de Sofia2 podemos representar de manera rápida y sencilla los datos que estamos almacenando.  Para ello entramos en visualización ->Mis Gadgets-> Crear gadgets, desde donde podemos seleccionar el tipo de herramienta que más nos conviene en función de los datos. Atendiendo a los datos que se obtienen del tester de Lora, dos tipos de visualizaciones interesantes podrían ser la representación de coordenadas en un mapa y los valores de la relación señal a ruido (SNR) a lo largo del tiempo.

    Mapa
    Representación de coordenadas en un mapa

    SNR
    Representación del parámetro SNR
Integración de Lora con Sofia2

Generación Código Cliente en TEst&Doc APIS

54

Esta nueva utilidad consiste en un editor de código cliente para las APIs de las Ontologías en los principales lenguajes de programación, de esta forma solo tendremos que copiar el código que genera e insertarlo en nuestras aplicaciones.

 

Para ello debemos acceder a la API de la Ontología que queremos invocar. En este ejemplo será “AparcamientoPublicosMadrides”. Así que accederemos al menú de “API MANAGER”, y al submenú “APIs”:Image 003

Una vez aquí, vamos a la pestaña de “Mis Suscripciones”:Image 006

Y elegimos la API que queremos probar. Y clickamos sobre el botón “Test & Doc”:Image 009

Aquí tenemos información de la API y de las funciones que expone para su consumo. Nosotros vamos a elegir la función “getAll”:Image 012

A continuación se nos muestra la información referente a dicha función, y en la parte derecha aparecerá un menú desplegable llamado “Invocación al API”, en el elegiremos el lenguaje que queremos usar para invocar a la función:Image 015

Y esto generará el trozo de código necesario para invocar a la función. Solo tendremos que completar dicho código usando el token del usuario con el que estamos logados en la parte del “x-sofia2-apikey”:Image 018

He creado una pagina de ejemplo en HTML usando JQuery, para insertar el código que nos genera para el método del API,  el codigo HTML utilizado para el ejemplo seria:

<code>

<!DOCTYPE html>
<html>

<head>
<meta charset=”UTF-8″>
<title>Test API</title>
http://code.jquery.com/jquery-2.2.3.min.js

$(document).ready(function() {
$(“#myButton”).click(function() {

var settings = {
“async”: true,
“crossDomain”: true,
“url”: “https://sofia2.com/sib-api/api/v1/aparcamientospublicosmadrides/getAll&#8221;,
“method”: “GET”,
“headers”: {
“x-sofia2-apikey”: “********************”
}
}

$.ajax(settings).done(function (response) {
console.log(response);
var num = response.data.length;
$(“#apiTestDiv”).html(“Request URL: https://sofia2.com/sib-api/api/v1/aparcamientospublicosmadrides/getAll
Num Result: ” + num);

});

});
});

</head>

<body>
<button id=”myButton”>Test API</button>
</br>
</br>

</body>

</html>

</code>

 

resultado sería asi:

Image 028

Generación Código Cliente en TEst&Doc APIS

5 IoT trends that will define 2018

(From NetworldWorld)

The Internet of Things (IoT) wasted no time spreading across the world and connecting millions of individuals. In just a few short years, billions of sensors redefined how businesses operated and how people interacted with one another, and that was only the start; one IHS forecast predicts the IoT will grow to reach a staggering 75 billion devices by 2025.

What changes will the IoT bring even sooner, in 2018? Is the phenomenon of an interconnected world a mere fad, or will the trends of the IoT continue to define us for decades to come? These five trends highlight the stunning innovations that may lurk just around the corner, and could be a taste of the world yet to come.

More IoT devices than ever

While IHS and others are predicting massive upticks in the amount of digitally-connected devices over the next decade, it’s likely we won’t need to wait very long. BI Intelligence’s report on the IoT notes that nearly $6 trillion will be spent on IoT solutions in just the next five years, for instance, meaning the rapid proliferation of IoT gadgets has already begun.

As more consumers around the globe purchase smartphones, tablets, and other gadgets which hook them into the web, the expanse of the IoT will only grow ever-greater. Low-power, short-ranged networked devices will be increasingly pushed by companies hoping to cash in on the boom in tech, and millions of more sensors embedded in our world in just a year’s time.

The forthcoming retail shakeup

One of the largest impacts the IoT could have in 2018 is the waves of change it’s bringing to retail. Consumers and business-owners alike have profited greatly off of the increase in sensors and data driven by the IoT, as it allows businesses to better market their products to prospective customers.

Increasingly, tech-savvy companies eager to use new data are investing in sensors-based analytics, which allows them to, among other things, track which areas of their stores are the most trafficked by customers. CBInsight’s report on the IoT’s impact on retail outlines the innovative ways companies are using the IoT to better track their inventory, manage losses from theft, and reach out to customers in new and exciting ways.

Forget Amazon’s coming drone-delivery systems or increased amounts of online shoppers; the boom in embedded-sensor driven retail shopping will by itself single handedly change how customers find and buy their favorite products.

Reshaping healthcare

As more and more patients turn to big data driven healthcare solutions, the IoT also stands to reshape how people access and pay for their healthcare services. An ongoing boom in wearable tech has largely been fueled by its applications to people’s healthcare, such as wearable gadgets’ abilities to monitor your heartrate or stress levels.

As hospitals and clinics face larger amounts of patients who need care, they can turn to networked gadgets which can remind patients when to take their prescriptions, when to exercise, and alerts patients when their blood pressure levels are too high.

New network security challenges

Not all of the forthcoming trends in the IoT are positive; new network security challenges will push IT experts to their limits in 2018 as hackers and other malevolent actors seek to harness the IoT for their own nefarious purposes. One cyberattack in October of 2016 already crippled large swaths of the internet after hackers effectively exploited the IoT to power their attack.

As industrial IoT continues to grow at an explosive rate, vulnerabilities in global internet-infrastructure systems will only grow worse. As more devices become connected to one another, security experts and major businesses will need to move quickly to patch holes in their defenses as malware jumps from one networked device to another.

Greater access to capital

These staggering leaps forward in tech aren’t occurring in vacuum; investors are taking notice of the IoT more so now than ever before, and are ponying up the funds needed for the IoT’s expansion. In 2018, IoT-based ventures will have greater access to startup capital and be taken more seriously in the market.

About 19% of business respondents to one Forrester survey reported using the IoT already, but a staggering 28% also reported that they planned to adopt IoT usage in their business operations in the near future. The utilities, transportation, manufacturing and mining industries are all perched to invest and benefit heavily in the IoT in coming years.

It’s never easy to accurately predict the future, and the true capabilities of the Internet of Things may not yet be realized. As consumers and corporations alike embrace the IoT’s world-changing impact on global commerce and lifestyle, however, it’s hard to imagine the IoT doing anything but growing to new and greater heights in 2018.

5 IoT trends that will define 2018

The Top 8 IoT Trends For 2018

(From Forbes)

A recent study shows about 2/3 of companies are currently utilizing IoT

An IHS survey estimates that there are 20 billion connected devices globally as of this year. Will 2018 be “The Year of IoT”? Not exactly, but the future looks promising and 2018 will show a promising trajectory.

Despite the huge gains in connectivity, the truth is 2018 will be more of a steady (rather than explosive) growth period for the IoT, full of fits and spasms, and everything that goes along with them. It will see lots of investment—lots of growth—and widespread adoption in a few major industries. But it will also see some growing pains—“fragmentation frustration,” potential data breaches, and security issues galore.

Futurum Research

So, will 2018 be an exciting year? Yes—ish. The truth is, we’re right smack in the midst of a revolution—no matter how imperfect it may initially seem. If that isn’t exciting, I don’t know what is. The following are the top eight trends we’ll see in the coming year:

1. The IoT Will Grow: In what might be the most obvious prediction of the decade, the IoT will continue to expand next year, with more and more devices coming online every single day. What isn’t so obvious about this prediction: where that growth will occur. The retail, healthcare, and industrial/supply chain industries will likely see the greatest growth. Forrester Research has predicted the IoT will become “the backbone” of customer value as it continues to grow. It is no surprise that retail is jumping aboard, hoping to harness the power of the IoT to connect with customers, grow their brands, and improve the customer journey in deeply personal ways. But industries like healthcare and supply are not far behind. They’re using the technology to connect with patients via wearable devices, and track products from factory to floor. In many ways, the full potential of the IoT is still being realized; we’ll likely see more of that in 2018.

2. It Will Also Become More Fragmented: Just as the IoT continues to grow, it will also become increasingly fragmented. As we’ve seen with the growth of as-a-Service (aaS) programs and cloud solutions, that fragmentation will create some hurdles for many companies, as they deal with compatibility issues throughout their industries. Though companies like Qualcomm are leading the push for IoT device standards and certifications, in many ways, the genie has already left the bottle. It’s now a matter of wrangling her back into place if we want to put those standards in place.

3. Which Leads to Greater Security Concerns: I’ve said it before, but fragmentation leads to system compromise. Almost every time. The more complex, the more network security challenges. Indeed, securing all these connected devices in an environment with minimal regulation will be difficult. Finding a solution to keep data safe will be a main goal in the coming year.

4. Mobile Platforms Will Make More Sense: The trend from mobile-first to mobile-only will likely continue to grow, as mobile platforms will become the de facto management system for IoT devices. Again, this isn’t shocking—but it isn’t finished yet, either. The development of the IoT is one that will happen over time as early adopters begin to refine, and late-comers jump into the mix. The coming year will continue to see many transition into mobile platform development.

5. And Marketing Efforts Will Continue: Again—perhaps a little obvious. But this coming year will be ripe with dings, bells, and whistles as customers are alerted to bargains, incentives, and other news regarding their homes and offices. An increasing number of companies will begin to use the IoT for these more personalized marketing efforts. They’ll also get closer to finding the “how much is too much” balance when it comes to marketing.

6. Companies Will be Pushed to the Edge with Data: Because of the huge influx of data being created through the IoT, it makes sense that companies will need to find a better, closer, cheaper way to process it. That’s why edge networking will be less of a trend and more of a necessity, as companies seek to cut costs and reduce network usage. Today we are seeing companies like Cisco, HPE and Dell leading the migration of compute infrastructure to the edge. Legacy industrial IoT firms like GE and ABB are also continuing to develop hardened infrastructure to handle challenging environments that are less ideal to hosting compute than traditional data centers.

7. And Need Advanced Analytics and Machines to Help Manage It: Just as the increase in data will push companies to “the edge,” it will also push them toward artificial intelligence (AI) and machine learning. Indeed, AI will also become a necessity, as the amount of data created by the IoT will simply be too large for humans to manage. These more advanced technologies will need to find their way to support the rapidly growing IoT space soon, however, in the meantime, we will see a strong growth in analytics software and tools to provide real-time data streaming for IoT devices. Analytics companies like Software Advice, SAS, SAP, and Teradata are a few of the players making noise in this arena. I also expect a series of new entrants in the IoT analytics, machine learning and AI space as this data deluge is going to require sophisticated tools to manage and extract the most valuable insights.

8. But There will be Lots of Money to be Had: Business Insider predicts business spending on IoT solutions will hit $6 trillion by 2021. It makes sense, then, that venture capitalists will continue to poor funds into the promise of IoT—underscoring its potential to improve customer experience in almost every industry.

Like I said—this won’t be a silver bullet year for the IoT. It rarely is for any new technology. But some major inroads will be created that should help build a larger and more solid foundation for the technology in the next five years. After that—it’s anyone’s guess; we may be talking about a whole new technology altogether.

The Top 8 IoT Trends For 2018