-
-
Notifications
You must be signed in to change notification settings - Fork 436
/
Copy pathboards-service.ts
51 lines (43 loc) · 1.62 KB
/
boards-service.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import { ArduinoComponent } from "./arduino-component";
export const BoardsServicePath = '/services/boards-service';
export const BoardsService = Symbol('BoardsService');
export interface BoardsService {
getAttachedBoards(): Promise<{ boards: Board[] }>;
selectBoard(board: Board | AttachedSerialBoard | AttachedNetworkBoard): Promise<void>;
getSelectBoard(): Promise<Board | AttachedSerialBoard | AttachedNetworkBoard | undefined>;
search(options: { query?: string }): Promise<{ items: BoardPackage[] }>;
install(item: BoardPackage): Promise<void>;
}
export interface BoardPackage extends ArduinoComponent {
id: string;
boards: Board[];
}
export interface Board {
name: string
fqbn?: string
}
export interface AttachedSerialBoard extends Board {
port: string;
type: 'serial';
serialNumber?: string;
productID?: string;
vendorID?: string;
}
export namespace AttachedSerialBoard {
export function is(b: Board): b is AttachedSerialBoard {
return 'type' in b && (b as Board & { type: any }).type === 'serial' &&
'port' in b && !!(b as Board & { port: any }).port && typeof (b as Board & { port: any }).port === 'string';
}
}
export interface AttachedNetworkBoard extends Board {
info?: string;
address?: string;
port: number;
type: 'network';
}
export namespace AttachedNetworkBoard {
export function is(b: Board): b is AttachedNetworkBoard {
return 'type' in b && (b as Board & { type: any }).type === 'network' &&
'port' in b && !!(b as Board & { port: any }).port && typeof (b as Board & { port: any }).port === 'number';
}
}