You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: RFCs/0002-pluggable-discovery.md
+75-4
Original file line number
Diff line number
Diff line change
@@ -48,9 +48,11 @@ All the commands listed in this specification must be implemented in the discove
48
48
49
49
After startup, the tool will just stay idle waiting for commands. The available commands are: `HELLO`, `START`, `STOP`, `QUIT`, `LIST` and `START_SYNC`.
50
50
51
+
The discovery must not introduce any delay in the protocol and must respond to all commands as fast as possible.
52
+
51
53
#### HELLO command
52
54
53
-
`HELLO`is the **first command that must be sent** to the discovery to tell the name of the client/IDE and the version of the pluggable discovery protocol that the client/IDE supports.
55
+
`HELLO`**must be the first command sent** to the discovery to tell the name of the client/IDE and the version of the pluggable discovery protocol that the client/IDE supports.
54
56
The syntax of the command is:
55
57
56
58
`HELLO <PROTOCOL_VERSION> "<USER_AGENT>"`
@@ -92,6 +94,18 @@ The `START` command initializes and start the discovery internal subroutines. Th
92
94
}
93
95
```
94
96
97
+
If the discovery could not start, for any reason, it must report the error with:
98
+
99
+
```JSON
100
+
{
101
+
"eventType": "start",
102
+
"error": true,
103
+
"message": "Permission error"
104
+
}
105
+
```
106
+
107
+
The `error` field must be set to `true` and the `message` field should contain a description of the error.
108
+
95
109
#### STOP command
96
110
97
111
The `STOP` command stops the discovery internal subroutines and possibly free the internally used resources. This command should be called if the client wants to pause the discovery for a while. The response to the command is:
@@ -103,6 +117,18 @@ The `STOP` command stops the discovery internal subroutines and possibly free th
103
117
}
104
118
```
105
119
120
+
If an error occurs:
121
+
122
+
```JSON
123
+
{
124
+
"eventType": "stop",
125
+
"error": true,
126
+
"message": "Resource busy"
127
+
}
128
+
```
129
+
130
+
The `error` field must be set to `true` and the `message` field should contain a description of the error.
131
+
106
132
#### QUIT command
107
133
108
134
The `QUIT` command terminates the discovery. The response to `QUIT` is:
@@ -114,7 +140,7 @@ The `QUIT` command terminates the discovery. The response to `QUIT` is:
114
140
}
115
141
```
116
142
117
-
after this output the discovery exits.
143
+
after this output the discovery exits. This command is supposed to always succeed.
118
144
119
145
#### LIST command
120
146
@@ -181,11 +207,42 @@ The `LIST` command performs a one-shot polling of the ports. The discovery shoul
181
207
182
208
Some discoveries may require some time to discover a new port (for example network protocols like MDNS, Bluetooth, etc. requires some seconds to receive the broadcasts from all available clients) in that case is fine to answer with an empty or incomplete list.
183
209
210
+
If an error occurs and the discovery can't complete the enumeration is must report the error with:
211
+
212
+
```JSON
213
+
{
214
+
"eventType": "list",
215
+
"error": true,
216
+
"message": "Resource busy"
217
+
}
218
+
```
219
+
220
+
The `error` field must be set to `true` and the `message` field should contain a description of the error.
221
+
184
222
#### START_SYNC command
185
223
186
-
The `START_SYNC` command puts the tool in "events" mode: the discovery will send `add` and `remove` events each time a new port is detected or removed respectively.
224
+
The `START_SYNC` command puts the tool in "events" mode: the discovery will send `add` and `remove` events each time a new port is detected or removed respectively. If the discovery goes into "events" mode successfully the response to this command is:
225
+
226
+
```JSON
227
+
{
228
+
"eventType": "start_sync",
229
+
"message": "OK"
230
+
}
231
+
```
187
232
188
-
If the CLI is used in command-line mode (`arduino-cli board list` command) then we need a one-shot output and we can run the discoveries with the `LIST` command instead. Note that some discoveries may not be able to `LIST` ports immediately after the launch (in particular network protocols like MDNS, Bluetooth, etc. requires some seconds to receive the broadcasts from all available clients).
233
+
After this message the discoery will send `add` and `remove` event asyncronoushly (more on that later). If an error occurs and the discovery can't go in "events" mode the error must be reported as:
234
+
235
+
```JSON
236
+
{
237
+
"eventType": "start_sync",
238
+
"error": true,
239
+
"message": "Resource busy"
240
+
}
241
+
```
242
+
243
+
The `error` field must be set to `true` and the `message` field should contain a description of the error.
244
+
245
+
If the CLI is used in command-line mode (for example the `arduino-cli board list` command) then we need a one-shot output and we can run the discoveries with the `LIST` command instead of using `START_SYNC`. Note that some discoveries may not be able to `LIST` ports immediately after the launch (in particular network protocols like MDNS, Bluetooth, etc. requires some seconds to receive the broadcasts from all available clients).
189
246
190
247
If the CLI is running in daemon mode, ideally, all the installed discoveries should be started simultaneously in “event mode” (with `START_SYNC`) and the list of available ports should be cached inside the CLI daemon.
191
248
@@ -227,6 +284,20 @@ The content is straightforward, in this case only the `address` and `protocol` f
227
284
228
285
If the information about a port needs to be updated the discovery may send a new `add` message for the same port address and protocol without sending a `remove` first: this means that all the previous information about the port must be discarded and replaced with the new one.
229
286
287
+
#### Invalid commands
288
+
289
+
If the client sends an invalid or malformed command, the discovery should answer with:
0 commit comments