@@ -7,183 +7,29 @@ import {
7
7
SelectBoardsConfigActionParams ,
8
8
} from '../../common/protocol/board-list' ;
9
9
import {
10
- BoardIdentifier ,
11
- DetectedPort ,
12
- DetectedPorts ,
13
10
emptyBoardsConfig ,
14
- Port ,
15
11
unconfirmedBoard ,
16
12
} from '../../common/protocol/boards-service' ;
17
-
18
- const mkr1000 : BoardIdentifier = {
19
- name : 'Arduino MKR1000' ,
20
- fqbn : 'arduino:samd:mkr1000' ,
21
- } ;
22
- const uno : BoardIdentifier = {
23
- name : 'Arduino Uno' ,
24
- fqbn : 'arduino:avr:uno' ,
25
- } ;
26
- const arduinoNanoEsp32 : BoardIdentifier = {
27
- fqbn : 'arduino:esp32:nano_nora' ,
28
- name : 'Arduino Nano ESP32' ,
29
- } ;
30
- const esp32NanoEsp32 : BoardIdentifier = {
31
- fqbn : 'esp32:esp32:nano_nora' ,
32
- name : 'Arduino Nano ESP32' ,
33
- } ;
34
- const esp32S3DevModule : BoardIdentifier = {
35
- name : 'ESP32S3 Dev Module' ,
36
- fqbn : 'esp32:esp32:esp32s3' ,
37
- } ;
38
- const esp32S3Box : BoardIdentifier = {
39
- name : 'ESP32-S3-Box' ,
40
- fqbn : 'esp32:esp32:esp32s3box' ,
41
- } ;
42
-
43
- const bluetoothSerialPort : Port = {
44
- address : '/dev/cu.Bluetooth-Incoming-Port' ,
45
- addressLabel : '/dev/cu.Bluetooth-Incoming-Port' ,
46
- protocol : 'serial' ,
47
- protocolLabel : 'Serial Port' ,
48
- properties : { } ,
49
- hardwareId : '' ,
50
- } ;
51
- const builtinSerialPort : Port = {
52
- address : '/dev/cu.BLTH' ,
53
- addressLabel : '/dev/cu.BLTH' ,
54
- protocol : 'serial' ,
55
- protocolLabel : 'Serial Port' ,
56
- properties : { } ,
57
- hardwareId : '' ,
58
- } ;
59
- const undiscoveredSerialPort : Port = {
60
- address : '/dev/cu.usbserial-0001' ,
61
- addressLabel : '/dev/cu.usbserial-0001' ,
62
- protocol : 'serial' ,
63
- protocolLabel : 'Serial Port (USB)' ,
64
- properties : {
65
- pid : '0xEA60' ,
66
- serialNumber : '0001' ,
67
- vid : '0x10C4' ,
68
- } ,
69
- hardwareId : '0001' ,
70
- } ;
71
- const mkr1000NetworkPort : Port = {
72
- address : '192.168.0.104' ,
73
- addressLabel : 'Arduino at 192.168.0.104' ,
74
- protocol : 'network' ,
75
- protocolLabel : 'Network Port' ,
76
- properties : {
77
- '.' : 'mkr1000' ,
78
- auth_upload : 'yes' ,
79
- board : 'mkr1000' ,
80
- hostname : 'Arduino.local.' ,
81
- port : '65280' ,
82
- ssh_upload : 'no' ,
83
- tcp_check : 'no' ,
84
- } ,
85
- hardwareId : '' ,
86
- } ;
87
- const undiscoveredUsbToUARTSerialPort : Port = {
88
- address : '/dev/cu.SLAB_USBtoUART' ,
89
- addressLabel : '/dev/cu.SLAB_USBtoUART' ,
90
- protocol : 'serial' ,
91
- protocolLabel : 'Serial Port (USB)' ,
92
- properties : {
93
- pid : '0xEA60' ,
94
- serialNumber : '0001' ,
95
- vid : '0x10C4' ,
96
- } ,
97
- hardwareId : '0001' ,
98
- } ;
99
- const mkr1000SerialPort : Port = {
100
- address : '/dev/cu.usbmodem14301' ,
101
- addressLabel : '/dev/cu.usbmodem14301' ,
102
- protocol : 'serial' ,
103
- protocolLabel : 'Serial Port (USB)' ,
104
- properties : {
105
- pid : '0x804E' ,
106
- serialNumber : '94A3397C5150435437202020FF150838' ,
107
- vid : '0x2341' ,
108
- } ,
109
- hardwareId : '94A3397C5150435437202020FF150838' ,
110
- } ;
111
- const unoSerialPort : Port = {
112
- address : '/dev/cu.usbmodem14201' ,
113
- addressLabel : '/dev/cu.usbmodem14201' ,
114
- protocol : 'serial' ,
115
- protocolLabel : 'Serial Port (USB)' ,
116
- properties : {
117
- pid : '0x0043' ,
118
- serialNumber : '75830303934351618212' ,
119
- vid : '0x2341' ,
120
- } ,
121
- hardwareId : '75830303934351618212' ,
122
- } ;
123
- const nanoEsp32SerialPort : Port = {
124
- address : '/dev/cu.usbmodem3485187BD9882' ,
125
- addressLabel : '/dev/cu.usbmodem3485187BD9882' ,
126
- protocol : 'serial' ,
127
- protocolLabel : 'Serial Port (USB)' ,
128
- properties : {
129
- pid : '0x0070' ,
130
- serialNumber : '3485187BD988' ,
131
- vid : '0x2341' ,
132
- } ,
133
- hardwareId : '3485187BD988' ,
134
- } ;
135
- const nanoEsp32DetectsMultipleEsp32BoardsSerialPort : Port = {
136
- address : 'COM41' ,
137
- addressLabel : 'COM41' ,
138
- protocol : 'serial' ,
139
- protocolLabel : 'Serial Port (USB)' ,
140
- properties : {
141
- pid : '0x1001' ,
142
- serialNumber : '' ,
143
- vid : '0x303A' ,
144
- } ,
145
- } ;
146
-
147
- function createPort ( address : string , protocol = 'serial' ) : Port {
148
- return {
149
- address,
150
- addressLabel : `Address label: ${ address } ` ,
151
- protocol,
152
- protocolLabel : `Protocol label: ${ protocol } ` ,
153
- } ;
154
- }
155
-
156
- function detectedPort (
157
- port : Port ,
158
- ...boards : BoardIdentifier [ ]
159
- ) : { [ portKey : string ] : DetectedPort } {
160
- return { [ Port . keyOf ( port ) ] : boards . length ? { port, boards } : { port } } ;
161
- }
162
-
163
- function history (
164
- port : Port ,
165
- board : BoardIdentifier
166
- ) : { [ portKey : string ] : BoardIdentifier } {
167
- return { [ Port . keyOf ( port ) ] : board } ;
168
- }
169
-
170
- const detectedPorts : DetectedPorts = {
171
- ...detectedPort ( builtinSerialPort ) ,
172
- ...detectedPort ( bluetoothSerialPort ) ,
173
- ...detectedPort ( unoSerialPort , uno ) ,
174
- ...detectedPort ( mkr1000SerialPort , mkr1000 ) ,
175
- ...detectedPort ( mkr1000NetworkPort , mkr1000 ) ,
176
- ...detectedPort ( undiscoveredSerialPort ) ,
177
- ...detectedPort ( undiscoveredUsbToUARTSerialPort ) ,
178
- // multiple discovered on the same port with different board names
179
- ...detectedPort (
180
- nanoEsp32DetectsMultipleEsp32BoardsSerialPort ,
181
- esp32S3DevModule ,
182
- esp32S3Box
183
- ) ,
184
- // multiple discovered on the same port with the same board name
185
- ...detectedPort ( nanoEsp32SerialPort , arduinoNanoEsp32 , esp32NanoEsp32 ) ,
186
- } ;
13
+ import {
14
+ arduinoNanoEsp32 ,
15
+ bluetoothSerialPort ,
16
+ builtinSerialPort ,
17
+ createPort ,
18
+ detectedPort ,
19
+ detectedPorts ,
20
+ esp32NanoEsp32 ,
21
+ esp32S3Box ,
22
+ esp32S3DevModule ,
23
+ history ,
24
+ mkr1000 ,
25
+ mkr1000SerialPort ,
26
+ nanoEsp32DetectsMultipleEsp32BoardsSerialPort ,
27
+ nanoEsp32SerialPort ,
28
+ undiscoveredSerialPort ,
29
+ undiscoveredUsbToUARTSerialPort ,
30
+ uno ,
31
+ unoSerialPort ,
32
+ } from './fixtures' ;
187
33
188
34
describe ( 'board-list' , ( ) => {
189
35
describe ( 'createBoardList' , ( ) => {
0 commit comments