Exemple #1
0
 public AckDataPacket(XNLPacket pkt) : base(OpCode.DataMessageAck)
 {
     this.isXCMP        = pkt.IsXCMP;
     this.flags         = pkt.Flags;
     this.dest          = pkt.Destination;
     this.src           = pkt.Source;
     this.transactionID = pkt.TransactionID;
     this.data          = new byte[0];
 }
Exemple #2
0
        private void HandleXNLPacket(object sender, PacketEventArgs e)
        {
            XNLXCMPPacket xpkt = (XNLXCMPPacket)e.packet;
            XNLPacket     xnl  = xpkt.XNLData;

            switch (xnl.OpCode)
            {
            case OpCode.DeviceSysMapBroadcast:
                //Ignore for now...
                break;

            case OpCode.MasterStatusBroadcast:
                //Console.WriteLine("Got master status broadcast...");
                this.masterID = xnl.Source;
                break;

            case OpCode.DeviceAuthKeyReply:
                this.StartConnection((DevAuthKeyReplyPacket)xnl);
                break;

            case OpCode.DeviceConnectionReply:
                DevConnectionReplyPacket rp = (DevConnectionReplyPacket)xnl;
                this.xnlID = rp.AssignedID;
                break;

            case OpCode.DataMessage:
                if (this.GotDataPacket != null && (xnl.Destination.Int == 0 || xnl.Destination.Equals(this.xnlID)))
                {
                    this.GotDataPacket(this, new XNLEventArgs(xnl));
                    this.AckPacket(xnl);
                    break;
                }
                goto default;

            case OpCode.DataMessageAck:
                //This data message has been acknowledged by the master remove our retry attempts
                this.pendingTransactions.Remove(xnl.TransactionID);
                break;

            default:
                Console.WriteLine("Unhandled XNL Data: {0}", xnl);
                break;
            }
        }
Exemple #3
0
        public void SendPacket(XNLPacket xnl)
        {
            if (xnl.OpCode == OpCode.DataMessage)
            {
                xnl.Source        = this.xnlID;
                xnl.Destination   = this.masterID;
                xnl.TransactionID = this.transactionID++;
                xnl.Flags         = this.flags++;
                if (this.flags > 0x07)
                {
                    this.flags = 0;
                }
                this.pendingTransactions[xnl.TransactionID] = xnl;
                System.Timers.Timer t = new System.Timers.Timer(5000);
                t.Elapsed += (sender, e) => this.ResendPacket(sender, e, xnl.TransactionID);
            }
            XNLXCMPPacket pkt = new XNLXCMPPacket(this.id, xnl);

            r.SendPacket(pkt);
        }
Exemple #4
0
 public XNLEventArgs(XNLPacket pkt)
 {
     this.Packet = pkt;
 }
Exemple #5
0
 private void AckPacket(XNLPacket pkt)
 {
     this.SendPacket(new AckDataPacket(pkt));
 }