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) }); }
public static BlockityCommand <Boolean> FactoryReset() { return(new BlockityCommand <Boolean> { RequestBytes = new Byte[] { (Byte)CommandByte.FactoryResetRequest, 0, 0 }, ResponseCommand = input => ResponseCommands.SimpleResponse(CommandByte.FactoryResetResponse, input) }); }
public static BlockityCommand <Boolean> ClearData() { return(new BlockityCommand <Boolean> { RequestBytes = new Byte[] { (Byte)CommandByte.ClearDataRequest, 0, 0 }, ResponseCommand = input => ResponseCommands.SimpleResponse(CommandByte.ClearDataRequest, input) }); }
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) }); }