예제 #1
0
파일: NFC.cs 프로젝트: rdavisau/hello-ios13
        public static async Task <byte[]> DoFastRead(
            this INFCMiFareTag tag,
            byte from,
            byte to,
            byte batchSize)
        {
            var results = new List <MifareCommandResult>();

            while (from < to)
            {
                var thisTo = (byte)Math.Min(from + batchSize, to);
                var data   = await tag.SendMifareCommand(0x3a, from, thisTo);

                results.Add(data);

                from = (byte)(from + (byte)(batchSize + 0x1));
            }

            if (results.Any(x => x.Error != null))
            {
                throw new Exception($"Failed to fast read; first error: {results.First(x => x.Error != null).Error}");
            }

            var all = MifareCommandResult.Combine(results);

            return(all.Data);
        }
예제 #2
0
파일: NFC.cs 프로젝트: rdavisau/hello-ios13
        public static async Task <byte[]> WritePage(
            this INFCMiFareTag tag,
            byte page,
            byte[] data)
        {
            var cmd = new byte[] { 0xa2, (byte)(page) }.Concat(data).ToArray();
            var result = await tag.SendMifareCommand(cmd);

            if (result.Error != null)
            {
                Debug.WriteLine(result.Error);
            }

            return(result.Data);
        }