Created
September 19, 2018 12:53
-
-
Save wybiral/2a96c1d1605af7efa11b690586c4b13e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <BLEAdvertisedDevice.h> | |
#include <BLEDevice.h> | |
#include <BLEScan.h> | |
const int PIN = 2; | |
const int CUTOFF = -60; | |
void setup() { | |
pinMode(PIN, OUTPUT); | |
BLEDevice::init(""); | |
} | |
void loop() { | |
BLEScan *scan = BLEDevice::getScan(); | |
scan->setActiveScan(true); | |
BLEScanResults results = scan->start(1); | |
int best = CUTOFF; | |
for (int i = 0; i < results.getCount(); i++) { | |
BLEAdvertisedDevice device = results.getDevice(i); | |
int rssi = device.getRSSI(); | |
if (rssi > best) { | |
best = rssi; | |
} | |
} | |
digitalWrite(PIN, best > CUTOFF ? HIGH : LOW); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi, Can you post the contents of the Puck.js script? Thanks.