Skip to content

Commit d12e330

Browse files
committed
Added 'default_fqbn' and 'default_port' fields to sketch.yaml
1 parent ea0a067 commit d12e330

File tree

4 files changed

+46
-10
lines changed

4 files changed

+46
-10
lines changed

Diff for: arduino/sketch/profiles.go

+15-3
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,13 @@ import (
2929
"gopkg.in/yaml.v2"
3030
)
3131

32-
// Project represents all the profiles defined for the sketch
32+
// Project represents the sketch project file
3333
type Project struct {
34-
Profiles Profiles `yaml:"profiles"`
35-
DefaultProfile string `yaml:"default_profile"`
34+
Profiles Profiles `yaml:"profiles"`
35+
DefaultProfile string `yaml:"default_profile"`
36+
DefaultFqbn string `yaml:"default_fqbn"`
37+
DefaultPort string `yaml:"default_port,omitempty"`
38+
DefaultProtocol string `yaml:"default_protocol,omitempty"`
3639
}
3740

3841
// AsYaml outputs the sketch project file as YAML
@@ -46,6 +49,15 @@ func (p *Project) AsYaml() string {
4649
if p.DefaultProfile != "" {
4750
res += fmt.Sprintf("default_profile: %s\n", p.DefaultProfile)
4851
}
52+
if p.DefaultFqbn != "" {
53+
res += fmt.Sprintf("default_fqbn: %s\n", p.DefaultFqbn)
54+
}
55+
if p.DefaultPort != "" {
56+
res += fmt.Sprintf("default_port: %s\n", p.DefaultPort)
57+
}
58+
if p.DefaultProtocol != "" {
59+
res += fmt.Sprintf("default_protocol: %s\n", p.DefaultProtocol)
60+
}
4961
return res
5062
}
5163

Diff for: arduino/sketch/profiles_test.go

+18-7
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,22 @@ import (
2424
)
2525

2626
func TestProjectFileLoading(t *testing.T) {
27-
sketchProj := paths.New("testdata", "SketchWithProfiles", "sketch.yml")
28-
proj, err := LoadProjectFile(sketchProj)
29-
require.NoError(t, err)
30-
fmt.Println(proj)
31-
golden, err := sketchProj.ReadFile()
32-
require.NoError(t, err)
33-
require.Equal(t, proj.AsYaml(), string(golden))
27+
{
28+
sketchProj := paths.New("testdata", "SketchWithProfiles", "sketch.yml")
29+
proj, err := LoadProjectFile(sketchProj)
30+
require.NoError(t, err)
31+
fmt.Println(proj)
32+
golden, err := sketchProj.ReadFile()
33+
require.NoError(t, err)
34+
require.Equal(t, proj.AsYaml(), string(golden))
35+
}
36+
{
37+
sketchProj := paths.New("testdata", "SketchWithDefaultFQBNAndPort", "sketch.yml")
38+
proj, err := LoadProjectFile(sketchProj)
39+
require.NoError(t, err)
40+
fmt.Println(proj)
41+
golden, err := sketchProj.ReadFile()
42+
require.NoError(t, err)
43+
require.Equal(t, proj.AsYaml(), string(golden))
44+
}
3445
}

Diff for: arduino/sketch/testdata/SketchWithDefaultFQBNAndPort/SketchWithDefaultFQBNAndPort.ino

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
profiles:
2+
nanorp:
3+
fqbn: arduino:mbed_nano:nanorp2040connect
4+
platforms:
5+
- platform: arduino:mbed_nano (2.1.0)
6+
libraries:
7+
- ArduinoIoTCloud (1.0.2)
8+
- Arduino_ConnectionHandler (0.6.4)
9+
- TinyDHT sensor library (1.1.0)
10+
11+
default_fqbn: arduino:avr:uno
12+
default_port: /dev/ttyACM0
13+
default_protocol: serial

0 commit comments

Comments
 (0)