Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added option to disable call to Arduino Cloud API for board detection
Browse files Browse the repository at this point in the history
cmaglie committed Dec 10, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 4076037 commit 2d4aee1
Showing 5 changed files with 22 additions and 2 deletions.
2 changes: 1 addition & 1 deletion commands/service_board_list.go
Original file line number Diff line number Diff line change
@@ -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
5 changes: 4 additions & 1 deletion docs/configuration.md
Original file line number Diff line number Diff line change
@@ -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

10 changes: 10 additions & 0 deletions internal/cli/configuration/configuration.schema.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
}
}
},
2 changes: 2 additions & 0 deletions internal/cli/configuration/defaults.go
Original file line number Diff line number Diff line change
@@ -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", "")
5 changes: 5 additions & 0 deletions internal/cli/configuration/network.go
Original file line number Diff line number Diff line change
@@ -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 {

0 comments on commit 2d4aee1

Please sign in to comment.