@@ -9,11 +9,11 @@ The IOT_PROTOCOL (*iot://*) request minimum size is 8 bytes withless to require
9
9
## Preamble Version 1
10
10
11
11
``` js
12
- VERSION \n
13
- METHOD + ID \n
14
- PATH \n
15
- [HEADERS \n]
16
- [B \n BODY ]
12
+ VERSION \n
13
+ METHOD + ID \n
14
+ PATH \n
15
+ [HEADERS \n]
16
+ [BODY_CHAR + BODY_LENGTH \n BODY ]
17
17
```
18
18
19
19
### SEPARATOR char
@@ -26,64 +26,136 @@ SEPARATOR char serves to divide pieces of information
26
26
* char: ` \n `
27
27
* hex: ` 0xA `
28
28
* decimal: ` 10 `
29
+ * binary: ` 0b1010 `
29
30
30
31
### [ 0] VERSION
31
32
32
33
Version is the version of iot protocol. Used for compatibility.
33
34
34
- * Type: ` byte ` | ` uint8_t ` . ** REQUIRED**
35
+ Format: ` VERSION + SEPARATOR ` . ** REQUIRED** | ** SINGLE**
36
+
37
+ * Type: ` byte ` | ` uint8_t `
35
38
* Size: 1 byte
36
- * Example: ` 1 `
39
+ * Example:
40
+ * decimal: ` 1 `
41
+ * hex: ` 0x1 `
42
+ * binary: ` 0b00000001 `
37
43
38
44
### [ 1] METHOD+ID
39
45
40
46
Method ID identifies the method of request and its id.
41
47
42
- Methods:
48
+ Format: ` METHOD + ID + SEPARATOR ` . ** REQUIRED** | ** SINGLE**
49
+
50
+ ** METHOD** :
43
51
44
- * Type: ` char ` . ** REQUIRED**
52
+ Method is the reason why the request is made. ** REQUIRED**
53
+
54
+ * Type: ` char ` .
45
55
* Size: 1 byte
46
56
* Example: ` R `
47
57
48
- - ` S ` | ` 0x83 ` : * Signal* method used to send signals like events
49
- - ` R ` | ` 0x82 ` : * Request* method used to do calls needs a response
50
- - ` r ` | ` 0x114 ` : * Response* method used to responds a request
58
+ * Methods types:
59
+ - * Signal* : method used to send signals like events
60
+ * char: ` S `
61
+ * decimal: ` 131 `
62
+ * hex: ` 0x83 `
63
+ * binary: ` 0b10000011 `
64
+
65
+ - * Request* : method used to do calls that needs a response
66
+ * char: ` R `
67
+ * decimal: ` 130 `
68
+ * hex: ` 0x82 `
69
+ * binary: ` 0b10000010 `
51
70
71
+ - * Response* : method used to responds a request
72
+ * char: ` r `
73
+ * decimal: ` 114 `
74
+ * hex: ` 0x72 `
75
+ * binary: ` 0b1110010 `
52
76
53
- ID :
77
+ ** ID ** :
54
78
55
- Unsigned random number with up to 2^16 that identifies the request.
79
+ Unsigned random number with up to 2^16 that identifies the request. ** REQUIRED **
56
80
57
- * Type: ` uint16_t ` as Big Endian format. ** REQUIRED **
81
+ * Type: ` uint16_t ` as Big Endian format.
58
82
* Size: 2 bytes
59
- * Example: ` 1822 `
83
+ * Example:
84
+ * decimal: ` 276 `
85
+ * uint_8[ 2] : ` [ 1 , 20 ] `
86
+ * binary: ` 0b00000001 00010100 `
60
87
61
88
### [ 2] PATH
62
89
63
90
The path component contains data, usually organized in hierarchical
64
- form, that, serves to identify a resource [ URI > 3.3 Path] ( https://www.rfc-editor.org/info/rfc3986 ) .
91
+ form, that, serves to identify a resource [ URI > 3.3 Path] ( https://www.rfc-editor.org/info/rfc3986 ) .
92
+
93
+ Format: ` PATH + SEPARATOR ` . ** REQUIRED** | ** SINGLE**
65
94
66
- * Type: ` string ` . ** REQUIRED **
95
+ * Type: ` string `
67
96
* Example: ` /foo/bar `
68
97
* Default: ` / `
69
98
70
99
### [ 3] HEADERS
71
100
72
- Key Value Pair joined by ` : ` char, that, serves to set an attribute value for the request. Multiple headers must be separate by SEPARATOR char (` \n ` ).
101
+ Headers are be Key Value Pair that serves to set an attribute value for the request. Case sensitive.
102
+
103
+ Format: ` HEADER + SEPARATOR ` . ** OPTIONAL** | ** MULTIPLE**
104
+
105
+ ** HEADER**
73
106
74
- * Type: ` Map<string, string> ` . ** OPTIONAL**
107
+ * Type: ` string `
108
+ * Format: ` KEY + KEY_VALUE_SEPARATOR + VALUE `
109
+ * * KEY* :
110
+ * Type: ` string `
111
+ * * VALUE* :
112
+ * Type: ` string `
113
+ * * KEY_VALUE_SEPARATOR* :
114
+ * Constant:
115
+ * char: ` : `
116
+ * decimal: ` 58 `
117
+ * hex: ` 0x3a `
118
+ * binary: ` 0b00111010 `
75
119
* Example:
76
120
* Single header: ` foo:bar\n `
77
121
* Multiple headers: ` foo:bar\nlorem:ipsum\n `
78
122
79
123
### [ 4] BODY
80
124
81
- The final data to be sent for request receiver. Starts with ` B\n ` .
125
+ The final data to be sent for request receiver.
126
+
127
+ Format: ` BODY_CHAR + BODY_LENGTH+SEPARATOR + BODY ` . ** OPTIONAL** | ** SINGLE**
128
+
129
+ ** BODY_CHAR** :
130
+
131
+ Identifies the body part. ** REQUIRED**
132
+
133
+ * Type: ` char `
134
+ * Size: 1 byte
135
+ * Constant:
136
+ * char: ` B `
137
+ * hex: ` 0x42 `
138
+ * decimal: ` 66 `
139
+
140
+ ** BODY_LENGTH** :
141
+
142
+ The body's length. ** REQUIRED**
143
+
144
+ * Type: ` uint16_t ` as Big Endian format
145
+ * Size: 2 bytes
146
+ * Example:
147
+ * decimal: ` 2321 `
148
+ * uint_8[ 2] : ` [ 9 , 17 ] `
149
+ * binary: ` 0b00001001 00010001 `
150
+
151
+ ** BODY** :
152
+
153
+ The body / contents of request. ** REQUIRED**
82
154
83
155
* Type: ` uint8_t[] `
84
156
* Example:
85
- * Message : ` B\nlorem ipsum message`
86
- * Buffer: ` ['B', '\n', 0x1, 0x2, 0x3, 0x4 ] `
157
+ * String : ` the message`
158
+ * Buffer: ` [ 116, 104, 101, 32, 109, 101, 115, 115, 97, 103, 101 ] `
87
159
88
160
## Middlewares
89
161
0 commit comments