+
+ //get response if there is one
+ uint8_t got[6000]; // 8 bit preamble + 32 bit word response (max clock (128) * 40bits = 5120 samples)
+ GetFromBigBuf(got, sizeof(got), 0);
+ if ( !WaitForResponseTimeout(CMD_ACK, NULL, 8000) ) {
+ PrintAndLog("command execution time out");
+ return -2;
+ }
+ setGraphBuf(got, sizeof(got));
+
+ int ans = 0;
+ //bool ST = true;
+ DemodBufferLen = 0x00;
+
+ //ans = ASKDemod_ext("0 0 1", FALSE, FALSE, 1, &ST);
+ ans = ASKbiphaseDemod("0 0 1", FALSE);
+ if (!ans) {
+ if (g_debugMode) PrintAndLog("DEBUG: Error - EM4305: ASK/Manchester Demod failed");
+ return -3;
+ }
+ PrintAndLog("ANS: %d", ans);
+
+ //todo: check response for 00001010 then write data for write confirmation!
+ size_t startIdx = 0, size = DemodBufferLen;
+
+ uint8_t preamble[8] = {0,0,0,0,1,0,1,0};
+ if (!preambleSearch(DemodBuffer, preamble, sizeof(preamble), &size, &startIdx)){
+ if (g_debugMode) PrintAndLog("DEBUG: Error - EM4305 preamble not found :: %d", startIdx);
+ return -4;
+ }
+ PrintAndLog("Write OK");