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

随时解析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.

  • 写回答

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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
  • ¥15 错误 LNK2001 无法解析的外部符号
  • ¥50 安装pyaudiokits失败
  • ¥15 计组这些题应该咋做呀
  • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
  • ¥15 让node服务器有自动加载文件的功能
  • ¥15 jmeter脚本回放有的是对的有的是错的
  • ¥15 r语言蛋白组学相关问题
  • ¥15 Python时间序列如何拟合疏系数模型