@@ -37,7 +37,6 @@ import (
3737 "github.com/arduino/arduino-cli/pkg/fqbn"
3838 rpc "github.com/arduino/arduino-cli/rpc/cc/arduino/cli/commands/v1"
3939 "github.com/arduino/go-properties-orderedmap"
40- discovery "github.com/arduino/pluggable-discovery-protocol-handler/v2"
4140 "github.com/sirupsen/logrus"
4241)
4342
@@ -139,20 +138,20 @@ func identifyViaCloudAPI(props *properties.Map, settings *configuration.Settings
139138}
140139
141140// 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
146144 }
147145
148146 // first query installed cores through the Package Manager
147+ boards := []* rpc.BoardListItem {}
149148 logrus .Debug ("Querying installed cores for board identification..." )
150- for _ , board := range pme .IdentifyBoard (port . Properties ) {
149+ for _ , board := range pme .IdentifyBoard (properties ) {
151150 fqbn , err := fqbn .Parse (board .FQBN ())
152151 if err != nil {
153152 return nil , & cmderrors.InvalidFQBNError {Cause : err }
154153 }
155- fqbn .Configs = board .IdentifyBoardConfiguration (port . Properties )
154+ fqbn .Configs = board .IdentifyBoardConfiguration (properties )
156155
157156 // We need the Platform maintaner for sorting so we set it here
158157 platform := & rpc.Platform {
@@ -171,7 +170,7 @@ func identify(pme *packagemanager.Explorer, port *discovery.Port, settings *conf
171170 // if installed cores didn't recognize the board, try querying
172171 // the builder API if the board is a USB device port
173172 if len (boards ) == 0 && ! skipCloudAPI && ! settings .SkipCloudApiForBoardDetection () {
174- items , err := identifyViaCloudAPI (port . Properties , settings )
173+ items , err := identifyViaCloudAPI (properties , settings )
175174 if err != nil {
176175 // this is bad, but keep going
177176 logrus .WithError (err ).Debug ("Error querying builder API" )
@@ -225,7 +224,7 @@ func (s *arduinoCoreServerImpl) BoardList(ctx context.Context, req *rpc.BoardLis
225224
226225 ports := []* rpc.DetectedPort {}
227226 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 ())
229228 if err != nil {
230229 warnings = append (warnings , err .Error ())
231230 }
@@ -298,7 +297,7 @@ func (s *arduinoCoreServerImpl) BoardListWatch(req *rpc.BoardListWatchRequest, s
298297
299298 boardsError := ""
300299 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 ())
302301 if err != nil {
303302 boardsError = err .Error ()
304303 }
0 commit comments