@@ -63,12 +63,14 @@ type Upload struct {
63
63
Rewrite string `json:"rewrite"`
64
64
Commandline string `json:"commandline"`
65
65
Signature string `json:"signature"`
66
- Extra upload.Extra `json:"extra"`
66
+ Extra upload.Extra `json:"extra"`
67
67
Hex []byte `json:"hex"`
68
68
Filename string `json:"filename"`
69
69
ExtraFiles []AdditionalFile `json:"extrafiles"`
70
70
}
71
71
72
+ var uploadStatusStr string = "ProgrammerStatus"
73
+
72
74
func uploadHandler (c * gin.Context ) {
73
75
data := new (Upload )
74
76
c .BindJSON (data )
@@ -130,27 +132,27 @@ func uploadHandler(c *gin.Context) {
130
132
// Resolve commandline
131
133
commandline , err := upload .Resolve (data .Port , data .Board , filePath , data .Commandline , data .Extra , & Tools )
132
134
if err != nil {
133
- send (map [string ]string {"uploadStatus" : "Error" , "Msg" : err .Error ()})
135
+ send (map [string ]string {uploadStatusStr : "Error" , "Msg" : err .Error ()})
134
136
return
135
137
}
136
138
137
139
l := PLogger {Verbose : data .Extra .Verbose }
138
140
139
141
// Upload
140
142
if data .Extra .Network {
141
- send (map [string ]string {"uploadStatus" : "Starting" , "Cmd" : "Network" })
143
+ send (map [string ]string {uploadStatusStr : "Starting" , "Cmd" : "Network" })
142
144
err = upload .Network (data .Port , data .Board , filePath , commandline , data .Extra .Auth , l )
143
145
} else {
144
- send (map [string ]string {"uploadStatus" : "Starting" , "Cmd" : "Serial" })
146
+ send (map [string ]string {uploadStatusStr : "Starting" , "Cmd" : "Serial" })
145
147
err = upload .Serial (data .Port , commandline , data .Extra , l )
146
148
}
147
149
148
150
// Handle result
149
151
if err != nil {
150
- send (map [string ]string {"uploadStatus" : "Error" , "Msg" : err .Error ()})
152
+ send (map [string ]string {uploadStatusStr : "Error" , "Msg" : err .Error ()})
151
153
return
152
154
}
153
- send (map [string ]string {"uploadStatus" : "Done" , "Flash" : "Ok" })
155
+ send (map [string ]string {uploadStatusStr : "Done" , "Flash" : "Ok" })
154
156
}()
155
157
156
158
c .String (http .StatusAccepted , "" )
@@ -172,7 +174,7 @@ func (l PLogger) Debug(args ...interface{}) {
172
174
func (l PLogger ) Info (args ... interface {}) {
173
175
output := fmt .Sprint (args ... )
174
176
log .Println (output )
175
- send (map [string ]string {"uploadStatus" : "Busy" , "Msg" : output })
177
+ send (map [string ]string {uploadStatusStr : "Busy" , "Msg" : output })
176
178
}
177
179
178
180
func send (args map [string ]string ) {
0 commit comments