@@ -41,12 +41,29 @@ func (d *dummyPlugin) GetPluginInfo() *helper.PluginInfo {
41
41
}
42
42
43
43
// UploadFirmware performs a firmware upload on the board
44
- func (d * dummyPlugin ) UploadFirmware (portAddress string , firmwarePath * paths.Path , feedback * helper.PluginFeedback ) error {
44
+ func (d * dummyPlugin ) UploadFirmware (portAddress , fqbn string , firmwarePath * paths.Path , feedback * helper.PluginFeedback ) error {
45
45
if portAddress == "" {
46
46
fmt .Fprintln (feedback .Err (), "Port address not specified" )
47
47
return fmt .Errorf ("invalid port address" )
48
48
}
49
49
fmt .Fprintf (feedback .Out (), "Uploading %s to %s...\n " , firmwarePath , portAddress )
50
+ if fqbn == "" {
51
+ fmt .Fprintln (feedback .Err (), "FQBN not specified" )
52
+ return fmt .Errorf ("invalid fqbn" )
53
+ }
54
+
55
+ // Providing the fqbn to the plugin allows us to support a family of boards instead of a single one
56
+ switch fqbn {
57
+ case "arduino:renesas_uno:unor5" :
58
+ // Do some board specific operations here
59
+ fmt .Fprintf (feedback .Out (), "Uploading firmware for %s \n " , fqbn )
60
+ case "arduino:renesas_uno:unor4wifi" :
61
+ // Do some board specific operations here
62
+ fmt .Fprintf (feedback .Out (), "Uploading firmware for %s \n " , fqbn )
63
+ default :
64
+ fmt .Fprintf (feedback .Err (), "FQBN %s not supported by the plugin\n " , fqbn )
65
+ return fmt .Errorf ("invalid fqbn" )
66
+ }
50
67
51
68
// Fake upload
52
69
time .Sleep (5 * time .Second )
@@ -56,7 +73,7 @@ func (d *dummyPlugin) UploadFirmware(portAddress string, firmwarePath *paths.Pat
56
73
}
57
74
58
75
// UploadCertificate performs a certificate upload on the board
59
- func (d * dummyPlugin ) UploadCertificate (portAddress string , certificatePath * paths.Path , feedback * helper.PluginFeedback ) error {
76
+ func (d * dummyPlugin ) UploadCertificate (portAddress , fqbn string , certificatePath * paths.Path , feedback * helper.PluginFeedback ) error {
60
77
if portAddress == "" {
61
78
fmt .Fprintln (feedback .Err (), "Port address not specified" )
62
79
return fmt .Errorf ("invalid port address" )
@@ -71,7 +88,7 @@ func (d *dummyPlugin) UploadCertificate(portAddress string, certificatePath *pat
71
88
}
72
89
73
90
// GetFirmwareVersion retrieve the firmware version installed on the board
74
- func (d * dummyPlugin ) GetFirmwareVersion (portAddress string , feedback * helper.PluginFeedback ) (* semver.RelaxedVersion , error ) {
91
+ func (d * dummyPlugin ) GetFirmwareVersion (portAddress , fqbn string , feedback * helper.PluginFeedback ) (* semver.RelaxedVersion , error ) {
75
92
if portAddress == "" {
76
93
fmt .Fprintln (feedback .Err (), "Port address not specified" )
77
94
return nil , fmt .Errorf ("invalid port address" )
0 commit comments