+// detect configuration?\r
+bool tryDetectModulation(){\r
+ \r
+ uint8_t hits = 0;\r
+ \r
+ //IF true, the wave is almost certainly FSK\r
+ if (GetFskClock("", FALSE, FALSE)){ \r
+\r
+ if ( FSKrawDemod("0 0", FALSE) && test()){\r
+ printT55xxBlock("FSK");\r
+ ++hits;\r
+ }\r
+ if ( FSKrawDemod("0 1", FALSE) && test()) {\r
+ printT55xxBlock("FSK inv");\r
+ ++hits;\r
+ }\r
+ } else {\r
+ if ( ASKmanDemod("0 0 1", FALSE, FALSE) && test()) {\r
+ printT55xxBlock("ASK/MAN");\r
+ ++hits;\r
+ }\r
+\r
+ if ( ASKmanDemod("0 1 1", FALSE, FALSE) && test()) {\r
+ printT55xxBlock("ASK/MAN Inv");\r
+ ++hits;\r
+ }\r
+ \r
+ if ( NRZrawDemod("0 0 1", FALSE) && test()) {\r
+ printT55xxBlock("NZR");\r
+ ++hits;\r
+ }\r
+\r
+ if ( NRZrawDemod("0 1 1", FALSE) && test()) {\r
+ printT55xxBlock("NZR inv");\r
+ ++hits;\r
+ }\r
+ \r
+ if ( PSKDemod("0 0 1", FALSE) && test()) {\r
+ printT55xxBlock("PSK");\r
+ ++hits;\r
+ }\r
+ \r
+ if ( PSKDemod("0 1 1", FALSE) && test()) {\r
+ printT55xxBlock("PSK inv");\r
+ ++hits;\r
+ }\r
+ //PSK2?\r
+ // if (!BiphaseRawDecode("0",FALSE) && test()) {\r
+ // printT55xx("BIPHASE");\r
+ //}\r
+ // if (!BiphaseRawDecode("1",FALSE) && test()) {\r
+ // printT55xx("BIPHASE inv");\r
+ // }\r
+ } \r
+ if ( hits == 1) \r
+ return TRUE;\r
+ \r
+ if ( hits > 1)\r
+ PrintAndLog("Found [%d] possible matches for modulation.",hits);\r
+\r
+ return FALSE;\r
+}\r
+\r
+bool test(){\r
+\r
+ if ( !DemodBufferLen) \r
+ return false;\r
+ \r
+ uint8_t si = 1;\r
+ uint8_t safer = PackBits(si, 4, DemodBuffer); si += 4; \r
+ uint8_t resv = PackBits(si, 7, DemodBuffer); si += 7+3;\r
+ uint8_t extend = PackBits(si, 1, DemodBuffer); si += 1;\r
+\r
+ //PrintAndLog("test: %X %X %X ", safer, resv, extend);\r
+ \r
+ // 2nibble must be zeroed.\r
+ if ( resv > 0x00) return FALSE;\r
+\r
+ if ( safer == 0x6 || safer == 0x9){\r
+ if ( extend == 0x00)\r
+ return TRUE;\r
+ }\r
+ if ( resv== 0x00) return TRUE;\r
+ return FALSE;\r
+}\r
+\r
+void printT55xxBlock(const char *demodStr){\r
+ \r
+ uint32_t blockData = 0;\r
+ uint8_t bits[MAX_GRAPH_TRACE_LEN] = {0x00};\r
+ \r
+ if ( !DemodBufferLen) \r
+ return;\r
+ \r
+ int i =0;\r
+ for (;i<DemodBufferLen;++i)\r
+ bits[i]=DemodBuffer[i];\r
+ \r
+ blockData = PackBits(1, 32, bits);\r
+ PrintAndLog("0x%08X %s [%s]", blockData, sprint_bin(bits+1,32), demodStr);\r
+}\r