Skip to content

Commit f6ce0dc

Browse files
author
Akos Kitta
committed
Optional properties.
Fixed the enhanced port address. Signed-off-by: Akos Kitta <[email protected]>
1 parent 0850da6 commit f6ce0dc

File tree

3 files changed

+13
-19
lines changed

3 files changed

+13
-19
lines changed

arduino-ide-extension/src/common/protocol/boards-service.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -151,15 +151,11 @@ export interface BoardsService
151151
}
152152

153153
export interface Port {
154-
// id is the combination of address and protocol
155-
// formatted like "<address>|<protocol>" used
156-
// to uniquely recognize a port
157-
// readonly id: string;
158154
readonly address: string;
159155
readonly addressLabel: string;
160156
readonly protocol: string;
161157
readonly protocolLabel: string;
162-
readonly properties: Record<string, string>;
158+
readonly properties?: Record<string, string>;
163159
}
164160
export namespace Port {
165161
export type Properties = Record<string, string>;

arduino-ide-extension/src/node/board-discovery.ts

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -393,16 +393,18 @@ const PortAddressEnhancers = [enhanceESP32_S2];
393393
function enhanceESP32_S2(detectedPort: DetectedPort): DetectedPort | undefined {
394394
if (DetectedPort.isUnrecognizedNetwork(detectedPort)) {
395395
const { properties } = detectedPort.port;
396-
const board = properties['board']; // This is just a cheap hack. See https://github.com/arduino/arduino-ide/issues/567#issuecomment-1219494389
397-
if (board) {
398-
const { boards, port } = detectedPort;
399-
return {
400-
boards,
401-
port: {
402-
...port,
403-
address: `${port.address} at ${board}`,
404-
},
405-
};
396+
if (properties) {
397+
const board = properties['board']; // This is just a cheap hack. See https://github.com/arduino/arduino-ide/issues/567#issuecomment-1219494389
398+
if (board) {
399+
const { boards, port } = detectedPort;
400+
return {
401+
boards,
402+
port: {
403+
...port,
404+
address: `${board} at ${port.address}`,
405+
},
406+
};
407+
}
406408
}
407409
}
408410
return undefined;

arduino-ide-extension/src/test/browser/fixtures/boards.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,13 @@ export const aBoard: Board = {
99
addressLabel: '/lol/port1234',
1010
protocol: 'serial',
1111
protocolLabel: 'Serial Port (USB)',
12-
properties: {},
1312
},
1413
};
1514
export const aPort: Port = {
1615
address: aBoard.port!.address,
1716
addressLabel: aBoard.port!.addressLabel,
1817
protocol: aBoard.port!.protocol,
1918
protocolLabel: aBoard.port!.protocolLabel,
20-
properties: {},
2119
};
2220
export const aBoardConfig: BoardsConfig.Config = {
2321
selectedBoard: aBoard,
@@ -31,15 +29,13 @@ export const anotherBoard: Board = {
3129
addressLabel: '/kek/port5678',
3230
protocol: 'serial',
3331
protocolLabel: 'Serial Port (USB)',
34-
properties: {},
3532
},
3633
};
3734
export const anotherPort: Port = {
3835
address: anotherBoard.port!.address,
3936
addressLabel: anotherBoard.port!.addressLabel,
4037
protocol: anotherBoard.port!.protocol,
4138
protocolLabel: anotherBoard.port!.protocolLabel,
42-
properties: {},
4339
};
4440
export const anotherBoardConfig: BoardsConfig.Config = {
4541
selectedBoard: anotherBoard,

0 commit comments

Comments
 (0)