@@ -648,23 +648,34 @@ bool scanForFriendlyDevices(uint16_t maxScanTimeMs)
648648
649649#ifdef COMPILE_BT
650650
651+ // The remote device will advertise as 'BlueSMiRF-ABCD-Pairing' during pairing discovery mode
652+ // Look for BlueSMiRF and -Pairing in a name
651653void btAdvertisedDeviceFound (BTAdvertisedDevice *pDevice)
652654{
653655 if (settings.debugBluetooth == true )
654656 systemPrintf (" Found a device Name: %s\n\r " , pDevice->getName ().c_str ());
655657
656- // Only pair with devices that have the name "BlueSMiRF-Pairing"
657- if (strcmp (pDevice->getName ().c_str (), " BlueSMiRF-Pairing" ) == 0 )
658+ char search1[] = " BlueSMiRF" ;
659+ char search2[] = " -Pairing" ;
660+
661+ char *ptr = strstr (pDevice->getName ().c_str (), search1);
662+
663+ if (ptr != NULL ) // Found first search
658664 {
659- // Convert "94:e6:86:b6:89:0a" to {0x94, 0xE6, 0x86, 0xB6, 0x89, 0x0A}
660- convertMac ((char *)pDevice->getAddress ().toString ().c_str (), settings.btPairedMac );
665+ char *ptr2 = strstr (pDevice->getName ().c_str (), search2);
661666
662- recordSystemSettings (); // Store this MAC
667+ if (ptr2 != NULL ) // Found
668+ {
669+ // Convert "94:e6:86:b6:89:0a" to {0x94, 0xE6, 0x86, 0xB6, 0x89, 0x0A}
670+ convertMac ((char *)pDevice->getAddress ().toString ().c_str (), settings.btPairedMac );
663671
664- if (settings.debugBluetooth == true )
665- systemPrintf (" Found a friendly device MAC: %s" , stringMac (settings.btPairedMac ));
672+ recordSystemSettings (); // Store this MAC
666673
667- friendlyDeviceFound = true ; // Indicate we can stop scanning
674+ if (settings.debugBluetooth == true )
675+ systemPrintf (" Found a friendly device MAC: %s" , stringMac (settings.btPairedMac ));
676+
677+ friendlyDeviceFound = true ; // Indicate we can stop scanning
678+ }
668679 }
669680}
670681
0 commit comments