@@ -81,7 +81,7 @@ type Upload struct {
8181
8282var uploadStatusStr = "ProgrammerStatus"
8383
84- func uploadHandler (h * hub , pubKey * rsa.PublicKey , tools * tools.Tools ) func (* gin.Context ) {
84+ func uploadHandler (hub * hub , pubKey * rsa.PublicKey , tools * tools.Tools ) func (* gin.Context ) {
8585 return func (c * gin.Context ) {
8686 data := new (Upload )
8787 if err := c .BindJSON (data ); err != nil {
@@ -165,7 +165,7 @@ func uploadHandler(h *hub, pubKey *rsa.PublicKey, tools *tools.Tools) func(*gin.
165165 // Resolve commandline
166166 commandline , err := upload .PartiallyResolve (data .Board , filePath , tmpdir , data .Commandline , data .Extra , tools )
167167 if err != nil {
168- send (h , map [string ]string {uploadStatusStr : "Error" , "Msg" : err .Error ()})
168+ send (hub , map [string ]string {uploadStatusStr : "Error" , "Msg" : err .Error ()})
169169 return
170170 }
171171
@@ -175,16 +175,16 @@ func uploadHandler(h *hub, pubKey *rsa.PublicKey, tools *tools.Tools) func(*gin.
175175 if data .Extra .Network {
176176 err = errors .New ("network upload is not supported anymore, pease use OTA instead" )
177177 } else {
178- send (h , map [string ]string {uploadStatusStr : "Starting" , "Cmd" : "Serial" })
178+ send (hub , map [string ]string {uploadStatusStr : "Starting" , "Cmd" : "Serial" })
179179 err = upload .Serial (data .Port , commandline , data .Extra , l )
180180 }
181181
182182 // Handle result
183183 if err != nil {
184- send (h , map [string ]string {uploadStatusStr : "Error" , "Msg" : err .Error ()})
184+ send (hub , map [string ]string {uploadStatusStr : "Error" , "Msg" : err .Error ()})
185185 return
186186 }
187- send (h , map [string ]string {uploadStatusStr : "Done" , "Flash" : "Ok" })
187+ send (hub , map [string ]string {uploadStatusStr : "Done" , "Flash" : "Ok" })
188188 }()
189189
190190 c .String (http .StatusAccepted , "" )
@@ -194,7 +194,7 @@ func uploadHandler(h *hub, pubKey *rsa.PublicKey, tools *tools.Tools) func(*gin.
194194// PLogger sends the info from the upload to the websocket
195195type PLogger struct {
196196 Verbose bool
197- h * hub
197+ hub * hub
198198}
199199
200200// Debug only sends messages if verbose is true (always true for now)
@@ -208,29 +208,29 @@ func (l PLogger) Debug(args ...interface{}) {
208208func (l PLogger ) Info (args ... interface {}) {
209209 output := fmt .Sprint (args ... )
210210 log .Println (output )
211- send (l .h , map [string ]string {uploadStatusStr : "Busy" , "Msg" : output })
211+ send (l .hub , map [string ]string {uploadStatusStr : "Busy" , "Msg" : output })
212212}
213213
214- func send (h * hub , args map [string ]string ) {
214+ func send (hub * hub , args map [string ]string ) {
215215 mapB , _ := json .Marshal (args )
216- h .broadcastSys <- mapB
216+ hub .broadcastSys <- mapB
217217}
218218
219- func wsHandler (h * hub ) * WsServer {
219+ func wsHandler (hub * hub ) * WsServer {
220220 server , err := socketio .NewServer (nil )
221221 if err != nil {
222222 log .Fatal (err )
223223 }
224224
225225 server .On ("connection" , func (so socketio.Socket ) {
226226 c := & connection {send : make (chan []byte , 256 * 10 ), ws : so }
227- h .register <- c
227+ hub .register <- c
228228 so .On ("command" , func (message string ) {
229- h .broadcast <- []byte (message )
229+ hub .broadcast <- []byte (message )
230230 })
231231
232232 so .On ("disconnection" , func () {
233- h .unregister <- c
233+ hub .unregister <- c
234234 })
235235 go c .writer ()
236236 })
0 commit comments