Skip to content

Commit 8241808

Browse files
committed
Merge pull request #64 from arduino/version
Version
2 parents 986d3e3 + e025b88 commit 8241808

File tree

3 files changed

+49
-4
lines changed

3 files changed

+49
-4
lines changed

info.go

+20-4
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,30 @@
11
package main
22

33
import (
4+
"github.com/facchinm/go-serial"
5+
"github.com/facchinm/systray"
46
"github.com/gin-gonic/gin"
57
)
68

79
func infoHandler(c *gin.Context) {
810
c.JSON(200, gin.H{
9-
"http": "http://localhost" + port,
10-
"https": "https://localhost" + portSSL,
11-
"ws": "ws://localhost" + port,
12-
"wss": "wss://localhost" + portSSL,
11+
"version": version,
12+
"http": "http://localhost" + port,
13+
"https": "https://localhost" + portSSL,
14+
"ws": "ws://localhost" + port,
15+
"wss": "wss://localhost" + portSSL,
1316
})
1417
}
18+
19+
func pauseHandler(c *gin.Context) {
20+
go func() {
21+
ports, _ := serial.GetPortsList()
22+
for _, element := range ports {
23+
spClose(element)
24+
}
25+
systray.Quit()
26+
*hibernate = true
27+
restart("")
28+
}()
29+
c.JSON(200, nil)
30+
}

info_linux_arm.go

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package main
2+
3+
import (
4+
"github.com/facchinm/go-serial"
5+
"github.com/gin-gonic/gin"
6+
)
7+
8+
func infoHandler(c *gin.Context) {
9+
c.JSON(200, gin.H{
10+
"version": version,
11+
"http": "http://localhost" + port,
12+
"https": "https://localhost" + portSSL,
13+
"ws": "ws://localhost" + port,
14+
"wss": "wss://localhost" + portSSL,
15+
})
16+
}
17+
18+
func pauseHandler(c *gin.Context) {
19+
go func() {
20+
ports, _ := serial.GetPortsList()
21+
for _, element := range ports {
22+
spClose(element)
23+
}
24+
*hibernate = true
25+
restart("")
26+
}()
27+
c.JSON(200, nil)
28+
}

main.go

+1
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@ func main() {
242242
r.Handle("WSS", "/socket.io/", socketHandler)
243243
r.GET("/info", infoHandler)
244244
r.POST("/killbrowser", killBrowserHandler)
245+
r.POST("/pause", pauseHandler)
245246

246247
go func() {
247248
// check if certificates exist; if not, use plain http

0 commit comments

Comments
 (0)