Skip to content

Commit c519cdb

Browse files
committed
Renamed repo, working on 8810FT driver
1 parent d87ae1d commit c519cdb

File tree

7 files changed

+140
-22
lines changed

7 files changed

+140
-22
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,5 @@
2020
# Go workspace file
2121
go.work
2222
go.work.sum
23+
24+
.VSCodeCounter

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
# zte-modem-cli
2-
CLI tool for managing ZTE USB modems
1+
# usb-modem-cli
2+
CLI tool for managing USB modems with HTTP API

drivers/8810ft.go

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
package drivers
22

3+
4+
import (
5+
"net/http"
6+
)
7+
38
// DO NOT USE DIRECTLY
4-
type ZTE8810FT struct {
9+
type zte8810ft struct {
510
TargetIP string
611
basePath string
712
}
@@ -11,18 +16,35 @@ func init() {
1116
}
1217

1318
func newZTE8810FT(ip string) BaseModem {
14-
return &ZTE8810FT{TargetIP: ip, basePath: "/goform/goform_set_cmd_process"}
19+
return &zte8810ft{TargetIP: ip, basePath: "/goform/goform_set_cmd_process"}
1520
}
1621

17-
func (m *ZTE8810FT) SetTargetIP(ip string) error {
22+
func (m *zte8810ft) SetTargetIP(ip string) error {
1823
m.TargetIP = ip
1924
return nil
2025
}
2126

22-
func (m *ZTE8810FT) GetTargetIP() string {
27+
func (m *zte8810ft) GetTargetIP() string {
2328
return m.TargetIP
2429
}
2530

26-
func (m *ZTE8810FT) GetModel() string {
31+
func (m *zte8810ft) GetModel() string {
2732
return "ZTE 8810FT"
2833
}
34+
35+
func (m *zte8810ft) ConnectCell() error {
36+
// GET /goform/goform_set_cmd_process?goformId=CONNECT_NETWORK
37+
return nil
38+
}
39+
40+
func (m *zte8810ft) DisconnectCell() error {
41+
// GET /goform/goform_set_cmd_process?goformId=DISCONNECT_NETWORK
42+
return nil
43+
}
44+
45+
func (m *zte8810ft) GetCellConnStatus() (bool, error) {
46+
// Lines 251-258
47+
resp, err := http.Get()
48+
// /goform/goform_get_cmd_process?isTest=False&cmd=ppp_connected,multi_data=1&sms_received_flag_flag=0&sts_received_flag_flag=0&_=<curr_time>
49+
return false, nil
50+
}

drivers/common.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ type BaseModem interface {
1111
type ModemCell interface {
1212
BaseModem
1313

14-
GetCellConnStatus() error
14+
GetCellConnStatus() (bool, error)
1515
ConnectCell() error
1616
DisconnectCell() error
1717
}
@@ -28,7 +28,7 @@ type ModemSMS interface {
2828
GetAllSMS() ([]SMS, error)
2929
}
3030

31-
var models map[string]func(ip string) BaseModem
31+
var models map[string]func(ip string) BaseModem = map[string]func(ip string) BaseModem{}
3232

3333
func isRegistered(name string) bool {
3434
// Check if model has already been registered
@@ -39,7 +39,7 @@ func isRegistered(name string) bool {
3939
func registerModel(name string, generator func(ip string) BaseModem) {
4040
// Check if model has already been registered
4141
if isRegistered(name) {
42-
panic(fmt.Sprintf("Attempted to register %s twice", name))
42+
panic(fmt.Sprintf("attempted to register %s twice", name))
4343
}
4444

4545
// Register the model

go.mod

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,38 @@
1-
module brokenCursor/zte-modem-cli
1+
module github.com/brokenCursor/usb-modem-cli
22

3-
go 1.20
3+
go 1.22
44

5-
require github.com/go-playground/validator/v10 v10.22.0
5+
require (
6+
github.com/alexflint/go-arg v1.5.1
7+
github.com/go-playground/validator/v10 v10.22.0
8+
)
69

710
require (
8-
github.com/alexflint/go-arg v1.5.1 // indirect
911
github.com/alexflint/go-scalar v1.2.0 // indirect
12+
github.com/fsnotify/fsnotify v1.7.0 // indirect
1013
github.com/gabriel-vasile/mimetype v1.4.3 // indirect
1114
github.com/go-playground/locales v0.14.1 // indirect
1215
github.com/go-playground/universal-translator v0.18.1 // indirect
16+
github.com/hashicorp/hcl v1.0.0 // indirect
1317
github.com/leodido/go-urn v1.4.0 // indirect
14-
golang.org/x/crypto v0.19.0 // indirect
15-
golang.org/x/net v0.21.0 // indirect
16-
golang.org/x/sys v0.17.0 // indirect
18+
github.com/magiconair/properties v1.8.7 // indirect
19+
github.com/mitchellh/mapstructure v1.5.0 // indirect
20+
github.com/pelletier/go-toml/v2 v2.2.2 // indirect
21+
github.com/sagikazarmark/locafero v0.4.0 // indirect
22+
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
23+
github.com/sourcegraph/conc v0.3.0 // indirect
24+
github.com/spf13/afero v1.11.0 // indirect
25+
github.com/spf13/cast v1.6.0 // indirect
26+
github.com/spf13/pflag v1.0.5 // indirect
27+
github.com/spf13/viper v1.19.0 // indirect
28+
github.com/subosito/gotenv v1.6.0 // indirect
29+
go.uber.org/atomic v1.9.0 // indirect
30+
go.uber.org/multierr v1.9.0 // indirect
31+
golang.org/x/crypto v0.21.0 // indirect
32+
golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect
33+
golang.org/x/net v0.23.0 // indirect
34+
golang.org/x/sys v0.18.0 // indirect
1735
golang.org/x/text v0.14.0 // indirect
36+
gopkg.in/ini.v1 v1.67.0 // indirect
37+
gopkg.in/yaml.v3 v3.0.1 // indirect
1838
)

go.sum

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,86 @@ github.com/alexflint/go-arg v1.5.1 h1:nBuWUCpuRy0snAG+uIJ6N0UvYxpxA0/ghA/AaHxlT8
22
github.com/alexflint/go-arg v1.5.1/go.mod h1:A7vTJzvjoaSTypg4biM5uYNTkJ27SkNTArtYXnlqVO8=
33
github.com/alexflint/go-scalar v1.2.0 h1:WR7JPKkeNpnYIOfHRa7ivM21aWAdHD0gEWHCx+WQBRw=
44
github.com/alexflint/go-scalar v1.2.0/go.mod h1:LoFvNMqS1CPrMVltza4LvnGKhaSpc3oyLEBUZVhhS2o=
5+
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
6+
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
57
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
8+
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
9+
github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA=
10+
github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM=
611
github.com/gabriel-vasile/mimetype v1.4.3 h1:in2uUcidCuFcDKtdcBxlR0rJ1+fsokWf+uqxgUFjbI0=
712
github.com/gabriel-vasile/mimetype v1.4.3/go.mod h1:d8uq/6HKRL6CGdk+aubisF/M5GcPfT7nKyLpA0lbSSk=
13+
github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=
14+
github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
815
github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA=
916
github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
1017
github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
1118
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
1219
github.com/go-playground/validator/v10 v10.22.0 h1:k6HsTZ0sTnROkhS//R0O+55JgM8C4Bx7ia+JlgcnOao=
1320
github.com/go-playground/validator/v10 v10.22.0/go.mod h1:dbuPbCMFw/DrkbEynArYaCwl3amGuJotoKCe95atGMM=
21+
github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
22+
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
1423
github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ=
1524
github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI=
25+
github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY=
26+
github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0=
27+
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
28+
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
29+
github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM=
30+
github.com/pelletier/go-toml/v2 v2.2.2/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs=
31+
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
1632
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
33+
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=
34+
github.com/sagikazarmark/locafero v0.4.0 h1:HApY1R9zGo4DBgr7dqsTH/JJxLTTsOt7u6keLGt6kNQ=
35+
github.com/sagikazarmark/locafero v0.4.0/go.mod h1:Pe1W6UlPYUk/+wc/6KFhbORCfqzgYEpgQ3O5fPuL3H4=
36+
github.com/sagikazarmark/slog-shim v0.1.0 h1:diDBnUNK9N/354PgrxMywXnAwEr1QZcOr6gto+ugjYE=
37+
github.com/sagikazarmark/slog-shim v0.1.0/go.mod h1:SrcSrq8aKtyuqEI1uvTDTK1arOWRIczQRv+GVI1AkeQ=
38+
github.com/sourcegraph/conc v0.3.0 h1:OQTbbt6P72L20UqAkXXuLOj79LfEanQ+YQFNpLA9ySo=
39+
github.com/sourcegraph/conc v0.3.0/go.mod h1:Sdozi7LEKbFPqYX2/J+iBAM6HpqSLTASQIKqDmF7Mt0=
40+
github.com/spf13/afero v1.11.0 h1:WJQKhtpdm3v2IzqG8VMqrr6Rf3UYpEF239Jy9wNepM8=
41+
github.com/spf13/afero v1.11.0/go.mod h1:GH9Y3pIexgf1MTIWtNGyogA5MwRIDXGUr+hbWNoBjkY=
42+
github.com/spf13/cast v1.6.0 h1:GEiTHELF+vaR5dhz3VqZfFSzZjYbgeKDpBxQVS4GYJ0=
43+
github.com/spf13/cast v1.6.0/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo=
44+
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
45+
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
46+
github.com/spf13/viper v1.19.0 h1:RWq5SEjt8o25SROyN3z2OrDB9l7RPd3lwTWU8EcEdcI=
47+
github.com/spf13/viper v1.19.0/go.mod h1:GQUN9bilAbhU/jgc1bKs99f/suXKeUMct8Adx5+Ntkg=
48+
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
49+
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
50+
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
51+
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
1752
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
53+
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
54+
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
55+
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
56+
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
57+
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
58+
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
59+
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
60+
github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8=
61+
github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU=
62+
go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE=
63+
go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
64+
go.uber.org/multierr v1.9.0 h1:7fIwc/ZtS0q++VgcfqFDxSBZVv/Xo49/SYnDFupUwlI=
65+
go.uber.org/multierr v1.9.0/go.mod h1:X2jQV1h+kxSjClGpnseKVIxpmcjrj7MNnI0bnlfKTVQ=
1866
golang.org/x/crypto v0.19.0 h1:ENy+Az/9Y1vSrlrvBSyna3PITt4tiZLf7sgCjZBX7Wo=
1967
golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU=
68+
golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA=
69+
golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs=
70+
golang.org/x/exp v0.0.0-20230905200255-921286631fa9 h1:GoHiUyI/Tp2nVkLI2mCxVkOjsbSXD66ic0XW0js0R9g=
71+
golang.org/x/exp v0.0.0-20230905200255-921286631fa9/go.mod h1:S2oDrQGGwySpoQPVqRShND87VCbxmc6bL1Yd2oYrm6k=
2072
golang.org/x/net v0.21.0 h1:AQyQV4dYCvJ7vGmJyKki9+PBdyvhkSd8EIx/qb0AYv4=
2173
golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44=
74+
golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs=
75+
golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg=
2276
golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y=
2377
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
78+
golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4=
79+
golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
2480
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
2581
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
82+
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
83+
gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA=
84+
gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
85+
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
86+
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
87+
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

main.go

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ package main
22

33
import (
44
"fmt"
5-
6-
"github.com/brokenCursor/zte-modem-cli/drivers"
7-
5+
6+
"github.com/brokenCursor/usb-modem-cli/drivers"
7+
88
"github.com/alexflint/go-arg"
99
"github.com/go-playground/validator/v10"
1010
)
@@ -37,10 +37,24 @@ func init() {
3737

3838
func main() {
3939
parser := arg.MustParse(&args)
40+
model := "8810FT"
41+
42+
modem, err := drivers.GetModemDriver(model, "192.168.0.1")
43+
if err != nil {
44+
panic("failed to get drivers")
45+
}
4046

4147
switch {
4248
case args.Connection != nil:
4349
err := validate.Struct(args.Connection)
50+
51+
cell, ok := modem.(drivers.ModemCell)
52+
if !ok {
53+
fmt.Printf("Modem %s does not support cell connection", modem.GetModel())
54+
return
55+
}
56+
57+
err, err := cell.GetCellConnStatus()
4458

4559
if err != nil {
4660
parser.FailSubcommand("Unknown action", "conn")
@@ -49,8 +63,6 @@ func main() {
4963
case parser.Subcommand() == nil:
5064
parser.Fail("Missing or unknown command")
5165
}
52-
53-
GetModemDriver()
5466

5567
fmt.Printf("Modem cmd: %s\n", args.Ip)
5668
}

0 commit comments

Comments
 (0)