Skip to content

Commit 6df6b17

Browse files
committed
Added option to disable call to Arduino Cloud API for board detection
1 parent 4076037 commit 6df6b17

File tree

5 files changed

+22
-2
lines changed

5 files changed

+22
-2
lines changed

Diff for: commands/service_board_list.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ func identify(pme *packagemanager.Explorer, port *discovery.Port, settings *conf
170170

171171
// if installed cores didn't recognize the board, try querying
172172
// the builder API if the board is a USB device port
173-
if len(boards) == 0 && !skipCloudAPI {
173+
if len(boards) == 0 && !skipCloudAPI && !settings.SkipCloudApiForBoardDetection() {
174174
items, err := identifyViaCloudAPI(port.Properties, settings)
175175
if err != nil {
176176
// this is bad, but keep going

Diff for: docs/configuration.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,10 @@
4646
- `network` - configuration options related to the network connection.
4747
- `proxy` - URL of the proxy server.
4848
- `connection_timeout` - network connection timeout, the value format must be a valid input for
49-
[time.ParseDuration()](https://pkg.go.dev/time#ParseDuration), defaults to `60s` (60 seconds). `0` means it will wait indefinitely.
49+
[time.ParseDuration()](https://pkg.go.dev/time#ParseDuration), defaults to `60s` (60 seconds). `0` means it will
50+
wait indefinitely.
51+
- `cloud_api.skip_board_detection_calls` - if set to `true` it will make the Arduino CLI skip network calls to Arduino
52+
Cloud API to help detection of an unknown board.
5053

5154
### Default directories
5255

Diff for: internal/cli/configuration/configuration.schema.json

+10
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,16 @@
154154
"description": "timeout for network connections, defaults to '30s'",
155155
"type": "string",
156156
"pattern": "^[+-]?(([0-9]+(\\.[0-9]*)?|(\\.[0-9]+))(ns|us|µs|μs|ms|s|m|h))+$"
157+
},
158+
"cloud_api": {
159+
"description": "settings related to the Arduino Cloud API.",
160+
"type": "object",
161+
"properties": {
162+
"skip_board_detection_calls": {
163+
"description": "do not call the Arduino Cloud API to detect an unknown board",
164+
"type": "boolean"
165+
}
166+
}
157167
}
158168
}
159169
},

Diff for: internal/cli/configuration/defaults.go

+2
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ func SetDefaults(settings *Settings) {
7272
setKeyTypeSchema("network.proxy", "")
7373
setKeyTypeSchema("network.user_agent_ext", "")
7474
setDefaultValueAndKeyTypeSchema("network.connection_timeout", (time.Second * 60).String())
75+
// network: Arduino Cloud API settings
76+
setKeyTypeSchema("network.cloud_api.skip_board_detection_calls", false)
7577

7678
// locale
7779
setKeyTypeSchema("locale", "")

Diff for: internal/cli/configuration/network.go

+5
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,11 @@ func (settings *Settings) ConnectionTimeout() time.Duration {
6767
return settings.Defaults.GetDuration("network.connection_timeout")
6868
}
6969

70+
// SkipCloudApiForBoardDetection returns whether the cloud API should be ignored for board detection
71+
func (settings *Settings) SkipCloudApiForBoardDetection() bool {
72+
return settings.GetBool("network.cloud_api.skip_board_detection_calls")
73+
}
74+
7075
// NetworkProxy returns the proxy configuration (mainly used by HTTP clients)
7176
func (settings *Settings) NetworkProxy() (*url.URL, error) {
7277
if proxyConfig, ok, _ := settings.GetStringOk("network.proxy"); !ok {

0 commit comments

Comments
 (0)