public Task <bool> WritePage(INFCMiFareTag tag, byte page, byte [] data) { var tcs = new TaskCompletionSource <bool>(); tag.SendMiFareCommand(NSData.FromArray(new byte[] { 0xA2, page, data[0], data[1], data[2], data[3] }), (tagdata, error) => tcs.SetResult((tagdata != null) && (error == null) && (tagdata.Count() == 1))); return(tcs.Task); }
public static Task <MifareCommandResult> SendMifareCommand( this INFCMiFareTag tag, params byte[] command) { var tcs = new TaskCompletionSource <MifareCommandResult>(); tag.SendMiFareCommand( NSData.FromArray(command), (data, err) => tcs.SetResult(MifareCommandResult.From(data, err))); return(tcs.Task); }
public Task <byte[]> Read4Pages(INFCMiFareTag tag, byte page) { var tcs = new TaskCompletionSource <byte[]>(); tag.SendMiFareCommand(NSData.FromArray(new byte[] { 0x30, page }), (data, error) => { if ((data != null) && (error == null) && (data.Count() == 16)) { tcs.SetResult(data.ToArray()); } else { tcs.SetResult(null); } }); return(tcs.Task); }