Skip to content

Commit c14e248

Browse files
committed
Added 'hardwareId' support to pluggable discovery
1 parent 6bf2c23 commit c14e248

File tree

4 files changed

+40
-12
lines changed

4 files changed

+40
-12
lines changed

Diff for: arduino/discovery/discovery.go

+2
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ type Port struct {
9191
AddressLabel string `json:"label"`
9292
Protocol string `json:"protocol"`
9393
ProtocolLabel string `json:"protocolLabel"`
94+
HardwareID string `json:"hardwareId,omitempty"`
9495
Properties *properties.Map `json:"properties"`
9596
}
9697

@@ -107,6 +108,7 @@ func (p *Port) ToRPC() *rpc.Port {
107108
Label: p.AddressLabel,
108109
Protocol: p.Protocol,
109110
ProtocolLabel: p.ProtocolLabel,
111+
HardwareId: p.HardwareID,
110112
Properties: props.AsMap(),
111113
}
112114
}

Diff for: docs/pluggable-discovery-specification.md

+14-1
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ call. The format of the response is the following:
127127
"label": <-- HOW THE PORT IS DISPLAYED ON THE GUI
128128
"protocol": <-- THE PROTOCOL USED BY THE BOARD
129129
"protocolLabel": <-- HOW THE PROTOCOL IS DISPLAYED ON THE GUI
130+
"hardwareId": <-- A STRING THAT UNIQUELY IDENTIFIES A BOARD SAMPLE
130131
"properties": {
131132
<-- A LIST OF PROPERTIES OF THE PORT
132133
}
@@ -147,7 +148,15 @@ Each port has:
147148
`SSH on 192.168.10.100`)
148149
- `protocol` is the protocol identifier (such as `serial` or `dfu` or `ssh`)
149150
- `protocolLabel` is the `protocol` in human readable form (for example `Serial port` or `DFU USB` or `Network (ssh)`)
150-
- `properties` is a list of key/value pairs that represent information relative to the specific port
151+
- `hardwareId` (optional) a string that uniquely identify a specific board sample (even among other boards of the same
152+
model). Different ports with the same `hardwareId` must belong to the same board sample. The identifier should be
153+
sufficiently long to uniquely identify the board sample and reduce the probability of collisions. Good examples of
154+
`hardwareId` values are: Ethernet MAC Address, USB Serial Number, CPU-ID number, etc.
155+
156+
This value **should not** be used to identify the board **model** (see the
157+
[board identification](#board-identification) section for more information about identification of the board model).
158+
159+
- `properties` is a list of key/value pairs that represent information relative to the specific port.
151160

152161
To make the above more clear let's show an example output from the `serial-discovery` builtin in the Arduino CLI:
153162

@@ -160,6 +169,7 @@ To make the above more clear let's show an example output from the `serial-disco
160169
"label": "ttyACM0",
161170
"protocol": "serial",
162171
"protocolLabel": "Serial Port (USB)",
172+
"hardwareId": "EBEABFD6514D32364E202020FF10181E",
163173
"properties": {
164174
"pid": "0x804e",
165175
"vid": "0x2341",
@@ -175,6 +185,8 @@ In this case the serial port metadata comes from a USB serial converter. Inside
175185
properties of the port, and some of them may be useful for product identification (in this case only USB VID/PID is
176186
useful to identify the board model).
177187

188+
The `hardwareId` field is populated with the USB `serialNumber` since this value is useful to identify the board sample.
189+
178190
The `LIST` command performs a one-shot polling of the ports. The discovery should answer as soon as reasonably possible,
179191
without any additional delay.
180192

@@ -231,6 +243,7 @@ The `add` event looks like the following:
231243
"port": {
232244
"address": "/dev/ttyACM0",
233245
"label": "ttyACM0",
246+
"hardwareId": "EBEABFD6514D32364E202020FF10181E",
234247
"properties": {
235248
"pid": "0x804e",
236249
"vid": "0x2341",

Diff for: rpc/cc/arduino/cli/commands/v1/port.pb.go

+22-11
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: rpc/cc/arduino/cli/commands/v1/port.proto

+2
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,6 @@ message Port {
3131
string protocol_label = 4;
3232
// A set of properties of the port
3333
map<string, string> properties = 5;
34+
// The hardware ID (serial number) of the board attached to the port
35+
string hardware_id = 6;
3436
}

0 commit comments

Comments
 (0)