Hello,
I am currently trying to use my android smartphone (Google Pixel 4a) as a key for a keyless entry system. The idea is to make the Particle Tracker detect the presence of my phone via BLE. Sofar I have been unable to detect it when using the following code:
/*
* Project BLETest
* Description:
* Author:
* Date:
*/
#include "Particle.h"
SYSTEM_MODE(MANUAL);
SerialLogHandler logHandler(LOG_LEVEL_TRACE);
// setup() runs once, when the device is first turned on.
void setup() {
// Put initialization like pinMode and begin functions here.
BLE.on();
}
// loop() runs over and over again, as quickly as it can execute.
void loop() {
// The core of your code will likely live here.
Vector<BleScanResult> scanResults = BLE.scan();
if (scanResults.size()) {
Log.info("%d devices found", scanResults.size());
for (int ii = 0; ii < scanResults.size(); ii++) {
// For Device OS 2.x and earlier, use scanResults[ii].address[0], etc. without the ()
Log.info("MAC: %02X:%02X:%02X:%02X:%02X:%02X | RSSI: %dBm",
scanResults[ii].address()[0], scanResults[ii].address()[1], scanResults[ii].address()[2],
scanResults[ii].address()[3], scanResults[ii].address()[4], scanResults[ii].address()[5], scanResults[ii].rssi());
// String name = scanResults[ii].advertisingData().deviceName();
// if (name.length() > 0) {
// Log.info("Advertising name: %s", name.c_str());
// }
}
Log.info("\n");
}
delay(10000);
}
In the list of the MAC adresses I don’t see the MAC adress of my phone though I opened up the Bluetooth setting. This should indicate that the device is present.
Do any of you know if this works at all with an Android device? Is there something I am missing?
Thanks for any help!