static void Main(string[] args) { IPacketProvider pConvert = PacketProvider.CreateProvider(); string phone = "18212001111"; //终端连接鉴权平台回复通用应答 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(), }); //解析终端发回的数据包 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); } }
public static void R9003(IPacketProvider pConvert, string[] data) { for (int i = 0; i < SControl.CarDict.Count; i++) { sockets = SControl.CarDict.ElementAt(i).Key; val = SControl.CarDict[sockets]; if (val.Item1 == data[0]) { buffer = pConvert.Encode(new PacketFrom() { msgBody = body_9003, msgId = JT808Cmd.REQ_9003, msgSerialnumber = 0, pEncryptFlag = 0, pSerialnumber = 1, pSubFlag = 0, pTotal = 1, simNumber = Extension.ToBCD(data[0]), }); sockets.Send(buffer); break; } } }