@@ -90,6 +90,17 @@ func apiByVidPid(vid, pid string) ([]*rpc.BoardListItem, error) {
90
90
return retVal , nil
91
91
}
92
92
93
+ func identifyViaCloudAPI (port * commands.BoardPort ) ([]* rpc.BoardListItem , error ) {
94
+ // If the port is not USB do not try identification via cloud
95
+ id := port .IdentificationPrefs
96
+ if ! id .ContainsKey ("vid" ) || ! id .ContainsKey ("pid" ) {
97
+ return nil , ErrNotFound
98
+ }
99
+
100
+ logrus .Debug ("Querying builder API for board identification..." )
101
+ return apiByVidPid (id .Get ("vid" ), id .Get ("pid" ))
102
+ }
103
+
93
104
// List FIXMEDOC
94
105
func List (instanceID int32 ) ([]* rpc.DetectedPort , error ) {
95
106
m .Lock ()
@@ -120,15 +131,8 @@ func List(instanceID int32) ([]*rpc.DetectedPort, error) {
120
131
121
132
// if installed cores didn't recognize the board, try querying
122
133
// the builder API if the board is a USB device port
123
- if len (b ) == 0 &&
124
- port .IdentificationPrefs .ContainsKey ("vid" ) &&
125
- port .IdentificationPrefs .ContainsKey ("pid" ) {
126
-
127
- logrus .Debug ("Querying builder API for board identification..." )
128
- items , err := apiByVidPid (
129
- port .IdentificationPrefs .Get ("vid" ),
130
- port .IdentificationPrefs .Get ("pid" ),
131
- )
134
+ if len (b ) == 0 {
135
+ items , err := identifyViaCloudAPI (port )
132
136
if err == ErrNotFound {
133
137
// the board couldn't be detected, print a warning
134
138
logrus .Debug ("Board not recognized" )
0 commit comments