1
0
mirror of https://github.com/arduino/Arduino.git synced 2025-02-20 14:54:31 +01:00

PluggableDiscovery: added a 'port' field in json messages

The new format of 'add' and 'remove' actions is changed from:

{
  "eventType": "add",
  "address": "/dev/ttyACM0",
  "label": "/dev/ttyACM0",
  "prefs": {
    "vendorId": "0x2341"
    "productId": "0x0043",
    "serialNumber": "85235353137351018160",
  },
  "identificationPrefs": {
    "vid": "0x2341"
    "pid": "0x0043",
  },
  "protocol": "serial",
  "protocolLabel": "Serial Port"
}

to:

{
  "eventType": "add",
  "port": {
    "address": "/dev/ttyACM0",
    "label": "/dev/ttyACM0",
    "prefs": {
      "vendorId": "0x2341"
      "productId": "0x0043",
      "serialNumber": "85235353137351018160",
    },
    "identificationPrefs": {
      "vid": "0x2341"
      "pid": "0x0043",
    },
    "protocol": "serial",
    "protocolLabel": "Serial Port"
  }
}
This commit is contained in:
Cristian Maglie 2018-11-30 11:19:07 +01:00
parent 7186213034
commit 8e9f0cfd76

View File

@ -156,7 +156,7 @@ public class PluggableDiscovery implements Discovery {
case "add":
try {
BoardPort port = mapper.treeToValue(node, BoardPort.class);
BoardPort port = mapper.treeToValue(node.get("port"), BoardPort.class);
port.searchMatchingBoard();
addOrUpdate(port);
} catch (JsonProcessingException e) {
@ -167,7 +167,7 @@ public class PluggableDiscovery implements Discovery {
case "remove":
try {
BoardPort port = mapper.treeToValue(node, BoardPort.class);
BoardPort port = mapper.treeToValue(node.get("port"), BoardPort.class);
remove(port);
} catch (JsonProcessingException e) {
System.err.println(format("{0}: Invalid BoardPort message", discoveryName));