Pular para o conteúdo principal

Introdução

O protocolo SynapseLink é um protocolo de chamada de procedimento remoto (RPC) desenvolvido para o Ecossistema EvoluxIoT. Este permite a comunicação bidirecional entre o Ecossistema EvoluxIoT e os Dispositivos Synapse através de qualquer protocolo de transporte de dados como por exemplo MQTT, e a sua comunicação é feita através de comandos.

Como funciona?

Estrutura de um comando

Um comando permite a comunicação entre o Ecossistema EvoluxIoT e os Dispositivos Synapse. Este executa uma ação no Dispositivo Synapse e devolve o resultado da execução da mesma.

A estrutura de um comando enviada entre o ecossistema e os dispositivos é a seguinte:


Sintaxe do Comando

  • NOME DO COMANDO:,:PARAMETRO 1:,:PARAMETRO 2:,: (...) :,:ID DO EVENTO
  • !VALOR DECIMAL DO COMANDO:,:PARAMETRO 1:,:PARAMETRO 2:,: (...) :,:ID DO EVENTO

Command Parameters

  • !: Indica que o comando foi enviado pelo Dispositivo Synapse para o Ecossistema EvoluxIoT. (não é usado quando o comando é enviado pelo ecossistema para o dispositivo Synapse)
  • NOME/VALOR DECIMAL DO COMANDO: Valor ou nome do comando a ser executado no Dispositivo Synapse.
  • PARAMETRO: OS parâmetros do comando a ser executado no Dispositivo Synapse. (separados por :,: e o número de parâmetros depende do comando a ser executado)
  • ID DO EVENTO: ID do evento indicando o último evento recebido (incrementa sempre que um comando é enviado por um dos lados)

Practical example

  1. The EvoluxIoT Ecosystem sends a command to the Synapse Device.

    For example a user wants to display a message on the display of the Synapse Device and in the Ecossystem Portal the user enters the text and presses show.

    The ecossystem receives the instruction from the user and builds a equivalent command to be sent to the Synapse Device:

    • DISPLAYWRITE is the command to be executed
    • Hello World is the paramenter of DISPLAYWRITE which contains the text to be displayed
    • 0 is the event id, assuming that this is the first communication between the Ecosystem and the Synapse Device.

    Ecosystem Portal outputs DISPLAYWRITE:,:Hello World:,:0 to Synapse Device

  2. The Synapse Device receives the command and sends a acknowledge back to the EvoluxIoT Ecosystem.

    When the Synapse Device receives a command, the Ecosystem Portal expects a acknowledge back from the Synapse Device to ensure that the command was received successfully and it's being executed on the Synapse Device:

    • ! is always included when it's the Synapse Device communicating with the Ecosystem Portal
    • 2 is the command acknowledge represented in decimal format (0x02 in hexadecimal format)
    • The following parameters are the same as the command sent by the Ecosystem Portal except the event id received
    • 1 is the event id, incremented by one since one message was sent from the Ecosystem Portal to the Synapse Device before.

    Synapse Device outputs !2:,:DISPLAYWRITE:,:Hello World:,:1 to Ecosystem Portal

    Ecosystem Portal knows that the command was received successfully, it's being executed on the Synapse Device and gets ready for receving the command status response.

  3. The Synapse Device executes the command and sends the result back to the EvoluxIoT Ecosystem.

Commands Available

Code Hex/DecCommand NameCommand Description
0x00/0MAXVERSIONReturns the maximum version of the SynapseLink Protocol supported by the Synapse Device
0x01/1HEARTBEATChecks if the Synapse Device is online and responsive to requests
0x02/2ACKNOWLEDGEReturns the acknowledge of the command sent by the Ecosystem Portal
0x03/3REBOOTReboots the Synapse Device
0x04/4DIGITALREADReads the value of a digital pin
0x05/5DIGITALWRITEWrites a value to a digital pin
0x06/6ANALOGREADReads the value of a analog pin
0x07/7ANALOGWRITEWrites a value to a analog pin
0x08/8PWMREADReads the value of a pwm pin
0x09/9PWMWRITEWrites a value to a pwm pin
0x0A/10DISPLAYWRITEWrites a text to the display of the Synapse Device