-
Notifications
You must be signed in to change notification settings - Fork 1
/
tpi.txt
180 lines (161 loc) · 7.21 KB
/
tpi.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
TPI - Thing Protocol for Internet
==================================
Introdução:
---------------
*** V-0.1
O TPI ou Internet Protocol for Things é um protocolo de comunicação criado
pelo grupo de desenvolvimento WiserUFBA setor TatuDev, setor tal que tem por
objetivo a pesquisa e o desenvolvimento de hardware e software para embarcados.
O TPI nasceu com a necessidade a padronização da comunicação entre dispositivos
e serviços e por tal razão foi criado para ter o melhor desempenho tanto nos
serviços como nas coisas, para tal o TPI trabalha com uma aplicação rodando na
porta 171 e transmitindo pequenas mensagens as quais podem ser autenticadas através
de um processo próprio de autenticação também desenvolvido por nós.
O TPI é uma das diretivas utilizadas na criação do ecossistema TATU
(Thing Accessibility Through Utilities) para o dispositivo de codinome UFBAINO.
*** V-0.2
- Agora todos as funções tem retorno mesmo que este não seja usado
- Status foi renomeado para STATE em todas as funções.
- <var> Deve ser um número de um digito entre 0 e 7 (TEMPORARIO)
-
-
*** V-0.3
Ele está sendo implementado através de um driver que utiliza um MQTT Broker para enviar uma função
a um dispositivo. A resposta do dispositivo será um POST, que é uma string JSON que o driver será capaz
de interpretar e pegar a informação correta se necessário.(https://github.com/WiserUFBA/DriverMQTT)
- Adicionado a propriedade VALUE para numeiros inteiros
- STATE passa a só ser usado para valores booleanos
- INFO passa a ser usado em GET, SET e EDIT
Funções:
---------------
> GET
: Funcionamento
Requisição de informações de outra fonte ou controlador
: Propriedades
- ALL: Retorna todas as informações presentes no controlador
Sem variaveis.
- INFO: Retorna uma informação do tipo string especificada por parametro como uma propriedade
<var>*
- VALUE: Retorna uma informação do tipo inteiro especificada por parametro como uma propriedade
<var>
- STATE: Retorna uma informação do tipo booleano especificada por parametro como uma propriedade
<var>
: Estrutura
=======================
GET <propriedade> <var>
=======================
> SET
: Funcionamento
Modifica uma informação em outro dispositivo
: Propriedades
- INFO: Modifica uma string
<var1> <valor1>** ...
- VALUE: Modifica o valor de uma variável inteira
<var1> <valor1> ...
- STATE: Modifica o estado de uma variável booleana
<var1> <valor1> ...
: Estrutura
=====================================================
SET <propriedade> <var1> <valor1> <var2> <valor2> ...
=====================================================
> POST
: Funcionamento
Retorno de uma requisição
O retorno de uma requisição é composto por um objeto JSON
: Estilo
O post é formado por dois objetos o HEADER e o BODY
O HEADER representa o cabeçalho da requisiçao e nele estarão contidas todas as propriedades
do dispositivo o qual está enviando as informações
O BODY em caso da propriedade GET representa todas as variaveis ou informações que foram requisitadas
caso contrário o valor é nulo(null)
- HEADER
<propriedade1>: <valor1>, ...
- BODY
<type1>: {<var1>: <valor1>, ...}, ...
: Estrutura
=====================================================================================================
POST <device>[<opt>]:{HEADER: { <propriedade1>: <valor1>, ...}, BODY:{<type1>:{<var1>:..., ...}, ...}
=====================================================================================================
* <device> é o nome do dispositivo
** [<opt>] é opcional e pode ser removido caso não venha a ser utilizado
:V-0.3 Header estrucure
HEADER:{"NAME":<string>,"ID":<inteiro>,"PAN":<inteiro>,"IP":<string>}
> EDIT
: Funcionamento
Modifica propriedades internas a um controlador
: Propriedades
- INFO: Modifica uma string
<var1> <valor1> ...
- VALUE: Modifica um inteiro
<var1> <valor1> ...
- STATUS: Modifica um valor booleano
<var1> <valor1> ...
- RETORNO: Indica a necessidade do retorno
: Estrutura
=================================================================
EDIT <propriedade> <retorno?> <var1> <valor1> <var2> <valor2> ...
=================================================================
// Teorico até a versão 0.3 deve ser implementado em versões futuras
> CRYPTO
: Funcionamento
Indica a criptografia de uma informação e a necessidade da descriptografia
: Propriedade
- REQUIRE - Prepara o sistema para o envio de um pacote criptografado
- DECRYPT - Indica que a mensagem precisa ser descriptografada
: Estrutura
========================================
CRYPTO <propriedade> <encrypted_message>
========================================
// Teorico até a versão 0.3 deve ser implementado em versões futuras
> TCHK
: Funcionamento
TATU CHECK - Informa que o cabeçalho do arquivo está correto e a mensagen pode
ser descriptografada com segurança. Estes quatro caracteres tem que ser o começo de qualquer
pacote criptografado as quatro letras tem que estar em MAIUSCULO e na ordem apresentada abaixo
se o pacote não apresentar tal informação o pacote será considerado inválido e descartado
: Estrutura
====================
TCHK <short_message>
====================
* <var> Deve ser uma string em caso de um atributo do dispositivo
E um número em caso de um pino
Exemplo:
"SET STATE LAMP T" modifica o valor booleana dessa variável
"SET STATE 1 T" modifica o valor booleano desse pino
** <valor> O formato do valor varia dependendo da propriedade e da função
GET, SET e EDIT:
INFO
string
VALUE
inteiro
STATE
F - false
T - true
POST:
string ou inteiro dependendo do tipo da informação
obs: strings ficam entre double quote ("")
Short and Full TPI
-------------------
!!! WARNING !!!
// É importante que a versão SHORT seja usada apenas em pacotes criptografados!
// Deve ser evitado o uso da notação SHORT nas versões 0.1, 0.2 e 0.3
Há duas formas de se criar pacotes TPI e são Short e Full. Eles são bem parecidos mas
tem uma diferença marcanta que é quantidade de caracteres por comando, enquanto que
no Full as mensagens são escritas de forma completa no Short a única coisa que interessa
é o primeiro caractere e isso é algo importante no TPI já que como o foco dele é dispositivos
com recursos limitados não se faz questão de armazenar a string inteira e sim só um caractere.
: Exemplo
== Full ===
GET INFO P1
===========
== Short ==
G I P1
===========
Observando o exemplo também fica claro que comparar a string não é o foco do TPI e por isso
é necessário que a parte importante da string (os primeiros caracteres) e a informação que se
passa por parametro estejam em corretas, caso contrário a informação não será lida.
Obs.: Toda requisição acaba com um '\n'
Obs.: Todo comando é escrito com letras maiusculas
**** Developed By The TatuDevGroup ****
**** From Wiser Corporation - UFBA ****
**** Project Smart UFBA ****