Introdução
O que é o protocolo SynapseLink?
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 EVENTOCommand 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
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:
DISPLAYWRITEis the command to be executedHello Worldis the paramenter of DISPLAYWRITE which contains the text to be displayed0is the event id, assuming that this is the first communication between the Ecosystem and the Synapse Device.
Ecosystem Portal outputs
DISPLAYWRITE:,:Hello World:,:0to Synapse DeviceThe 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 Portal2is 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
1is 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:,:1to Ecosystem PortalEcosystem 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.
The Synapse Device executes the command and sends the result back to the EvoluxIoT Ecosystem.
Commands Available
| Code Hex/Dec | Command Name | Command Description |
|---|---|---|
| 0x00/0 | MAXVERSION | Returns the maximum version of the SynapseLink Protocol supported by the Synapse Device |
| 0x01/1 | HEARTBEAT | Checks if the Synapse Device is online and responsive to requests |
| 0x02/2 | ACKNOWLEDGE | Returns the acknowledge of the command sent by the Ecosystem Portal |
| 0x03/3 | REBOOT | Reboots the Synapse Device |
| 0x04/4 | DIGITALREAD | Reads the value of a digital pin |
| 0x05/5 | DIGITALWRITE | Writes a value to a digital pin |
| 0x06/6 | ANALOGREAD | Reads the value of a analog pin |
| 0x07/7 | ANALOGWRITE | Writes a value to a analog pin |
| 0x08/8 | PWMREAD | Reads the value of a pwm pin |
| 0x09/9 | PWMWRITE | Writes a value to a pwm pin |
| 0x0A/10 | DISPLAYWRITE | Writes a text to the display of the Synapse Device |