@@ -37,7 +37,6 @@ import (
37
37
"github.com/arduino/arduino-cli/pkg/fqbn"
38
38
rpc "github.com/arduino/arduino-cli/rpc/cc/arduino/cli/commands/v1"
39
39
"github.com/arduino/go-properties-orderedmap"
40
- discovery "github.com/arduino/pluggable-discovery-protocol-handler/v2"
41
40
"github.com/sirupsen/logrus"
42
41
)
43
42
@@ -139,20 +138,20 @@ func identifyViaCloudAPI(props *properties.Map, settings *configuration.Settings
139
138
}
140
139
141
140
// identify returns a list of boards checking first the installed platforms or the Cloud API
142
- func identify (pme * packagemanager.Explorer , port * discovery.Port , settings * configuration.Settings , skipCloudAPI bool ) ([]* rpc.BoardListItem , error ) {
143
- boards := []* rpc.BoardListItem {}
144
- if port .Properties == nil {
145
- return boards , nil
141
+ func identify (pme * packagemanager.Explorer , properties * properties.Map , settings * configuration.Settings , skipCloudAPI bool ) ([]* rpc.BoardListItem , error ) {
142
+ if properties == nil {
143
+ return nil , nil
146
144
}
147
145
148
146
// first query installed cores through the Package Manager
147
+ boards := []* rpc.BoardListItem {}
149
148
logrus .Debug ("Querying installed cores for board identification..." )
150
- for _ , board := range pme .IdentifyBoard (port . Properties ) {
149
+ for _ , board := range pme .IdentifyBoard (properties ) {
151
150
fqbn , err := fqbn .Parse (board .FQBN ())
152
151
if err != nil {
153
152
return nil , & cmderrors.InvalidFQBNError {Cause : err }
154
153
}
155
- fqbn .Configs = board .IdentifyBoardConfiguration (port . Properties )
154
+ fqbn .Configs = board .IdentifyBoardConfiguration (properties )
156
155
157
156
// We need the Platform maintaner for sorting so we set it here
158
157
platform := & rpc.Platform {
@@ -171,7 +170,7 @@ func identify(pme *packagemanager.Explorer, port *discovery.Port, settings *conf
171
170
// if installed cores didn't recognize the board, try querying
172
171
// the builder API if the board is a USB device port
173
172
if len (boards ) == 0 && ! skipCloudAPI && ! settings .SkipCloudApiForBoardDetection () {
174
- items , err := identifyViaCloudAPI (port . Properties , settings )
173
+ items , err := identifyViaCloudAPI (properties , settings )
175
174
if err != nil {
176
175
// this is bad, but keep going
177
176
logrus .WithError (err ).Debug ("Error querying builder API" )
@@ -225,7 +224,7 @@ func (s *arduinoCoreServerImpl) BoardList(ctx context.Context, req *rpc.BoardLis
225
224
226
225
ports := []* rpc.DetectedPort {}
227
226
for _ , port := range dm .List () {
228
- boards , err := identify (pme , port , s .settings , req .GetSkipCloudApiForBoardDetection ())
227
+ boards , err := identify (pme , port . Properties , s .settings , req .GetSkipCloudApiForBoardDetection ())
229
228
if err != nil {
230
229
warnings = append (warnings , err .Error ())
231
230
}
@@ -298,7 +297,7 @@ func (s *arduinoCoreServerImpl) BoardListWatch(req *rpc.BoardListWatchRequest, s
298
297
299
298
boardsError := ""
300
299
if event .Type == "add" {
301
- boards , err := identify (pme , event .Port , s .settings , req .GetSkipCloudApiForBoardDetection ())
300
+ boards , err := identify (pme , event .Port . Properties , s .settings , req .GetSkipCloudApiForBoardDetection ())
302
301
if err != nil {
303
302
boardsError = err .Error ()
304
303
}
0 commit comments