xlab / at Goto Github PK
View Code? Open in Web Editor NEWAT is a framework written in Go for communication with AT-compatible devices like Huawei modems via serial port.
License: MIT License
AT is a framework written in Go for communication with AT-compatible devices like Huawei modems via serial port.
License: MIT License
Line 272 of sms.go needs removing. It adds incorrect content length for Gsm7Bit encoding type when encoding deliver message type.
sms.UserDataLength = byte(len(userData))
I'm trying to get the tests on my machine to run, but both TestSmsDeliverPduUCS2
and TestSmsDeliverPduGsm7
fail.
$ go test -run '^TestSmsDeliverPduGsm7$' github.com/xlab/at/sms
--- FAIL: TestSmsDeliverPduGsm7 (0.00s)
sms_test.go:136:
Error Trace: sms_test.go:136
Error: Not equal:
expected: []byte{0x7, 0x91, 0x97, 0x62, 0x2, 0x0, 0x33, 0xf1, 0x4, 0xb, 0x91, 0x97, 0x62, 0x99, 0x56, 0x96, 0xf0, 0x0, 0x0, 0x41, 0x60, 0x62, 0x91, 0x40, 0x15, 0x61, 0x4, 0x63, 0x79, 0x18, 0xe}
actual : []byte{0x7, 0x91, 0x97, 0x62, 0x2, 0x0, 0x33, 0xf1, 0x4, 0xb, 0x91, 0x97, 0x62, 0x99, 0x56, 0x96, 0xf0, 0x0, 0x0, 0x41, 0x60, 0x62, 0x51, 0x40, 0x15, 0x0, 0x4, 0x63, 0x79, 0x18, 0xe}
Diff:
--- Expected
+++ Actual
@@ -2,3 +2,3 @@
00000000 07 91 97 62 02 00 33 f1 04 0b 91 97 62 99 56 96 |...b..3.....b.V.|
- 00000010 f0 00 00 41 60 62 91 40 15 61 04 63 79 18 0e |...A`[email protected]..|
+ 00000010 f0 00 00 41 60 62 51 40 15 00 04 63 79 18 0e |...A`[email protected]..|
}
Test: TestSmsDeliverPduGsm7
FAIL
FAIL github.com/xlab/at/sms 0.002s
FAIL
The difference in output is found in the TP-SCTS field (service centre time stamp).
If I run the test in a different time zone, the test output changes:
$ TZ=Etc/GMT-6 go test -run '^TestSmsDeliverPduGsm7$' github.com/xlab/at/sms
(snip)
--- Expected
+++ Actual
@@ -2,3 +2,3 @@
00000000 07 91 97 62 02 00 33 f1 04 0b 91 97 62 99 56 96 |...b..3.....b.V.|
- 00000010 f0 00 00 41 60 62 91 40 15 61 04 63 79 18 0e |...A`[email protected]..|
+ 00000010 f0 00 00 41 60 62 12 40 15 42 04 63 79 18 0e |...A`[email protected]..|
}
(snip)
TP-SCTS | System time zone | Semi octets |
---|---|---|
expected | 41 60 62 91 40 15 61 |
|
actual | UTC | 41 60 62 51 40 15 00 |
actual | GMT-6 | 41 60 62 12 40 15 42 |
It seems, the tests only work in GMT-4:
TZ=Etc/GMT-4 go test ./...
ok github.com/xlab/at 0.002s
? github.com/xlab/at/example/daemon [no test files]
ok github.com/xlab/at/pdu 0.003s
ok github.com/xlab/at/sms 0.006s
ok github.com/xlab/at/util 0.002s
Hello,
I'm playing a little with this package but I was unable to get it decode a valid SMS PDU, the simple example bellow always returns:
&{0 0 0 0 {0 0 } 0 false false false false false false false}
import (
"encoding/hex"
"fmt"
"github.com/xlab/at/sms"
)
func main() {
bs, err := hex.DecodeString("0791551010010201040D91551699296568F80011719022124215293DD4B71C5E26BF41D3E6145476D3E5E573BD0C82BF40B59A2D96CBE564351BCE8603A164319D8CA6ABD540E432482673C172AED82DE502")
if err != nil {
panic(err)
}
msg := new(sms.Message)
msg.ReadFrom(bs)
fmt.Println(msg)
}
The code bellow was extracted from this link: https://stackoverflow.com/questions/30291987/parse-sms-pdu-on-go
It works with the sample PDU message provided on the link but not with the the SMS Messages I'm receiving.
Concatenated message not parsing properly specially message with data header
First message: bold text are unexpected character
é@ø@/ @ Hello this is just a test sms from Mostain Billah personal phone, to verify multiple concatenated messaging system. Weather it is working or not. We hope
Second Message: bold text are unexpected character
é@ø@/¡@ this is working so see how it works from the beginning....
Hi please i didn't understand what is the NotifyPortPath
go version: go version go1.10.2 linux/amd64
go get github.com/xlab/at
outputs:
# github.com/xlab/at/sms
../../go/src/github.com/xlab/at/sms/sms.go:386:5: id declared and not used
../../go/src/github.com/xlab/at/sms/sms.go:387:5: total declared and not used
../../go/src/github.com/xlab/at/sms/sms.go:388:5: num declared and not used
I can not decode the smspdu message.
07919730071111F1400DD0C272999D7697010019021021902130218B06080478E006020020043C0438043D002004370432043E043D043A043E04320020043D04300020043D043E043C043504400430002004110438043B04300439043D00200420043E0441044104380438002004380020043C043504410442043D044B04350020043C043E04310438043B044C043D044B04350020043D043E043C043504400430002004340440
As ErrIncorrectDataLength is not defined in pdu/ucs2.go
, using the pdu
module fails.
func (t *Timestamp) ReadFrom(octets []byte) in sms.go calculate timezone offset as follow:
diff := time.Duration(blocks[6]) * 15 * time.Minute
if blocks[6]>>3&0x01 == 1 { // bit 3 = GMT offset sgn
// was negative, so make UTC
date = date.Add(diff)
} else {
// was positive, so make UTC
date = date.Add(-diff)
}
In accordance with GSM 03.**:
The Time Zone indicates the difference, expressed in quarters of an hour, between the local time and GMT. In the first of the two semi-octets, the first bit (bit 3 of the seventh octet of the TP-Service CentreTime-Stamp ield) represents the algebraic sign of this difference (0 : positive, 1 : negative)
But semi-octets was swapped and recoded to decimal with DecodeSemi:
for example, zone +03:00 trasmitted like 0x21, but after DecodeSemi looks like 12,
or zone -03:00 trasmitted like 0x29, but after DecodeSemi looks like 92,
I.e. negative offset after DecodeSemi will greater than 80 (bit 3 in seventh octet is 0x08 )
I propose to replace the code with something like follow:
if blocks[6] >= 80 {
// was negative, so make UTC
diff := time.Duration(blocks[6]-80) * 15 * time.Minute
date = date.Add(diff)
} else {
// was positive, so make UTC
diff := time.Duration(blocks[6]) * 15 * time.Minute
date = date.Add(-diff)
}
Also func (t Timestamp) PDU() needs to be modified
Hi,
Do you plan to support TP-UDHI flag and then multiple part SMS ?
Thxs
when compiling:
at.go:290:30 not enough arguments to pdu.Decode7Bit
have ([]byte)
want([]byte,byte)
I new to the go language I would like a simple example for sending messages using at package.
import package
import "github.com/xlab/at"
func main(){
dev = &Device{
CommandPort: "/dev/ttyUSB1",
NotifyPort: ?,
}
if err = dev.Open(); err != nil {
return
//how to send message code
//how to check balance code
}
}
A perfect example how the code should look like: tinySMS/src/rpdu/tsms_rpdu.c
(note the comments and references)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.