Browse Source

Update Infinitime library to use custom agent

pull/12/head
Arsen Musayelyan 5 months ago
parent
commit
23b9cfe8a3
  1. 4
      go.mod
  2. 7
      go.sum
  3. 30
      main.go
  4. 1
      socket.go

4
go.mod

@ -9,10 +9,12 @@ require (
github.com/abiosoft/readline v0.0.0-20180607040430-155bce2042db // indirect
github.com/cheggaaa/pb/v3 v3.0.8
github.com/flynn-archive/go-shlex v0.0.0-20150515145356-3f9db97f8568 // indirect
github.com/gen2brain/dlgs v0.0.0-20211108104213-bade24837f0b
github.com/go-gl/gl v0.0.0-20211210172815-726fda9656d6 // indirect
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20211204153444-caad923f49f4 // indirect
github.com/godbus/dbus/v5 v5.0.6
github.com/google/uuid v1.3.0
github.com/mattn/go-isatty v0.0.14
github.com/mattn/go-runewidth v0.0.13 // indirect
github.com/mitchellh/mapstructure v1.4.3
github.com/mozillazg/go-pinyin v0.19.0
@ -23,7 +25,7 @@ require (
github.com/srwiley/oksvg v0.0.0-20211120171407-1837d6608d8c // indirect
github.com/srwiley/rasterx v0.0.0-20210519020934-456a8d69b780 // indirect
github.com/yuin/goldmark v1.4.4 // indirect
go.arsenm.dev/infinitime v0.0.0-20211213175634-9250d26fdc8c
go.arsenm.dev/infinitime v0.0.0-20211217053029-738e140bfb96
golang.org/x/image v0.0.0-20211028202545-6944b10bf410 // indirect
golang.org/x/net v0.0.0-20211209124913-491a49abca63 // indirect
golang.org/x/sys v0.0.0-20211210111614-af8b64212486 // indirect

7
go.sum

@ -137,6 +137,8 @@ github.com/fsnotify/fsnotify v1.5.1 h1:mZcQUHVQUQWoPXXtuf9yuEXKudkV2sx1E06UadKWp
github.com/fsnotify/fsnotify v1.5.1/go.mod h1:T3375wBYaZdLLcVNkcVbzGHY7f1l/uK5T5Ai1i3InKU=
github.com/fxamacker/cbor/v2 v2.3.0 h1:aM45YGMctNakddNNAezPxDUpv38j44Abh+hifNuqXik=
github.com/fxamacker/cbor/v2 v2.3.0/go.mod h1:TA1xS00nchWmaBnEIxPSE5oHLuJBAVvqrtAnWBwBCVo=
github.com/gen2brain/dlgs v0.0.0-20211108104213-bade24837f0b h1:M0/hjawi9ur15zpqL/h66ga87jlYA7iAuZ4HC6ak08k=
github.com/gen2brain/dlgs v0.0.0-20211108104213-bade24837f0b/go.mod h1:/eFcjDXaU2THSOOqLxOPETIbHETnamk8FA/hMjhg/gU=
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
github.com/go-gl/gl v0.0.0-20210813123233-e4099ee2221f/go.mod h1:wjpnOv6ONl2SuJSxqCPVaPZibGFdSci9HFocT9qtVYM=
github.com/go-gl/gl v0.0.0-20211210172815-726fda9656d6 h1:zDw5v7qm4yH7N8C8uWd+8Ii9rROdgWxQuGoJ9WDXxfk=
@ -236,6 +238,7 @@ github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+
github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk=
github.com/googleapis/gax-go/v2 v2.1.0/go.mod h1:Q3nei7sK6ybPYH7twZdmQpAd1MKb7pfu6SK+H1/DsU0=
github.com/googleapis/gax-go/v2 v2.1.1/go.mod h1:hddJymUZASv3XPyGkUpKj8pPO47Rmb0eJc8R6ouapiM=
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8=
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw=
github.com/hashicorp/consul/api v1.1.0/go.mod h1:VmuI/Lkw1nC05EYQWNKwWGbkg+FbDBtguAZLlVdkD9Q=
@ -447,8 +450,8 @@ github.com/yuin/goldmark v1.3.8/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1
github.com/yuin/goldmark v1.4.0/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
github.com/yuin/goldmark v1.4.4 h1:zNWRjYUW32G9KirMXYHQHVNFkXvMI7LpgNW2AgYAoIs=
github.com/yuin/goldmark v1.4.4/go.mod h1:rmuwmfZ0+bvzB24eSC//bk1R1Zp3hM0OXYv/G2LIilg=
go.arsenm.dev/infinitime v0.0.0-20211213175634-9250d26fdc8c h1:cnvVLBNWyBHRhNUI01xKL+gE/2UQ49fFDnvQ5YdMwvQ=
go.arsenm.dev/infinitime v0.0.0-20211213175634-9250d26fdc8c/go.mod h1:xioFSrICUc4ghNJPOMSZjF7nj7QHAFLUJ2qkrSsgFfQ=
go.arsenm.dev/infinitime v0.0.0-20211217053029-738e140bfb96 h1:3cJF0QA8c0bznxIpLpGr2qhrhHQvVMt28iSlnBTFgC4=
go.arsenm.dev/infinitime v0.0.0-20211217053029-738e140bfb96/go.mod h1:xioFSrICUc4ghNJPOMSZjF7nj7QHAFLUJ2qkrSsgFfQ=
go.etcd.io/etcd/api/v3 v3.5.0/go.mod h1:cbVKeC6lCfl7j/8jBhAK6aIYO9XOjdptoxU/nLQcPvs=
go.etcd.io/etcd/api/v3 v3.5.1/go.mod h1:cbVKeC6lCfl7j/8jBhAK6aIYO9XOjdptoxU/nLQcPvs=
go.etcd.io/etcd/client/pkg/v3 v3.5.0/go.mod h1:IJHfcCEKxYu1Os13ZdwCwIUTUVGYTSAM3YSwc9/Ac1g=

30
main.go

@ -19,8 +19,13 @@
package main
import (
"fmt"
"os"
"strconv"
"time"
"github.com/gen2brain/dlgs"
"github.com/mattn/go-isatty"
"github.com/rs/zerolog/log"
"github.com/spf13/viper"
"go.arsenm.dev/infinitime"
@ -32,6 +37,28 @@ var (
updateFS = false
)
func onReqPasskey() (uint32, error) {
var out uint32
if isatty.IsTerminal(os.Stdin.Fd()) {
fmt.Print("Passkey: ")
_, err := fmt.Scanln(&out)
if err != nil {
return 0, err
}
} else {
passkey, ok, err := dlgs.Entry("Pairing", "Enter the passkey displayed on your watch.", "")
if err != nil {
return 0, err
}
if !ok {
return 0, nil
}
passkeyInt, err := strconv.Atoi(passkey)
return uint32(passkeyInt), err
}
return out, nil
}
func main() {
infinitime.Init()
// Cleanly exit after function
@ -42,9 +69,10 @@ func main() {
AttemptReconnect: viper.GetBool("conn.reconnect"),
WhitelistEnabled: viper.GetBool("conn.whitelist.enabled"),
Whitelist: viper.GetStringSlice("conn.whitelist.devices"),
OnReqPasskey: onReqPasskey,
})
if err != nil {
log.Error().Err(err).Msg("Error connecting to InfiniTime")
log.Fatal().Err(err).Msg("Error connecting to InfiniTime")
}
// When InfiniTime reconnects

1
socket.go

@ -617,7 +617,6 @@ func handleConnection(conn net.Conn, dev *infinitime.Device, fs *blefs.FS) {
go func() {
// For every progress event
for rcvd := range remoteFile.Progress() {
fmt.Println(rcvd)
// Encode event on connection
json.NewEncoder(conn).Encode(types.Response{
Type: req.Type,

Loading…
Cancel
Save