beacon-scanner-library
beacon-scanner-library copied to clipboard
Scanner.setCallback(onCallback) not firing
Callback is not firing, is it implemented?
Following the readme to implement, it doesn't appear to fire and I cant seem to get the 'newly_scanned' or type to change upon tag going on/off. I'm using iBeacons.
Your help is very much appreciated. -John
implemented as:
#include "Particle.h"
#include "BeaconScanner.h"
SYSTEM_THREAD(ENABLED);
SYSTEM_MODE(SEMI_AUTOMATIC);
SerialLogHandler logHandler;
void onCallback(Beacon& beacon, callback_type type) {
Log.trace("Callback!");
Log.trace("Address: %s. Type: %s", beacon.getAddress().toString().c_str(), (type == NEW) ? "Entered" : "Left");
}
void setup() {
// Other setup
BLE.on();
Scanner.setCallback(onCallback);
Scanner.setMissedCount(2);
Scanner.setScanPeriod(6);
Scanner.startContinuous(SCAN_IBEACON);
}
unsigned long scannedTime = 0;
void loop() {
Scanner.loop();
if ((millis() - scannedTime) > 5000) {
scannedTime = millis();
for (auto i : Scanner.getiBeacons()) {
Log.info("Address: %s, RSSI: %u, new? %d", i.getAddress().toString().c_str(), i.getRssi(), i.newly_scanned );
}
}
}