diff --git a/commands/service_board_list.go b/commands/service_board_list.go index 8f90e544748..a7ba7da0676 100644 --- a/commands/service_board_list.go +++ b/commands/service_board_list.go @@ -170,7 +170,7 @@ func identify(pme *packagemanager.Explorer, port *discovery.Port, settings *conf // if installed cores didn't recognize the board, try querying // the builder API if the board is a USB device port - if len(boards) == 0 && !skipCloudAPI { + if len(boards) == 0 && !skipCloudAPI && !settings.SkipCloudApiForBoardDetection() { items, err := identifyViaCloudAPI(port.Properties, settings) if err != nil { // this is bad, but keep going diff --git a/docs/configuration.md b/docs/configuration.md index 376c4aa5d2b..c069638328f 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -46,7 +46,10 @@ - `network` - configuration options related to the network connection. - `proxy` - URL of the proxy server. - `connection_timeout` - network connection timeout, the value format must be a valid input for - [time.ParseDuration()](https://pkg.go.dev/time#ParseDuration), defaults to `60s` (60 seconds). `0` means it will wait indefinitely. + [time.ParseDuration()](https://pkg.go.dev/time#ParseDuration), defaults to `60s` (60 seconds). `0` means it will + wait indefinitely. + - `cloud_api.skip_board_detection_calls` - if set to `true` it will make the Arduino CLI skip network calls to Arduino + Cloud API to help detection of an unknown board. ### Default directories diff --git a/internal/cli/configuration/configuration.schema.json b/internal/cli/configuration/configuration.schema.json index 82173c0d96d..4d129e5efd8 100644 --- a/internal/cli/configuration/configuration.schema.json +++ b/internal/cli/configuration/configuration.schema.json @@ -154,6 +154,16 @@ "description": "timeout for network connections, defaults to '30s'", "type": "string", "pattern": "^[+-]?(([0-9]+(\\.[0-9]*)?|(\\.[0-9]+))(ns|us|µs|μs|ms|s|m|h))+$" + }, + "cloud_api": { + "description": "settings related to the Arduino Cloud API.", + "type": "object", + "properties": { + "skip_board_detection_calls": { + "description": "do not call the Arduino Cloud API to detect an unknown board", + "type": "boolean" + } + } } } }, diff --git a/internal/cli/configuration/defaults.go b/internal/cli/configuration/defaults.go index 8e8f28fdcf5..6e46e2a1564 100644 --- a/internal/cli/configuration/defaults.go +++ b/internal/cli/configuration/defaults.go @@ -72,6 +72,8 @@ func SetDefaults(settings *Settings) { setKeyTypeSchema("network.proxy", "") setKeyTypeSchema("network.user_agent_ext", "") setDefaultValueAndKeyTypeSchema("network.connection_timeout", (time.Second * 60).String()) + // network: Arduino Cloud API settings + setKeyTypeSchema("network.cloud_api.skip_board_detection_calls", false) // locale setKeyTypeSchema("locale", "") diff --git a/internal/cli/configuration/network.go b/internal/cli/configuration/network.go index a5487a2dc53..5af46f65d30 100644 --- a/internal/cli/configuration/network.go +++ b/internal/cli/configuration/network.go @@ -67,6 +67,11 @@ func (settings *Settings) ConnectionTimeout() time.Duration { return settings.Defaults.GetDuration("network.connection_timeout") } +// SkipCloudApiForBoardDetection returns whether the cloud API should be ignored for board detection +func (settings *Settings) SkipCloudApiForBoardDetection() bool { + return settings.GetBool("network.cloud_api.skip_board_detection_calls") +} + // NetworkProxy returns the proxy configuration (mainly used by HTTP clients) func (settings *Settings) NetworkProxy() (*url.URL, error) { if proxyConfig, ok, _ := settings.GetStringOk("network.proxy"); !ok {