protected virtual void OnRead(object sender, FelicaEventArgs e) { FReadEventArgs read = e as FReadEventArgs; int blockCount = read.Block.Count; int index = 0; byte[] res = new byte[2 + 1 + blockCount * Felica.BLOCK_LENGTH];//ST[2],BLOCK,DATA[16*BLOCK] res[index++] = 0;//ST res[index++] = 0;//ST fFelica.DoResponse(FCmd.ReadWERes, res); }
protected override void OnRead(object sender, FelicaEventArgs e) { FReadEventArgs read = e as FReadEventArgs; for (int i = 0; i < read.Block.Count; i++) { BlockElement elm = read.Block[i]; if (elm.ServiceCode != TYPE3_SERVICE) { byte st1 = (byte)((0x01 << i)%0xff); byte st2 = 0xa8; OnError(fFelica, FCmd.ReadWERes, st1, st2); return; } } int blockCount = read.Block.Count; int index = 0; byte[] res = new byte[2 + 1 + blockCount * Felica.BLOCK_LENGTH];//ST[2],BLOCK,DATA[16*BLOCK] res[index++] = 0;//ST res[index++] = 0;//ST res[index++] = (byte)blockCount; for (int i = 0; i < blockCount; i++) { BlockElement elm = read.Block[i]; if (elm.Number * Felica.BLOCK_LENGTH < data.Length) { Array.Copy(data, elm.Number * Felica.BLOCK_LENGTH, res, index + i * Felica.BLOCK_LENGTH, Felica.BLOCK_LENGTH); } } fFelica.DoResponse(FCmd.ReadWERes, res); }
protected virtual void OnPolling(object sender, FelicaEventArgs e) { FPollEventArgs poll = e as FPollEventArgs; foreach (ushort sys in systemCode) { ushort maskSys=sys; for (int i = 0; i < 4; i++) { ushort mask = (ushort)(0x000f << i * 4); if ((poll.SystemCode&mask)==mask) { maskSys |= mask; } } if ((maskSys & poll.SystemCode) == maskSys) { fFelica.DoResponse(FCmd.PollRes, fFelica.Pmm); return; } } Thread.Sleep(100); }
private void onReqSys(byte[] cmd) { if (CommandReceived != null) { FelicaEventArgs e = new FelicaEventArgs(FCmd.ReqSys); CommandReceived(this, e); } }
protected virtual void OnReqSys(object sender, FelicaEventArgs e) { int index = 0; byte[] res = new byte[1 + systemCode.Length * 2]; res[index++] = 1; foreach (ushort sys in systemCode) { EndianConverter.SetUIntToBytes((ushort)sys, res, index); index += 2; } fFelica.DoResponse(FCmd.ReqSysRes, res); }
private void fFelica_CommandReceived(object sender, FelicaEventArgs e) { switch (e.Cmd) { case FCmd.Poll: OnPolling(sender, e); break; case FCmd.ReqSv: break; case FCmd.ReadWE: OnRead(sender, e); break; case FCmd.WriteWE: OnWrite(sender, e); break; case FCmd.ReqSys: OnReqSys(sender, e); break; } }
protected virtual void OnWrite(object sender, FelicaEventArgs e) { FWriteEventArgs write = e as FWriteEventArgs; int index = 0; byte[] res = new byte[2]; res[index++] = 0x00;//ST 0 res[index++] = 0x00;//ST 0 fFelica.DoResponse(FCmd.WriteWERes, res); }