+// search for given preamble in given BitStream and return success=1 or fail=0 and startIndex (where it was found)
+// does not look for a repeating preamble
+// em4x05/4x69 only sends preamble once, so look for it once in the first pLen bits
+// leave it generic so it could be reused later...
+bool onePreambleSearch(uint8_t *BitStream, uint8_t *preamble, size_t pLen, size_t size, size_t *startIdx) {
+ // Sanity check. If preamble length is bigger than bitstream length.
+ if ( size <= pLen ) return false;
+ for (size_t idx = 0; idx < size - pLen; idx++) {
+ if (memcmp(BitStream+idx, preamble, pLen) == 0) {
+ if (g_debugMode) prnt("DEBUG: preamble found at %u", idx);
+ *startIdx = idx;
+ return true;
+ }
+ }
+ return false;
+}
+