+ // FOR READER SIDE COMMUMICATION...
+
+ decbyter <<= 2;
+ decbyter ^= (smpl & 0x30);
+
+ div++;
+
+ if ((div + 1) % 2 == 0) {
+ smpl = decbyter;
+ if (OutOfNDecoding((smpl & 0xF0) >> 4)) {
+ rsamples = samples - Uart.samples;
+ time_stop = (GetCountSspClk()-time_0) << 4;
+ LED_C_ON();
+
+ //if (!LogTrace(Uart.output, Uart.byteCnt, rsamples, Uart.parityBits,true)) break;
+ //if (!LogTrace(NULL, 0, Uart.endTime*16 - DELAY_READER_AIR2ARM_AS_SNIFFER, 0, true)) break;
+ uint8_t parity[MAX_PARITY_SIZE];
+ GetParity(Uart.output, Uart.byteCnt, parity);
+ LogTrace(Uart.output, Uart.byteCnt, time_start, time_stop, parity, true);
+
+ /* And ready to receive another command. */
+ Uart.state = STATE_UNSYNCD;
+ /* And also reset the demod code, which might have been */
+ /* false-triggered by the commands from the reader. */
+ Demod.state = DEMOD_UNSYNCD;
+ LED_B_OFF();
+ Uart.byteCnt = 0;
+ } else {
+ time_start = (GetCountSspClk()-time_0) << 4;
+ }
+ decbyter = 0;
+ }
+
+ if (div > 3) {
+ smpl = decbyte;
+ if (ManchesterDecoding(smpl & 0x0F)) {
+ time_stop = (GetCountSspClk()-time_0) << 4;
+
+ rsamples = samples - Demod.samples;
+ LED_B_ON();
+
+ uint8_t parity[MAX_PARITY_SIZE];
+ GetParity(Demod.output, Demod.len, parity);
+ LogTrace(Demod.output, Demod.len, time_start, time_stop, parity, false);
+
+ // And ready to receive another response.
+ memset(&Demod, 0, sizeof(Demod));
+ Demod.output = tagToReaderResponse;
+ Demod.state = DEMOD_UNSYNCD;
+ LED_C_OFF();
+ } else {
+ time_start = (GetCountSspClk()-time_0) << 4;
+ }
+
+ div = 0;
+ decbyte = 0x00;
+ }
+
+ if (BUTTON_PRESS()) {
+ DbpString("cancelled_a");
+ goto done;
+ }
+ }