示例#1
0
        public static BlockityCommand <Boolean> SetName(String newName)
        {
            if (String.IsNullOrEmpty(newName))
            {
                throw new ArgumentException("Name is either null or empty.", "newName");
            }

            byte[] newNameBytes = Encoding.ASCII.GetBytes(newName.PadRight(15, '#'));
            if (newNameBytes.Length != 15)
            {
                throw new ArgumentException("Name is greater than 15 bytes in length.", "newName");
            }

            var command = new Byte[18];

            command[0] = (Byte)CommandByte.SetBluetoothNameRequest;
            command[1] = 0x0F;

            newNameBytes.CopyTo(command, 2);
            command[17] = BlockityHelpers.GetCrc(newNameBytes);

            return(new BlockityCommand <Boolean> {
                RequestBytes = command,
                ResponseCommand = input => ResponseCommands.SimpleResponse(CommandByte.SetBluetoothNameResponse, input)
            });
        }
示例#2
0
 public static BlockityCommand <Boolean> FactoryReset()
 {
     return(new BlockityCommand <Boolean> {
         RequestBytes = new Byte[] {
             (Byte)CommandByte.FactoryResetRequest,
             0,
             0
         },
         ResponseCommand = input => ResponseCommands.SimpleResponse(CommandByte.FactoryResetResponse, input)
     });
 }
示例#3
0
 public static BlockityCommand <Boolean> ClearData()
 {
     return(new BlockityCommand <Boolean> {
         RequestBytes = new Byte[] {
             (Byte)CommandByte.ClearDataRequest,
             0,
             0
         },
         ResponseCommand = input => ResponseCommands.SimpleResponse(CommandByte.ClearDataRequest, input)
     });
 }
示例#4
0
 public static BlockityCommand <Boolean> SetPassword(BlockityPin pin)
 {
     return(new BlockityCommand <Boolean> {
         RequestBytes = new Byte[] {
             (Byte)CommandByte.SetBluetoothPinRequest,
             4,
             pin.A,
             pin.B,
             pin.C,
             pin.D,
             BlockityHelpers.GetCrc(
                 new[] {
                 pin.A,
                 pin.B,
                 pin.C,
                 pin.D
             })
         },
         ResponseCommand = input => ResponseCommands.SimpleResponse(CommandByte.SetBluetoothPinResponse, input)
     });
 }