Bouyei.BdProto - 北斗导航车载定位终端通信数据包解析


MIT
跨平台
C#

软件简介

北斗导航车载定位终端通信(JT/T808-2011协议),使用例子

static void Main(string[] args)
        {
            IPacketProvider pConvert = PacketProvider.CreateProvider();
            string phone = "18212004771";

            //终端连接鉴权平台回复通用应答,通信内容
            byte[] body = new REQ_PB_8001().Encode(new PB8001()
            {
                MessageId = JT808Cmd.RSP_0102,
                Serialnumber = 0,
                Result = 0
            });

            //完整通信数据包格式
            byte[] buffer = pConvert.Encode(new PacketFrom()
            {
                msgBody = body,
                msgId = JT808Cmd.REQ_8001,
                msgSerialnumber = 0,
                pEncryptFlag = 0,
                pSerialnumber = 1,
                pSubFlag = 0,
                pTotal = 1,
                simNumber = phone.ToBCD(),
            });
             //socket通信可以使用Bouyei.NetFactory库(推荐.net)
            //socket.send(buffer);

            //解析终端发回的数据包
            PacketMessage msg = pConvert.Decode(buffer,0,buffer.Length);
            //解析消息体内容
            if (msg.pmPacketHead.phMessageId == JT808Cmd.RSP_0102)
            {
                PB0102 bodyInfo = new REP_PB_0102().Decode(msg.pmMessageBody);
            }
            else if (msg.pmPacketHead.phMessageId == JT808Cmd.RSP_0100)
            {
                PB0100 bodyinfo = new REP_PB_0100().Decode(msg.pmMessageBody);
            }
        }