Skip to content

Commit 70d3dd4

Browse files
committed
Remove debug log, update binaries
1 parent 4132190 commit 70d3dd4

File tree

6 files changed

+24
-20
lines changed

6 files changed

+24
-20
lines changed

distrib/linux32/bin/arduinoOTA

-38.4 KB
Binary file not shown.

distrib/linux64/bin/arduinoOTA

-48.7 KB
Binary file not shown.

distrib/linuxarm/bin/arduinoOTA

-42.2 KB
Binary file not shown.

distrib/osx/bin/arduinoOTA

-46.7 KB
Binary file not shown.

distrib/windows/bin/arduinoOTA.exe

-41 KB
Binary file not shown.

main.go

+24-20
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,27 @@ import (
77
"io"
88
"io/ioutil"
99
"net/http"
10-
"net/http/httputil"
1110
"os"
1211
"regexp"
1312
"strconv"
1413
"strings"
1514
"time"
1615
)
1716

17+
const AppVersion = "1.0.0"
18+
19+
var compileInfo string
20+
1821
var (
22+
version = flag.Bool("version", false, "Prints program version")
1923
networkAddress = flag.String("address", "localhost", "The address of the board")
2024
networkPort = flag.String("port", "80", "The board needs to be listening on this port")
2125
sketchPath = flag.String("sketch", "", "Sketch path")
2226
uploadEndpoint = flag.String("upload", "", "Upload endpoint")
2327
resetEndpoint = flag.String("reset", "", "Upload endpoint")
2428
syncEndpoint = flag.String("sync", "", "Upload endpoint")
25-
verbose = flag.String("v", "true", "Verbose flag")
26-
quiet = flag.String("q", "", "Quiet flag")
29+
verbose = flag.Bool("v", true, "Verbose flag")
30+
quiet = flag.Bool("q", false, "Quiet flag")
2731
useSsl = flag.String("ssl", "", "SSL flag")
2832
syncRet = flag.String("sync_exp", "", "sync expected return code in format code:string")
2933
)
@@ -36,6 +40,11 @@ type Item struct {
3640
func main() {
3741
flag.Parse()
3842

43+
if *version {
44+
fmt.Println(AppVersion + compileInfo)
45+
os.Exit(0)
46+
}
47+
3948
httpheader := "http://"
4049

4150
if *useSsl != "" {
@@ -54,15 +63,13 @@ func main() {
5463
}
5564

5665
if *syncEndpoint != "" {
57-
if *verbose != "" {
66+
if *verbose {
5867
fmt.Println("Resetting the board")
5968
}
6069

6170
resp, err := http.Post(httpheader+*networkAddress+":"+*networkPort+*syncEndpoint, "", nil)
62-
fmt.Println(resp.StatusCode)
63-
fmt.Println(resp.Status)
6471
if err != nil || resp.StatusCode != syncRetCode {
65-
if *verbose != "" {
72+
if *verbose {
6673
fmt.Println("Failed to reset the board, upload failed")
6774
}
6875
os.Exit(1)
@@ -71,7 +78,7 @@ func main() {
7178
}
7279

7380
if *syncEndpoint != "" {
74-
if *verbose != "" {
81+
if *verbose {
7582
fmt.Println("Waiting for the upload to start")
7683
}
7784

@@ -80,7 +87,7 @@ func main() {
8087
for timeout < 10 {
8188
resp, err := http.Get(httpheader + *networkAddress + ":" + *networkPort + *syncEndpoint)
8289
if err != nil {
83-
if *verbose != "" {
90+
if *verbose {
8491
fmt.Println("Failed to reset the board, upload failed")
8592
}
8693
os.Exit(1)
@@ -100,13 +107,13 @@ func main() {
100107
}
101108

102109
if *uploadEndpoint != "" {
103-
if *verbose != "" {
110+
if *verbose {
104111
fmt.Println("Uploading the sketch")
105112
}
106113

107114
f, err := os.Open(*sketchPath)
108115
if err != nil {
109-
if *verbose != "" {
116+
if *verbose {
110117
fmt.Println("Failed to open the sketch")
111118
}
112119
os.Exit(1)
@@ -119,19 +126,16 @@ func main() {
119126

120127
req, err := http.NewRequest("POST", httpheader+*networkAddress+":"+*networkPort+*uploadEndpoint, bytes.NewBufferString(str))
121128
if err != nil {
122-
if *verbose != "" {
129+
if *verbose {
123130
fmt.Println("Error sending sketch file")
124131
}
125132
os.Exit(1)
126133
}
127134
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
128135

129-
aaa, _ := httputil.DumpRequestOut(req, true)
130-
fmt.Println(string(aaa))
131-
132136
resp, err := http.DefaultClient.Do(req)
133137
if err != nil {
134-
if *verbose != "" {
138+
if *verbose {
135139
fmt.Println("Error flashing the sketch")
136140
}
137141
os.Exit(1)
@@ -141,26 +145,26 @@ func main() {
141145
respStr, _ := ioutil.ReadAll(resp.Body)
142146

143147
if resp.StatusCode != 200 {
144-
if *verbose != "" {
148+
if *verbose {
145149
fmt.Println("Error flashing the sketch:" + string(respStr))
146150
}
147151
os.Exit(1)
148152
}
149153

150-
if *verbose != "" {
154+
if *verbose {
151155
fmt.Println(string(respStr))
152156
fmt.Println("Sketch uploaded successfully")
153157
}
154158
}
155159

156160
if *resetEndpoint != "" {
157-
if *verbose != "" {
161+
if *verbose {
158162
fmt.Println("Resetting the board")
159163
}
160164

161165
resp, err := http.Post(httpheader+*networkAddress+":"+*networkPort+*resetEndpoint, "", nil)
162166
if err != nil {
163-
if *verbose != "" {
167+
if *verbose {
164168
fmt.Println("Failed to reset the board, please reset maually")
165169
}
166170
os.Exit(0)

0 commit comments

Comments
 (0)