Esempio n. 1
0
 /// <summary>Send a command packet to the device.</summary>
 /// <param name="packet">Command packet</param>
 /// <returns>Task</returns>
 /// <exception cref="BandSocketConnectedNot">Not connected.<exception>
 public async Task Send(CommandPacket packet)
 {
     if (!this.Connected)
     {
         throw new BandSocketConnectedNot();
     }
     this.DataWriter.WriteBytes(packet.GetBytes());
     await this.DataWriter.StoreAsync();
 }
Esempio n. 2
0
        public void Command_CommandPacket()
        {
            CommandPacket packet = new CommandPacket(
                CommandEnum.GetDeviceTime
                );

            byte[] bytes      = packet.GetBytes();
            int[]  ints       = Array.ConvertAll(bytes, b => (int)b);
            int[]  intsExpect = new int[] {
                12, 249, 46, 130, 117, 16, 0, 0, 0, 16, 0, 0, 0
            };
            Console.WriteLine("[{0}]", string.Join(", ", ints));
            CollectionAssert.AreEqual(intsExpect, ints);
        }