Example #1
0
        /// <summary>
        /// 三者間通信実施
        /// </summary>
        /// <param name="data">送信データ。三者間通信のフォーマットに従っていること。</param>
        /// <param name="data_len">送信データサイズ。最大224byte。</param>
        /// <returns>処理結果</returns>
        public bool push(byte[] data, int data_len)
        {
            if (data_len > 224)
            {
                return(false);
            }

            byte[] cmd = new byte[1 + 10 + data_len];
            cmd[0] = (byte)cmd.Length;
            cmd[1] = (byte)0xb0;
            Buffer.BlockCopy(mFNS.NfcId, 0, cmd, 2, 8);
            cmd[10] = (byte)data_len;
            Buffer.BlockCopy(data, 0, cmd, 11, data_len);
            UInt16 cmd_len = (UInt16)cmd[0];

            byte[] res     = new byte[256];
            UInt16 res_len = 0x00;
            bool   bRet    = mFNS.felica_nfc.FeliCaLibNfcThru(
                cmd,
                cmd_len,
                res,
                ref res_len);

            if (bRet == false)
            {
                Console.Write("Failed: FeliCaLibNfcThru\n");
                mFNS.unpoll();
                return(false);
            }


            // xx:IDm
            // [cmd]a4 xx xx xx xx xx xx xx xx 00
            cmd[0]  = 11;
            cmd[1]  = (byte)0xa4;                               //inactivate? activate2?
            cmd[10] = 0x00;
            cmd_len = (UInt16)cmd[0];
            res_len = 0x00;
            bRet    = mFNS.felica_nfc.FeliCaLibNfcThru(
                cmd,
                cmd_len,
                res,
                ref res_len);
            if (bRet == false)
            {
                Console.Write("Failed: FeliCaLibNfcThru\n");
                mFNS.unpoll();
                return(false);
            }

            return(true);
        }
        /// <summary>
        /// ポーリング
        /// </summary>
        /// <returns>処理結果</returns>
        public bool polling()
        {
            bool b = mFNS.pollingA();

            if (b)
            {
                if (mFNS.NfcId.Length != 4)
                {
                    // UID 4byteタイプしか手元にない
                    b = false;
                    mFNS.unpoll();
                }
            }
            return(b);
        }