Compare commits
6 Commits
v0.0.4
...
3a877c41a4
| Author | SHA1 | Date | |
|---|---|---|---|
| 3a877c41a4 | |||
| 04fb390bee | |||
| 50b17d3266 | |||
| 763d408405 | |||
| fbb7cd9bc1 | |||
| f1b7f70313 |
@@ -19,6 +19,9 @@
|
|||||||
package firmware
|
package firmware
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/cheggaaa/pb/v3"
|
"github.com/cheggaaa/pb/v3"
|
||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
@@ -38,6 +41,8 @@ var upgradeCmd = &cobra.Command{
|
|||||||
Short: "Upgrade InfiniTime firmware using files or archive",
|
Short: "Upgrade InfiniTime firmware using files or archive",
|
||||||
Aliases: []string{"upg"},
|
Aliases: []string{"upg"},
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
|
start := time.Now()
|
||||||
|
|
||||||
client := viper.Get("client").(*api.Client)
|
client := viper.Get("client").(*api.Client)
|
||||||
|
|
||||||
var upgType api.UpgradeType
|
var upgType api.UpgradeType
|
||||||
@@ -79,6 +84,9 @@ var upgradeCmd = &cobra.Command{
|
|||||||
}
|
}
|
||||||
// Finish progress bar
|
// Finish progress bar
|
||||||
bar.Finish()
|
bar.Finish()
|
||||||
|
|
||||||
|
fmt.Printf("Transferred %d B in %s.\n", bar.Total(), time.Since(start))
|
||||||
|
fmt.Println("Remember to validate the new firmware in the InfiniTime settings.")
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -134,8 +134,6 @@ func upgradeTab(parent fyne.Window, client *api.Client) *fyne.Container {
|
|||||||
|
|
||||||
// Show progress dialog
|
// Show progress dialog
|
||||||
progressDlg.Show()
|
progressDlg.Show()
|
||||||
// Hide progress dialog after completion
|
|
||||||
defer progressDlg.Hide()
|
|
||||||
|
|
||||||
for event := range progress {
|
for event := range progress {
|
||||||
// Set label text to received / total B
|
// Set label text to received / total B
|
||||||
@@ -150,6 +148,24 @@ func upgradeTab(parent fyne.Window, client *api.Client) *fyne.Container {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Hide progress dialog after completion
|
||||||
|
progressDlg.Hide()
|
||||||
|
|
||||||
|
// Reset screen to default
|
||||||
|
upgradeTypeSelect.SetSelectedIndex(0)
|
||||||
|
firmwareBtn.SetText("Select firmware (.bin)")
|
||||||
|
initPktBtn.SetText("Select init packet (.dat)")
|
||||||
|
archiveBtn.SetText("Select archive (.zip)")
|
||||||
|
firmwarePath = ""
|
||||||
|
initPktPath = ""
|
||||||
|
archivePath = ""
|
||||||
|
|
||||||
|
dialog.NewInformation(
|
||||||
|
"Upgrade Complete",
|
||||||
|
"The firmware was transferred successfully.\nRemember to validate the firmware in InfiniTime settings.",
|
||||||
|
parent,
|
||||||
|
).Show()
|
||||||
})
|
})
|
||||||
|
|
||||||
// Return container containing all elements
|
// Return container containing all elements
|
||||||
|
|||||||
@@ -28,17 +28,21 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func setCfgDefaults() {
|
func setCfgDefaults() {
|
||||||
viper.SetDefault("cfg.version", 2)
|
|
||||||
|
|
||||||
viper.SetDefault("socket.path", "/tmp/itd/socket")
|
viper.SetDefault("socket.path", "/tmp/itd/socket")
|
||||||
|
|
||||||
viper.SetDefault("conn.reconnect", true)
|
viper.SetDefault("conn.reconnect", true)
|
||||||
|
|
||||||
|
viper.SetDefault("conn.whitelist.enabled", false)
|
||||||
|
viper.SetDefault("conn.whitelist.devices", []string{})
|
||||||
|
|
||||||
viper.SetDefault("on.connect.notify", true)
|
viper.SetDefault("on.connect.notify", true)
|
||||||
|
|
||||||
viper.SetDefault("on.reconnect.notify", true)
|
viper.SetDefault("on.reconnect.notify", true)
|
||||||
viper.SetDefault("on.reconnect.setTime", true)
|
viper.SetDefault("on.reconnect.setTime", true)
|
||||||
|
|
||||||
|
viper.SetDefault("notifs.translit.use", []string{"eASCII"})
|
||||||
|
viper.SetDefault("notifs.translit.custom", []string{})
|
||||||
|
|
||||||
viper.SetDefault("notifs.ignore.sender", []string{})
|
viper.SetDefault("notifs.ignore.sender", []string{})
|
||||||
viper.SetDefault("notifs.ignore.summary", []string{"InfiniTime"})
|
viper.SetDefault("notifs.ignore.summary", []string{"InfiniTime"})
|
||||||
viper.SetDefault("notifs.ignore.body", []string{})
|
viper.SetDefault("notifs.ignore.body", []string{})
|
||||||
|
|||||||
2
go.mod
2
go.mod
@@ -25,7 +25,7 @@ require (
|
|||||||
github.com/srwiley/oksvg v0.0.0-20210519022825-9fc0c575d5fe // indirect
|
github.com/srwiley/oksvg v0.0.0-20210519022825-9fc0c575d5fe // indirect
|
||||||
github.com/srwiley/rasterx v0.0.0-20210519020934-456a8d69b780 // indirect
|
github.com/srwiley/rasterx v0.0.0-20210519020934-456a8d69b780 // indirect
|
||||||
github.com/yuin/goldmark v1.4.1 // indirect
|
github.com/yuin/goldmark v1.4.1 // indirect
|
||||||
go.arsenm.dev/infinitime v0.0.0-20211023042633-53aa6f8a0c72
|
go.arsenm.dev/infinitime v0.0.0-20211122091416-ec43bad46652
|
||||||
golang.org/x/image v0.0.0-20210628002857-a66eb6448b8d // indirect
|
golang.org/x/image v0.0.0-20210628002857-a66eb6448b8d // indirect
|
||||||
golang.org/x/net v0.0.0-20211011170408-caeb26a5c8c0 // indirect
|
golang.org/x/net v0.0.0-20211011170408-caeb26a5c8c0 // indirect
|
||||||
golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac // indirect
|
golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac // indirect
|
||||||
|
|||||||
8
go.sum
8
go.sum
@@ -287,8 +287,8 @@ github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lN
|
|||||||
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
||||||
github.com/mozillazg/go-pinyin v0.18.0 h1:hQompXO23/0ohH8YNjvfsAITnCQImCiR/Fny8EhIeW0=
|
github.com/mozillazg/go-pinyin v0.18.0 h1:hQompXO23/0ohH8YNjvfsAITnCQImCiR/Fny8EhIeW0=
|
||||||
github.com/mozillazg/go-pinyin v0.18.0/go.mod h1:iR4EnMMRXkfpFVV5FMi4FNB6wGq9NV6uDWbUuPhP4Yc=
|
github.com/mozillazg/go-pinyin v0.18.0/go.mod h1:iR4EnMMRXkfpFVV5FMi4FNB6wGq9NV6uDWbUuPhP4Yc=
|
||||||
github.com/muka/go-bluetooth v0.0.0-20210812063148-b6c83362e27d h1:EG/xyWjHT19rkUpwsWSkyiCCmyqNwFovr9m10rhyOxU=
|
github.com/muka/go-bluetooth v0.0.0-20211122080231-b99792bbe62a h1:KxRXeSWoBM5FCPAnSUYxt1qwEzmoH/K7upb4fiSDwdc=
|
||||||
github.com/muka/go-bluetooth v0.0.0-20210812063148-b6c83362e27d/go.mod h1:dMCjicU6vRBk34dqOmIZm0aod6gUwZXOXzBROqGous0=
|
github.com/muka/go-bluetooth v0.0.0-20211122080231-b99792bbe62a/go.mod h1:dMCjicU6vRBk34dqOmIZm0aod6gUwZXOXzBROqGous0=
|
||||||
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646/go.mod h1:jpp1/29i3P1S/RLdc7JQKbRpFeM1dOBd8T9ki5s+AY8=
|
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646/go.mod h1:jpp1/29i3P1S/RLdc7JQKbRpFeM1dOBd8T9ki5s+AY8=
|
||||||
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs=
|
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs=
|
||||||
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
|
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
|
||||||
@@ -367,8 +367,8 @@ github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1
|
|||||||
github.com/yuin/goldmark v1.3.8/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
|
github.com/yuin/goldmark v1.3.8/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
|
||||||
github.com/yuin/goldmark v1.4.1 h1:/vn0k+RBvwlxEmP5E7SZMqNxPhfMVFEJiykr15/0XKM=
|
github.com/yuin/goldmark v1.4.1 h1:/vn0k+RBvwlxEmP5E7SZMqNxPhfMVFEJiykr15/0XKM=
|
||||||
github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
|
github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
|
||||||
go.arsenm.dev/infinitime v0.0.0-20211023042633-53aa6f8a0c72 h1:e8kOuL6Jj8ZjJzkGwJ3xqpGG9EhUzfvZk9AlSsm3X1U=
|
go.arsenm.dev/infinitime v0.0.0-20211122091416-ec43bad46652 h1:2Z09crdXIs+aMy1xwuD6w2kml+EObfmzgCBaOxoZIv0=
|
||||||
go.arsenm.dev/infinitime v0.0.0-20211023042633-53aa6f8a0c72/go.mod h1:gaepaueUz4J5FfxuV19B4w5pi+V3mD0LTef50ryxr/Q=
|
go.arsenm.dev/infinitime v0.0.0-20211122091416-ec43bad46652/go.mod h1:kNBKxQfqeLUfi13GM6tB1kSvLm8HlZ7PM47AYeJQIiw=
|
||||||
go.etcd.io/etcd/api/v3 v3.5.0/go.mod h1:cbVKeC6lCfl7j/8jBhAK6aIYO9XOjdptoxU/nLQcPvs=
|
go.etcd.io/etcd/api/v3 v3.5.0/go.mod h1:cbVKeC6lCfl7j/8jBhAK6aIYO9XOjdptoxU/nLQcPvs=
|
||||||
go.etcd.io/etcd/client/pkg/v3 v3.5.0/go.mod h1:IJHfcCEKxYu1Os13ZdwCwIUTUVGYTSAM3YSwc9/Ac1g=
|
go.etcd.io/etcd/client/pkg/v3 v3.5.0/go.mod h1:IJHfcCEKxYu1Os13ZdwCwIUTUVGYTSAM3YSwc9/Ac1g=
|
||||||
go.etcd.io/etcd/client/v2 v2.305.0/go.mod h1:h9puh54ZTgAKtEbut2oe9P4L/oqKCVB6xsXlzd7alYQ=
|
go.etcd.io/etcd/client/v2 v2.305.0/go.mod h1:h9puh54ZTgAKtEbut2oe9P4L/oqKCVB6xsXlzd7alYQ=
|
||||||
|
|||||||
8
itd.toml
8
itd.toml
@@ -1,13 +1,13 @@
|
|||||||
# This is temporary, it is to show a notice
|
|
||||||
# to people still using the old config
|
|
||||||
cfg.version = 2
|
|
||||||
|
|
||||||
[socket]
|
[socket]
|
||||||
path = "/tmp/itd/socket"
|
path = "/tmp/itd/socket"
|
||||||
|
|
||||||
[conn]
|
[conn]
|
||||||
reconnect = true
|
reconnect = true
|
||||||
|
|
||||||
|
[conn.whitelist]
|
||||||
|
enabled = false
|
||||||
|
devices = []
|
||||||
|
|
||||||
[on.connect]
|
[on.connect]
|
||||||
notify = true
|
notify = true
|
||||||
|
|
||||||
|
|||||||
7
main.go
7
main.go
@@ -29,16 +29,15 @@ import (
|
|||||||
var firmwareUpdating = false
|
var firmwareUpdating = false
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
if viper.GetInt("cfg.version") != 2 {
|
infinitime.Init()
|
||||||
log.Fatal().Msg("Please update your config to the newest format, only v2 configs supported.")
|
|
||||||
}
|
|
||||||
|
|
||||||
// Cleanly exit after function
|
// Cleanly exit after function
|
||||||
defer infinitime.Exit()
|
defer infinitime.Exit()
|
||||||
|
|
||||||
// Connect to InfiniTime with default options
|
// Connect to InfiniTime with default options
|
||||||
dev, err := infinitime.Connect(&infinitime.Options{
|
dev, err := infinitime.Connect(&infinitime.Options{
|
||||||
AttemptReconnect: viper.GetBool("conn.reconnect"),
|
AttemptReconnect: viper.GetBool("conn.reconnect"),
|
||||||
|
WhitelistEnabled: viper.GetBool("conn.whitelist.enabled"),
|
||||||
|
Whitelist: viper.GetStringSlice("conn.whitelist.devices"),
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error().Err(err).Msg("Error connecting to InfiniTime")
|
log.Error().Err(err).Msg("Error connecting to InfiniTime")
|
||||||
|
|||||||
Reference in New Issue
Block a user