File tree 1 file changed +7
-16
lines changed
arduino-core/src/cc/arduino/packages/discoverers/serial
1 file changed +7
-16
lines changed Original file line number Diff line number Diff line change @@ -148,29 +148,20 @@ public synchronized void forceRefresh() {
148
148
149
149
Map <String , Object > boardData = platform .resolveDeviceByVendorIdProductId (port , BaseNoGui .packages );
150
150
151
- BoardPort boardPort = null ;
152
- int i = 0 ;
153
-
154
- // create new board if in ports but not in boardPorts
155
- for (BoardPort board : boardPorts ) {
156
- if (board .toCompleteString ().equalsIgnoreCase (newPort )) {
157
- boardPort = boardPorts .get (i );
158
- boardPorts .get (i ).setOnlineStatus (true );
159
- break ;
160
- }
161
- i ++;
162
- }
163
-
164
- if (boardPort != null ) {
151
+ // if port has been already discovered bring it back online
152
+ BoardPort oldBoardPort = boardPorts .stream () //
153
+ .filter (bp -> bp .toCompleteString ().equalsIgnoreCase (newPort )) //
154
+ .findAny ().orElse (null );
155
+ if (oldBoardPort != null ) {
156
+ oldBoardPort .setOnlineStatus (true );
165
157
continue ;
166
158
}
167
159
168
- boardPort = new BoardPort ();
160
+ BoardPort boardPort = new BoardPort ();
169
161
boardPorts .add (boardPort );
170
162
boardPort .setAddress (port );
171
163
boardPort .setProtocol ("serial" );
172
164
boardPort .setOnlineStatus (true );
173
-
174
165
boardPort .setLabel (port );
175
166
176
167
if (boardData != null ) {
You can’t perform that action at this time.
0 commit comments