dousi7579
2015-05-17 20:48
浏览 120
已采纳

随时解析SMS PDU

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.

图片转代码服务由CSDN问答提供 功能建议

是否可以仅使用golang来解析SMS PDU

执行AT命令

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

是否可以随时对其进行解码?

  0791361907002039040040C91361987487013000051502202203083083C8303A8C0EA3C3 
   
 
 

如果没有,您可以建议解决方法。

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • dongshukou0240 2015-05-18 00:52
    已采纳

    Yep. A quick search turned up: github.com/xlab/at/sms. Here's an example program:

    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)
    }
    

    Running that gives me:

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

    Also the parent package seems like it has a bunch of functions you may find useful.

    点赞 打赏 评论

相关推荐 更多相似问题