Ensure that the FS works after a reconnect
This commit is contained in:
parent
b363a20a9d
commit
655af5c446
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-20211125213558-bd057815cf1b
|
go.arsenm.dev/infinitime v0.0.0-20211126043306-522c10a9c0a7
|
||||||
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
|
||||||
|
4
go.sum
4
go.sum
@ -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-20211125213558-bd057815cf1b h1:9QHz8eZDmjfZWB6atK8Agwdf60xE5W5S2mEkjOmAjTs=
|
go.arsenm.dev/infinitime v0.0.0-20211126043306-522c10a9c0a7 h1:m6BVtAiWMRbfUgBZVthXq2eZhSwDxdtOi8Dh/59hXik=
|
||||||
go.arsenm.dev/infinitime v0.0.0-20211125213558-bd057815cf1b/go.mod h1:TzAhsz7TAqEm/vWhgMvmIxHS5jt46hqKkPvr6cqvVyA=
|
go.arsenm.dev/infinitime v0.0.0-20211126043306-522c10a9c0a7/go.mod h1:TzAhsz7TAqEm/vWhgMvmIxHS5jt46hqKkPvr6cqvVyA=
|
||||||
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
main.go
8
main.go
@ -26,7 +26,11 @@ import (
|
|||||||
"go.arsenm.dev/infinitime"
|
"go.arsenm.dev/infinitime"
|
||||||
)
|
)
|
||||||
|
|
||||||
var firmwareUpdating = false
|
var (
|
||||||
|
firmwareUpdating = false
|
||||||
|
// The FS must be updated when the watch is reconnected
|
||||||
|
updateFS = false
|
||||||
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
infinitime.Init()
|
infinitime.Init()
|
||||||
@ -61,6 +65,8 @@ func main() {
|
|||||||
log.Error().Err(err).Msg("Error sending notification to InfiniTime")
|
log.Error().Err(err).Msg("Error sending notification to InfiniTime")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateFS = true
|
||||||
})
|
})
|
||||||
|
|
||||||
// Get firmware version
|
// Get firmware version
|
||||||
|
14
socket.go
14
socket.go
@ -107,6 +107,20 @@ func startSocket(dev *infinitime.Device) error {
|
|||||||
func handleConnection(conn net.Conn, dev *infinitime.Device, fs *blefs.FS) {
|
func handleConnection(conn net.Conn, dev *infinitime.Device, fs *blefs.FS) {
|
||||||
defer conn.Close()
|
defer conn.Close()
|
||||||
|
|
||||||
|
// If an FS update is required (reconnect ocurred)
|
||||||
|
if updateFS {
|
||||||
|
// Get new FS
|
||||||
|
newFS, err := dev.FS()
|
||||||
|
if err != nil {
|
||||||
|
fs = nil
|
||||||
|
log.Warn().Err(err).Msg("Error updating BLE filesystem")
|
||||||
|
}
|
||||||
|
// Set FS pointer to new FS
|
||||||
|
*fs = *newFS
|
||||||
|
// Reset updateFS
|
||||||
|
updateFS = false
|
||||||
|
}
|
||||||
|
|
||||||
// Create new scanner on connection
|
// Create new scanner on connection
|
||||||
scanner := bufio.NewScanner(conn)
|
scanner := bufio.NewScanner(conn)
|
||||||
for scanner.Scan() {
|
for scanner.Scan() {
|
||||||
|
Loading…
Reference in New Issue
Block a user