Esempio n. 1
0
 public static int WriteAckPacket(byte[] packetBuffer, byte channelID, ushort ack, uint ackBits)
 {
     using (ByteArrayReaderWriter byteArrayReaderWriter = ByteArrayReaderWriter.Get(packetBuffer))
     {
         byte b = 128;
         if ((ackBits & 0xFF) != 255)
         {
             b = (byte)(b | 2);
         }
         if ((ackBits & 0xFF00) != 65280)
         {
             b = (byte)(b | 4);
         }
         if ((ackBits & 0xFF0000) != 16711680)
         {
             b = (byte)(b | 8);
         }
         if (((int)ackBits & -16777216) != -16777216)
         {
             b = (byte)(b | 0x10);
         }
         byteArrayReaderWriter.Write(b);
         byteArrayReaderWriter.Write(channelID);
         byteArrayReaderWriter.Write(ack);
         if ((ackBits & 0xFF) != 255)
         {
             byteArrayReaderWriter.Write((byte)(ackBits & 0xFF));
         }
         if ((ackBits & 0xFF00) != 65280)
         {
             byteArrayReaderWriter.Write((byte)((ackBits & 0xFF00) >> 8));
         }
         if ((ackBits & 0xFF0000) != 16711680)
         {
             byteArrayReaderWriter.Write((byte)((ackBits & 0xFF0000) >> 16));
         }
         if (((int)ackBits & -16777216) != -16777216)
         {
             byteArrayReaderWriter.Write((byte)((uint)((int)ackBits & -16777216) >> 24));
         }
         return((int)byteArrayReaderWriter.WritePosition);
     }
 }