I have a Serial Bluetooth dongle i’m attempting to pair with (from the Particle Boron)
I have the Scan code done, but I seem to be getting nonsense MAC addresses (unknown vendor) and missing the bluetooth devices (who are announcing)
Example code:
void scanResultCallback(const BleScanResult *scanResult, void *context) {
String name = scanResult->advertisingData.deviceName();
if (name.length() == 0) {
name = "Unknown";
}
for (int vindex = 0; vindex < sizeof(knownVendors) / sizeof(vendor_t); vindex++) {
if (scanResult->address[0] == knownVendors[vindex].first
&& scanResult->address[1] == knownVendors[vindex].second
&& scanResult->address[2] == knownVendors[vindex].third) {
Log.info("BLE: rssid=%d address=%02X:%02X:%02X:%02X:%02X:%02X (Known OBDII!) %s",
scanResult->rssi, scanResult->address[0], scanResult->address[1],
scanResult->address[2], scanResult->address[3], scanResult->address[4],
scanResult->address[5], name.c_str());
if (bestAdapter == NULL || scanResult->rssi > bestAdapter->rssi) {
// Show whatever device has the strongest signal
bestAdapter = (BleScanResult*)malloc(sizeof(BleScanResult));
memcpy(bestAdapter, (BleScanResult*)scanResult, sizeof(BleScanResult));
}
} else {
Log.info("BLE: rssid=%d address=%02X:%02X:%02X:%02X:%02X:%02X (Unknown Device) %s",
scanResult->rssi, scanResult->address[0], scanResult->address[1],
scanResult->address[2], scanResult->address[3], scanResult->address[4],
scanResult->address[5], name.c_str());
}
}
}
void bl_scan() {
Log.info("BLE: Starting Scan...");
BLE.scan(&scanResultCallback, NULL);
if (bestAdapter == NULL) {
RGB.color(255, 0, 0);
} else {
RGB.color(0, 255, 0);
}
}
Result:
0005977934 [app] INFO: BLE: rssid=-77 address=DF:4F:18:D3:33:D6 (Unknown Device) Unknown
0005986136 [app] INFO: BLE: Starting Scan...
0005987964 [app] INFO: BLE: rssid=-74 address=DF:4F:18:D3:33:D6 (Unknown Device) Unknown
0005997090 [app] INFO: BLE: Starting Scan...
0006008044 [app] INFO: BLE: Starting Scan...
0006018997 [app] INFO: BLE: Starting Scan...