Skip to content

Commit fba08d6

Browse files
committed
Debugging sms send
1 parent eb3d348 commit fba08d6

File tree

3 files changed

+10
-15
lines changed

3 files changed

+10
-15
lines changed

drivers/8810ft.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,14 @@ func (m *zte8810ft) getBaseURL(path string) *url.URL {
4242
return &url.URL{Scheme: "http", Host: m.ip, Path: path}
4343
}
4444

45-
func (m *zte8810ft) getNewRequest(method string, url *url.URL) *http.Request {
45+
func (m *zte8810ft) getNewRequest(method string, url *url.URL, headers ...http.Header) *http.Request {
4646
return &http.Request{
4747
Proto: "HTTP/1.1",
4848
Method: method,
4949
URL: url,
5050
Header: http.Header{
5151
"Referer": {fmt.Sprintf("http://%s/index.html", m.ip)},
52-
"Content"
52+
// "Content"
5353
},
5454
}
5555
}
@@ -219,11 +219,11 @@ func (m *zte8810ft) SendSMS(phone string, message string) error {
219219
query.Add("MessageBody", "0074006500730074")
220220

221221
// Build send timestamp
222-
currTime := time.Now()
223-
if _, tz := currTime.Zone(); tz >= 0 {
224-
query.Add("sms_time", currTime.Format("06;01;02;15;04;05;+")+strconv.Itoa(tz/3600))
222+
t := time.Now()
223+
if _, tz := t.Zone(); tz >= 0 {
224+
query.Add("sms_time", t.Format("06;01;02;15;04;05;+")+strconv.Itoa(tz/3600))
225225
} else {
226-
query.Add("sms_time", currTime.Format("06;01;02;15;04;05;")+strconv.Itoa(tz/3600))
226+
query.Add("sms_time", t.Format("06;01;02;15;04;05;")+strconv.Itoa(tz/3600))
227227
}
228228

229229
// data := map[string]string{
@@ -243,7 +243,7 @@ func (m *zte8810ft) SendSMS(phone string, message string) error {
243243
stringReader := strings.NewReader("goformId=SEND_SMS&Number=%2B79124446729&sms_time=24%3B07%3B28%3B19%3B01%3B24%3B%2B4&MessageBody=0074006500730074&ID=-1&encode_type=GSM7_default")
244244
stringReadCloser := io.NopCloser(stringReader)
245245
request.Body = stringReadCloser
246-
246+
request.Header.Add("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8")
247247

248248
resp, err := httpClient.Do(request)
249249

go.mod

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ require (
2020
github.com/leodido/go-urn v1.4.0 // indirect
2121
github.com/magiconair/properties v1.8.7 // indirect
2222
github.com/mitchellh/mapstructure v1.5.0 // indirect
23+
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e // indirect
2324
github.com/pelletier/go-toml/v2 v2.2.2 // indirect
2425
github.com/sagikazarmark/locafero v0.4.0 // indirect
2526
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
@@ -28,14 +29,14 @@ require (
2829
github.com/spf13/cast v1.6.0 // indirect
2930
github.com/spf13/pflag v1.0.5 // indirect
3031
github.com/subosito/gotenv v1.6.0 // indirect
31-
github.com/warthog618/sms v0.3.0 // indirect
3232
go.uber.org/atomic v1.9.0 // indirect
3333
go.uber.org/multierr v1.9.0 // indirect
3434
golang.org/x/crypto v0.21.0 // indirect
3535
golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect
3636
golang.org/x/net v0.23.0 // indirect
3737
golang.org/x/sys v0.18.0 // indirect
3838
golang.org/x/text v0.14.0 // indirect
39+
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f // indirect
3940
gopkg.in/ini.v1 v1.67.0 // indirect
4041
gopkg.in/yaml.v3 v3.0.1 // indirect
4142
)

go.sum

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0V
4040
github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0=
4141
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
4242
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
43+
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs=
4344
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
4445
github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM=
4546
github.com/pelletier/go-toml/v2 v2.2.2/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs=
@@ -68,16 +69,13 @@ github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpE
6869
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
6970
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
7071
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
71-
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
7272
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
7373
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
7474
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
7575
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
7676
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
7777
github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8=
7878
github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU=
79-
github.com/warthog618/sms v0.3.0 h1:LYAb5ngmu2qjNExgji3B7xi2tIZ9+DsuE9pC5xs4wwc=
80-
github.com/warthog618/sms v0.3.0/go.mod h1:+bYZGeBxu003sxD5xhzsrIPBAjPBzTABsRTwSpd7ld4=
8179
go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE=
8280
go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
8381
go.uber.org/multierr v1.9.0 h1:7fIwc/ZtS0q++VgcfqFDxSBZVv/Xo49/SYnDFupUwlI=
@@ -93,14 +91,10 @@ golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
9391
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
9492
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
9593
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
96-
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=
97-
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
9894
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f h1:BLraFXnmrev5lT+xlilqcH8XK9/i0At2xKjWk4p6zsU=
9995
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
10096
gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA=
10197
gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
102-
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
103-
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
10498
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
10599
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
106100
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

0 commit comments

Comments
 (0)