Skip to content

Commit 483c1e0

Browse files
matteosuppofacchinm
authored andcommitted
Use a package for the programmer
1 parent 6db09ee commit 483c1e0

File tree

2 files changed

+31
-2
lines changed

2 files changed

+31
-2
lines changed

conn.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616
"path/filepath"
1717

1818
log "github.com/Sirupsen/logrus"
19+
"github.com/arduino/arduino-create-agent/programmer"
1920
"github.com/arduino/arduino-create-agent/utilities"
2021
"github.com/gin-gonic/gin"
2122
"github.com/googollee/go-socket.io"
@@ -60,7 +61,7 @@ type Upload struct {
6061
Rewrite string `json:"rewrite"`
6162
Commandline string `json:"commandline"`
6263
Signature string `json:"signature"`
63-
Extra boardExtraInfo `json:"extra"`
64+
Extra programmer.Extra `json:"extra"`
6465
Hex []byte `json:"hex"`
6566
Filename string `json:"filename"`
6667
ExtraFiles []AdditionalFile `json:"extrafiles"`
@@ -123,7 +124,7 @@ func uploadHandler(c *gin.Context) {
123124
data.Board = data.Rewrite
124125
}
125126

126-
go spProgramRW(data.Port, data.Board, filePath, data.Commandline, data.Extra)
127+
go programmer.Do(data.Port, data.Board, filePath, data.Commandline, data.Extra, nil)
127128

128129
c.String(http.StatusAccepted, "")
129130
}

programmer/programmer.go

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package programmer
2+
3+
type logger interface {
4+
Info()
5+
Debug()
6+
}
7+
8+
// Auth contains username and password used for a network upload
9+
type Auth struct {
10+
Username string `json:"username"`
11+
Password string `json:"password"`
12+
}
13+
14+
// Extra contains some options used during the upload
15+
type Extra struct {
16+
Use1200bpsTouch bool `json:"use_1200bps_touch"`
17+
WaitForUploadPort bool `json:"wait_for_upload_port"`
18+
Network bool `json:"network"`
19+
Auth Auth `json:"auth"`
20+
Verbose bool `json:"verbose"`
21+
ParamsVerbose string `json:"params_verbose"`
22+
ParamsQuiet string `json:"params_quiet"`
23+
}
24+
25+
// Do performs a command on a port with a board attached to it
26+
func Do(port, board, path, commandline string, extra Extra, l logger) {
27+
28+
}

0 commit comments

Comments
 (0)