Exemplo n.º 1
0
        private byte[] GetBlockData(NdefMessage ndef)
        {
            byte[] msg = ndef.ToBytes();
            byte[] info = new byte[Felica.BLOCK_LENGTH];
            //ndef version
            info[0] = 0x10;

            info[1] = 0x04;
            info[2] = 0x01;

            //available block
            EndianConverter.SetUIntToBytes((ushort)AVAILABLE_BLOCK, info, 3);

            //read only
            info[10] = 0x00;

            //data length
            byte[] len = EndianConverter.UIntergerToBytes((uint)msg.Length);
            Array.Copy(len, 1, info, 11, 3);

            //check sum
            int sum = 0;
            for (int i = 0; i < 14; i++)
            {
                sum += info[i];
            }
            EndianConverter.SetUIntToBytes((ushort)sum, info, 14);

            byte[] data = new byte[BLOCK_COUNT * Felica.BLOCK_LENGTH];

            int index = 0;
            info.CopyTo(data, 0);
            index += info.Length;
            msg.CopyTo(data, index);
            return data;
        }
Exemplo n.º 2
0
 public Type3TagController(FakeFelica fFelica, byte[] idm, NdefMessage ndef)
     : base(fFelica, idm)
 {
     data = GetBlockData(ndef);
     systemCode = new ushort[] { SYSTEM_CODE };
 }