0

Is it possible to parse SMS PDU using just golang

executing AT command

AT+CMGF=0
OK

AT+CMGL=4
+CMGL: 0,1,,26
0791361907002039040C9136198748701300005150713220052308C8303A8C0EA3C3

is there way to decode this in go?

0791361907002039040C9136198748701300005150713220052308C8303A8C0EA3C3

if there's not, can you suggest a work around.

4

1 回答 1

4

是的。快速搜索出现:github.com/xlab/at/sms。这是一个示例程序:

package main

import (
    "encoding/hex"
    "fmt"

    "github.com/xlab/at/sms"
)

func main() {
    bs, err := hex.DecodeString("0791361907002039040C9136198748701300005150713220052308C8303A8C0EA3C3")
    if err != nil {
        panic(err)
    }
    msg := new(sms.Message)
    msg.ReadFrom(bs)
    fmt.Println(msg)
}

跑步给了我:

&{0 0 0 0 {63567471770 0 0x57bac0} +639170000293 +639178840731 Hahahaha 0 false false false false false false false}

此外,父包似乎有一堆你可能会觉得有用的功能。

于 2015-05-18T00:52:11.637 回答