@@ -34,12 +34,13 @@ import (
3434
3535// projectRaw is a support struct used only to unmarshal the yaml
3636type projectRaw struct {
37- ProfilesRaw yaml.Node `yaml:"profiles"`
38- DefaultProfile string `yaml:"default_profile"`
39- DefaultFqbn string `yaml:"default_fqbn"`
40- DefaultPort string `yaml:"default_port,omitempty"`
41- DefaultProtocol string `yaml:"default_protocol,omitempty"`
42- DefaultProgrammer string `yaml:"default_programmer,omitempty"`
37+ ProfilesRaw yaml.Node `yaml:"profiles"`
38+ DefaultProfile string `yaml:"default_profile"`
39+ DefaultFqbn string `yaml:"default_fqbn"`
40+ DefaultPort string `yaml:"default_port,omitempty"`
41+ DefaultPortConfig map [string ]string `yaml:"default_port_config,omitempty"`
42+ DefaultProtocol string `yaml:"default_protocol,omitempty"`
43+ DefaultProgrammer string `yaml:"default_programmer,omitempty"`
4344}
4445
4546// Project represents the sketch project file
@@ -48,6 +49,7 @@ type Project struct {
4849 DefaultProfile string
4950 DefaultFqbn string
5051 DefaultPort string
52+ DefaultPortConfig map [string ]string
5153 DefaultProtocol string
5254 DefaultProgrammer string
5355}
@@ -70,6 +72,12 @@ func (p *Project) AsYaml() string {
7072 if p .DefaultPort != "" {
7173 res += fmt .Sprintf ("default_port: %s\n " , p .DefaultPort )
7274 }
75+ if len (p .DefaultPortConfig ) > 0 {
76+ res += "default_port_config:\n "
77+ for k , v := range p .DefaultPortConfig {
78+ res += fmt .Sprintf (" %s: %s\n " , k , v )
79+ }
80+ }
7381 if p .DefaultProtocol != "" {
7482 res += fmt .Sprintf ("default_protocol: %s\n " , p .DefaultProtocol )
7583 }
@@ -103,17 +111,33 @@ type Profile struct {
103111 Name string
104112 Notes string `yaml:"notes"`
105113 FQBN string `yaml:"fqbn"`
114+ Port string `yaml:"port"`
115+ PortConfig map [string ]string `yaml:"port_config"`
116+ Protocol string `yaml:"protocol"`
106117 Programmer string `yaml:"programmer"`
107118 Platforms ProfileRequiredPlatforms `yaml:"platforms"`
108119 Libraries ProfileRequiredLibraries `yaml:"libraries"`
109120}
110121
111122// ToRpc converts this Profile to an rpc.SketchProfile
112123func (p * Profile ) ToRpc () * rpc.SketchProfile {
124+ var portConfig * rpc.MonitorPortConfiguration
125+ if len (p .PortConfig ) > 0 {
126+ portConfig = & rpc.MonitorPortConfiguration {}
127+ for k , v := range p .PortConfig {
128+ portConfig .Settings = append (portConfig .Settings , & rpc.MonitorPortSetting {
129+ SettingId : k ,
130+ Value : v ,
131+ })
132+ }
133+ }
113134 return & rpc.SketchProfile {
114135 Name : p .Name ,
115136 Fqbn : p .FQBN ,
116137 Programmer : p .Programmer ,
138+ Port : p .Port ,
139+ PortConfig : portConfig ,
140+ Protocol : p .Protocol ,
117141 }
118142}
119143
@@ -127,6 +151,18 @@ func (p *Profile) AsYaml() string {
127151 if p .Programmer != "" {
128152 res += fmt .Sprintf (" programmer: %s\n " , p .Programmer )
129153 }
154+ if p .Port != "" {
155+ res += fmt .Sprintf (" port: %s\n " , p .Port )
156+ }
157+ if p .Protocol != "" {
158+ res += fmt .Sprintf (" protocol: %s\n " , p .Protocol )
159+ }
160+ if len (p .PortConfig ) > 0 {
161+ res += " port_config:\n "
162+ for k , v := range p .PortConfig {
163+ res += fmt .Sprintf (" %s: %s\n " , k , v )
164+ }
165+ }
130166 res += p .Platforms .AsYaml ()
131167 res += p .Libraries .AsYaml ()
132168 return res
@@ -291,6 +327,7 @@ func LoadProjectFile(file *paths.Path) (*Project, error) {
291327 DefaultProfile : raw .DefaultProfile ,
292328 DefaultFqbn : raw .DefaultFqbn ,
293329 DefaultPort : raw .DefaultPort ,
330+ DefaultPortConfig : raw .DefaultPortConfig ,
294331 DefaultProtocol : raw .DefaultProtocol ,
295332 DefaultProgrammer : raw .DefaultProgrammer ,
296333 }, nil
0 commit comments